Browse Source

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

chenshilong 7 năm trước cách đây
mục cha
commit
03a4678688
41 tập tin đã thay đổi với 1769 bổ sung1222 xóa
  1. 4 1
      modules/complementary_glj_lib/routes/routes.js
  2. 103 0
      modules/complementary_ration_lib/controllers/compleRationController.js
  3. 36 0
      modules/complementary_ration_lib/controllers/compleSectionTreeController.js
  4. 53 0
      modules/complementary_ration_lib/controllers/compleViewController.js
  5. 390 0
      modules/complementary_ration_lib/models/compleRationModel.js
  6. 29 0
      modules/complementary_ration_lib/models/compleViewModel.js
  7. 76 0
      modules/complementary_ration_lib/models/schemas.js
  8. 88 0
      modules/complementary_ration_lib/models/sectionTreeModel.js
  9. 46 0
      modules/complementary_ration_lib/routes/routes.js
  10. 2 0
      modules/main/models/bills.js
  11. 2 0
      modules/ration_glj/models/ration_glj_temp.js
  12. 14 3
      modules/ration_repository/models/coe.js
  13. 5 4
      public/web/sheet/sheet_common.js
  14. 24 35
      web/building_saas/complementary_glj_lib/js/glj.js
  15. 1 0
      web/building_saas/complementary_glj_lib/js/sheetOpr.js
  16. 9 11
      web/building_saas/complementary_ration_lib/html/dinge.html
  17. 8 78
      web/building_saas/complementary_ration_lib/html/fuzhu.html
  18. 9 8
      web/building_saas/complementary_ration_lib/html/gongliao.html
  19. 9 9
      web/building_saas/complementary_ration_lib/js/annotation.js
  20. 17 447
      web/building_saas/complementary_ration_lib/js/coe.js
  21. 7 7
      web/building_saas/complementary_ration_lib/js/jobContent.js
  22. 10 10
      web/building_saas/complementary_ration_lib/js/main.js
  23. 109 106
      web/building_saas/complementary_ration_lib/js/ration.js
  24. 7 3
      web/building_saas/complementary_ration_lib/js/ration_assist.js
  25. 33 57
      web/building_saas/complementary_ration_lib/js/ration_coe.js
  26. 106 123
      web/building_saas/complementary_ration_lib/js/ration_glj.js
  27. 40 12
      web/building_saas/complementary_ration_lib/js/repository_glj.js
  28. 132 216
      web/building_saas/complementary_ration_lib/js/section_tree.js
  29. 1 0
      web/building_saas/glj/js/project_glj.js
  30. 2 0
      web/building_saas/glj/js/project_glj_spread.js
  31. 44 1
      web/building_saas/main/js/controllers/project_controller.js
  32. 85 3
      web/building_saas/main/js/models/bills.js
  33. 0 1
      web/building_saas/main/js/models/cache_tree.js
  34. 7 43
      web/building_saas/main/js/models/calc_base.js
  35. 55 1
      web/building_saas/main/js/models/main_consts.js
  36. 91 0
      web/building_saas/main/js/models/project_glj.js
  37. 2 2
      web/building_saas/main/js/models/ration.js
  38. 8 7
      web/building_saas/main/js/models/ration_glj.js
  39. 15 12
      web/building_saas/main/js/views/glj_view.js
  40. 16 15
      web/building_saas/main/js/views/main_tree_col.js
  41. 74 7
      web/building_saas/main/js/views/project_view.js

+ 4 - 1
modules/complementary_glj_lib/routes/routes.js

@@ -3,10 +3,12 @@
  */
 
 import express from "express";
-import GljController from "../controllers/gljController"
+import GljController from "../controllers/gljController";
+import CompleRationController from '../../complementary_ration_lib/controllers/compleRationController';
 
 let router = express.Router();
 let gljController = new GljController();
+let compleRationController = new CompleRationController();
 
 module.exports = function (app) {
     app.get('/complementaryGlj', gljController.init, gljController.redirectGlj);
@@ -21,6 +23,7 @@ module.exports = function (app) {
     router.post("/getGljItems", gljController.init, gljController.getGljItems);
     router.post("/updateComponent", gljController.init, gljController.updateComponent);
     router.post("/mixUpdateGljItems", gljController.init, gljController.mixUpdateGljItems);
+    router.post("/updateRationBasePrc",compleRationController.init, compleRationController.updateRationBasePrc);//更新定额单价
     //router.post("/getGljItemsByIds", gljController.init, gljController.getGljItemsByIds);
     //router.post("/getGljItemsByCodes", gljController.init, gljController.getGljItemsByCodes);
 

+ 103 - 0
modules/complementary_ration_lib/controllers/compleRationController.js

@@ -0,0 +1,103 @@
+/**
+ * Created by Zhong on 2017/12/21.
+ */
+
+import BaseController from '../../common/base/base_controller';
+import CompleRationDao from '../models/compleRationModel';
+
+let compleRationDao = new CompleRationDao();
+let coeListDAO = require('../../ration_repository/models/coe');
+let callback = function (req, res, err, msg, data) {
+    res.json({error: err, message: msg, data: data})
+}
+
+class CompleRationController extends BaseController{
+    getRationItems(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.getRationItems(req.session.sessionUser.ssoId, data.rationRepId, data.sectionId, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    updateRations(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.updateRation(req.session.sessionUser.ssoId, req.session.sessionCompilation._id, data.updateData, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    //更新补充定额价格
+    updateRationBasePrc(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.updateRationBasePrc(req.session.sessionUser.ssoId, data.basePrcArr, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    mixUpdateRationItems(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.mixUpdateRationItems(req.session.sessionUser.ssoId, req.session.sessionCompilation._id,
+            data.rationRepId, data.sectionId, data.updateItems, data.addItems, data.removeIds, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    //获取所有定额的编号
+    getRationsCodes(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.getRationsCodes(req.session.sessionUser.ssoId, data.rationRepId, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    getGljItems(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.getGljItems(data.gljLibId, function (err, data) {
+            callback(req, res, err, '', data);
+        })
+    }
+
+    getGljItemsOccupied(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.getGljItemsOccupied(data.gljLibId, data.occupation, function (err, data) {
+            callback(req, res, err, '', data);
+        })
+    }
+
+    getGljItemsByIds(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.getGljItemsByIds(req.session.sessionUser.ssoId, data.ids, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    getGljItemsByCodes(req, res){
+        let data = JSON.parse(req.body.data);
+        compleRationDao.getGljItemsByCodes(req.session.sessionUser.ssoId, req.session.sessionCompilation._id, data.rationRepId, data.gljCodes, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    getCoeList(req, res){
+        let data = JSON.parse(req.body.data);
+        coeListDAO.getCoesByLibID(data.libID, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    getCoeItemsByIDs(req, res){
+        let data = JSON.parse(req.body.data);
+        coeListDAO.getCoeItemsByIDs(data, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    getCoeItemsByNos(req, res){
+        let data = JSON.parse(req.body.data);
+        coeListDAO.getCoeItemsByNos(data, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+}
+
+export default CompleRationController;

+ 36 - 0
modules/complementary_ration_lib/controllers/compleSectionTreeController.js

@@ -0,0 +1,36 @@
+/**
+ * Created by Zhong on 2017/12/21.
+ */
+
+import BaseController from '../../common/base/base_controller';
+import SectionTreeDao from '../models/sectionTreeModel';
+
+let sectionTreeDao = new SectionTreeDao();
+let callback = function (req, res, err, msg, data) {
+    res.json({error: err, message: msg, data: data});
+};
+
+class CompleSectionTreeController extends BaseController{
+    //保证章节树ID唯一,标准树与补充树才可进行拼接
+    getNewTreeID(req, res){
+        sectionTreeDao.getNewTreeID(function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    getRationTree(req, res){
+        let data = JSON.parse(req.body.data);
+        sectionTreeDao.getRationTree(req.session.sessionUser.ssoId, data.rationRepId, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    updateRationSection(req, res){
+        let data = JSON.parse(req.body.data);
+        sectionTreeDao.updateSection(req.session.sessionUser.ssoId, req.session.sessionCompilation._id, data.updateData, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+}
+
+export default CompleSectionTreeController;

+ 53 - 0
modules/complementary_ration_lib/controllers/compleViewController.js

@@ -0,0 +1,53 @@
+/**
+ * Created by Zhong on 2017/12/22.
+ */
+
+import BaseController from '../../common/base/base_controller';
+import CompleViewModel from '../models/compleViewModel';
+
+let compleViewModel = new CompleViewModel();
+let callback = function (req, res, err, msg, data) {
+    res.json({error: err, message: msg, data: data});
+};
+
+class CompleViewController extends BaseController{
+    redirectMain(req, res){
+        res.render('building_saas/complementary_ration_lib/html/main.html', {
+            userID: req.session.sessionUser.ssoId,
+            compilationId: req.session.sessionCompilation._id
+        });
+    }
+
+    redirectRation(req, res){
+        res.render('building_saas/complementary_ration_lib/html/dinge.html', {
+            userID: req.session.sessionUser.ssoId
+        });
+    }
+
+    redirectGljList(req, res){
+        res.render('building_saas/complementary_ration_lib/html/gongliao.html', {
+            userID: req.session.sessionUser.ssoId
+        });
+    }
+
+    redirectCoeList(req, res){
+        res.render('building_saas/complementary_ration_lib/html/fuzhu.html', {
+            userID: req.session.sessionUser.ssoId
+        });
+    }
+
+    getRationLib(req, res){
+        let data = JSON.parse(req.body.data);
+        compleViewModel.getRationLib(data.rationRepId, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+
+    getRationLibs(req, res){
+        compleViewModel.getRationLibs(req.session.sessionCompilation._id, function (err, data) {
+            callback(req, res, err, '', data);
+        });
+    }
+}
+
+export default CompleViewController;

+ 390 - 0
modules/complementary_ration_lib/models/compleRationModel.js

@@ -0,0 +1,390 @@
+/**
+ * Created by Zhong on 2017/12/21.
+ */
+
+import {compleRationModel} from './schemas';
+import {complementaryGljModel, stdGljModel} from '../../complementary_glj_lib/models/schemas';
+import async from 'async';
+let stdRationModel = require ('../../ration_repository/models/ration_item').Model;
+let counter = require('../../../public/counter/counter');
+const scMathUtil = require('../../../public/scMathUtil').getUtil();
+
+class CompleRatoinDao {
+    async updateRation(userID, compilationId, updateData, callback){
+        try{
+            for(let i = 0, len = updateData.length; i < len; i++){
+                let updateObj = updateData[i];
+                if(updateObj.updateType === 'new'){
+                    updateObj.updateData.userID = userID;
+                    updateObj.updateData.compilationId = compilationId;
+                    await compleRationModel.create(updateObj.updateData);
+                }
+                else if(updateObj.updateType === 'update'){
+                    await compleRationModel.update({userID: userID, rationRepId: updateObj.updateData.rationRepId}, updateObj.updateData);
+                }
+            }
+            callback(0, '');
+        }
+        catch(err){
+            callback(err, null);
+        }
+    }
+
+    async getRationItems(userID, rationRepId, sectionId, callback){
+        try{
+            let stdRations = await stdRationModel.find({rationRepId: rationRepId, sectionId: sectionId, $or: [{isDeleted: null}, {isDeleted: false}]});
+            //mark std
+            for(let i = 0, len = stdRations.length; i < len; i++){
+                stdRations[i]._doc.type = 'std';
+            }
+            let compleRations = await compleRationModel.find({userId: userID, rationRepId: rationRepId, sectionId: sectionId, deleteInfo: null});
+            //mark complementary
+            for(let i = 0, len = compleRations.length; i < len; i++){
+                compleRations[i]._doc.type = 'complementary';
+            }
+            callback(0, stdRations.concat(compleRations));
+        }
+        catch(err){
+            callback(err, null);
+        }
+    }
+
+    async getRationsCodes(userID, rationRepId, callback){
+        try{
+            let stdRationCodes = await stdRationModel.find({rationRepId: rationRepId, $or: [{isDeleted: null}, {isDeleted: false}]}, '-_id code');
+            let compleRationCodes = await compleRationModel.find({userId: userID, rationRepId: rationRepId, deleteInfo: null}, '-_id code');
+            let rstCodes = [];
+            stdRationCodes.concat(compleRationCodes).forEach(function (rationItem) {
+                rstCodes.push(rationItem.code);
+            });
+            callback(0, rstCodes);
+        }
+        catch(err){
+            callback(err, null);
+        }
+    }
+
+    async getGljItems(gljLibId, callback){
+        try{
+            let stdGljs = await stdGljModel.find({repositoryId: gljLibId, $or: [{deleted: null}, {deleted: false}]});
+            callback(0, stdGljs);
+        }
+        catch(err){
+            callback(err, null);
+        }
+    }
+
+    async getGljItemsOccupied(gljLibId, occupation, callback){
+        try{
+            let stdGls = await stdGljModel.find({repositoryId: gljLibId, $or: [{deleted: null}, {deleted: false}]}, occupation);
+            callback(0, stdGls);
+        }
+        catch (err){
+            callback(err, null);
+        }
+    }
+
+
+    async getGljItemsByIds(userID, ids, callback){
+        try{
+            let rst = [];
+            for(let i = 0, len = ids.length; i < len; i++){
+                if(ids[i].type === 'std'){
+                    let stdGlj = await stdGljModel.find({ID: ids[i].id, deleteInfo: null});
+                    if(stdGlj.length > 0){
+                        stdGlj[0]._doc.type = 'std';
+                        rst.push(stdGlj[0]);
+                    }
+                }
+                else if(ids[i].type === 'complementary'){
+                    let compleGlj = await complementaryGljModel.find({userId: userID, ID: ids[i].id, deleteInfo: null});
+                    if(compleGlj.length > 0){
+                        compleGlj[0]._doc.type = 'complementary';
+                        rst.push(compleGlj[0]);
+                    }
+                }
+            }
+            callback(0, rst);
+        }
+        catch(err){
+            callback(err, null);
+        }
+    }
+
+    async getGljItemsByCodes(userID, compilationId, rationRepId, codes, callback){
+        try{
+            let rst = [];
+            for(let i = 0, len = codes.length; i < len; i++){
+                let stdGlj = await stdGljModel.find({repositoryId: rationRepId, code: codes[i]});
+                if(stdGlj.length > 0){
+                    stdGlj[0]._doc.type = 'std';
+                    rst.push(stdGlj[0]);
+                }
+                else {
+                    let compleGlj = await complementaryGljModel.find({userId: userID, compilationId: compilationId, code: codes[i]});
+                    if(compleGlj.length > 0){
+                        compleGlj[0]._doc.type = 'complementary';
+                        rst.push(compleGlj[0]);
+                    }
+                }
+            }
+            callback(0, rst);
+        }
+        catch(err){
+            callback(err, null);
+        }
+    }
+
+    updateRationBasePrc(userID, basePrcArr, callback){
+        let me  = this;
+        async.each(basePrcArr, function (basePrcObj, finalCb) {
+            let adjGljId = basePrcObj.gljId, adjBasePrice = basePrcObj.basePrice, adjGljType = basePrcObj.gljType;
+            async.waterfall([
+                function (cb) {
+                    if(typeof basePrcObj.delete !== 'undefined' && basePrcObj.delete === 1){
+                        //补充定额
+                        compleRationModel.find({'rationGljList.gljId': adjGljId},{ID: 1, rationGljList: 1}, function (err, compleRst) {
+                            if(err){
+                                cb(err);
+                            }
+                            else {
+                                compleRationModel.update({'rationGljList.gljId': adjGljId}, {$pull: {rationGljList: {gljId: adjGljId}}}, {multi: true}, function (err) {
+                                    if(err){
+                                        cb(err);
+                                    }
+                                    else {
+                                        cb(null, compleRst);
+                                    }
+                                });
+                            }
+                        });
+
+                    }
+                    else{
+                        compleRationModel.find({'rationGljList.gljId': adjGljId}, function (err, compleRst) {
+                            if(err){
+                                cb(err);
+                            }
+                            else {
+                                cb(null, compleRst);
+                            }
+                        });
+                    }
+                },
+                function (result, cb) {
+                    async.each(result, function (rationItem, ecb) {
+                        let rationGljList = rationItem.rationGljList,
+                            gljIds = [];
+                        rationGljList.forEach(function (rationGlj) {
+                            let idObj = Object.create(null);
+                            idObj.id = rationGlj.gljId;
+                            idObj.type = rationGlj.type;
+                            gljIds.push(idObj);
+                        });
+                        me.getGljItemsByIds(userID, gljIds, function(err, gljItems){
+                            if(err){
+                                ecb(err);
+                            }
+                            else{
+                                let gljArr = [];
+                                for(let i=0; i<gljItems.length; i++){
+                                    let gljParentType = -1;
+                                    if(gljItems[i].ID === adjGljId){
+                                        gljItems[i].gljType = adjGljType;
+                                    }
+                                    if(gljItems[i].gljType <= 3){
+                                        gljParentType = gljItems[i].gljType;
+                                    }
+                                    if(gljItems[i].gljType > 200 && gljItems[i].gljType < 300){
+                                        gljParentType = 2;
+                                    }
+                                    if(gljItems[i].gljType > 300 && gljItems[i].gljType < 400){
+                                        gljParentType = 3;
+                                    }
+                                    if(gljItems[i].ID === adjGljId){
+                                        gljArr.push({gljId: gljItems[i].ID, basePrice: adjBasePrice, gljParentType: gljParentType});
+                                    }
+                                    else {
+                                        gljArr.push({gljId: gljItems[i].ID, basePrice: parseFloat(gljItems[i].basePrice), gljParentType: gljParentType});
+                                    }
+                                }
+                                gljArr.forEach(function (gljItem) {
+                                    rationGljList.forEach(function (rationGlj) {
+                                        if(gljItem.gljId === rationGlj.gljId){
+                                            gljItem.consumeAmt = parseFloat(rationGlj.consumeAmt);
+                                        }
+                                    })
+                                });
+                                //recalculate the price of ration
+                                let labourPrc = [], materialPrc = [], machinePrc = [], singlePrc, updatePrc = {labourPrice: 0, materialPrice: 0, machinePrice: 0, basePrice: 0};
+                                gljArr.forEach(function (gljItem) {
+                                    if(gljItem.gljParentType !== -1){
+                                        singlePrc = scMathUtil.roundTo(gljItem.basePrice * gljItem.consumeAmt, -3);
+                                        if(gljItem.gljParentType === 1){
+                                            labourPrc.push(singlePrc);
+                                        }
+                                        else if(gljItem.gljParentType ===2){
+                                            materialPrc.push(singlePrc);
+                                        }
+                                        else{
+                                            machinePrc.push(singlePrc);
+                                        }
+                                    }
+                                });
+                                if(labourPrc.length > 0){
+                                    let sumLaP = 0;
+                                    for(let i=0; i<labourPrc.length; i++){
+                                        sumLaP += labourPrc[i];
+                                    }
+                                    updatePrc.labourPrice = scMathUtil.roundTo(sumLaP, -2);
+                                }
+                                if(materialPrc.length > 0){
+                                    let sumMtP = 0;
+                                    for(let i= 0; i<materialPrc.length; i++){
+                                        sumMtP += materialPrc[i];
+                                    }
+                                    updatePrc.materialPrice = scMathUtil.roundTo(sumMtP, -2);
+                                }
+                                if(machinePrc.length > 0){
+                                    let sumMaP = 0;
+                                    for(let i =0; i< machinePrc.length; i++){
+                                        sumMaP += machinePrc[i];
+                                    }
+                                    updatePrc.machinePrice = scMathUtil.roundTo(sumMaP, -2);
+                                }
+                                updatePrc.basePrice = scMathUtil.roundTo(updatePrc.labourPrice + updatePrc.materialPrice + updatePrc.machinePrice, -2);
+                                //updateDataBase
+                                compleRationModel.update({ID: rationItem.ID}, {$set: {labourPrice: updatePrc.labourPrice.toString(), materialPrice: updatePrc.materialPrice.toString(),
+                                        machinePrice: updatePrc.machinePrice.toString(), basePrice: updatePrc.basePrice.toString()}},
+                                    function (err, result) {
+                                        if(err){
+                                            ecb(err);
+                                        }
+                                        else {
+                                            ecb(null);
+                                        }
+                                    });
+                            }
+                        });
+                    }, function(err){
+                        if(err){
+                            cb(err);
+                        }
+                        else {
+                            cb(null);
+                        }
+                    });
+                },
+            ], function (err) {
+                if(err){
+                    finalCb(err);
+                }
+                else{
+                    finalCb(null);
+                }
+            });
+        }, function (err) {
+            if(err){
+                callback(err, 'Error');
+            }
+            else{
+                callback(0, '');
+            }
+        });
+    }
+
+    mixUpdateRationItems (userID, compilationId, rationLibId, sectionId, updateItems, addItems, rIds, callback){
+        let me = this;
+        if (updateItems.length == 0 && rIds.length == 0) {
+            me.addRationItems(userID, compilationId, rationLibId, sectionId, addItems, callback);
+        } else {
+            me.removeRationItems(rationLibId, rIds, function(err, message, docs) {
+                if (err) {
+                    callback(true, false);
+                } else {
+                    me.updateRationItems(userID, rationLibId, sectionId, updateItems, function(err, results){
+                        if (err) {
+                            callback(true, false);
+                        } else {
+                            if (addItems && addItems.length > 0) {
+                                me.addRationItems(rationLibId, sectionId, addItems, callback);
+                            } else {
+                                callback(0, results);
+                            }
+                        }
+                    });
+                }
+            })
+        }
+    }
+
+     removeRationItems(rationRepId, rIds,callback){
+        if (rIds.length > 0) {
+            compleRationModel.remove({rationRepId: rationRepId, ID: {$in: rIds}}, function(err, docs){
+                if (err) {
+                    callback(true, false);
+                } else {
+                    callback(0, docs);
+                }
+            })
+        } else {
+            callback(0,  null);
+        }
+    }
+
+
+     addRationItems(userID, compilationId, rationLibId, sectionId, items,callback){
+        if (items && items.length > 0) {
+            counter.counterDAO.getIDAfterCount(counter.moduleName.rations, items.length, function(err, result){
+                let maxId = result.value.sequence_value;
+                let arr = [];
+                for (let i = 0; i < items.length; i++) {
+                    let obj = new compleRationModel(items[i]);
+                    obj.ID = (maxId - (items.length - 1) + i);
+                    obj.sectionId = sectionId;
+                    obj.rationRepId = rationLibId;
+                    obj.userId = userID;
+                    obj.compilationId = compilationId;
+                    arr.push(obj);
+                }
+                compleRationModel.collection.insert(arr, null, function(err, docs){
+                    if (err) {
+                        callback(true, false);
+                    } else {
+                        callback(0, docs);
+                    }
+                })
+            });
+        } else {
+            callback(true, "Source error!", false);
+        }
+    }
+
+     updateRationItems(userID, rationLibId, sectionId, items,callback){
+        let functions = [];
+        for (let i=0; i < items.length; i++) {
+            functions.push((function(doc) {
+                return function(cb) {
+                    var filter = {};
+                    if (doc.ID) {
+                        filter.ID = doc.ID;
+                    } else {
+                        filter.sectionId = sectionId;
+                        filter.userId = userID;
+                        if (rationLibId) filter.rationRepId = rationLibId;
+                        filter.code = doc.code;
+                    }
+                    compleRationModel.update(filter, doc, cb);
+                };
+            })(items[i]));
+        }
+        async.parallel(functions, function(err, results) {
+            if(!err){
+                err = 0;
+            }
+            callback(err, results);
+        });
+    }
+}
+
+export default CompleRatoinDao;

+ 29 - 0
modules/complementary_ration_lib/models/compleViewModel.js

@@ -0,0 +1,29 @@
+/**
+ * Created by Zhong on 2017/12/22.
+ */
+
+let rationRepositoryModel = require('../../ration_repository/models/repository_map').Model;
+
+class CompleViewModel {
+    async getRationLib(rationRepId, callback){
+        try{
+            let rationLib = await rationRepositoryModel.find({ID: rationRepId, $or: [{deleted: null}, {deleted: false}]});
+            callback(0, rationLib);
+        }
+        catch(err) {
+            callback(err, null);
+        }
+    }
+
+    async getRationLibs(compilationId, callback){
+        try{
+            let rationLibs = await rationRepositoryModel.find({compilationId: compilationId, $or: [{deleted: null}, {deleted: false}]});
+            callback(0, rationLibs);
+        }
+        catch(err) {
+            callback(err, null);
+        }
+    }
+}
+
+export default CompleViewModel;

+ 76 - 0
modules/complementary_ration_lib/models/schemas.js

@@ -0,0 +1,76 @@
+/**
+ * Created by Zhong on 2017/12/21.
+ */
+
+import mongoose from 'mongoose';
+
+let deleteSchema = require('../../../public/models/delete_schema');
+let Schema = mongoose.Schema;
+
+//补充定额章节树
+let compleRationSectionTreeSchema = new Schema({
+    //用户名
+    userId: Number,
+    //编办
+    compilationId: String,
+    //标准定额库
+    rationRepId: Number,
+    //名称
+    name: String,
+    //是否是同层第一个节点
+    isFirst: Boolean,
+    ID: Number,
+    NextSiblingID: Number,
+    ParentID: Number,
+    deleteInfo: deleteSchema
+}, {versionKey: false});
+
+//定额工料机
+let compleRationGljItemSchema = new Schema({
+    gljId: Number,
+    consumeAmt: String,
+    type: String    //std or complementary
+
+}, { _id: false });
+
+//辅助定额调整
+let compleRationAssItemSchema = new Schema({
+    name: String,
+    assistID: Number,
+    assistCode: String,
+    stdValue: String,
+    stepValue: String,
+    decimal: Number,
+    carryBit: String,
+    minValue: String,
+    maxValue: String
+}, { _id: false });
+
+//补充定额
+let compleRationSchema = new Schema({
+    userId: Number,
+    compilationId: String,
+    rationRepId: Number,
+    ID:Number,
+    code: String,
+    name: String,
+    unit: String,
+    labourPrice: String,
+    materialPrice: String,
+    machinePrice: String,
+    basePrice: String,
+    sectionId: Number,
+    caption: String,
+    feeType: Number,
+    jobContent: String,
+    annotation: String,
+    rationGljList: [compleRationGljItemSchema],
+    rationCoeList: Array,
+    rationAssList: [compleRationAssItemSchema],
+    deleteInfo: deleteSchema
+}, {versionKey: false});
+
+let compleRationSectionTreeModel = mongoose.model('complementary_ration_section_tree', compleRationSectionTreeSchema, 'complementary_ration_section_tree');
+let compleRationModel = mongoose.model('complementary_ration_items', compleRationSchema, 'complementary_ration_items');
+
+export {compleRationSectionTreeModel, compleRationModel};

+ 88 - 0
modules/complementary_ration_lib/models/sectionTreeModel.js

@@ -0,0 +1,88 @@
+/**
+ * Created by Zhong on 2017/12/21.
+ */
+
+import {compleRationSectionTreeModel} from './schemas';
+
+let counter = require('../../../public/counter/counter');
+let stdSectionTreeModel = require ('../../ration_repository/models/ration_section_tree').Model;
+
+class SectionTreeDao {
+    getNewTreeID(callback){
+        counter.counterDAO.getIDAfterCount(counter.moduleName.rationTree, 1, function (err, result) {
+            if(err){
+                callback(err, null);
+            }
+            else {
+                callback(0, result.value.sequence_value);
+            }
+        });
+
+    }
+
+    //获取补充定额拼接章节树
+    async getRationTree(userID, rationRepId, callback){
+        try{
+            let stdSectionTree = await stdSectionTreeModel.find({rationRepId: rationRepId, $or: [{isDeleted: null}, {isDeleted: false}]});
+            let compleSectionTree = await compleRationSectionTreeModel.find({userId: userID, rationRepId: rationRepId, deleteInfo: null});
+            let dropPids = [], rstCompleSectionTree = [];
+            //mark std
+            for(let i = 0, len = stdSectionTree.length; i < len; i++){
+                stdSectionTree[i]._doc.type = 'std';
+            }
+            for(let i = 0, len = compleSectionTree.length; i < len; i++){
+                //mark complementary
+                compleSectionTree[i]._doc.type = 'complementary';
+                if(compleSectionTree[i]['isFirst']){
+                    let updateSection = getUpdateSection(compleSectionTree[i]['ParentID'], stdSectionTree);
+                    if(updateSection) {
+                        updateSection._doc.NextSiblingID = compleSectionTree[i]['ID'];
+                    }
+                    else if(!updateSection && compleSectionTree[i]['ParentID'] !== -1){
+                        dropPids.push(compleSectionTree[i]['ParentID']);
+                    }
+                }
+            }
+            function getUpdateSection(pid, datas){
+                for(let i = 0, len = datas.length; i < len; i++){
+                    if(datas[i]['ParentID'] === pid && datas[i]['NextSiblingID'] === -1){
+                        return datas[i];
+                    }
+                }
+                return null;
+            }
+            //返回父节点未被删除的
+            for(let i = 0, len = compleSectionTree.length; i < len; i++){
+                if(dropPids.indexOf(compleSectionTree[i]['ParentID']) === -1){
+                    rstCompleSectionTree.push(compleSectionTree[i]);
+                }
+            }
+            callback(0, stdSectionTree.concat(rstCompleSectionTree));
+        }
+        catch (err){
+            callback(err, null);
+        }
+    }
+
+    async updateSection(userID, compilationId, updateData, callback){
+        try{
+            for(let i = 0, len = updateData.length; i < len; i++){
+                let updateObj = updateData[i];
+                if(updateObj.updateType === 'new'){
+                    updateObj.updateData.userId = userID;
+                    updateObj.updateData.compilationId = compilationId;
+                    await compleRationSectionTreeModel.create(updateObj.updateData);
+                }
+                else if(updateObj.updateType === 'update'){
+                    await compleRationSectionTreeModel.update({userId: userID, rationRepId: updateObj.updateData.rationRepId, ID: updateObj.updateData.ID}, updateObj.updateData);
+                }
+            }
+            callback(0, 'success');
+        }
+        catch(err){
+            callback(err, null);
+        }
+    }
+}
+
+export default SectionTreeDao;

+ 46 - 0
modules/complementary_ration_lib/routes/routes.js

@@ -0,0 +1,46 @@
+/**
+ * Created by Zhong on 2017/12/21.
+ */
+
+import express from 'express';
+import CompleViewController from '../controllers/compleViewController';
+import CompleSectionTreeController from '../controllers/compleSectionTreeController';
+import CompleRationController from '../controllers/compleRationController';
+import GljController from '../../complementary_glj_lib/controllers/gljController';
+
+let router = express.Router();
+let compleViewController = new CompleViewController();
+let compleSectionTreeController = new CompleSectionTreeController();
+let compleRationController = new CompleRationController();
+let gljController = new GljController();
+
+module.exports = function (app) {
+    //app.get('/complementaryRation/main', compleViewController.init, compleViewController.redirectMain);
+    app.get('/complementaryRation/ration', compleViewController.init, compleViewController.redirectRation);
+    app.get('/complementaryRation/glj', compleViewController.init, compleViewController.redirectGljList);
+    app.get('/complementaryRation/coe', compleViewController.init, compleViewController.redirectCoeList);
+
+    router.post('/getRationLib', compleViewController.init, compleViewController.getRationLib);
+    router.post('/getRationLibs', compleViewController.init, compleViewController.getRationLibs);
+
+    router.post('/getNewTreeID', compleSectionTreeController.init, compleSectionTreeController.getNewTreeID);
+    router.post('/getRationTree', compleSectionTreeController.init, compleSectionTreeController.getRationTree);
+    router.post('/updateRationSection', compleSectionTreeController.init, compleSectionTreeController.updateRationSection);
+
+    router.post('/getRationItems', compleRationController.init, compleRationController.getRationItems);
+    router.post('/mixUpdateRationItems', compleRationController.init, compleRationController.mixUpdateRationItems);
+
+    router.post('/getGljDistType', gljController.init, gljController.getGljDistType);
+    router.post('/getGljTree', gljController.init, gljController.getGljTree);
+    router.post('/getGljItems', compleRationController.init, compleRationController.getGljItems);
+    router.post('/getGljItemsOccupied', compleRationController.init, compleRationController.getGljItemsOccupied);
+    router.post('/getRationsCodes', compleRationController.init, compleRationController.getRationsCodes);
+    router.post('/getGljItemsByIds', compleRationController.init, compleRationController.getGljItemsByIds);
+    router.post('/getGljItemsByCodes', compleRationController.init, compleRationController.getGljItemsByCodes);
+
+    router.post('/getCoeList', compleRationController.init, compleRationController.getCoeList);
+    router.post('/getCoeItemsByIDs', compleRationController.init, compleRationController.getCoeItemsByIDs);
+    router.post('/getCoeItemsByNos', compleRationController.init, compleRationController.getCoeItemsByNos);
+
+    app.use('/complementaryRation/api', router);
+};

+ 2 - 0
modules/main/models/bills.js

@@ -23,6 +23,8 @@ let billsSchema = new Schema({
     chapterID: Number,
     code: String,
     fullCode: String,
+    type:Number,
+    isAdd:{type: Number,default:0},//1 true 0 false是否新增
     name: String,
     unit: String,
     quantity: String, // Decimal

+ 2 - 0
modules/ration_glj/models/ration_glj_temp.js

@@ -147,6 +147,8 @@ let billsSchema = new Schema({
     chapterID: Number,
     code: String,
     fullCode: String,
+    type:Number,
+    isAdd:{type: Number,default:0},//1 true 0 false是否新增
     name: String,
     unit: String,
     quantity: String, // Decimal

+ 14 - 3
modules/ration_repository/models/coe.js

@@ -46,10 +46,21 @@ coeListDAO.prototype.getCoeItemsByIDs = function (data, callback) {
     coeListModel.find({
             "libID": data.libID,
             "ID": {"$in":data.coeIDs}
-        }, ["libID","ID","name","content","-_id"],
+        }, ["libID","ID", "serialNo","name","content","-_id"],
         function (err, doc) {
             if (err) callback("批量获取系数明细错误!", null)
-            else callback(null, doc);
+            else callback(0, doc);
+        })
+};
+
+coeListDAO.prototype.getCoeItemsByNos = function (data, callback) {
+    coeListModel.find({
+            "libID": data.libID,
+            "serialNo": {"$in":data.coeNos}
+        }, ["libID","ID","serialNo","name","content","-_id"],
+        function (err, doc) {
+            if (err) callback("批量获取系数明细错误!", null)
+            else callback(0, doc);
         })
 };
 
@@ -57,7 +68,7 @@ coeListDAO.prototype.getCoesByLibID = function (libID, callback) {
     coeListModel.find({ "libID": libID },
         function (err, doc) {
             if (err) callback("获取定额库系数表错误", null)
-            else callback(null, doc);
+            else callback(0, doc);
         })
 };
 

+ 5 - 4
public/web/sheet/sheet_common.js

@@ -228,7 +228,7 @@ var sheetCommonObj = {
         var rst = true;
         if (rObj) {
             for (var i = 0; i < setting.header.length; i++) {
-                if (rObj[setting.header[i]]) {
+                if (rObj[setting.header[i].dataCode]) {
                     rst = false;
                     break;
                 }
@@ -238,12 +238,13 @@ var sheetCommonObj = {
     },
     //add by zhong 2017-10-10
     //动态下拉框,配合EnterCell, args.sheet.repaint();
-    getDynamicCombo: function () {
+    getDynamicCombo: function (forLocked) {
         let ComboCellForActiveCell = function () { };
         ComboCellForActiveCell.prototype = new GC.Spread.Sheets.CellTypes.ComboBox();
         ComboCellForActiveCell.prototype.paintValue = function (ctx, value, x, y, w, h, style, options) {
             let sheet = options.sheet;
-            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex() && !sheet.getCell(options.row, options.col).locked()) {
+            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex() && (!forLocked || forLocked && !sheet.getCell(options.row, options.col).locked())) {
+
                 GC.Spread.Sheets.CellTypes.ComboBox.prototype.paintValue.apply(this, arguments);
 
             } else {
@@ -252,7 +253,7 @@ var sheetCommonObj = {
         };
         ComboCellForActiveCell.prototype.getHitInfo = function (x, y, cellStyle, cellRect, options) {
             let sheet = options.sheet;
-            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex() && !sheet.getCell(options.row, options.col).locked()) {
+            if (options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex() && (!forLocked || forLocked && !sheet.getCell(options.row, options.col).locked())) {
                 return GC.Spread.Sheets.CellTypes.ComboBox.prototype.getHitInfo.apply(this, arguments);
 
             } else {

+ 24 - 35
web/building_saas/complementary_glj_lib/js/glj.js

@@ -447,7 +447,7 @@ let repositoryGljObj = {
             //--------------------------------------
             if(me.currentEditingGlj.basePrice !== rObj.basePrice){
                 //update basePrice of ration when editting basePrice of glj
-               /* let gljType = -1;
+                let gljType = -1;
                 let gljTypeParent = me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj.gljType].parent;
                 if(gljTypeParent && gljTypeParent.data.ID <=3){
                     gljType = gljTypeParent.data.ID;
@@ -458,18 +458,14 @@ let repositoryGljObj = {
                 let gljBasePrcObj = {gljId: me.currentEditingGlj.ID, gljType: gljType, basePrice: rObj.basePrice};
                 if(gljBasePrcObj.gljType !== -1){
                     updateBasePrcArr.push(gljBasePrcObj);
-                    if(me.rationLibs.length > 0){//重算定额单价
-                        me.updateRationBasePrcRq(updateBasePrcArr);
-                    }
-                }*/
+                    me.updateRationBasePrcRq(updateBasePrcArr);
+                }
             }
             //update basePrice of ration when editting gljType of glj
             if(me.currentEditingGlj.gljType !== rObj.gljType){
-                /*let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
+                let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
                 updateBasePrcArr.push(gljTypeObj);
-                if(me.rationLibs.length > 0){
-                    me.updateRationBasePrcRq(updateBasePrcArr);
-                }*/
+                me.updateRationBasePrcRq(updateBasePrcArr);
             }
             //-----------------------------------------------------------
         }
@@ -783,7 +779,7 @@ let repositoryGljObj = {
         }
     },
     onClipboardPasted: function(e, info) {
-        if(info.pasteData.text.trim().length > 0){
+      //  if(info.pasteData.text.trim().length > 0){
             let me = repositoryGljObj;
             let updateArr = [], addArr = [];
             let items = sheetOpr.analyzePasteData(me.setting, info);
@@ -795,11 +791,12 @@ let repositoryGljObj = {
                 //updateItems = items;
                 for(let i = 0; i < items.length; i++){
                     let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
-                    if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
-                        updateArr = updateObj.updateGlj;
-                        /*if(typeof updateObj.updateBasePrcArr !== 'undefined'){
-                         updateBasePrcArr = updateObj.updateBasePrcArr;
-                         }*/
+                    if(updateObj && typeof updateObj.updateGlj !== 'undefined' && updateObj.updateGlj.length > 0){
+                        //updateArr = updateObj.updateGlj;
+                        updateArr = updateArr.concat(updateObj.updateGlj);
+                        if(typeof updateObj.updateBasePrcArr !== 'undefined'){
+                            updateBasePrcArr = updateBasePrcArr.concat(updateObj.updateBasePrcArr);
+                         }
                     }
                     else{
                         resumeArr.push(info.cellRange.row + i);
@@ -811,10 +808,11 @@ let repositoryGljObj = {
                 for(let i = 0; i < updateCount; i++){
                     let updateObj = me.validUpdateObj(items[i], info.cellRange.row + i);
                     if(updateObj && typeof updateObj.updateGlj !== 'undefined'){
-                        updateArr = updateObj.updateGlj;
-                        /* if(typeof updateObj.updateBasePrcArr !== 'undefined'){
-                         updateBasePrcArr = updateObj.updateBasePrcArr;
-                         }*/
+                        //updateArr = updateObj.updateGlj;
+                        updateArr = updateArr.concat(updateObj.updateGlj);
+                        if(typeof updateObj.updateBasePrcArr !== 'undefined'){
+                            updateBasePrcArr = updateBasePrcArr.concat(updateObj.updateBasePrcArr);
+                        }
                     }
                     else{
                         resumeArr.push(info.cellRange.row + i);
@@ -889,29 +887,20 @@ let repositoryGljObj = {
             if (updateArr.length > 0 || addArr.length > 0) {
                 me.mixUpdateRequest(updateArr, addArr, []);
             }
-            /*if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
-             me.updateRationBasePrcRq(updateBasePrcArr);
-             }*/
-        }
-        else{//解决bug: 从原本的sheet复制一行数据,会两次调用粘贴事件函数..,todo:找出原因
+            if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
+                me.updateRationBasePrcRq(updateBasePrcArr);
+            }
+       // }
+      /*  else{//解决bug: 从原本的sheet复制一行数据,会两次调用粘贴事件函数..,todo:找出原因
             for(let i = 0, len = info.cellRange.rowCount; i < len; i++){
                 for(let col = 0; col < 6; col++){
                     info.sheet.setValue(info.cellRange.row + i, col, '');
                 }
             }
-        }
+        }*/
     },
     updateRationBasePrcRq: function (basePrcArr) {
-        $.ajax({
-            type: 'post',
-            url: 'complementartGlj/api/updateRationBasePrc',
-            data:{basePrcArr: JSON.stringify(basePrcArr)},
-            dataType: 'json',
-            success: function (result) {
-                if(result.error){
-                    alert("计算定额基价失败");
-                }
-            }
+        CommonAjax.post('complementartGlj/api/updateRationBasePrc', {basePrcArr: basePrcArr}, function (rstData) {
         });
     },
   /*  getRationGljIds: function (repId) {

+ 1 - 0
web/building_saas/complementary_glj_lib/js/sheetOpr.js

@@ -49,6 +49,7 @@ let sheetOpr = {
         //Set rowHeader count and columnHeader count.
         sheet.setRowCount(1, spreadNS.SheetArea.colHeader);
         sheet.setColumnCount(setting.header.length, spreadNS.SheetArea.viewport);
+        sheet.options.clipBoardOptions = GC.Spread.Sheets.ClipboardPasteOptions.values;
         sheet.options.colHeaderAutoTextIndex = 1;
         sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
         sheet.options.protectionOptions = {

+ 9 - 11
web/building_saas/complementary_ration_lib/html/dinge.html

@@ -48,10 +48,10 @@
                       <div class="tab-bar">
                           <a href="javascript:void(0);" id="tree_Insert" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-plus" aria-hidden="true"></i></a>
                           <a href="javascript:void(0);" id="tree_remove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm " data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
-                          <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upLevel" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="升级"><i class="fa fa-arrow-left" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downLevel" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="降级"><i class="fa fa-arrow-right" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_downMove" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
+                          <a href="javascript:void(0);" id="tree_upMove" class="btn btn-sm disabled" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                       </div>
                     <div class="tab-content" id="sectionSpread" style="overflow: hidden">
                       <!--<ul id="rationChapterTree" class="ztree"></ul>-->
@@ -110,31 +110,29 @@
                           <!--说明-->
                           <div class="tab-pane" id="tsm" role="tabpanel">
                               <div class="main-data">
-                                <!--  <div class="m-2"><a href="javacript:void(0);" data-toggle="modal" data-target="#editTsm" title="编辑">编辑说明</a></div>-->
                                   <div class="main-content m-2">
                                       <h5>说明</h5>
-                                      <textarea id="explanationShow" class="form-control" rows="35" style="background: white;"></textarea>
+                                      <textarea id="explanationShow" class="form-control" disabled="disabled" rows="35" style="background: white;"></textarea>
                                   </div>
                               </div>
                           </div>
                           <!--计算规则-->
                           <div class="tab-pane" id="tjs" role="tabpanel">
                               <div class="main-data">
-                         <!--         <div class="m-2"><a href="javacript:void(0);" data-toggle="modal" data-target="#editTjs" title="编辑">编辑计算规则</a></div>-->
                                   <div class="main-content m-2">
                                       <h5>计算规则</h5>
-                                      <textarea id="ruleTextShow" class="form-control"   rows="35" style="background: white;"></textarea>
+                                      <textarea id="ruleTextShow" class="form-control" disabled="disabled"  rows="35" style="background: white;"></textarea>
                                   </div>
                               </div>
                           </div>
                           <!--工作内容-->
                           <div class="tab-pane" id="tgz" role="tabpanel">
                               <div class="main-data">
-                                  <div class="form-check m-2"><label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="ALL" disabled=""> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input" name="optionsRadios" value="PARTIAL" disabled> 适合本项部分定额</label></div>
+                                  <div class="form-check m-2"><label class="form-check-label"><input type="radio"  class="form-check-input" name="optionsRadios" value="ALL" disabled="true"> 适合本项所有定额</label>&nbsp;&nbsp;<label class="form-check-label"><input type="radio" class="form-check-input disabled" name="optionsRadios" value="PARTIAL" disabled="true"> 适合本项部分定额</label></div>
                                   <!-- <p class="m-2">适合本项所有定额</p> -->
                                   <table class="table table-sm table-bordered m-0" id="tableAll">
                                       <tr>
-                                          <td><textarea class="form-control" rows="30" id="txtareaAll"></textarea></td>
+                                          <td><textarea class="form-control" rows="30" id="txtareaAll" disabled="disabled" style="background: white;"></textarea></td>
                                       </tr>
                                   </table>
                                   <table class="table table-sm table-bordered m-0" id="tablePartial">
@@ -148,7 +146,7 @@
                                   <!-- <p class="m-2">适合本项所有定额</p> -->
                                   <table class="table table-sm table-bordered m-0" id="fzTableAll">
                                       <tr>
-                                          <td><textarea class="form-control" rows="30" id="fzTxtareaAll"></textarea></td>
+                                          <td><textarea class="form-control" rows="30" id="fzTxtareaAll" disabled="disabled" style="background: white;"></textarea></td>
                                       </tr>
                                   </table>
                                   <table class="table table-sm table-bordered m-0" id="fzTablePartial">

+ 8 - 78
web/building_saas/complementary_ration_lib/html/fuzhu.html

@@ -7,7 +7,7 @@
     <meta http-equiv="x-ua-compatible" content="ie=edge">
     <title>定额库编辑器</title>
     <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
-    <link rel="stylesheet" href="/web/maintain/ration_repository/css/main.css">
+    <link rel="stylesheet" href="/web/building_saas/css/main.css">
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
     <!--zTree-->
@@ -36,26 +36,10 @@
                   </li>
 
                   <li class="nav-item">
-                  <!--<input type="button" id="btnAddRow" value="Add Row" />-->
-                  <!--<input type="button" id="btnDeleteRow" value="Delete Row" />-->
                   </li>
               </ul>
         </nav>
     </div>
-   <!-- <div class="main">
-        <div class="content">
-            <div class="container-fluid">
-                <div class="row">
-                  <div class="main-side col-lg-7 p-0">
-                    <div class="main-data" id="mainSpread"  style="height:1000px;"></div>
-                  </div>
-                  <div class="main-content col-lg-5 p-0">
-                      <div class="main-data" id="contentSpread" style="height:1000px;"></div>
-                  </div>
-                </div>
-            </div>
-        </div>
-    </div>-->
     <div class="main">
         <div class="content">
             <div class="container-fluid">
@@ -74,83 +58,29 @@
     </div>
 
     <!-- JS. -->
-    <script src="/lib/jquery/jquery.min.js"></script>
-    <script src="/lib/tether/tether.min.js"></script>
+    <script src="/lib/jquery/jquery-3.2.1.min.js"></script>
+    <script src="/lib/popper/popper.min.js"></script>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
-    <script type="text/javascript" src="/web/maintain/ration_repository/js/global.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/global.js"></script>
     <!-- zTree -->
     <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
     <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.exedit.js"></script>
+    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/QueryParam.js"></script>
-    <script src="/public/common_util.js"></script>
-    <script src="/public/debug.js"></script>
+    <script src="/public/web/common_util.js"></script>
     <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
-    <script type="text/javascript" src="/web/maintain/ration_repository/js/sheetsOpr.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/sheetsOpr.js"></script>
     <script type="text/javascript" src="/public/web/storageUtil.js"></script>
-    <script type="text/javascript" src="/web/maintain/ration_repository/js/coe.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/coe.js"></script>
     <script type="text/javascript">
         $(document).ready(function () {
             pageObj.initPage();
         });
     </script>
-   <!-- <SCRIPT type="text/javascript">
-  		&lt;!&ndash;
-  		var setting = {
-  			view: {
-  				showIcon: false
-  			},
-  			data: {
-  				simpleData: {
-  					enable: true
-  				}
-  			}
-  		};
-
-  		var zNodes =[
-  			{ id:1, pId:0, name:"父节点1 - 展开", open:true},
-  			{ id:11, pId:1, name:"父节点11 - 折叠"},
-  			{ id:111, pId:11, name:"叶子节点111"},
-  			{ id:112, pId:11, name:"叶子节点112"},
-  			{ id:113, pId:11, name:"叶子节点113"},
-  			{ id:114, pId:11, name:"叶子节点114"},
-  			{ id:12, pId:1, name:"父节点12 - 折叠"},
-  			{ id:121, pId:12, name:"叶子节点121"},
-  			{ id:122, pId:12, name:"叶子节点122"},
-  			{ id:123, pId:12, name:"叶子节点123"},
-  			{ id:124, pId:12, name:"叶子节点124"},
-  			{ id:13, pId:1, name:"父节点13 - 没有子节点", isParent:true},
-  			{ id:2, pId:0, name:"父节点2 - 折叠"},
-  			{ id:21, pId:2, name:"父节点21 - 展开", open:true},
-  			{ id:211, pId:21, name:"叶子节点211"},
-  			{ id:212, pId:21, name:"叶子节点212"},
-  			{ id:213, pId:21, name:"叶子节点213"},
-  			{ id:214, pId:21, name:"叶子节点214"},
-  			{ id:22, pId:2, name:"父节点22 - 折叠"},
-  			{ id:221, pId:22, name:"叶子节点221"},
-  			{ id:222, pId:22, name:"叶子节点222"},
-  			{ id:223, pId:22, name:"叶子节点223"},
-  			{ id:224, pId:22, name:"叶子节点224"},
-  			{ id:23, pId:2, name:"父节点23 - 折叠"},
-  			{ id:231, pId:23, name:"叶子节点231"},
-  			{ id:232, pId:23, name:"叶子节点232"},
-  			{ id:233, pId:23, name:"叶子节点233"},
-  			{ id:234, pId:23, name:"叶子节点234"},
-  			{ id:3, pId:0, name:"父节点3 - 没有子节点", isParent:true}
-  		];
-
-  		function showIconForTree(treeId, treeNode) {
-  			return !treeNode.isParent;
-  		};
-
-  		$(document).ready(function(){
-  			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
-  		});
-  		//&ndash;&gt;
-  	</SCRIPT>-->
 </body>
 <script type="text/javascript">
     autoFlashHeight();

+ 9 - 8
web/building_saas/complementary_ration_lib/html/gongliao.html

@@ -7,7 +7,7 @@
     <meta http-equiv="x-ua-compatible" content="ie=edge">
     <title>定额库编辑器</title>
     <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
-    <link rel="stylesheet" href="/web/maintain/ration_repository/css/main.css">
+    <link rel="stylesheet" href="/web/building_saas/css/main.css">
     <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
     <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
     <!--zTree-->
@@ -26,7 +26,7 @@
         <nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0">
               <ul class="nav nav-tabs" role="tablist">
                   <li class="nav-item">
-                      <a class="nav-link px-3" id="drirect-dinge" href="/rationRepository/ration">定额</a>
+                      <a class="nav-link px-3" id="drirect-dinge" href="/complementaryRation/ration">定额</a>
                   </li>
                   <li class="nav-item">
                       <a class="nav-link active px-3">工料机</a>
@@ -212,25 +212,26 @@
         </div>
     </div>
     <!-- JS. -->
-    <script src="/lib/jquery/jquery.min.js"></script>
-    <script src="/lib/tether/tether.min.js"></script>
+    <script src="/lib/jquery/jquery-3.2.1.min.js"></script>
+    <script type="text/javascript" src="/lib/popper/popper.min.js"></script>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
-    <script type="text/javascript" src="/web/maintain/ration_repository/js/global.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/global.js"></script>
     <!-- zTree -->
     <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
     <script>GC.Spread.Sheets.LicenseKey = "559432293813965#A0y3iTOzEDOzkjMyMDN9UTNiojIklkI1pjIEJCLi4TPB9mM5AFNTd4cvZ7SaJUVy3CWKtWYXx4VVhjMpp7dYNGdx2ia9sEVlZGOTh7NRlTUwkWR9wEV4gmbjBDZ4ElR8N7cGdHVvEWVBtCOwIGW0ZmeYVWVr3mI0IyUiwCMzETN8kzNzYTM0IicfJye&Qf35VfiEzRwEkI0IyQiwiIwEjL6ByUKBCZhVmcwNlI0IiTis7W0ICZyBlIsIyNyMzM5ADI5ADNwcTMwIjI0ICdyNkIsIibj9SbvNmL4N7bjRnch56ciojIz5GRiwiI8+Y9sWY9QmZ0Jyp96uL9v6L0wap9biY9qiq95q197Wr9g+89iojIh94Wiqi";</script>
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
   	<script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.exedit.js"></script>
+    <script type="text/javascript" src="/public/web/common_ajax.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/QueryParam.js"></script>
-    <script type="text/javascript" src="/web/maintain/ration_repository/js/repository_glj.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/repository_glj.js"></script>
     <script type="text/javascript" src="/public/web/ztree_common.js"></script>
     <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
-    <script type="text/javascript" src="/web/maintain/ration_repository/js/sheetsOpr.js"></script>
+    <script type="text/javascript" src="/web/building_saas/complementary_ration_lib/js/sheetsOpr.js"></script>
     <script type="text/javascript" src="/public/web/storageUtil.js"></script>
     <script type="text/javascript">
-        let userAccount = '<%=userAccount %>';
+        let userID = '<%=userID %>';
         var gljSetting = {
             view: {
                // addHoverDom: gljTypeTreeOprObj.addHoverDom,

+ 9 - 9
web/building_saas/complementary_ration_lib/js/annotation.js

@@ -73,12 +73,12 @@ let annotationOprObj = {
             $tbody.append($newTr);
             count++;
         }
-        let $trEnd = $("<tr><td>"+ count +"</td><td><a href data-toggle='modal' data-target='#fzEditBianma' class='m-0'>点击勾选编码</a></td><td><textarea class='form-control'></textarea></td></tr>");//勾选行
-        $($trEnd.children().children()[0]).bind('click', function () {
+        let $trEnd = $("<tr><td>"+ count +"</td><td></td><td><textarea class='form-control' disabled='disabled' style='background: white'></textarea></td></tr>");//勾选行
+        /*$($trEnd.children().children()[0]).bind('click', function () {
             me.onclickFuncAdd($(this));
             me.currentOprTr = $trEnd;
             me.currentAnnotation = $(me.currentOprTr.children()[2]).children().val();
-        });
+        });*/
         $tbody.append($trEnd);
         table.append($thead);
         table.append($tbody);
@@ -88,17 +88,17 @@ let annotationOprObj = {
         let me = annotationOprObj;
         let count = tbody.children().length > 0 ? tbody.children().length : 1;
         let $textTd = $("<td></td>");
-        let $textarea = $("<textarea class='form-control'></textarea>");
+        let $textarea = $("<textarea class='form-control' disabled='disabled' style='background: white'></textarea>");
         $textarea.val(jobContent);
         $textTd.append($textarea);
         let $tr = $("<tr><td>" + count + "</td><td><a href data-toggle='modal' data-target='#fzEditBianmaQ' class='m-0'>编辑编码</a></td></tr>");
-        $tr.children().children().bind('click', function () {
+        /*$tr.children().children().bind('click', function () {
             me.currentOprTr = $tr;
             me.currentAnnotation = $(me.currentOprTr.children()[2]).children().val();
             me.onclickFuncEdit($(this));
-        });
+        });*/
         //文本变化;
-        $textarea.bind('change', function () {
+       /* $textarea.bind('change', function () {
             let codes = me.getUpdateCodes($($(this).parent().parent().children()[1]).children());
             let annotation = $(this).val();
             me.updateAnnotation(pageOprObj.rationLibId, me.getUpdateArr(codes, annotation), function () {
@@ -106,7 +106,7 @@ let annotationOprObj = {
                     me.buildTablePartial(me.fzTablePartial, me.getGroup(jobContentOprObj.currentRationItems));
                 }
             });
-        });
+        });*/
         $tr.append($textTd);
         for(let i = 0, len = codes.length; i < len; i ++){
             let $p = $("<p class='m-0'>" + codes[i] + "</p>");
@@ -319,7 +319,7 @@ let annotationOprObj = {
     //定额工作内容相关操作
     rationAnnotationOpr: function (rationItems) {
         let me = annotationOprObj;
-        me.setRadiosDisabled(rationItems.length > 0 ? false : true, me.radios);
+     //   me.setRadiosDisabled(rationItems.length > 0 ? false : true, me.radios);
         me.setRadiosChecked(me.currentSituation, me.radios);
         me.buildTablePartial(me.fzTablePartial, me.getGroup(rationItems));
     },

+ 17 - 447
web/building_saas/complementary_ration_lib/js/coe.js

@@ -9,11 +9,11 @@ var pageObj = {
     gljLibID: null,
     initPage: function (){
         $("#drirect-dinge").click(function(){
-            $(this).attr('href', "/rationRepository/ration" + "?repository=" + getQueryString("repository"))
+            $(this).attr('href', "/complementaryRation/ration" + "?repository=" + getQueryString("repository"))
         });
 
         $("#gongliao").click(function(){
-            $(this).attr('href', "/rationRepository/lmm" + "?repository=" + getQueryString("repository"))
+            $(this).attr('href', "/complementaryRation/glj" + "?repository=" + getQueryString("repository"))
         });
 
         var libID = getQueryString("repository");
@@ -83,11 +83,9 @@ let coeOprObj = {
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         me.workSheet = me.workBook.getSheet(0);
         me.workSheet.options.isProtected = true;
-        me.onDelOpr(me.workBook, me.setting);
         me.workSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
-        me.workSheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
+        me.workSheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStarting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-        me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
     },
     onSelectionChanged: function (sender, info) {
         let me = coeOprObj, that = gljAdjOprObj;
@@ -109,194 +107,15 @@ let coeOprObj = {
             that.show(that.currentGljAdjList);
         }
     },
-    onEditEnded: function (sender, args) {
-        let me = coeOprObj, addArr = [], updateArr = [], dataCode = me.setting.header[args.col].dataCode;
-        if(args.editingText && args.editingText.toString().trim().length > 0){
-            let inputT = args.editingText.toString().trim();
-            //update
-            if(args.row < me.currentCoeList.length){
-                let updateObj = me.currentCoeList[args.row];
-                if(updateObj[dataCode] != inputT){
-                    if(dataCode === 'serialNo'){
-                        if(me.isInt(inputT) && !me.hasTisNo(me.currentCoeList, inputT)){
-                            me.currentMaxNo = me.currentMaxNo >= inputT ? me.currentMaxNo : inputT;
-                            updateObj[dataCode] = inputT;
-                            updateArr.push(updateObj);
-                            me.save([], updateArr, [], true);
-                        }
-                        else if(!me.isInt(inputT)){
-                            alert('编号只能为整数!');
-                            args.sheet.setValue(args.row, args.col, updateObj[dataCode] + '');
-                        }
-                        else if(me.hasTisNo(me.currentCoeList, inputT)){
-                            alert('该编号已存在!');
-                            args.sheet.setValue(args.row, args.col, updateObj[dataCode] + '');
-                        }
-                    }
-                    else {
-                        updateObj[dataCode] = inputT;
-                        updateArr.push(updateObj);
-                        me.save([], updateArr, [], true);
-                    }
-                }
-            }
-            //insert
-            else{
-                let newCoe = {};
-                newCoe.libID = pageObj.libID;
-                if(dataCode === 'serialNo'){
-                    if(me.isInt(inputT) && !me.hasTisNo(me.currentCoeList, inputT)){
-                        me.currentMaxNo = me.currentMaxNo >= inputT ? me.currentMaxNo : inputT;
-                        newCoe[dataCode] = inputT;
-                        addArr.push(newCoe);
-                        me.save(addArr, [], [], true, function (result) {
-                            me.updateCurrentCoeList(result);
-                        });
-                    }
-                    else if(!me.isInt(inputT)){
-                        args.sheet.setValue(args.row, args.col, '');
-                        alert('编号只能为整数!');
-                    }
-                    else if(me.hasTisNo(me.currentCoeList, inputT)){
-                        args.sheet.setValue(args.row, args.col, '');
-                        alert('该编号已存在!');
-                    }
-                }
-                else{
-                    newCoe.serialNo = ++me.currentMaxNo;
-                    newCoe[dataCode] = inputT;
-                    addArr.push(newCoe);
-                    me.save(addArr, [], [], true, function (result) {
-                        me.updateCurrentCoeList(result);
-                    });
-                }
-            }
-        }
+    onEditStarting: function (sender, args) {
+        args.cancel = true;
     },
     onClipboardPasting: function (sender, info) {
-        let me = coeOprObj, maxCol = info.cellRange.col + info.cellRange.colCount - 1;
-        if(maxCol > me.setting.header.length){
-            info.cancel = true;
-        }
-    },
-    onClipboardPasted: function (sender, info) {
-        let me = coeOprObj, addArr = [], updateArr = [];
-        let items = sheetCommonObj.analyzePasteData(me.setting, info);
-        let uniqItems = me.makeUniqItems(items);
-        for(let i = 0, len = uniqItems.length; i < len; i++){
-            let row = i + info.cellRange.row;
-            //update
-            if(row < me.currentCoeList.length){
-                let updateObj = me.currentCoeList[row];
-                for(let attr in uniqItems[i]){
-                    if(attr === 'serialNo'){
-                        if(me.isInt(uniqItems[i][attr]) && !me.hasTisNo(me.currentCoeList, uniqItems[i][attr])){
-                            me.currentMaxNo = me.currentMaxNo >= uniqItems[i][attr] ? me.currentMaxNo : uniqItems[i][attr];
-                            updateObj[attr] = uniqItems[i][attr];
-                        }
-                    }
-                    else {
-                        updateObj[attr] = uniqItems[i][attr];
-                    }
-                }
-                updateArr.push(updateObj);
-            }
-            //insert
-            else {
-                if(typeof uniqItems[i].serialNo !== 'undefined' && uniqItems[i] && me.isInt(uniqItems[i].serialNo) && !me.hasTisNo(me.currentCoeList, uniqItems[i].serialNo)){
-                    me.currentMaxNo = me.currentMaxNo >= uniqItems[i].serialNo ? me.currentMaxNo : uniqItems[i].serialNo;
-                }
-                else {
-                    uniqItems[i].serialNo = ++me.currentMaxNo;
-                }
-                uniqItems[i].libID = pageObj.libID;
-                addArr.push(uniqItems[i]);
-            }
-        }
-        if(addArr.length > 0 || updateArr.length > 0){
-            me.save(addArr, updateArr, [], true, function (result) {
-                me.updateCurrentCoeList(result);
-            });
-        }
-    },
-    onDelOpr: function (workBook, setting) {
-        let me = coeOprObj, that = gljAdjOprObj;
-        workBook.commandManager().register('coeListDel', function () {
-            let deleteArr = [];
-            let sheet = workBook.getSheet(0);
-            let sels = sheet.getSelections();
-            let idx = sels[0].row;
-            for(let i = 0, len = sels.length; i < len; i++){
-                if(idx > sels[i].row){
-                    idx = sels[i].row;
-                }
-                if(sels[i].colCount === setting.header.length){//can del
-                    for(let r = 0, rLen = sels[i].rowCount; r < rLen; r++){
-                        let row = sels[i].row + r;
-                        if(row < me.currentCoeList.length){
-                            deleteArr.push({libID: me.currentCoeList[row].libID, ID: me.currentCoeList[row].ID});
-                        }
-                    }
-                    me.currentCoeList.splice(sels[i].row, sels[i].rowCount);
-                }
-            }
-            if(deleteArr.length > 0){
-                me.save([], [], deleteArr, true);
-                me.currentCoe = typeof me.currentCoeList[idx] !== 'undefined' ? me.currentCoeList[idx] : null;
-                that.currentGljAdjList = me.currentCoe ? me.currentCoe.coes : [];
-                gljAdjOprObj.show(that.currentGljAdjList);
-            }
-
-        });
-        workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
-        workBook.commandManager().setShortcutKey('coeListDel', GC.Spread.Commands.Key.del, false, false, false, false);
-    },
-    //粘贴的数据,编号唯一化,去除编号重复的项
-    makeUniqItems: function (items) {
-        let rst = [];
-        for(let i = 0, len = items.length; i < len; i++){
-            if(typeof items[i].serialNo !== 'undefined' && items[i].serialNo){
-                if(rst.length === 0){
-                    rst.push(items[i]);
-                }
-                else{
-                    let isExist = false;
-                    for(let j = 0, jLen = rst.length; j < jLen; j++){
-                        if(items[i].serialNo === rst[j].serialNo){
-                            isExist = true;
-                            break;
-                        }
-                    }
-                    if(!isExist){
-                        rst.push(items[i]);
-                    }
-                }
-            }
-            else {
-                rst.push(items[i]);
-            }
-        }
-        return rst;
+        info.cancel = true;
     },
     isInt: function (num) {
         return !isNaN(num) && num % 1 === 0;
     },
-    hasTisNo: function (coeList, newSerialNo) {
-        let rst = false;
-        for(let i = 0, len = coeList.length; i < len; i++){
-            if(coeList[i].serialNo == newSerialNo){
-                rst = true;
-                break;
-            }
-        }
-        return rst;
-    },
-    updateCurrentCoeList: function (newCoeList) {
-        let me = coeOprObj;
-        if(newCoeList){
-            me.currentCoeList = me.currentCoeList.concat(newCoeList);
-        }
-    },
     sortCoeList: function (coeList) {
         coeList.sort(function (a, b) {
             let rst = 0;
@@ -307,59 +126,12 @@ let coeOprObj = {
     },
     getCoeList: function () {
         let me = coeOprObj;
-        $.ajax({
-            type: 'post',
-            url: '/rationRepository/api/getCoeList',
-            data: {libID: pageObj.libID},
-            dataType: 'json',
-            timeout:20000,
-            success: function (result) {
-                if(!result.error){
-                    me.currentCoeList = result.data;
-                    me.sortCoeList(me.currentCoeList);
-                    me.currentMaxNo =  me.currentCoeList.length > 0 ? me.currentCoeList[me.currentCoeList.length - 1].serialNo : 0;
-                    pageObj.showData(me.workSheet, me.setting, me.currentCoeList);
-                    me.workSheet.clearSelection();
-                }
-            },
-            error:function(err){
-                alert("内部程序错误!");
-            }
-        });
-    },
-    save: function (addArr, updateArr, deleteArr, refresh, callback) {
-        let me = coeOprObj;
-        $.ajax({
-            type:"POST",
-            url:"api/saveCoeList",
-            data: {data: JSON.stringify({addArr: addArr, updateArr: updateArr, deleteArr: deleteArr})},
-            dataType:"json",
-            timeout:5000,
-            success:function(result){
-                if (result.error) {
-                    alert(result.message);
-                } else{
-                    if(callback){
-                        if(result.message === 'mixed'){
-                            for(let i = 0, len = result.data.length; i < len; i++){
-                                if(result.data[i][0] === 'addSc'){
-                                    result.data = result.data[i][1];
-                                    break;
-                                }
-                            }
-                        }
-                        callback(result.data);
-                    }
-                    if(refresh){
-                        me.sortCoeList(me.currentCoeList);
-                        me.currentMaxNo = me.currentCoeList.length > 0 ? me.currentCoeList[me.currentCoeList.length - 1].serialNo : 0;
-                        pageObj.showData(me.workSheet, me.setting, me.currentCoeList);
-                    }
-                }
-            },
-            error:function(err){
-                alert("内部程序错误!");
-            }
+        CommonAjax.post('api/getCoeList', {libID: pageObj.libID}, function (rstData) {
+            me.currentCoeList = rstData;
+            me.sortCoeList(me.currentCoeList);
+            me.currentMaxNo =  me.currentCoeList.length > 0 ? me.currentCoeList[me.currentCoeList.length - 1].serialNo : 0;
+            pageObj.showData(me.workSheet, me.setting, me.currentCoeList);
+            me.workSheet.clearSelection();
         });
     }
 };
@@ -389,13 +161,10 @@ let gljAdjOprObj = {
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 3);
         me.workSheet = me.workBook.getSheet(0);
         me.workSheet.options.isProtected = true;
-        me.onDelOpr(me.workBook, me.setting);
         me.workSheet.clearSelection();
         me.workSheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStart);
-        me.workSheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
         me.workSheet.bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
         me.workSheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
-        me.workSheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
     },
     buildBaseCell: function (sheet) {
         let me = gljAdjOprObj;
@@ -425,196 +194,10 @@ let gljAdjOprObj = {
     },
     onEditStart: function (sender, args) {
         let me = gljAdjOprObj;
-        if(!coeOprObj.currentCoe || args.row >= me.currentGljAdjList.length && args.col === 1
-            || args.row < me.currentGljAdjList.length && args.col === 1 && me.currentGljAdjList[args.row].coeType !== '单个工料机'){
-            args.cancel = true;
-        }
-    },
-    onEditEnded: function (sender, args) {
-        let me = gljAdjOprObj, isUpdate = false,
-            dataCode = me.setting.header[args.col].dataCode;
-        if(args.editingText && args.editingText.toString().trim().length > 0){
-            if(dataCode === 'amount' &&  isNaN(args.editingText)){
-                alert("只能输入数值!");
-                args.sheet.setValue(args.row, args.col, typeof me.currentGljAdjList[args.row] !== 'undefined' && typeof me.currentGljAdjList[args.row][dataCode] !== 'undefined'
-                    ? me.currentGljAdjList[args.row][dataCode] + '' : '');
-            }
-            else {
-                //update
-                if(args.row < me.currentGljAdjList.length && args.editingText.toString().trim() !== me.currentGljAdjList[args.row][dataCode]){
-                    let updateObj = me.currentGljAdjList[args.row];
-                    if(dataCode === 'gljCode' && typeof updateObj.coeType !== 'undefined' && updateObj.coeType === '单个工料机'){
-                        let gljName = me.getGljName(args.editingText, me.gljList);
-                        if(gljName){
-                            updateObj.gljCode = args.editingText;
-                            updateObj.gljName = gljName;
-                            isUpdate = true;
-                        }
-                        else {
-                            alert("不存在编号为"+ args.editingText +"的工料机");
-                        }
-                    }
-                    else if(dataCode !== 'gljCode') {
-                        isUpdate = true;
-                        updateObj[dataCode] = args.editingText;
-                    }
-                }
-                //insert
-                else if(args.row >= me.currentGljAdjList.length){
-                    isUpdate = true;
-                    let newAdjGlj = {};
-                    newAdjGlj[dataCode] = args.editingText;
-                    me.currentGljAdjList.push(newAdjGlj);
-                }
-                if(isUpdate){
-                    coeOprObj.save([], [coeOprObj.currentCoe], [], false, function () {
-                        me.show(me.currentGljAdjList);
-                    });
-                }
-                else {
-                    args.sheet.setValue(args.row, args.col, typeof me.currentGljAdjList[args.row] !== 'undefined' && typeof me.currentGljAdjList[args.row][dataCode] !== 'undefined'
-                        ? me.currentGljAdjList[args.row][dataCode] + '' : '');
-                }
-            }
-        }
+        args.cancel = true;
     },
     onClipboardPasting: function (sender, info) {
-
-    },
-    getValidPasteDatas: function (pasteItems, info) {
-        let me = gljAdjOprObj;
-        let rst = [];
-        for(let i = 0, len = pasteItems.length; i < len; i++){
-            let row = i + info.cellRange.row;
-            let validObj = {};
-            //update
-            if(row < me.currentGljAdjList.length){
-                let updateObj = me.currentGljAdjList[row];
-                if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
-                    let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
-                    if(pasteItems[i].coeType === '单个工料机' && gljName){
-                        validObj.coeType = pasteItems[i].coeType;
-                        validObj.gljCode = pasteItems[i].gljCode;
-                        validObj.gljName = gljName;
-                    }
-                    else if(pasteItems[i].coeType !== '单个工料机' && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
-                    }
-                }
-                else if(typeof pasteItems[i].coeType === 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
-                    let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
-                    if(typeof updateObj.coeType !== 'undefined' && updateObj.coeType === '单个工料机' && gljName){
-                        validObj.gljCode = pasteItems[i].gljCode;
-                        validObj.gljName = gljName;
-                    }
-                }
-                else if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode === 'undefined'){
-                    if(me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
-                        if(validObj.coeType !== '单个工料机' && typeof updateObj.gljCode !== '单个工料机' && updateObj.gljCode.toString().trim().length > 0){
-                            validObj.gljCode = '';
-                            validObj.gljName = '';
-                        }
-                    }
-                }
-                else {
-                    if(typeof pasteItems[i].operator !== 'undefined' && me.setting.comboItems.operator.indexOf(pasteItems[i].operator) !== -1){
-                        validObj.operator = pasteItems[i].operator;
-                    }
-                    if(typeof pasteItems[i].amount !== 'undefined' && !isNaN(pasteItems[i].amount)){
-                        validObj.amount = pasteItems[i].amount;
-                    }
-                }
-            }
-            else {
-                if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
-                    let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
-                    if(pasteItems[i].coeType === '单个工料机' && gljName){
-                        validObj.coeType = pasteItems[i].coeType;
-                        validObj.gljCode = pasteItems[i].gljCode;
-                        validObj.gljName = gljName;
-                    }
-                    else if(pasteItems[i].coeType !== '单个工料机' && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
-                    }
-                }
-                else if(typeof pasteItems[i].gljCode === 'undefined') {
-                    if(typeof pasteItems[i].coeType !== 'undefined' && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
-                        validObj.coeType = pasteItems[i].coeType;
-                    }
-                    if(typeof pasteItems[i].operator !== 'undefined' && me.setting.comboItems.operator.indexOf(pasteItems[i].operator) !== -1){
-                        validObj.operator = pasteItems[i].operator;
-                    }
-                    if(typeof pasteItems[i].amount !== 'undefined' && !isNaN(pasteItems[i].amount)){
-                        validObj.amount = pasteItems[i].amount;
-                    }
-                }
-            }
-            if(Object.keys(validObj).length > 0){
-                rst.push(validObj);
-            }
-        }
-        return rst;
-    },
-    onClipboardPasted: function (sender, info) {
-        let me = gljAdjOprObj, row;
-        let items = sheetCommonObj.analyzePasteData(me.setting, info);
-        let validDatas = me.getValidPasteDatas(items, info);
-        for(let i = 0, len = validDatas.length; i < len; i++){
-            row = i + info.cellRange.row;
-            //update
-            if(row < me.currentGljAdjList.length){
-                let updateObj = me.currentGljAdjList[row];
-                for(let attr in validDatas[i]){
-                    updateObj[attr] = validDatas[i][attr];
-                }
-            }
-            //insert
-            else{
-                me.currentGljAdjList.push(validDatas[i]);
-            }
-        }
-        if(validDatas.length > 0){
-            coeOprObj.save([], [coeOprObj.currentCoe], [], false, function () {
-                me.show(me.currentGljAdjList);
-            });
-        }
-        else {
-            me.show(me.currentGljAdjList);
-        }
-    },
-    onDelOpr: function (workBook, setting) {
-        let me = gljAdjOprObj;
-        workBook.commandManager().register('gljAdjDel', function () {
-            let sheet = workBook.getSheet(0);
-            let sels = sheet.getSelections();
-            let isUpdate = false;
-            for(let i = 0, len = sels.length; i < len; i++){
-                if(sels[i].colCount === setting.header.length){//can del
-                    if(sels[i].row < me.currentGljAdjList.length){
-                        isUpdate = true;
-                        me.currentGljAdjList.splice(sels[i].row, sels[i].rowCount);
-                    }
-                }
-            }
-            if(isUpdate){
-                coeOprObj.save([], [coeOprObj.currentCoe], [], false, function () {
-                    me.show(me.currentGljAdjList);
-                });
-            }
-        });
-        workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
-        workBook.commandManager().setShortcutKey('gljAdjDel', GC.Spread.Commands.Key.del, false, false, false, false);
-    },
-    getGljName: function (gljCode, gljList) {
-        let rst = null;
-        for(let i = 0, len = gljList.length; i < len; i++){
-            if(gljCode === gljList[i].code){
-                rst = gljList[i].name;
-                break;
-            }
-        }
-        return rst;
+        info.cancel = true;
     },
     show: function (coes) {
         let me = gljAdjOprObj;
@@ -622,23 +205,10 @@ let gljAdjOprObj = {
     },
     getGljItemsOcc: function () {
         let me = gljAdjOprObj;
-        $.ajax({
-            type: 'post',
-            url: '/stdGljRepository/api/getGljItemsOccupied',
-            data: {repId: pageObj.gljLibID, occupation: '-_id code name'},
-            dataType: 'json',
-            timeout: 5000,
-            success:function(result){
-                if (result.error) {
-                    alert(result.message);
-                } else{
-                    me.gljList = result.data;
-                }
-            },
-            error:function(err){
-                alert("内部程序错误!");
-            }
+        CommonAjax.post('api/getGljItemsOccupied', {gljLibId: pageObj.gljLibID, occupation: '-_id code name'}, function (rstData) {
+            me.gljList = rstData;
         });
+
     }
 };
 

+ 7 - 7
web/building_saas/complementary_ration_lib/js/jobContent.js

@@ -81,12 +81,12 @@ let jobContentOprObj = {
             $tbody.append($newTr);
             count++;
         }
-        let $trEnd = $("<tr><td>"+ count +"</td><td><a href data-toggle='modal' data-target='#editBianma' class='m-0'>点击勾选编码</a></td><td><textarea class='form-control'></textarea></td></tr>");//勾选行
-        $($trEnd.children().children()[0]).bind('click', function () {
+        let $trEnd = $("<tr><td>"+ count +"</td><td></td><td><textarea class='form-control' disabled='disabled' style='background: white'></textarea></td></tr>");//勾选行
+      /*  $($trEnd.children().children()[0]).bind('click', function () {
             me.onclickFuncAdd($(this));
             me.currentOprTr = $trEnd;
             me.currentJobContent = $(me.currentOprTr.children()[2]).children().val();
-        });
+        });*/
         $tbody.append($trEnd);
         table.append($thead);
         table.append($tbody);
@@ -96,15 +96,15 @@ let jobContentOprObj = {
         let me = jobContentOprObj;
         let count = tbody.children().length > 0 ? tbody.children().length : 1;
         let $textTd = $("<td></td>");
-        let $textarea = $("<textarea class='form-control'></textarea>");
+        let $textarea = $("<textarea class='form-control' disabled='disabled' style='background: white;'></textarea>");
         $textarea.val(jobContent);
         $textTd.append($textarea);
         let $tr = $("<tr><td>" + count + "</td><td><a href data-toggle='modal' data-target='#editBianmaQ' class='m-0'>编辑编码</a></td></tr>");
-        $tr.children().children().bind('click', function () {
+        /*$tr.children().children().bind('click', function () {
             me.currentOprTr = $tr;
             me.currentJobContent = $(me.currentOprTr.children()[2]).children().val();
             me.onclickFuncEdit($(this));
-        });
+        });*/
         //文本变化;
         $textarea.bind('change', function () {
             let codes = me.getUpdateCodes($($(this).parent().parent().children()[1]).children());
@@ -327,7 +327,7 @@ let jobContentOprObj = {
     //定额工作内容相关操作
     rationJobContentOpr: function (rationItems) {
         let me = jobContentOprObj;
-        me.setRadiosDisabled(me.currentRationItems.length > 0 ? false : true, me.radios);
+        //me.setRadiosDisabled(me.currentRationItems.length > 0 ? false : true, me.radios);
         me.setRadiosChecked(me.currentSituation, me.radios);
         me.buildTablePartial(me.tablePartial, me.getGroup(rationItems));
     },

+ 10 - 10
web/building_saas/complementary_ration_lib/js/main.js

@@ -8,18 +8,18 @@ let compleRationMain = {
             $("#comple_ration_table").empty();
             for(let i = 0; i < rstData.length; i++){
                 storageUtil.setSessionCache("RationGrp","repositoryID_" + rstData[i].ID, rstData[i].dispName);
-                if(rstData[i].gljLib){
+                if(rstData[i].gljLib !== undefined && rstData[i].gljLib && rstData[i].gljLib != -1){
                     storageUtil.setSessionCache("gljLib","repositoryID_" + rstData[i].ID, rstData[i].gljLib);
+                    let id = rstData[i].ID;
+                    let libName = rstData[i].dispName;
+                    $("#comple_ration_table").append(
+                        "<tr id='tempId'>" +
+                        "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td></tr>"
+                    );
+                    var newHref = "/complementaryRation/ration?repository="+id;
+                    $("#tempId td:first a").attr("href", newHref);
+                    $("#tempId").attr("id", id);
                 }
-                let id = rstData[i].ID;
-                let libName = rstData[i].dispName;
-                $("#comple_ration_table").append(
-                    "<tr id='tempId'>" +
-                    "<td><a href='/stdGljRepository/glj'>"+libName+"</a></td></tr>"
-                );
-                var newHref = "/complementaryRation/ration?repository="+id;
-                $("#tempId td:first a").attr("href", newHref);
-                $("#tempId").attr("id", id);
             }
         };
         CommonAjax.post('/complementaryRation/api/getRationLibs', {user_id: userID}, scFunc);

+ 109 - 106
web/building_saas/complementary_ration_lib/js/ration.js

@@ -3,11 +3,11 @@
  */
 
 $("#gongliao").click(function(){
-    $(this).attr('href', "/rationRepository/lmm" + "?repository=" + getQueryString("repository"))
+    $(this).attr('href', "/complementaryRation/glj" + "?repository=" + getQueryString("repository"))
 });
 
 $("#fuzhu").click(function(){
-    $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
+    $(this).attr('href', "/complementaryRation/coe" + "?repository=" + getQueryString("repository"))
 });
 const digital = {
     gljPrc: -3,//计算定额基价时单个工料机价格取三位
@@ -20,6 +20,7 @@ let rationOprObj = {
     currentEditingRation: null,
     currentSectionId: -1,
     rationsCodes: [],
+    type: {std: 'std', complementary: 'complementary'},
     setting: {
         header:[
             {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
@@ -47,11 +48,6 @@ let rationOprObj = {
     buildSheet: function(container) {
         let rationRepId = getQueryString("repository");
         let me = rationOprObj;
-        let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
-        if(!gljLibID || typeof gljLibID === 'undefined' || gljLibID == -1){
-            alert("没有引用工料机库!");
-            window.location.href = "/rationRepository/main";
-        }
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
         me.getRationsCodes(rationRepId);
         me.rationDelOpr();
@@ -102,7 +98,9 @@ let rationOprObj = {
             me.workBook.focus(true);
         }
     },
-
+    isDef: function (v) {
+        return v !== undefined && v !== null;
+    },
     isInt: function (num) {
         return !isNaN(num) && num % 1 === 0;
     },
@@ -114,7 +112,7 @@ let rationOprObj = {
         }
         return rst;
     },
-    updateCache: function(addArr, updateArr, removeIds, result) {
+    updateCache: function(addArr, updateArr, removeIds, rstData) {
         let me = this, cacheSection = me.getCache();
         if (addArr.length > 0) {
             me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
@@ -127,14 +125,14 @@ let rationOprObj = {
                 }
             }
         }
-        if (result && result.data.ops && result.data.ops.length > 0) {
-            for (let i = 0; i < result.data.ops.length; i++) {
+        if (rstData && rstData.ops && rstData.ops.length > 0) {
+            for (let i = 0; i < rstData.ops.length; i++) {
                 for (let j = 0; j < cacheSection.length; j++) {
-                    if (cacheSection[j][me.setting.header[0].dataCode] == result.data.ops[i][me.setting.header[0].dataCode]) {
-                        cacheSection[j]["ID"] = result.data.ops[i]["ID"];
-                        cacheSection[j]["rationGljList"] = result.data.ops[i]["rationGljList"];
-                        cacheSection[j]["rationCoeList"] = result.data.ops[i]["rationCoeList"];
-                        cacheSection[j]["rationAssList"] = result.data.ops[i]["rationAssList"];
+                    if (cacheSection[j][me.setting.header[0].dataCode] == rstData.ops[i][me.setting.header[0].dataCode]) {
+                        cacheSection[j]["ID"] = rstData.ops[i]["ID"];
+                        cacheSection[j]["rationGljList"] = rstData.ops[i]["rationGljList"];
+                        cacheSection[j]["rationCoeList"] = rstData.ops[i]["rationCoeList"];
+                        cacheSection[j]["rationAssList"] = rstData.ops[i]["rationAssList"];
                     }
                 }
             }
@@ -144,10 +142,12 @@ let rationOprObj = {
                 if (updateArr[i]["ID"] && cacheSection[j]["ID"]) {
                     if (cacheSection[j]["ID"] == updateArr[i]["ID"]) {
                         cacheSection[j] = updateArr[i];
+                        cacheSection[j].type = me.type.complementary;
                     }
                 } else {
                     if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
                         cacheSection[j] = updateArr[i];
+                        cacheSection[j].type = me.type.complementary;
                     }
                 }
             }
@@ -165,7 +165,7 @@ let rationOprObj = {
                     if(sels[sel].colCount === me.setting.header.length){
                         if(cacheSection){
                             for(let i = 0; i < sels[sel].rowCount; i++){
-                                if(sels[sel].row + i < cacheSection.length){
+                                if(sels[sel].row + i < cacheSection.length && cacheSection[sels[sel].row + i].type !== me.type.std){
                                     removeArr.push(cacheSection[sels[sel].row + i].ID);
                                     me.rationsCodes.splice(me.rationsCodes.indexOf(cacheSection[sels[sel].row + i].code), 1);
                                 }
@@ -173,7 +173,7 @@ let rationOprObj = {
                         }
                     }
                     else{
-                        if(sels[sel].col === 0){
+                        if(sels[sel].col === 0 && me.isDef(cacheSection[sels[sel].row]) && cacheSection[sels[sel].row].type !== me.type.std){
                             $('#alertText').text("编号不能为空,修改失败!");
                             $('#alertModalBtn').click();
                             $('#alertModalCls').click(function () {
@@ -186,12 +186,12 @@ let rationOprObj = {
                                 for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
                                     if(sels[sel].row + i < cacheSection.length){
                                         for(let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++){
-                                            if(lockCols.indexOf(col) === -1){
+                                            if(lockCols.indexOf(col) === -1 && cacheSection[sels[sel].row + i].type !== me.type.std){
                                                 cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = '';
                                             }
                                         }
                                     }
-                                    if(cacheSection[sels[sel].row + i] && typeof cacheSection[sels[sel].row + i] !== 'undefined'){
+                                    if(me.isDef(cacheSection[sels[sel].row + i]) && cacheSection[sels[sel].row + i].type !== me.type.std){
                                         updateArr.push(cacheSection[sels[sel].row + i]);
                                     }
                                 }
@@ -252,13 +252,14 @@ let rationOprObj = {
     },
     onCellEditStart: function(sender, args) {
         let me = rationOprObj;
-        if(!me.canRations || me.setting.view.lockColumns.indexOf(args.col) !== -1){
+        let cacheSection = me.getCache();
+        if(!me.canRations || me.setting.view.lockColumns.indexOf(args.col) !== -1
+        || (me.isDef(cacheSection[args.row]) && cacheSection[args.row].type === me.type.std)){
             args.cancel = true;
         }
         else{
             let rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row);
             me.currentEditingRation = rObj;
-            let cacheSection = me.getCache();
             if (cacheSection) {
                 for (let j = 0; j < cacheSection.length; j++) {
                     if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
@@ -352,12 +353,22 @@ let rationOprObj = {
     },
     onClipboardPasting: function(sender, args) {
         let me = rationOprObj;
+        let cacheSection = me.getCache();
         let maxCol = args.cellRange.col + args.cellRange.colCount -1;
         if(!me.canRations || !me.canPasted(args.cellRange.col, maxCol) || maxCol > me.setting.header.length - 1){
             args.cancel = true;
+            return;
+        }
+        let hasStd = false;
+        for(let row = args.cellRange.row, len = args.cellRange.row + args.cellRange.rowCount - 1; row < len; row++){
+            if(me.isDef(cacheSection[row]) && me.isDef(cacheSection[row].type) && cacheSection[row].type === me.type.std){
+                hasStd = true;
+            }
+        }
+        if(hasStd){
+            args.cancel = true;
         }
     },
-    //todo: overwrite?
     onClipboardPasted: function(e, info) {
         let me = rationOprObj;
         let cacheSection = me.getCache();
@@ -455,71 +466,56 @@ let rationOprObj = {
     },
     getRationsCodes: function (repId) {
         let me = rationOprObj;
-        $.ajax({
-            type: 'post',
-            url: 'api/getRationsCodes',
-            data: {data: JSON.stringify({repId: repId})},
-            dataType: 'json',
-            success: function (result) {
-                if(!result.error){
-                    me.rationsCodes = result.data;
-                }
-            }
-        })
+        CommonAjax.post('api/getRationsCodes', {rationRepId: repId}, function (rstData) {
+            me.rationsCodes = rstData;
+        });
     },
     mixUpdateRequest: function(updateArr, addArr, removeIds, callback) {
         let me = rationOprObj;
         me.saveInString(updateArr);
-        $.ajax({
-            type:"POST",
-            url:"api/mixUpdateRationItems",
-            data:{"rationLibId": getQueryString("repository"), "lastOpr": userAccount, "sectionID": me.currentSectionId, "updateItems": JSON.stringify(updateArr), "addItems": JSON.stringify(addArr), "removeIds": JSON.stringify(removeIds)},
-            dataType:"json",
-            cache:false,
-            timeout:20000,
-            success:function(result){
-                if (result.error) {
-                    alert('error');
-                    me.getRationItems(me.currentSectionId);
-                } else {
-                    let cacheSection = me.updateCache(addArr, updateArr, removeIds, result);
-                    cacheSection.sort(function(a, b){
-                        let rst = 0;
-                        if (a.code > b.code) rst = 1
-                        else if (a.code < b.code) rst = -1;
-                        return rst;
-                    });
-                    //jobContent
-                    if(jobContentOprObj ){
-                        jobContentOprObj.currentRationItems = cacheSection;
-                        jobContentOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, jobContentOprObj.radios);
-                        if(cacheSection.length === 0){
-                            jobContentOprObj.updateSituation(pageOprObj.rationLibId, me.currentSectionId, 'NONE');
-                        }
-                        jobContentOprObj.setRadiosChecked(jobContentOprObj.currentSituation, jobContentOprObj.radios);
-                        if(jobContentOprObj.currentSituation === jobContentOprObj.situations.PARTIAL){
-                            jobContentOprObj.buildTablePartial(jobContentOprObj.tablePartial, jobContentOprObj.getGroup(cacheSection));
-                        }
+        CommonAjax.post('api/mixUpdateRationItems',
+            {rationRepId: getQueryString("repository"),  sectionId: me.currentSectionId, updateItems: updateArr, addItems: addArr, removeIds: removeIds},
+            function (rstData) {
+                //mark complementary
+                for(let i = 0, len = addArr.length; i < len; i++){
+                    addArr[i].type = me.type.complementary;
+                }
+                let cacheSection = me.updateCache(addArr, updateArr, removeIds, rstData);
+                cacheSection.sort(function(a, b){
+                    let rst = 0;
+                    if (a.code > b.code) rst = 1
+                    else if (a.code < b.code) rst = -1;
+                    return rst;
+                });
+                //jobContent
+                if(jobContentOprObj ){
+                    jobContentOprObj.currentRationItems = cacheSection;
+                    jobContentOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, jobContentOprObj.radios);
+                    if(cacheSection.length === 0){
+                        jobContentOprObj.updateSituation(pageOprObj.rationLibId, me.currentSectionId, 'NONE');
                     }
-                    if(annotationOprObj ){
-                        annotationOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, annotationOprObj.radios);
-                        if(cacheSection.length === 0){
-                            annotationOprObj.updateAnnoSituation(pageOprObj.rationLibId, me.currentSectionId, 'NONE');
-                        }
-                        annotationOprObj.setRadiosChecked(annotationOprObj.currentSituation, annotationOprObj.radios);
-                        if(annotationOprObj.currentSituation === annotationOprObj.situations.PARTIAL){
-                            annotationOprObj.buildTablePartial(annotationOprObj.fzTablePartial, annotationOprObj.getGroup(cacheSection));
-                        }
+                    jobContentOprObj.setRadiosChecked(jobContentOprObj.currentSituation, jobContentOprObj.radios);
+                    if(jobContentOprObj.currentSituation === jobContentOprObj.situations.PARTIAL){
+                        jobContentOprObj.buildTablePartial(jobContentOprObj.tablePartial, jobContentOprObj.getGroup(cacheSection));
                     }
-                    me.showRationItems(me.currentSectionId);
-                    me.mixUpdate = 0;
-                    me.mixDel = 0;
                 }
+                if(annotationOprObj ){
+                    annotationOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, annotationOprObj.radios);
+                    if(cacheSection.length === 0){
+                        annotationOprObj.updateAnnoSituation(pageOprObj.rationLibId, me.currentSectionId, 'NONE');
+                    }
+                    annotationOprObj.setRadiosChecked(annotationOprObj.currentSituation, annotationOprObj.radios);
+                    if(annotationOprObj.currentSituation === annotationOprObj.situations.PARTIAL){
+                        annotationOprObj.buildTablePartial(annotationOprObj.fzTablePartial, annotationOprObj.getGroup(cacheSection));
+                    }
+                }
+                me.showRationItems(me.currentSectionId);
+                me.mixUpdate = 0;
+                me.mixDel = 0;
                 if(callback) callback();
-            },
-            error:function(){
-            }
-        });
+            }, function () {
+                me.getRationItems(me.currentSectionId);
+            });
     },
     getRationItems: function(sectionID){
         if (sectionID != -1) {
@@ -534,9 +530,9 @@ let rationOprObj = {
                 annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                 me.showRationItems(sectionID);
             } else {
-                CommonAjax.post('api/getRationItems', {rationRepId: pageOprObj.rationLibId, sectionId: sectionID}, function (rstData) {
+                CommonAjax.post('/complementaryRation/api/getRationItems', {rationRepId: pageOprObj.rationLibId, sectionId: sectionID}, function (rstData) {
                     me.currentRations["_SEC_ID_" + sectionID] = rstData;
-                    me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
+                    me.currentRations["_SEC_ID_" + sectionID] = me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
                     //job--
                     jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
                     jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
@@ -544,32 +540,23 @@ let rationOprObj = {
                     annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
                     me.showRationItems(sectionID);
                 });
-         /*       $.ajax({
-                    type:"POST",
-                    url:"api/getRationItems",
-                    data:{"rationRepId": pageOprObj.rationLibId, "sectionID": sectionID},
-                    dataType:"json",
-                    cache:false,
-                    timeout:10000,
-                    success:function(result){
-                        if (result) {
-                            me.currentRations["_SEC_ID_" + sectionID] = result.data;
-                            me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
-                            //job--
-                            jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
-                            jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
-                            //annotation
-                            annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
-                            me.showRationItems(sectionID);
-                        }
-                    },
-                    error:function(err){
-                        alert(err);
-                    }
-                })*/
             }
         }
     },
+    setColor: function (cache) {
+        let me = this;
+        let sheet = me.workBook.getSheet(0);
+        sheet.suspendPaint();
+        for(let i = 0, len = cache.length; i < len; i++){
+            if(cache[i].type === me.type.complementary){
+                sheet.getRange(i, -1, 1, -1).foreColor('gray');
+            }
+            else {
+                sheet.getRange(i, -1, 1, -1).foreColor('');
+            }
+        }
+        sheet.resumePaint();
+    },
     showRationItems: function(sectionID){
         let me = rationOprObj,
             sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
@@ -580,6 +567,8 @@ let rationOprObj = {
                 let cacheSection = me.currentRations["_SEC_ID_" + sectionID];
                 sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
                 sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
+                console.log(cacheSection);
+                me.setColor(cacheSection);
                 //combo
                 //sheetCommonObj.setStaticCombo(me.workBook.getActiveSheet(), 0, 2, cacheSection.length, rationUnits, 10, false);
                 //--sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
@@ -617,6 +606,20 @@ let rationOprObj = {
         sectionTreeObj.workBook.focus(true);
     },
     sortByCode: function(arr){
+        let me = rationOprObj;
+        //std complementary
+        let stdArr = [], compleArr = [];
+        for(let i = 0, len = arr.length; i < len; i++){
+            if(arr[i].type === me.type.std){
+                stdArr.push(arr[i]);
+            }
+            else if(arr[i].type === me.type.complementary){
+                compleArr.push(arr[i]);
+            }
+        }
+        stdArr.sort(compare());
+        compleArr.sort(compare());
+        return stdArr.concat(compleArr);
         function compare(){
             return function (a, b) {
                 let rst = 0;
@@ -629,7 +632,7 @@ let rationOprObj = {
                 return rst;
             }
         }
-        arr.sort(compare());
+       // arr.sort(compare());
     },
     saveInString(datas){
         for(let i = 0, len = datas.length; i < len; i++){

+ 7 - 3
web/building_saas/complementary_ration_lib/js/ration_assist.js

@@ -23,7 +23,8 @@ var rationAssistOprObj = {
     buildSheet: function(sheet) {
         var me = this;
         me.sheet = sheet;
-        me.libID = storageUtil.getSessionCache("RationGrp","repositoryID"); // 不可靠,有时取不到
+        //me.libID = storageUtil.getSessionCache("RationGrp","repositoryID"); // 不可靠,有时取不到
+        me.libID = pageOprObj.rationLibId;
         if (me.libID == undefined){me.libID = getQueryString('repository')};
 
         sheetCommonObj.initSheet(me.sheet, me.setting, 30);
@@ -50,7 +51,7 @@ var rationAssistOprObj = {
         let rationSection = rationOprObj.getCache();
         let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
         me.ration = rationRow < rationSection.length ? rationSection[rationRow] : null;
-        if (!me.ration) {
+        if (!me.ration || (me.ration && me.ration.type === rationOprObj.type.std)) {
             args.cancel = true;
         }
     },
@@ -81,7 +82,7 @@ var rationAssistOprObj = {
         let rationSection = rationOprObj.getCache();
         let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
         me.ration = rationRow < rationSection.length ? rationSection[rationRow] : null;
-        if(!me.ration){
+        if(!me.ration || (me.ration && me.ration.type === rationOprObj.type.std)){
             args.cancel = true;
         }
     },
@@ -146,6 +147,9 @@ var rationAssistOprObj = {
         let me = rationAssistOprObj;
         let workBook = me.sheet.getParent();
         workBook.commandManager().register('rationAssDel', function () {
+            if(!me.ration || me.ration.type === rationOprObj.type.std){
+                return;
+            }
             let sels = me.sheet.getSelections(), isUpdate = false;
             if(me.ration){
                 let curCahe = me.ration.rationAssList;

+ 33 - 57
web/building_saas/complementary_ration_lib/js/ration_coe.js

@@ -23,7 +23,8 @@ var rationCoeOprObj = {
     buildSheet: function(sheet) {
         var me = this;
         me.sheet = sheet;
-        me.libID = storageUtil.getSessionCache("RationGrp","repositoryID"); // 不可靠,有时取不到
+        //me.libID = storageUtil.getSessionCache("RationGrp","repositoryID"); // 不可靠,有时取不到
+        me.libID = pageOprObj.rationLibId;
         if (me.libID == undefined){me.libID = getQueryString('repository')};
         sheetCommonObj.initSheet(me.sheet, me.setting, 30);
         me.sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
@@ -38,7 +39,7 @@ var rationCoeOprObj = {
         let rationSection = rationOprObj.getCache();
         let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
         me.curRation = rationRow < rationSection.length ? rationSection[rationRow] : null;
-        if (args.cellRange.colCount != 1 || args.cellRange.col != 0 || !(me.curRation)) {
+        if (args.cellRange.colCount != 1 || args.cellRange.col != 0 || !(me.curRation) || (me.curRation && me.curRation.type === rationOprObj.type.std)) {
             args.cancel = true;
         }
     },
@@ -103,7 +104,7 @@ var rationCoeOprObj = {
         let rationSection = rationOprObj.getCache();
         let rationRow = rationOprObj.workBook.getSheet(0).getSelections()[0].row;
         me.curRation = rationRow < rationSection.length ? rationSection[rationRow] : null;
-        if(!me.curRation || args.col !== 0){
+        if(!me.curRation || args.col !== 0 || (me.curRation && me.curRation.type === rationOprObj.type.std)){
             args.cancel = true;
         }
 
@@ -146,6 +147,9 @@ var rationCoeOprObj = {
         let me = rationCoeOprObj;
         let workBook = me.sheet.getParent();
         workBook.commandManager().register('rationCoeDel', function () {
+            if(!me.curRation || me.curRation.type === rationOprObj.type.std){
+                return;
+            }
             let sels = me.sheet.getSelections(), isUpdate = false;
             let curCahe = me.cache["_Coe_" + me.curRation.ID];
             for(let i = 0, len = sels.length; i < len; i ++ ){
@@ -210,37 +214,23 @@ var rationCoeOprObj = {
             me.showCoeItems(me.curRation.ID);
             //sheetCommonObj.lockCells(me.sheet, me.setting);
         }else{
-            $.ajax({
-                type:"POST",
-                url:"api/getCoeItemsByNos",
-                data: {"data": JSON.stringify({"libID": me.libID, "coeNos": temp})},
-                dataType:"json",
-                cache:false,
-                timeout:5000,
-                success:function(result){
-                    if (result) {
-                        var rstArr = [];
-                        for (let obj of result.data){rstArr.push(obj)};
-                        if (curCache) {
-                            curCache = curCache.concat(rstArr);
-                        }else{
-                            curCache = rstArr;
-                        }
-                        let recoveryArr = me.getRecoveryArr(me.tempDelArr, result.data);
-                        if(recoveryArr.length > 0){
-                            curCache = curCache.concat(recoveryArr);
-                        }
-                        me.cache["_Coe_" + me.curRation.ID] = curCache;
-                        me.updateCurRation(function () {
-                            me.sheet.getParent().focus(true);
-                        });
-                        me.showCoeItems(me.curRation.ID);
-                    };
-                    //sheetCommonObj.lockCells(me.sheet, me.setting);
-                },
-                error:function(err){
-                    alert(err);
+            CommonAjax.post('api/getCoeItemsByNos', {libID: me.libID, coeNos: temp}, function (rstData) {
+                var rstArr = [];
+                for (let obj of rstData){rstArr.push(obj)};
+                if (curCache) {
+                    curCache = curCache.concat(rstArr);
+                }else{
+                    curCache = rstArr;
                 }
+                let recoveryArr = me.getRecoveryArr(me.tempDelArr, rstData);
+                if(recoveryArr.length > 0){
+                    curCache = curCache.concat(recoveryArr);
+                }
+                me.cache["_Coe_" + me.curRation.ID] = curCache;
+                me.updateCurRation(function () {
+                    me.sheet.getParent().focus(true);
+                });
+                me.showCoeItems(me.curRation.ID);
             });
         };
     },
@@ -259,31 +249,17 @@ var rationCoeOprObj = {
             //sheetCommonObj.lockCells(me.sheet, me.setting);
         } else if(!curCache && typeof coeList !== 'undefined' && coeList.length > 0) {
             var data = {"libID": me.libID, "coeIDs": coeList};
-            $.ajax({
-                type:"POST",
-                url:"api/getCoeItemsByIDs",
-                data: {"data": JSON.stringify(data)},
-                dataType:"json",
-                cache:false,
-                timeout:5000,
-                success:function(result){
-                    sheetCommonObj.cleanData(me.sheet, me.setting, -1);
-                    if (result.data) {
-                        var tempResult = [];
-                        for (let obj of result.data) {
-                            tempResult.push(obj);
-                        };
-
-                        me.cache["_Coe_" + ration.ID] = tempResult;
+            CommonAjax.post('api/getCoeItemsByIDs', data, function (rstData) {
+                sheetCommonObj.cleanData(me.sheet, me.setting, -1);
+                var tempResult = [];
+                for (let obj of rstData) {
+                    tempResult.push(obj);
+                };
+                me.cache["_Coe_" + ration.ID] = tempResult;
 
-                        me.showCoeItems(ration.ID);
-                    }
-                    //sheetCommonObj.lockCells(me.sheet, me.setting);
-                    if(callback) callback();
-                },
-                error:function(err){
-                    alert(err);
-                }
+                me.showCoeItems(ration.ID);
+                //sheetCommonObj.lockCells(me.sheet, me.setting);
+                if(callback) callback();
             });
         };
     },

+ 106 - 123
web/building_saas/complementary_ration_lib/js/ration_glj.js

@@ -90,6 +90,9 @@ var rationGLJOprObj = {
     bindRationGljDelOpr: function () {
         let me = rationGLJOprObj, spreadBook = me.sheet.getParent();
         spreadBook.commandManager().register('rationGljDelete', function () {
+            if(!me.currentRationItem || me.currentRationItem.type === rationOprObj.type.std){
+                return;
+            }
             let sels = me.sheet.getSelections(), lockCols = me.setting.view.lockColumns;
             let cacheSection = me.cache["_GLJ_" + me.currentRationItem.ID], isUpdate = false;
             if(sels.length > 0){
@@ -138,15 +141,16 @@ var rationGLJOprObj = {
         if(me.currentRationItem && typeof me.cache["_GLJ_" + me.currentRationItem.ID] === 'undefined'){
             me.cache["_GLJ_" + me.currentRationItem.ID] = [];
         }
-        if (!(args.cellRange.col === 0 || args.cellRange.col === 5) || !(me.currentRationItem)) {
+        if (!(args.cellRange.col === 0 || args.cellRange.col === 5) || !(me.currentRationItem) || (me.currentRationItem && me.currentRationItem.type === rationOprObj.type.std)) {
             args.cancel = true;
         }
     },
     onClipboardPasted: function(e, info) {
-        var me = rationGLJOprObj, repId = storageUtil.getSessionCache("RationGrp","repositoryID");
+        var me = rationGLJOprObj, repId = pageOprObj.rationLibId;
         me.tempCacheArr = [];
         if (repId) {
-            let gljLibId = storageUtil.getSessionCache("gljLib", "repositoryID_" + repId);
+            let gljLibId = pageOprObj.gljLibId;
+            console.log(gljLibId);
             if(gljLibId){
                 if (info.cellRange.col == 0) {
                     let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
@@ -205,7 +209,8 @@ var rationGLJOprObj = {
             args.cancel = true;
         }
         else {
-            if(args.col !== 0 && args.col !== 5 || args.col === 5 && args.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length){
+            if(args.col !== 0 && args.col !== 5 || args.col === 5 && args.row >= me.cache["_GLJ_" + me.currentRationItem.ID].length
+            || me.currentRationItem.type === rationOprObj.type.std){
                 args.cancel = true;
             }
         }
@@ -257,15 +262,13 @@ var rationGLJOprObj = {
                         if (args.row < cacheArr.length && args.editingText !== cacheArr[args.row].code) {//更新
                             me.tempCacheArr.push({org: cacheArr[args.row], newCode: args.editingText.toString().trim()});
                             cacheArr.splice(args.row, 1);
-                            let rationRepId = storageUtil.getSessionCache("RationGrp", "repositoryID");
-                            let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
+                            let gljLibID = pageOprObj.gljLibId;
                             let codes = [];
                             codes.push(args.editingText.toString().trim());
                             me.addGljItems(codes, gljLibID, args);
                         }
                         else if (args.row >= cacheArr.length) {//新增
-                            let rationRepId = storageUtil.getSessionCache("RationGrp", "repositoryID");
-                            let gljLibID = storageUtil.getSessionCache("gljLib", "repositoryID_" + rationRepId);
+                            let gljLibID = pageOprObj.gljLibId;
                             if (gljLibID) {
                                 var codes = [];
                                 codes.push(args.editingText.toString().trim());
@@ -341,84 +344,72 @@ var rationGLJOprObj = {
         return rst;
     },
     addGljItems: function(codes, repId, args) {
-        var me = this;
-        $.ajax({
-            type:"POST",
-            url:"api/getGljItemsByCodes",
-            data:{"gljCodes": JSON.stringify(codes), repId: repId},
-            dataType:"json",
-            cache:false,
-            timeout:5000,
-            success:function(result){
-                if (result) {
-                    if(result.data.length > 0){
-                        sheetCommonObj.cleanData(me.sheet, me.setting, -1);
-                        var rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
-                        for (var i = 0; i < result.data.length; i++) {
-                            dummyR.gljId = result.data[i].ID;
-                            rstArr.push(me.createRationGljDisplayItem(dummyR, result.data[i]));
-                        }
-                        if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
-                            var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
-                            for (var i = 0; i < rstArr.length; i++) {
-                                var hasDup = false;
-                                for (var j = 0; j < cacheArr.length; j++) {
-                                    if (cacheArr[j].gljId == rstArr[i].gljId) {
-                                        hasDup = true;
-                                        break;
-                                    }
-                                }
-                                if (!hasDup) {
-                                    newAddArr.push(rstArr[i]);
-                                }
-                            }
-                            me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(newAddArr);
-                            let recoveryArr = me.getRecoveryArr(me.tempCacheArr, result.data);
-                            if(recoveryArr.length > 0){
-                                me.cache["_GLJ_" + me.currentRationItem.ID] = me.cache["_GLJ_" + me.currentRationItem.ID].concat(recoveryArr);
+        let me = this;
+        CommonAjax.post('api/getGljItemsByCodes', {gljCodes: codes, rationRepId: repId}, function (rstData) {
+            if(rstData.length > 0){
+                sheetCommonObj.cleanData(me.sheet, me.setting, -1);
+                let rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
+                for (let i = 0; i < rstData.length; i++) {
+                    dummyR.gljId = rstData[i].ID;
+                    dummyR.type = rstData[i].type;
+                    rstArr.push(me.createRationGljDisplayItem(dummyR, rstData[i]));
+                }
+                if (me.cache["_GLJ_" + me.currentRationItem.ID]) {
+                    var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
+                    for (var i = 0; i < rstArr.length; i++) {
+                        var hasDup = false;
+                        for (var j = 0; j < cacheArr.length; j++) {
+                            if (cacheArr[j].gljId == rstArr[i].gljId) {
+                                hasDup = true;
+                                break;
                             }
-                            me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
-                                var rst = 0;
-                                if (a.code > b.code) rst = 1
-                                else if (a.code < b.code) rst = -1;
-                                return rst;
-                            });
                         }
-                        me.showGljItems(me.currentRationItem.ID);
-                        if (newAddArr.length > 0) {
-                            me.updateRationItem(function () {
-                                me.sheet.getParent().focus(true);
-                            });
+                        if (!hasDup) {
+                            newAddArr.push(rstArr[i]);
                         }
                     }
-                    else{
-                        let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID]?  me.cache["_GLJ_" + me.currentRationItem.ID] : [];
-                        let recoveryArr = me.getRecoveryArr(me.tempCacheArr, []);
-                        if(recoveryArr.length > 0){
-                            me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(recoveryArr);
-                        }
-                        //更新的工料机不存在
-                        me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
-                            var rst = 0;
-                            if (a.code > b.code) rst = 1
-                            else if (a.code < b.code) rst = -1;
-                            return rst;
-                        });
-                        $('#alertModalBtn').click();
-                        $('#alertText').text("工料机"+ codes + "不存在,请查找你所需要的工料机,或新增工料机");
-                        $('#alertModalCls').click(function () {
-                            me.showGljItems(me.currentRationItem.ID);
-                        });
-                        $('#alertModalCof').click(function () {
-                            me.showGljItems(me.currentRationItem.ID);
-                        })
+                    me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(newAddArr);
+                    let recoveryArr = me.getRecoveryArr(me.tempCacheArr, rstData);
+                    if(recoveryArr.length > 0){
+                        me.cache["_GLJ_" + me.currentRationItem.ID] = me.cache["_GLJ_" + me.currentRationItem.ID].concat(recoveryArr);
                     }
+                    me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
+                        var rst = 0;
+                        if (a.code > b.code) rst = 1
+                        else if (a.code < b.code) rst = -1;
+                        return rst;
+                    });
+                }
+                me.showGljItems(me.currentRationItem.ID);
+                if (newAddArr.length > 0) {
+                    me.updateRationItem(function () {
+                        me.sheet.getParent().focus(true);
+                    });
                 }
-            },
-            error:function(err){
-                alert(err);
             }
-        })
+            else{
+                let cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID]?  me.cache["_GLJ_" + me.currentRationItem.ID] : [];
+                let recoveryArr = me.getRecoveryArr(me.tempCacheArr, []);
+                if(recoveryArr.length > 0){
+                    me.cache["_GLJ_" + me.currentRationItem.ID] = cacheArr.concat(recoveryArr);
+                }
+                //更新的工料机不存在
+                me.cache["_GLJ_" + me.currentRationItem.ID].sort(function(a, b) {
+                    var rst = 0;
+                    if (a.code > b.code) rst = 1
+                    else if (a.code < b.code) rst = -1;
+                    return rst;
+                });
+                $('#alertModalBtn').click();
+                $('#alertText').text("工料机"+ codes + "不存在,请查找你所需要的工料机,或新增工料机");
+                $('#alertModalCls').click(function () {
+                    me.showGljItems(me.currentRationItem.ID);
+                });
+                $('#alertModalCof').click(function () {
+                    me.showGljItems(me.currentRationItem.ID);
+                })
+            }
+        });
     },
     round(v, e){
         var t=1;
@@ -492,10 +483,11 @@ var rationGLJOprObj = {
 
     buildRationItemGlj: function(){
         var me = this, rst = [];
+        console.log(me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]);
         if (me.currentRationItem && me.cache["_GLJ_" + me.currentRationItem.ID]) {
             var cacheArr = me.cache["_GLJ_" + me.currentRationItem.ID];
             for (var i = 0; i < cacheArr.length; i++) {
-                rst.push({gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, proportion: 0});
+                rst.push({gljId: cacheArr[i].gljId, consumeAmt: cacheArr[i].consumeAmt, type: cacheArr[i].type});
             }
         }
         return rst;
@@ -504,6 +496,7 @@ var rationGLJOprObj = {
     createRationGljDisplayItem: function(rItem, repGlj) {
         var rst = {};
         rst.gljId = rItem.gljId;
+        rst.type = rItem.type;
         rst.consumeAmt = rItem.consumeAmt;
         rst.code = repGlj.code;
         rst.name = repGlj.name;
@@ -514,56 +507,46 @@ var rationGLJOprObj = {
         return rst;
     },
     getGljItems: function(rationItem, callback) {
-        var me = this, rationID = rationItem.ID, rationGljList = rationItem.rationGljList;
+        let me = this, rationID = rationItem.ID, rationGljList = rationItem.rationGljList, rationType = rationItem.type;
         me.currentRationItem = rationItem;
         if (me.cache["_GLJ_" + rationID]) {
             me.showGljItems(rationID);
         } else {
-            var gljIds = [];
-            for (var i = 0; i < rationGljList.length; i++) {
-                gljIds.push(rationGljList[i].gljId);
+            let gljIds = [];
+            for (let i = 0; i < rationGljList.length; i++) {
+                let idObj = Object.create(null);
+                idObj.type = rationType === rationOprObj.type.std ? rationOprObj.type.std : rationGljList[i].type;
+                idObj.id = rationGljList[i].gljId;
+                gljIds.push(idObj);
             }
-                $.ajax({
-                    type:"POST",
-                    url:"api/getGljItemsByIds",
-                    data:{"gljIds": JSON.stringify(gljIds)},
-                    dataType:"json",
-                    cache:false,
-                    timeout:5000,
-                    success:function(result){
-                        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
-                        if (result) {
-                            var cacheArr = [];
-                            for (var i = 0; i < result.data.length; i++) {
-                                for (var j = 0; j < rationGljList.length; j++) {
-                                    if (rationGljList[j].gljId == result.data[i].ID) {
-                                        cacheArr.push(me.createRationGljDisplayItem(rationGljList[j], result.data[i]));
-                                        break;
-                                    }
-                                }
-                            }
-                            function compare(){
-                                return function (a, b) {
-                                    let rst = 0;
-                                    if (a.code > b.code) {
-                                        rst = 1;
-                                    }
-                                    else if (a.code < b.code) {
-                                        rst = -1;
-                                    }
-                                    return rst;
-                                }
-                            }
-                            cacheArr.sort(compare());
-                            me.cache["_GLJ_" + rationID] = cacheArr;
-                            me.showGljItems(rationID);
+            CommonAjax.post('api/getGljItemsByIds', {ids: gljIds}, function (rstData) {
+                sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
+                var cacheArr = [];
+                for (let i = 0; i < rstData.length; i++) {
+                    for (let j = 0; j < rationGljList.length; j++) {
+                        if (rationGljList[j].gljId == rstData[i].ID) {
+                            cacheArr.push(me.createRationGljDisplayItem(rationGljList[j], rstData[i]));
+                            break;
                         }
-                        if(callback) callback();
-                    },
-                    error:function(err){
-                        alert(err);
                     }
-                })
+                }
+                function compare(){
+                    return function (a, b) {
+                        let rst = 0;
+                        if (a.code > b.code) {
+                            rst = 1;
+                        }
+                        else if (a.code < b.code) {
+                            rst = -1;
+                        }
+                        return rst;
+                    }
+                }
+                cacheArr.sort(compare());
+                me.cache["_GLJ_" + rationID] = cacheArr;
+                me.showGljItems(rationID);
+                if(callback) callback();
+            });
         }
     },
     showGljItems: function(rationID) {

+ 40 - 12
web/building_saas/complementary_ration_lib/js/repository_glj.js

@@ -3,11 +3,11 @@
  */
 
 $("#drirect-dinge").click(function(){
-    $(this).attr('href', "/rationRepository/ration" + "?repository=" + getQueryString("repository"))
+    $(this).attr('href', "/complementaryRation/ration" + "?repository=" + getQueryString("repository"))
 });
 
 $("#fuzhu").click(function(){
-    $(this).attr('href', "/rationRepository/coeList" + "?repository=" + getQueryString("repository"))
+    $(this).attr('href', "/complementaryRation/coe" + "?repository=" + getQueryString("repository"))
 });
 
 var pageOprObj = {
@@ -23,7 +23,7 @@ var pageOprObj = {
             $("#rationname")[0].outerHTML = html;
             me.rationLibName = rationLibName;
             repositoryGljObj.buildSheet(container);
-            repositoryGljObj.getRationGljIds(rationLibId);
+            //repositoryGljObj.getRationGljIds(rationLibId);
             repositoryGljObj.getGljDistType(function () {
                 repositoryGljObj.currentRepositoryId = parseInt(rationLibId);
                 //引用的工料机库
@@ -99,23 +99,40 @@ repositoryGljObj = {
     },
     getGljDistType: function (callback) {
         let me = this;
-        $.ajax({
+        CommonAjax.post('api/getGljDistType', {}, function (rstData) {
+            me.distTypeTree = me.getComboData(rstData);
+            me.workBook.getSheet(0).getCell(-1, 5, GC.Spread.Sheets.SheetArea.viewport).value(me.distTypeTree.comboDatas[0].text);
+            if(callback){
+                callback();
+            }
+        });
+   /*     $.ajax({
             type: 'post',
             url: "api/getGljDistType",
             dataType: 'json',
             success: function (result) {
                 if(!result.error && callback){
                     me.distTypeTree = me.getComboData(result.data);
-                    /*let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
-                    combo.items(me.distTypeTree.comboDatas).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);*/
+                    /!*let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
+                    combo.items(me.distTypeTree.comboDatas).editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);*!/
                     me.workBook.getSheet(0).getCell(-1, 5, GC.Spread.Sheets.SheetArea.viewport).value(me.distTypeTree.comboDatas[0].text);
                     callback();
                 }
             }
-        })
+        })*/
     },
-    getGljTree: function(gljLibID, callback) {
+    getGljTree: function(gljLibId, callback) {
         var me = this;
+        CommonAjax.post('api/getGljTree', {gljLibId: gljLibId}, function (rstData) {
+            zTreeHelper.createTree(rstData, gljSetting, "repositoryTree", me);
+            if (rstData && rstData.length > 0) {
+                me.gljCurTypeId = rstData[0].ID;
+            } else {
+                gljTypeTreeOprObj.addRootNode();
+            }
+            callback();
+        });
+/*
         $.ajax({
             type:"POST",
             url:"api/getGljTree",
@@ -137,11 +154,22 @@ repositoryGljObj = {
             error:function(err){
                 alert(err.responseJSON.error);
             }
-        })
+        })*/
     },
-    getGljItems: function(gljLibID) {
+    getGljItems: function(gljLibId) {
         var me = this;
-        $.ajax({
+        CommonAjax.post('api/getGljItems', {gljLibId: gljLibId}, function (rstData) {
+            me.gljList = rstData;
+            me.workBook.getSheet(0).setRowCount(rstData.length);
+            me.sortGlj();
+            let rootNode = me.treeObj.getNodes()[0];
+            if(rootNode && rootNode.isParent && rootNode.isFirstNode){
+                me.treeObj.selectNode(rootNode);
+                gljTypeTreeOprObj.onClick(null, 'repositoryTree', rootNode);
+            }
+        });
+
+       /* $.ajax({
             type:"POST",
             url:"api/getGljItems",
             data:{"repositoryId": gljLibID},
@@ -164,7 +192,7 @@ repositoryGljObj = {
             error:function(err){
                 alert(err.responseJSON.error);
             }
-        })
+        })*/
     },
     showGljItems: function(data, type) {
         var me = repositoryGljObj;

+ 132 - 216
web/building_saas/complementary_ration_lib/js/section_tree.js

@@ -4,29 +4,35 @@
 let pageOprObj = {
     rationLibName : null,
     rationLibId : null,
+    gljLibId: null,
     initPage : function() {
-        var me = this, rationLibId = getQueryString("repository"),//获取定额库参数
-            rationLibName = storageUtil.getSessionCache("RationGrp","repositoryID_" + rationLibId);
-        if (rationLibName) {
-            var html = $("#rationname")[0].outerHTML;
-            html = html.replace("XXX定额库", rationLibName);
-            $("#rationname")[0].outerHTML = html;
-            me.rationLibName = rationLibName;
-            me.rationLibId = rationLibId;
-            sectionTreeObj.getSectionTree(rationLibId);
-            //job
-            jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
-            $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
-            $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
-            jobContentOprObj.bindAllEvents($('#txtareaAll'));
-            //fz
-            annotationOprObj.radiosChange(annotationOprObj.radios, annotationOprObj.fzTableAll, annotationOprObj.fzTablePartial);
-            $('#fzAddConBtn').click(annotationOprObj.bindAddConBtn());
-            $('#fzUpdateConBtn').click(annotationOprObj.bindUpdateConBtn());
-            annotationOprObj.bindAllEvents($('#fzTxtareaAll'));
-        }
+        let me = this, rationLibId = getQueryString("repository");
+        me.getRationLibInfo(rationLibId, function (rstData) {
+            if(rstData.length > 0){
+                me.rationLibName = rstData[0].dispName;
+                me.gljLibId = rstData[0].gljLib;
+                let html = $("#rationname")[0].outerHTML;
+                html = html.replace("XXX定额库", me.rationLibName);
+                $("#rationname")[0].outerHTML = html;
+                me.rationLibId = rationLibId;
+                sectionTreeObj.getSectionTree(rationLibId);
+                //job
+                jobContentOprObj.radiosChange(jobContentOprObj.radios, jobContentOprObj.tableAll, jobContentOprObj.tablePartial);
+                $('#addConBtn').click(jobContentOprObj.bindAddConBtn());
+                $('#updateConBtn').click(jobContentOprObj.bindUpdateConBtn());
+                jobContentOprObj.bindAllEvents($('#txtareaAll'));
+                //fz
+                annotationOprObj.radiosChange(annotationOprObj.radios, annotationOprObj.fzTableAll, annotationOprObj.fzTablePartial);
+                $('#fzAddConBtn').click(annotationOprObj.bindAddConBtn());
+                $('#fzUpdateConBtn').click(annotationOprObj.bindUpdateConBtn());
+                annotationOprObj.bindAllEvents($('#fzTxtareaAll'));
+            }
+        });
+    },
+    getRationLibInfo: function (rationLibId, callback) {
+        CommonAjax.post('api/getRationLib', {rationRepId: rationLibId}, callback);
     }
-}
+};
 
 let sectionTreeObj = {
     cache: null,//ref to tree.items
@@ -37,10 +43,7 @@ let sectionTreeObj = {
     updateType: {new: 'new', update: 'update'},
     insertBtn: $('#tree_Insert'),
     removeBtn: $('#tree_remove'),
-    upLevelBtn: $('#tree_upLevel'),
-    downLevelBtn: $('#tree_downLevel'),
-    downMoveBtn: $('#tree_downMove'),
-    upMoveBtn: $('#tree_upMove'),
+    type: {std: 'std', complementary: 'complementary'},
     setting: {
         sheet: {
             cols:[
@@ -121,6 +124,8 @@ let sectionTreeObj = {
         const Events = GC.Spread.Sheets.Events;
         sheet.bind(Events.SelectionChanging, me.onSelectionChanging);
         sheet.bind(Events.EditEnded, me.onEditEnded);
+        sheet.bind(Events.EditStarting, me.onEditStarting);
+        sheet.bind(Events.ClipboardPasting, me.onClipboardPasting);
         sheet.bind(Events.ClipboardPasted, me.onClipboardPasted);
     },
 
@@ -136,13 +141,25 @@ let sectionTreeObj = {
         }
     },
 
+    onEditStarting: function (sender, args) {
+        let me = sectionTreeObj;
+        let node = me.cache[args.row];
+        if(!me.isDef(node)){
+            args.cancel = true;
+            return;
+        }
+        if(node.data.type === me.type.std){
+            args.cancel = true;
+        }
+    },
+
     onEditEnded: function (sender, args) {
         let me = sectionTreeObj;
         let postData = [];
         let v = me.isDef(args.editingText) ? args.editingText.toString().trim() : '';
         let node = me.cache[args.row];
         if(me.isDef(node) && node.data.name !== v){
-            let updateObj = me.getUpdateObj(me.updateType.update, node.getID(), null, null, v, null);
+            let updateObj = me.getUpdateObj(me.updateType.update, {ID: node.getID(), name: v});
             postData.push(updateObj);
             //ajax
             //update
@@ -154,6 +171,19 @@ let sectionTreeObj = {
         }
     },
 
+    onClipboardPasting: function (sender, info) {
+        let me = sectionTreeObj;
+        let hasStd = false;
+        for(let row = info.cellRange.row, len = info.cellRange.row + info.cellRange.rowCount - 1; row < len; row ++){
+            if(me.isDef(me.cache[row]) && me.cache[row].data.type === me.type.std){
+                hasStd = true;
+            }
+        }
+        if(hasStd){
+            info.cancel = true;
+        }
+    },
+
     onClipboardPasted: function (sender, info) {
         let me = sectionTreeObj;
         let items = sheetCommonObj.analyzePasteData({header: [{dataCode: 'name'}]}, info);
@@ -163,7 +193,7 @@ let sectionTreeObj = {
             let row = info.cellRange.row + i;
             let node = me.cache[row];
             if(me.isDef(node) && me.isDef(items[i].name) && node.data.name !== items[i].name){
-                let updateObj = me.getUpdateObj(me.updateType.update, node.getID(), null, null, items[i].name, null);
+                let updateObj = me.getUpdateObj(me.updateType.update, {ID: node.getID(), name: items[i].name});
                 postData.push(updateObj);
                 frontData.push({row: row, name: items[i].name});
                 node.data.name = items[i].name;
@@ -202,6 +232,7 @@ let sectionTreeObj = {
             me.bindBtn();
             me.initController(me.tree, me.sheet, me.setting.sheet);
             me.controller.showTreeData();
+            me.setColor(me.cache);
             me.sheet.setFormatter(-1, 0, '@');
             me.initSelection(me.tree.selected);
             explanatoryOprObj.bindEvents($('#explanationShow'), $('#ruleTextShow'));
@@ -211,7 +242,18 @@ let sectionTreeObj = {
         };
         CommonAjax.post(url, postData, sucFunc, errFunc);
     },
-    
+
+    setColor: function (nodes) {
+        let me = this;
+        me.renderFunc(me.sheet, function () {
+            for(let i = 0, len = nodes.length; i < len; i++){
+                if(nodes[i].data.type === me.type.complementary){
+                    me.sheet.getCell(i, 0).foreColor('gray');
+                }
+            }
+        });
+    },
+
     initTree: function (datas) {
         this.tree = idTree.createNew(this.setting.tree);
         this.tree.loadDatas(datas);
@@ -226,28 +268,11 @@ let sectionTreeObj = {
         let me = this;
         me.insertBtn.removeClass('disabled');
         me.removeBtn.removeClass('disabled');
-        me.upLevelBtn.removeClass('disabled');
-        me.downLevelBtn.removeClass('disabled');
-        me.downMoveBtn.removeClass('disabled');
-        me.upMoveBtn.removeClass('disabled');
         if(!me.isDef(selected)){
             me.removeBtn.addClass('disabled');
-            me.upLevelBtn.addClass('disabled');
-            me.downLevelBtn.addClass('disabled');
-            me.downMoveBtn.addClass('disabled');
-            me.upMoveBtn.addClass('disabled');
         }
-        else {
-            if(!me.isDef(selected.preSibling)){
-                me.downLevelBtn.addClass('disabled');
-                me.upMoveBtn.addClass('disabled');
-            }
-            if(!me.isDef(selected.nextSibling)){
-                me.downMoveBtn.addClass('disabled');
-            }
-            if(!me.isDef(selected.parent)){
-                me.upLevelBtn.addClass('disabled');
-            }
+        else if(me.isDef(selected.data.type) && selected.data.type !== me.type.complementary){
+            me.removeBtn.addClass('disabled');
         }
     },
     
@@ -259,50 +284,60 @@ let sectionTreeObj = {
         me.removeBtn.click(function () {
            me.remove(me.tree.selected);
         });
-        me.upLevelBtn.click(function () {
-            me.upLevel(me.tree.selected);
-        });
-        me.downLevelBtn.click(function () {
-            me.downLevel(me.tree.selected);
-        });
-        me.downMoveBtn.click(function () {
-            me.downMove(me.tree.selected);
-        });
-        me.upMoveBtn.click(function () {
-            me.upMove(me.tree.selected);
-        });
     },
     
     insert: function () {
         let me = this;
         me.insertBtn.addClass('disabled');
         let postData = [];
-        let newID = me.tree.newNodeID();
-        let selected = me.tree.selected;
-        let insertObj = me.getUpdateObj(me.updateType.new, newID, -1, -1, '', null);
-        if(me.isDef(selected)) {
-            let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), newID, null, null, null);
-            postData.push(updateObj);
-            insertObj.updateData.ParentID = selected.getParentID();
-            if(me.isDef(selected.nextSibling)){
-                insertObj.updateData.NextSiblingID = selected.getNextSiblingID();
+        CommonAjax.post('api/getNewTreeID', {user_id: userID}, function (newID) {
+            if(!me.isDef(newID)){
+                return;
             }
-        }
-        postData.push(insertObj);
-        if(postData.length > 0){
-            //ajax
-            me.sectionTreeAjax(postData, function (rstData) {
-                me.controller.insert();
-                me.refreshBtn(me.tree.selected);
-                //fresh tools
-                me.initTools(me.tree.selected);
-            });
-        }
+            me.tree.maxNodeID(newID - 1);
+            let selected = me.tree.selected;
+            let insertObj = me.getUpdateObj(me.updateType.new, {ID: newID, NextSiblingID: -1, ParentID: -1, name: ''});
+            if(me.isDef(selected)) {
+                insertObj.updateData.ParentID = selected.getParentID();
+                //同级节点
+                let slNodes = [];
+                slNodes = !me.isDef(selected.parent)? me.tree.roots : selected.parent.children;
+                let updateNode = slNodes[slNodes.length - 1];
+                if(me.isDef(updateNode)){
+                    me.controller.setTreeSelected(updateNode);
+                    if(updateNode.data.type === me.type.complementary){
+                        let updateObj = me.getUpdateObj(me.updateType.update, {ID: updateNode.getID(), NextSiblingID: newID});
+                        postData.push('updateObj');
+                        postData.push(updateObj);
+                    }
+                    else {
+                        insertObj.updateData.isFirst = true;
+                    }
+                }
+            }
+            postData.push(insertObj);
+            if(postData.length > 0){
+                //ajax
+                me.sectionTreeAjax(postData, function (rstData) {
+                    me.controller.insert();
+                    me.sheet.getCell(me.sheet.getActiveRowIndex(), 0).foreColor('gray');
+                    me.tree.selected.data = insertObj.updateData;
+                    me.tree.selected.data.type = me.type.complementary;
+                    me.refreshBtn(me.tree.selected);
+                    //fresh tools
+                    me.initTools(me.tree.selected);
+                });
+            }
+        });
     },
     remove: function (selected) {
         let me = this;
         me.removeBtn.addClass('disabled');
         let postData = [], IDs = [];
+        let deleteObj = Object.create(null);
+        deleteObj.deleted = true;
+        deleteObj.deleteDateTime = new Date();
+        deleteObj.deleteBy = userID;
         if(!selected){
             return;
         }
@@ -317,13 +352,18 @@ let sectionTreeObj = {
                 }
             }
         }
-        if(me.isDef(selected.preSibling)){
+        if(me.isDef(selected.preSibling) && selected.preSibling.data.type === me.type.complementary){
             let updateObj = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
             postData.push(updateObj);
         }
+        else if((!me.isDef(selected.preSibling) || (me.isDef(selected.preSibling) && selected.preSibling.data.type === me.type.std))
+            && me.isDef(selected.nextSibling)){
+            let updateNextObj = me.getUpdateObj(me.updateType.update, {ID: selected.nextSibling.getID(), isFirst: true});
+            postData.push(updateNextObj);
+        }
         if(IDs.length > 0){
             for(let i = 0, len = IDs.length; i < len; i++){
-                let delObj = me.getUpdateObj(me.updateType.update, IDs[i], null, null, null, true);
+                let delObj = me.getUpdateObj(me.updateType.update, {ID: IDs[i], deleteInfo: deleteObj});
                 postData.push(delObj);
             }
         }
@@ -336,123 +376,7 @@ let sectionTreeObj = {
             });
         }
     },
-    upLevel: function (selected) {
-        let me = this;
-        me.upLevelBtn.addClass('disabled');
-        let postData = [];
-        if(!me.isDef(selected)){
-            return;
-        }
-        if(!me.isDef(selected.parent)){
-            return;
-        }
-        if(me.isDef(selected.preSibling)){
-            let updateObj = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), -1, null, null, null);
-            postData.push(updateObj);
-        }
-        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), selected.parent.getNextSiblingID(), selected.parent.getParentID(), null, null);
-        postData.push(updateObj);
-        let updateParent = me.getUpdateObj(me.updateType.update, selected.getParentID(), selected.getID(), null, null, null);
-        postData.push(updateParent);
-        let nextIDs = [];
-        getNext(selected);
-        function getNext(node){
-            if(me.isDef(node.nextSibling)){
-                nextIDs.push(node.getNextSiblingID());
-                getNext(node.nextSibling);
-            }
-        }
-        for(let i = 0, len = nextIDs.length; i < len; i++){
-            postData.push(me.getUpdateObj(me.updateType.update, nextIDs[i], null, selected.getID(), null, null));
-        }
-        if(postData.length > 0){
-            //ajax
-            me.sectionTreeAjax(postData, function (rstData) {
-                me.controller.upLevel();
-                me.refreshBtn(me.tree.selected);
-            });
-        }
-
-    },
-    downLevel: function (selected) {
-        let me = this;
-        me.downLevelBtn.addClass('disabled');
-        let postData = [];
-        if(!me.isDef(selected)){
-            return;
-        }
-        if(!me.isDef(selected.preSibling)){
-            return;
-        }
-        let updatePre = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
-        postData.push(updatePre);
-        if(selected.preSibling.children.length > 0){
-            let updateObj = me.getUpdateObj(me.updateType.update, selected.preSibling.children[selected.preSibling.children.length - 1].getID(), selected.getID(), null, null, null);
-            postData.push(updateObj);
-        }
-        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), -1, selected.preSibling.getID(), null, null);
-        postData.push(updateObj);
-        if(postData.length > 0){
-            //ajax
-            me.sectionTreeAjax(postData, function (rstData) {
-                me.controller.downLevel();
-                me.refreshBtn(me.tree.selected);
-            });
-        }
-    },
-    upMove: function (selected) {
-        let me = this;
-        me.upMoveBtn.addClass('disabled');
-        let postData = [];
-        if(!me.isDef(selected)){
-            return;
-        }
-        if(!me.isDef(selected.preSibling)){
-            return;
-        }
-        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), selected.preSibling.getID(), null, null, null);
-        postData.push(updateObj);
-        let updatePre = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
-        postData.push(updatePre);
-        if(me.isDef(selected.preSibling.preSibling)){
-            let updatePrepre = me.getUpdateObj(me.updateType.update, selected.preSibling.preSibling.getID(), selected.getID(), null, null, null);
-            postData.push(updatePrepre);
-        }
-        if(postData.length > 0){
-            //ajax
-            me.sectionTreeAjax(postData, function (rstData) {
-                me.controller.upMove();
-                me.refreshBtn(me.tree.selected);
-            });
-        }
-    },
-    downMove: function (selected) {
-        let me = this;
-        me.downMoveBtn.addClass('disabled');
-        let postData = [];
-        if(!me.isDef(selected)){
-            return;
-        }
-        if(!me.isDef(selected.nextSibling)){
-            return;
-        }
-        if(me.isDef(selected.preSibling)){
-            let updatePre = me.getUpdateObj(me.updateType.update, selected.preSibling.getID(), selected.getNextSiblingID(), null, null, null);
-            postData.push(updatePre);
-        }
-        let updateObj = me.getUpdateObj(me.updateType.update, selected.getID(), selected.nextSibling.getNextSiblingID(), null, null, null);
-        postData.push(updateObj);
-        let updateNext = me.getUpdateObj(me.updateType.update, selected.getNextSiblingID(), selected.getID(), null, null, null);
-        postData.push(updateNext);
-        if(postData.length > 0){
-            //ajax
-            me.sectionTreeAjax(postData, function (rstData) {
-                me.controller.downMove();
-                me.refreshBtn(me.tree.selected);
-            });
-        }
-    },
-    getUpdateObj: function (updateType, id, nid, pid, name, deleted) {
+    getUpdateObj: function (updateType, updateData) {
         let updateObj = Object.create(null);
         updateObj.updateType = '';
         updateObj.updateData = Object.create(null);
@@ -460,25 +384,15 @@ let sectionTreeObj = {
         if(this.isDef(updateType)){
             updateObj.updateType = updateType;
         }
-        if(this.isDef(id)){
-            updateObj.updateData.ID = id;
-        }
-        if(this.isDef(nid)){
-            updateObj.updateData.NextSiblingID = nid;
-        }
-        if(this.isDef(pid)){
-            updateObj.updateData.ParentID = pid;
-        }
-        if(this.isDef(name)){
-            updateObj.updateData.name = name;
-        }
-        if(this.isDef(deleted)){
-            updateObj.updateData.isDeleted = true;
+        if(this.isDef(updateData)){
+            for(let attr in updateData){
+                updateObj.updateData[attr] = updateData[attr];
+            }
         }
         return updateObj;
     },
     sectionTreeAjax: function (postData, scFunc, errFunc) {
-        CommonAjax.post('api/updateNodes', {updateData: postData, lastOpr: userAccount}, scFunc, errFunc);
+        CommonAjax.post('api/updateRationSection', {updateData: postData}, scFunc, errFunc);
     },
     initTools: function (node) {
         if(this.isDef(node)){
@@ -513,14 +427,16 @@ let sectionTreeObj = {
             rationOprObj.currentSectionId = node.data.ID;
             rationOprObj.workBook.getSheet(0).setRowCount(30);
             rationOprObj.setCombo(rationOprObj.workBook.getSheet(0), null);
-            jobContentOprObj.setRadiosDisabled(true, jobContentOprObj.radios);
+           // jobContentOprObj.setRadiosDisabled(true, jobContentOprObj.radios);
             jobContentOprObj.hideTable($('#tableAll'), $('#tablePartial'));
-            annotationOprObj.setRadiosDisabled(true, annotationOprObj.radios);
+          //  annotationOprObj.setRadiosDisabled(true, annotationOprObj.radios);
             annotationOprObj.hideTable($('#fzTableAll'), $('#fzTablePartial'));
             sheetCommonObj.cleanSheet(rationOprObj.workBook.getSheet(0), rationOprObj.setting, -1);
         }
         sheetCommonObj.cleanSheet(rationGLJOprObj.sheet, rationGLJOprObj.setting, -1);
-        rationGLJOprObj.sheet.getParent().focus(false);
+        sheetCommonObj.cleanSheet(rationCoeOprObj.sheet, rationCoeOprObj.setting, -1);
+        sheetCommonObj.cleanSheet(rationAssistOprObj.sheet, rationAssistOprObj.setting, -1);
+        //rationGLJOprObj.sheet.getParent().focus(false);
         me.workBook.focus(true);
     }
 };

+ 1 - 0
web/building_saas/glj/js/project_glj.js

@@ -417,6 +417,7 @@ function filterProjectGLJ(jsonData) {
     return jsonData;
 }
 
+
 function sortProjectGLJ(jsonData) {
     if (jsonData.length > 0) {
         jsonData = _.sortByAll(jsonData, [function (item) {

+ 2 - 0
web/building_saas/glj/js/project_glj_spread.js

@@ -48,6 +48,8 @@ ProjectGLJSpread.prototype.init = function () {
         {name: 'ID', field: 'id', visible: false},
         {name: '类型', field: 'unit_price.type', visible: false},
         {name: '总消耗量', field: 'quantity', visible: true,width:100,decimalField:'glj.quantity'},
+        {name: '分部分项总消耗量', field: 'subdivisionQuantity', visible: false,width:100,decimalField:'glj.quantity'},
+        {name: '技术措施项目总消耗量', field: 'techQuantity', visible: false,width:100,decimalField:'glj.quantity'},
         {name: '定额价', field: "base_price", visible: true,width:70,decimalField:"glj.unitPrice",validator: 'number'},//这里feiedID设置是为了在计不计取价差的时候做显示用
         {name: '调整价', field: 'adjust_price', visible: true,width:70,decimalField:"glj.unitPrice"},
         {name: '市场价', field: "unit_price.market_price", visible: true, validator: 'number',width:70,decimalField:"glj.unitPrice"},

+ 44 - 1
web/building_saas/main/js/controllers/project_controller.js

@@ -23,7 +23,6 @@ ProjectController = {
     },
     addBills: function (project, sheetController, std) {
         if (!project || !sheetController) { return null; }
-
         let target = project.getParentTarget(project.mainTree.selected, 'sourceType', project.Bills.getSourceType());
         let newSource = null, newNode = null, parentID, nextSiblingID;
         if (target) {
@@ -54,6 +53,50 @@ ProjectController = {
             this.syncDisplayNewNode(sheetController, newNode);
         }
     },
+    addRootBill:function (project, sheetController) {//添加大项费用
+        if (!project || !sheetController) { return null; }
+        this.addSpecialBill(project, sheetController,null, null,true,billType.DXFY);
+    },
+    addFB:function(project, sheetController) {//添加分部
+        if (!project || !sheetController) { return null; }
+        let selected = project.mainTree.selected;
+        if(selected.parent==null&&isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){//选中的是分部分项,则插入做为最后一个子项
+            this.addSpecialBill(project, sheetController,selected, null,true,billType.FB);
+        }
+        if(selected.parent){
+            this.addSpecialBill(project, sheetController,selected.parent, selected.nextSibling,true,billType.FB);
+        }
+
+    },
+    addFX:function(project, sheetController) {//添加分项
+        if (!project || !sheetController) { return null; }
+        let selected = project.mainTree.selected;
+        if(selected.data.type==billType.FB||(selected.parent==null&&isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING)){//选中的是分部或者是分部分项工程,则插入做为最后一个子项
+            this.addSpecialBill(project, sheetController,selected, null,true,billType.FX);
+        }
+        if(selected.parent){
+            if(selected.data.type==billType.FX){
+                this.addSpecialBill(project, sheetController,selected.parent, selected.nextSibling,true,billType.FX);
+            }
+        }
+    },
+    addSpecialBill(project,sheetController,parent,nextSibling,isUserAdd,type){
+        let newSource = null, newNode = null;
+        let b_nexID = nextSibling==null?-1:nextSibling.source.getID();//主树和清单树,对应的树节点ID不一样
+        let m_nexID = nextSibling==null?-1:nextSibling.getID();
+        let b_parent = parent==null?-1:parent.source.getID();
+        let m_parent = parent==null?-1:parent.getID();
+
+        newSource = project.Bills.insertSpecialBill(b_parent, b_nexID,isUserAdd,type);
+        newNode = project.mainTree.insert(m_parent,m_nexID);
+        if (newNode) {
+            newNode.source = newSource;
+            newNode.sourceType = project.Bills.getSourceType();
+            newNode.data = newSource.data;
+            this.syncDisplayNewNode(sheetController, newNode);
+        }
+    },
+
     addRation: function (project, sheetController, rationType, std) {
         if (!project || !sheetController) { return; }
 

+ 85 - 3
web/building_saas/main/js/models/bills.js

@@ -150,8 +150,26 @@ var Bills = {
             }
             return updateData;
         };
+        bills.prototype.insertSpecialBill=function(parentId, nextSiblingId,isUserAdd,type){
+            var insertData = this.tree.getInsertData(parentId, nextSiblingId);
+            var that = this, newData = null;
+            insertData.forEach(function (data) {
+                if (data.type === idTree.updateType.new) {
+                    if(isUserAdd==true){//如果是用户新增的
+                        data.data.isAdd = 1;
+                    }
+                    data.data.type = type;
+                    newData = data.data;
+                }
+            });
+            this.project.pushNow('insertBills', [this.getSourceType(), this.project.projCounter()],
+                [ tools.coverseTreeUpdateData(insertData, this.project.ID()), this.getCounterData()]);
+            //project.pushNow('insertBills', ModuleNames.bills, tools.coverseTreeUpdateData(insertData));
 
-        bills.prototype.insertBills = function (parentId, nextSiblingId) {
+            this.datas.push(newData);
+            return this.tree.insertByData(newData,parentId, nextSiblingId);
+        };
+        bills.prototype.insertBills = function (parentId, nextSiblingId) {//是否是用户新增的
             var insertData = this.tree.getInsertData(parentId, nextSiblingId);
             var that = this, newData = null;
             insertData.forEach(function (data) {
@@ -328,7 +346,6 @@ var Bills = {
             this.project.pushNow('replaceBills', this.getSourceType(), updateData);
             return node;            
         };
-
         bills.prototype.sameStdCodeBillsData = function (stdCode) {
             let reg = new RegExp('^' + stdCode);
             for (let data of this.datas) {
@@ -337,8 +354,73 @@ var Bills = {
                 }
             }
             return null;            
-        }
+        };
 
+        bills.prototype.getSubdivisionProjectLeavesID=function () {//取所有分部分项工程清单叶子节点ID
+            let roots = projectObj.project.mainTree.roots;//所有根节点
+            let subdivisionNode = null;
+            for(let r of roots){
+               if(isFlag(r.data)&&r.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING) {
+                   subdivisionNode = r;
+                   break;
+               }
+            }
+            let nodes = this.getLeavesBillNodes(subdivisionNode);
+            return  _.map(nodes,"data.ID");
+        };
+
+
+        bills.prototype.getTechLeavesID=function () {//取所有分计算技术措施项目清单叶子节点ID
+            let items = projectObj.project.mainTree.roots;//所有节点;
+            let techNode = null;
+            for(let item of items){
+                if(isFlag(item.data)&&item.data.flagsIndex.fixed.flag==fixedFlag.CONSTRUCTION_TECH){
+                    techNode = item;
+                    break;
+                }
+            }
+            let nodes = this.getLeavesBillNodes(techNode);
+            return  _.map(nodes,"data.ID");
+        };
+        bills.prototype.getLeavesBillNodes = function (rnode) {//取该节点下的所有清单叶子节点
+            let leaves = [];
+            getLeaves(rnode,leaves);
+            return leaves;
+
+            function  getLeaves(node,children) {
+                if(node){
+                    if(node.source.children.length>0){
+                        for(let c of node.children){
+                            getLeaves(c,children)
+                        }
+                    }else {
+                        children.push(node);
+                    }
+                }
+            }
+        };
+        bills.prototype.getRootNode = function (node) {
+            if(node.parent){
+                return this.getRootNode(node.parent)
+            }else {
+                return node
+            }
+        };
+        bills.prototype.isFBFX = function (node) {//判读是否属于分部分项
+           let rootNode = this.getRootNode(node);
+            if(isFlag(rootNode.data)&&rootNode.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){
+                return true
+            }else {
+                return false
+            }
+        };
         return new bills(project);
     }
 };
+function isDef(v) {
+    return v !== undefined && v !== null;
+}
+
+function isFlag(v) {
+    return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed);
+}

+ 0 - 1
web/building_saas/main/js/models/cache_tree.js

@@ -380,7 +380,6 @@ var cacheTree = {
             }
             return success;
         };
-
         return new Tree(owner);
     }
 };

+ 7 - 43
web/building_saas/main/js/models/calc_base.js

@@ -1,47 +1,7 @@
 /**
  * Created by Zhong on 2017/11/28.
  */
-//清单固定行
-const fixedFlag = {
-    // 分部分项工程
-    SUB_ENGINERRING: 1,
-    // 措施项目
-    MEASURE: 2,
-    // 施工技术措施项目
-    CONSTRUCTION_TECH: 3,
-    // 安全文明施工按实计算费用
-    SAFETY_CONSTRUCTION_ACTUAL: 4,
-    // 施工组织措施专项费用
-    CONSTRUCTION_ORGANIZATION: 5,
-    // 安全文明施工专项费用
-    SAFETY_CONSTRUCTION: 6,
-    // 其他项目
-    OTHER: 7,
-    // 暂列金额
-    PROVISIONAL: 8,
-    // 暂估价
-    ESTIMATE: 9,
-    // 材料(工程设备)暂估价
-    MATERIAL_PROVISIONAL: 10,
-    // 专业工程暂估价
-    ENGINEERING_ESITIMATE: 11,
-    // 计日工
-    DAYWORK: 12,
-    // 总承包服务费
-    TURN_KEY_CONTRACT: 13,
-    // 索赔与现场签证
-    CLAIM_VISA: 14,
-    // 规费
-    CHARGE: 15,
-    // 社会保险费及住房公积金 Social insurance fee and housing accumulation fund
-    SOCIAL_INSURANCE_HOUSING_FUND: 16,
-    // 工程排污费 charges for disposing pollutants
-    POLLUTANTS: 17,
-    // 税金
-    TAX: 18,
-    //工程造价
-    ENGINEERINGCOST: 19
-};
+
 
 let cbTools = {
     isDef: function (v) {
@@ -613,7 +573,7 @@ let calcBase = {
     getBaseBill: function (node) {
         return cbTools.getBaseBill(node);
     },
-    calculate: function (node) {
+    calculate: function (node, reCalc) {
         let me = calcBase,
             $CBA = cbAnalyzer,
             $CBP = cbParser,
@@ -622,7 +582,11 @@ let calcBase = {
             me.success = false;
             me.errMsg = '表达式不正确';
             //分析输入式合法性
-            let exp = $CBA.legalExp(node);
+            let exp = reCalc
+                ? cbTools.isDef(node.data.calcBase)
+                    ? node.data.calcBase
+                    : ''
+                : $CBA.legalExp(node);
             if(!cbTools.isDef(exp)){
                 throw '表达式不正确';
             }

+ 55 - 1
web/building_saas/main/js/models/main_consts.js

@@ -131,5 +131,59 @@ const zanguCalcType = {
     gatherMaterial: 1
 };
 
+//清单固定行
+const fixedFlag = {
+    // 分部分项工程
+    SUB_ENGINERRING: 1,
+    // 措施项目
+    MEASURE: 2,
+    // 施工技术措施项目
+    CONSTRUCTION_TECH: 3,
+    // 安全文明施工按实计算费用
+    SAFETY_CONSTRUCTION_ACTUAL: 4,
+    // 施工组织措施专项费用
+    CONSTRUCTION_ORGANIZATION: 5,
+    // 安全文明施工专项费用
+    SAFETY_CONSTRUCTION: 6,
+    // 其他项目
+    OTHER: 7,
+    // 暂列金额
+    PROVISIONAL: 8,
+    // 暂估价
+    ESTIMATE: 9,
+    // 材料(工程设备)暂估价
+    MATERIAL_PROVISIONAL: 10,
+    // 专业工程暂估价
+    ENGINEERING_ESITIMATE: 11,
+    // 计日工
+    DAYWORK: 12,
+    // 总承包服务费
+    TURN_KEY_CONTRACT: 13,
+    // 索赔与现场签证
+    CLAIM_VISA: 14,
+    // 规费
+    CHARGE: 15,
+    // 社会保险费及住房公积金 Social insurance fee and housing accumulation fund
+    SOCIAL_INSURANCE_HOUSING_FUND: 16,
+    // 工程排污费 charges for disposing pollutants
+    POLLUTANTS: 17,
+    // 税金
+    TAX: 18,
+    //工程造价
+    ENGINEERINGCOST: 19
+};
+
 const gljKeyArray =['code','name','specs','unit','type'];
-const gljLibKeyArray =['code', 'name', 'specs', 'unit', 'gljType']
+const gljLibKeyArray =['code', 'name', 'specs', 'unit', 'gljType'];
+const billType ={
+    DXFY:1,//大项费用
+    FB:2,//分部
+    FX:3,//分项
+    BILL:4//清单
+};
+const billText = {
+    1:'费用',
+    2:'分部',
+    3:'分项',
+    4:'清单'
+};

+ 91 - 0
web/building_saas/main/js/models/project_glj.js

@@ -41,6 +41,7 @@ ProjectGLJ.prototype.loadData = function (callback = null) {
                 return false;
             }
             self.datas = response.data;
+            self.calcQuantity();
             // 回调函数
             if (callback !== null) {
                 callback(response.data);
@@ -396,3 +397,93 @@ ProjectGLJ.prototype.getShortNameByID = function (ID) {
     let gljTypeMap = this.datas.constData.gljTypeMap;
     return gljTypeMap["typeId" + ID].shortName;
 }
+
+ProjectGLJ.prototype.calcQuantity  = function (){
+    let project_gljs = this.datas.gljList;
+    let mixRatioConnectData = this.datas.mixRatioConnectData;
+    let mixRatioSubdivisionMap = {};
+    let mixRatioTechMap={};
+    for(let pglj of project_gljs ){
+        if(pglj.quantity !== 0 && pglj.quantity !== '0'){
+            let result = this.getQuantityPerGLJ(pglj,mixRatioSubdivisionMap,mixRatioTechMap);
+            pglj.subdivisionQuantity = result.subdivisionQuantity;
+            pglj.techQuantity = result.techQuantity;
+        }
+    }
+    //计算做为组成物的消耗量
+    for(let pg of project_gljs ){
+        if(pg.quantity !== 0 && pg.quantity !== '0'){
+            let pg_index = gljOprObj.getIndex(pg,gljKeyArray);
+            if(mixRatioConnectData[pg_index]){
+                if(mixRatioSubdivisionMap[pg_index]){
+                    pg.subdivisionQuantity = scMathUtil.roundForObj(mixRatioSubdivisionMap[pg_index]+pg.subdivisionQuantity,getDecimal("glj.quantity"));
+                }
+                if(mixRatioTechMap[pg_index]){
+                    pg.techQuantity = scMathUtil.roundForObj(mixRatioTechMap[pg_index]+pg.techQuantity,getDecimal("glj.quantity"));
+                }
+            }
+        }
+    }
+
+}
+
+ProjectGLJ.prototype.getQuantityPerGLJ =function (pglj,mixRatioSubdivisionMap,mixRatioTechMap) {
+    let billIDs =   projectObj.project.Bills.getSubdivisionProjectLeavesID();//取分部分项上的所有叶子清单ID
+    let tech_billIDS =  projectObj.project.Bills.getTechLeavesID();//取所有技术措施项目叶子清单ID
+    let ration_glj_list = projectObj.project.ration_glj.datas;
+    let mixRatioMap = this.datas.mixRatioMap;
+    let rations = projectObj.project.Ration.datas;
+    let q_decimal = getDecimal("glj.quantity");
+    let result={};
+    let sum = 0;
+    let tech_sum = 0;
+    for(let rg of ration_glj_list){
+        if(rg.projectGLJID==pglj.id){
+            if(_.includes(billIDs,rg.billsItemID)){//计算分部分项
+               let total = calcQuantity(rg,mixRatioSubdivisionMap);
+               sum = scMathUtil.roundForObj(sum+total,q_decimal);
+            }
+            if(_.includes(tech_billIDS,rg.billsItemID)){//计算技术措施项目消耗量
+                let tech_total = calcQuantity(rg,mixRatioTechMap);
+                tech_sum = scMathUtil.roundForObj(tech_sum+tech_total,q_decimal);
+            }
+        }
+
+    }
+    for(let ra of rations){//计算定额类型工料机的消耗量
+        if(ra.type == rationType.gljRation&&ra.projectGLJID===pglj.id){
+            let r_quantity = scMathUtil.roundForObj(ra.quantity,q_decimal);
+            r_quantity = r_quantity?r_quantity:0;
+            if(_.includes(billIDs,ra.billsItemID)){//计算分部分项
+                sum = scMathUtil.roundForObj(sum+r_quantity,q_decimal);
+            }
+            if(_.includes(tech_billIDS,ra.billsItemID)){//计算技术措施项目消耗量
+                tech_sum = scMathUtil.roundForObj(tech_sum+r_quantity,q_decimal);
+            }
+        }
+
+    }
+    result.subdivisionQuantity = sum;
+    result.techQuantity = tech_sum;
+    return result;
+
+    function calcQuantity(rg,quantityMap) { //计算工料机在所属定额下的总消耗量
+        let tem_ration = _.find(rations,{"ID":rg.rationID});
+        let total = parseFloat(gljOprObj.getTotalQuantity(rg,tem_ration));
+        let r_index = gljOprObj.getIndex(rg,gljKeyArray);
+        if(mixRatioMap.hasOwnProperty(r_index)){
+            let mixRatioList = mixRatioMap[r_index];
+            for(let m of mixRatioList){
+                let m_index = gljOprObj.getIndex(m,gljKeyArray);
+                let m_quantity = scMathUtil.roundForObj(total*m.consumption,q_decimal);
+                if(quantityMap[m_index]){
+                    quantityMap[m_index] = scMathUtil.roundForObj(quantityMap[m_index]+m_quantity,q_decimal);
+                }else {
+                    quantityMap[m_index] = m_quantity;
+                }
+            }
+        }
+        return total;
+    }
+
+} 

+ 2 - 2
web/building_saas/main/js/models/ration.js

@@ -253,7 +253,7 @@ var Ration = {
             let updateData = [];
             for (let node of nodes) {
                 if (node.children.length > 0) {
-                    updateData = updateData.concat(this.getDeleteDataByBills[node.children]);
+                    updateData = updateData.concat(this.getDeleteDataByBill(node.children));
                 } else {
                     let rations = this.getBillsSortRation(node.getID());
                     for (let r of rations) {
@@ -266,7 +266,7 @@ var Ration = {
         ration.prototype.deleteByBills = function (nodes) {
             for (let node of nodes) {
                 if (node.children.length > 0) {
-                    this.deleteByBills([node.children]);
+                    this.deleteByBills(node.children);
                 } else {
                     let rations = this.getBillsSortRation(node.getID());
                     for (let r of rations) {

+ 8 - 7
web/building_saas/main/js/models/ration_glj.js

@@ -118,12 +118,13 @@ var ration_glj = {
             //add to mainTree;
             me.addToMainTree(neRecodes);
             let node = project.mainTree.selected;
-            project.calcProgram.calculate(node);
-            project.calcProgram.saveNode(node);
-            if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {
-                calcProgramObj.showData(node, false);
-            }
-            ;
+            project.projectGLJ.loadData(function () {
+                project.calcProgram.calculate(node);
+                project.calcProgram.saveNode(node);
+                if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {
+                    calcProgramObj.showData(node, false);
+                };
+            });
         };
         ration_glj.prototype.addToMainTree = function (datas) {
             datas = sortRationGLJ(datas);
@@ -367,8 +368,8 @@ var ration_glj = {
                 if (initShow == false) {//不需要初始化,只需耍新当前显示就可以了
                     gljOprObj.showRationGLJSheetData();
                 }
-                me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点
                 projectObj.project.projectGLJ.loadData(function () {//等项目工料机加载完成后再给用户编辑
+                    me.reCalcWhenGLJChange(recode);//触发计算定额以及父节点
                     if (initShow == true) {
                         gljOprObj.refreshView();
                     }

+ 15 - 12
web/building_saas/main/js/views/glj_view.js

@@ -1234,11 +1234,12 @@ var gljOprObj = {
                     gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData);
                     gljOprObj.showRationGLJSheetData();
                     project.ration_glj.addToMainTree(result.showData);
-                    project.projectGLJ.loadData();
-                    project.calcProgram.calculate(selected);
-                    project.calcProgram.saveNode(selected);
-                    projectObj.mainController.refreshTreeNode([selected]);
-                    $.bootstrapLoading.end();
+                    project.projectGLJ.loadData(function () {
+                        project.calcProgram.calculate(selected);
+                        project.calcProgram.saveNode(selected);
+                        projectObj.mainController.refreshTreeNode([selected]);
+                        $.bootstrapLoading.end();
+                    });
                 }
             });//doc.rationID=selected.data.ID;
         } else {
@@ -1274,11 +1275,12 @@ var gljOprObj = {
                     node ? nodes.push(node) : "";
                 }
                 //project.ration_glj.addToMainTree(data);
-                project.projectGLJ.loadData();
                 selected.data.adjustState = result.adjustState;
-                projectObj.mainController.refreshTreeNode(nodes);
-                project.calcProgram.calculate(selected);
-                project.calcProgram.saveNode(selected);
+                project.projectGLJ.loadData(function () {//加载完项目工料机再计算
+                    projectObj.mainController.refreshTreeNode(nodes);
+                    project.calcProgram.calculate(selected);
+                    project.calcProgram.saveNode(selected);
+                });
             }
             $.bootstrapLoading.end();
         })
@@ -1306,10 +1308,11 @@ var gljOprObj = {
                 }
             })
             me.showRationGLJSheetData();
-            project.projectGLJ.loadData();
             var rationNodes = me.refreshStateAfterMreplace(stateList, nodes);
-            project.calcProgram.calcRationsAndSave(rationNodes);
-            $.bootstrapLoading.end();
+            project.projectGLJ.loadData(function () {
+                project.calcProgram.calcRationsAndSave(rationNodes);
+                $.bootstrapLoading.end();
+            });
         })
     },
     updateProperty: function (obj, doc) {

+ 16 - 15
web/building_saas/main/js/views/main_tree_col.js

@@ -6,7 +6,7 @@ let MainTreeCol = {
     getText: {
         subType: function (node) {
             if (node.sourceType === projectObj.project.Bills.getSourceType()) {
-                return '';
+                return billText[node.data.type];
                 // CSL, 2017-11-29
             } else if (node.sourceType === projectObj.project.Ration.getSourceType()) {
                 if (node.data.type == 1 || node.data.type == undefined)    // 兼容旧定额
@@ -38,7 +38,7 @@ let MainTreeCol = {
     readOnly: {
         // CSL, 2017-11-28
         subType: function (node) {
-            return (node.data.type != 2 && node.data.type != 3 && !MainTreeCol.readOnly.glj(node)) || (node.data.type == rationType.gljRation && MainTreeCol.readOnly.non_editSubType(node));
+            return MainTreeCol.readOnly.bills(node)||(node.data.type != 2 && node.data.type != 3 && !MainTreeCol.readOnly.glj(node)) || (node.data.type == rationType.gljRation && MainTreeCol.readOnly.non_editSubType(node));
         },
         calcProgramName: function (node) {
             if (
@@ -137,7 +137,7 @@ let MainTreeCol = {
     cellType: {
         unit: function () {
             //let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
-            let dynamicCombo = sheetCommonObj.getDynamicCombo();
+            let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
             dynamicCombo.itemHeight(10).items(['m', 'm2', 'm3', 'km', 't', 'kg', '台班', '工日', '昼夜', '元', '项', '处', '个', '件',
                 '根', '组', '系统', '台', '套', '株', '丛', '缸', '支', '只', '块', '座', '对', '份', '樘', '攒', '榀']);
             return dynamicCombo;
@@ -170,19 +170,20 @@ let MainTreeCol = {
 
         // CSL, 2017-11-28
         subType: function (node) {
-            if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType()) {
-                let VPType = sheetCommonObj.getDynamicCombo();
-                if (node.data.type == rationType.volumePrice)
-                    VPType.itemHeight(5).items(["人工", "材料", "机械", "主材", "设备"])
-                else if (node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType())
-                    if (!MainTreeCol.readOnly.non_editSubType(node)) {
-                        VPType.itemHeight(3).items(["材料", "主材", "设备"]);
-                    } else {
-                        return null;
-                    }
-                return VPType;
+            if(node.sourceType!=projectObj.project.Bills.getSourceType()){
+                if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType()) {
+                    let VPType = sheetCommonObj.getDynamicCombo();
+                    if (node.data.type == rationType.volumePrice)
+                        VPType.itemHeight(5).items(["人工", "材料", "机械", "主材", "设备"])
+                    else if (node.data.type == rationType.gljRation || node.sourceType === projectObj.project.ration_glj.getSourceType())
+                        if (!MainTreeCol.readOnly.non_editSubType(node)) {
+                            VPType.itemHeight(3).items(["材料", "主材", "设备"]);
+                        } else {
+                            return null;
+                        }
+                    return VPType;
+                }
             }
-            ;
         },
     },
     getEvent: function (eventName) {

+ 74 - 7
web/building_saas/main/js/views/project_view.js

@@ -210,11 +210,11 @@ var projectObj = {
                 });
             }
         }
-        if (value.length === 9 && /^[\d]+$/.test(value)) {
+        if (value&&value.length === 9 && /^[\d]+$/.test(value)) {
             stdMatchCode = value;
             formatCode = project.Bills.newFormatCode(stdMatchCode);
             searchStdBillsAndUpdate(stdMatchCode, formatCode);
-        } else if (value.length === 12 && /^[\d]+$/.test(value)) {
+        } else if (value&&value.length === 12 && /^[\d]+$/.test(value)) {
             stdMatchCode = value.substr(0, 9);
             matchs = project.Bills.sameStdCode(stdMatchCode, node.data.code);
             if (matchs.indexOf(value) === -1) {
@@ -382,9 +382,11 @@ var projectObj = {
     loadProjectData: function () {
         var that = this;
         this.project = PROJECT.createNew(scUrlUtil.GetQueryString('project'), userID);
+        let startTime = +new Date();
+        console.log("开始加载-----"+startTime);
         this.project.loadDatas(function (err) {
-
             if (!err) {
+                that.project.projectGLJ.calcQuantity();//计算分部分项和技术措施项目消耗量;
                 that.project.property = projectInfoObj.projectInfo.property;
                 //that.project.calcProgram.compileAllTemps();
                 that.project.calcBase.init(that.project);
@@ -459,6 +461,8 @@ var projectObj = {
                 that.mainSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, that.amountAreaNumber);
                 that.loadMainSpreadContextMenu();
                 that.loadFocusLocation();
+                let endTime = +new Date();
+                console.log("加载完成-----"+endTime);
             }
             else {
 
@@ -477,16 +481,73 @@ var projectObj = {
             },
             items: {
                 "insertRootBill": {
-                    name: "插入大项",
+                    name: "插入大项费用",
                     icon: 'fa-sign-in',
                     disabled: function () {
                         //return project.mainTree.selected ? project.mainTree.selected.sourceType !== project.Bills.getSourceType() : false;
                     },
                     callback: function (key, opt) {
-                        //ProjectController.addBills(project, controller);
+                        ProjectController.addRootBill(project, controller);
+                    },
+                    visible: function(key, opt){
+                        return project.mainTree.selected&&project.mainTree.selected.parent==null;
+                    }
+                },
+                "insertFB": {
+                    name: "插入分部",
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        let selected = project.mainTree.selected;
+                        if(selected.sourceType==project.Bills.getSourceType()){
+                            if(selected.data.type==billType.FB){
+                                return false;
+                            }
+                            if(isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){//焦点行是分部分项工程
+                                if(selected.children.length>0){
+                                   return selected.children[0].data.type==billType.FX;//焦点行是分部分项工程,且子项是分项
+                                }
+                            }
+                        }
+                        return true;//除了清单,其它类型都只读
+                    },
+                    callback: function (key, opt) {
+                        ProjectController.addFB(project, controller);
                     },
                     visible: function(key, opt){
-                        return false;
+                        return project.Bills.isFBFX(project.mainTree.selected );//不属于分部分项的话隐藏
+                    }
+                },
+                "insertFX": {
+                    name: "插入分项",
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        let selected = project.mainTree.selected;
+                        if(selected.sourceType==project.Bills.getSourceType()){
+                            if(selected.data.type==billType.FX){//焦点行是分项,有效显示
+                                return false
+                            }
+                            if(selected.data.type==billType.FB){//点行是分部,
+                                if(selected.children.length>0){//且有子项,子项是分部,灰显。
+                                    return selected.children[0].data.type == billType.FB
+                                }else {
+                                    return false;
+                                }
+                            }
+                            if(isFlag(selected.data)&&selected.data.flagsIndex.fixed.flag==fixedFlag.SUB_ENGINERRING){//焦点行是分部分项工程
+                                if(selected.children.length>0){
+                                    return selected.children[0].data.type==billType.FB;//焦点行是分部分项工程,且子项是分部时灰显
+                                }else {
+                                    return false
+                                }
+                            }
+                        }
+                        return true;//除了清单,其它类型都只读
+                    },
+                    callback: function (key, opt) {
+                        ProjectController.addFX(project, controller);
+                    },
+                    visible: function(key, opt){
+                        return project.Bills.isFBFX(project.mainTree.selected );//不属于分部分项的话隐藏
                     }
                 },
                 "insertBills": {
@@ -496,8 +557,14 @@ var projectObj = {
                         return project.mainTree.selected ? project.mainTree.selected.sourceType !== project.Bills.getSourceType() : false;
                     },
                     callback: function (key, opt) {
+                        if(project.mainTree.selected.data.type == billType.DXFY){
+
+                        }
                         ProjectController.addBills(project, controller);
-                    }
+                    },
+                     visible: function(key, opt){
+                         return  project.Bills.isFBFX(project.mainTree.selected)==true?false:true;//不属于分部分项的话隐藏
+                     }
                 },
                 "insertRation": {
                     name: "插入定额",