Prechádzať zdrojové kódy

人材机库、定额库多单价

zhongzewei 6 rokov pred
rodič
commit
252328974d

+ 28 - 5
modules/ration_repository/controllers/repository_views_controller.js

@@ -3,6 +3,10 @@
  */
 import BaseController from "../../common/base/base_controller";
 let config = require("../../../config/config.js");
+import mongoose from 'mongoose';
+const compilationModel = mongoose.model('compilation');
+const rationLibModel = mongoose.model('std_ration_lib_map');
+const fs = require('fs');
 class ViewsController extends BaseController{
     redirectMain(req, res){
         res.render('maintain/ration_repository/main.html',
@@ -11,12 +15,20 @@ class ViewsController extends BaseController{
                 userID: req.session.managerData.userID
             });
     }
-    //rationRepository/lmm rationRepository/coeList rationRepository/installation
-    redirectRation(req, res){
+    async redirectRation(req, res){
         const repId = req.query.repository;
         const redirectGlj = `/rationRepository/lmm?repository=${repId}`;
         const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
         const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        let overWriteUrl = null;
+        let priceProperties = [];
+        let stdRationLib = await rationLibModel.findOne({ID: repId});
+        if(stdRationLib){
+            let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(stdRationLib.compilationId)});
+            priceProperties = compilation.priceProperties ? compilation.priceProperties : [];
+            let absoluteUrl = compilation.overWriteUrl ? req.app.locals.rootDir + compilation.overWriteUrl : req.app.locals.rootDir;
+            overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilation.overWriteUrl : null;
+        }
         res.render('maintain/ration_repository/dinge.html',
             {
                 userAccount: req.session.managerData.username,
@@ -24,14 +36,24 @@ class ViewsController extends BaseController{
                 redirectGlj: redirectGlj,
                 redirectCoe: redirectCoe,
                 redirectInstallation: redirectInstallation,
-                LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                priceProperties: JSON.stringify(priceProperties)
             });
     }
-    redirectGlj(req, res){
+    async redirectGlj(req, res){
         const repId = req.query.repository;
         const redirectRation = `/rationRepository/ration?repository=${repId}`;
         const redirectCoe = `/rationRepository/coeList?repository=${repId}`;
         const redirectInstallation = `/rationRepository/installation?repository=${repId}`;
+        let overWriteUrl = null;
+        let priceProperties = [];
+        let stdRationLib = await rationLibModel.findOne({ID: repId});
+        if(stdRationLib){
+            let compilation = await compilationModel.findOne({_id: mongoose.Types.ObjectId(stdRationLib.compilationId)});
+            priceProperties = compilation.priceProperties ? compilation.priceProperties : [];
+            let absoluteUrl = compilation.overWriteUrl ? req.app.locals.rootDir + compilation.overWriteUrl : req.app.locals.rootDir;
+            overWriteUrl = fs.existsSync(absoluteUrl) && fs.statSync(absoluteUrl).isFile()? compilation.overWriteUrl : null;
+        }
         res.render('maintain/ration_repository/gongliao.html',
             {
                 userAccount: req.session.managerData.username,
@@ -39,7 +61,8 @@ class ViewsController extends BaseController{
                 redirectRation: redirectRation,
                 redirectCoe: redirectCoe,
                 redirectInstallation: redirectInstallation,
-                LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
+                LicenseKey:config.getLicenseKey(process.env.NODE_ENV),
+                priceProperties: JSON.stringify(priceProperties)
             });
     }
     redirectCoeList(req, res){

+ 1 - 1
modules/std_glj_lib/controllers/gljController.js

@@ -133,7 +133,7 @@ class GljController extends BaseController{
                 let updateDatas = JSON.parse(LZString.decompressFromUTF16(compressData));
                 let bulkArr = [];
                 for(let uData of updateDatas){
-                    bulkArr.push({updateOne: {filter: {ID: uData.ID}, update: {$set: {component: uData.component, basePrice: uData.basePrice}}}});
+                    bulkArr.push({updateOne: {filter: {ID: uData.ID}, update: {$set: {component: uData.component}}}});
                 }
                 if(bulkArr.length > 0){
                     await gljModel.bulkWrite(bulkArr);

+ 13 - 1
public/web/sheet/sheet_common.js

@@ -427,5 +427,17 @@ var sheetCommonObj = {
         });
         workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.esc, false, false, false, false);
         workBook.commandManager().setShortcutKey('myEsc', GC.Spread.Commands.Key.esc, false, false, false, false);
-    }
+    },
+    //生成列字段与列号映射
+    initColMapping: function (obj, headers) {
+        //colToField 列下标与列字段映射
+        //fieldToCol 列字段与列下标映射
+        let colMapping = {colToField: {}, fieldToCol: {}};
+        for(let header of headers){
+            colMapping['colToField'][headers.indexOf(header)] = header.dataCode;
+            colMapping['fieldToCol'][header.dataCode] = headers.indexOf(header);
+        }
+        console.log(colMapping);
+        obj.colMapping = colMapping
+    },
 }

+ 4 - 0
web/maintain/ration_repository/dinge.html

@@ -18,6 +18,10 @@
         .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
         .modal-lg{max-width: 1000px}
     </style>
+    <script type="text/javascript">
+        let priceProperties = JSON.parse('<%- priceProperties %>');
+        console.log(priceProperties);
+    </script>
 </head>
 
 <body>

+ 4 - 0
web/maintain/ration_repository/gongliao.html

@@ -15,6 +15,10 @@
     <style type="text/css">
         .ztree li span.button.add{margin-right:2px;background-position:-144px 0;vertical-align:top;*vertical-align:middle}
     </style>
+    <script type="text/javascript">
+        let priceProperties = JSON.parse('<%- priceProperties %>');
+        console.log(priceProperties);
+    </script>
 </head>
 
 <body>

+ 6 - 0
web/maintain/ration_repository/js/ration_glj.js

@@ -651,6 +651,12 @@ var rationGLJOprObj = {
                     success:function(result){
                         sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
                         if (result) {
+                            if(priceProperties && priceProperties.length > 0){
+                                let priceField = priceProperties[0].price.dataCode;
+                                for(let glj of result.data){
+                                    glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
+                                }
+                            }
                             var cacheArr = [];
                             for (var i = 0; i < result.data.length; i++) {
                                 for (var j = 0; j < rationGljList.length; j++) {

+ 6 - 0
web/maintain/ration_repository/js/repository_glj.js

@@ -142,6 +142,12 @@ repositoryGljObj = {
             timeout:10000,
             success:function(result){
                 if(!result.error) {
+                    if(priceProperties && priceProperties.length > 0){
+                        let priceField = priceProperties[0].price.dataCode;
+                        for(let glj of result.data){
+                            glj.basePrice = glj.priceProperty && glj.priceProperty[priceField] ? glj.priceProperty[priceField] : 0;
+                        }
+                    }
                     me.gljList = result.data;
                     me.workBook.getSheet(0).setRowCount(result.data.length);
                     me.sortGlj();

+ 1 - 1
web/maintain/std_glj_lib/html/gongliao.html

@@ -119,8 +119,8 @@
                     <h5 class="text-danger" id="alertGljTxt">编号和类型不可为空!是否取消操作?</h5>
                 </div>
                 <div class="modal-footer">
-                    <button type="button" class="btn btn-secondary" id="aleCanceBtn" data-dismiss="modal">取消</button>
                     <a href="javascript: void(0);" id="aleConfBtn" class="btn btn-danger" data-dismiss="modal">确认</a>
+                    <button type="button" class="btn btn-secondary" id="aleCanceBtn" data-dismiss="modal">取消</button>
                 </div>
             </div>
         </div>

+ 83 - 27
web/maintain/std_glj_lib/js/components.js

@@ -21,9 +21,51 @@ let componentOprObj = {
             {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
         ]
     },
+    //生成列头(多单价)
+    initHeaders: function (priceProperties) {
+        let headers = [
+            {headerName:"选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center"},
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"规格型号",headerWidth:80,dataCode:"specs", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
+
+        ];
+        //生成单价列
+        if(!priceProperties || priceProperties.length === 0){
+            headers.push({headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"});
+        }
+        else {
+            for(let priceProp of priceProperties){
+                let colData = {
+                    headerName: priceProp.price.dataName,
+                    headerWidth: 100,
+                    dataCode: priceProp.price.dataCode,
+                    dataType: 'Number',
+                    formatter: '0.00',
+                    hAlign: 'right',
+                    vAlign: 'center'
+                };
+                headers.push(colData);
+            }
+        }
+        let tailHeaders = [
+        ];
+        headers = headers.concat(tailHeaders);
+        return headers;
+    },
     buildSheet: function (container) {
         let me = componentOprObj;
+        //生成人材机组成物表格列头
+        me.setting.header = me.initHeaders(priceProperties);
+        //生成人材机组成物列映射
+        sheetCommonObj.initColMapping(me, me.setting.header);
+        repositoryGljObj.initPriceCols.call(me, priceProperties, me.colMapping);
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
+        if(priceProperties && priceProperties.length > 0){
+            me.workBook.getSheet(0).frozenColumnCount(6);
+        }
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 1, "@", GC.Spread.Sheets.SheetArea.viewport);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
@@ -135,7 +177,7 @@ let componentOprObj = {
         if (me.workBook) {
             let cacheSection = data;
             sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
-            sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
+            sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, cacheSection, re.distTypeTree);
             me.workBook.getSheet(0).setRowCount(cacheSection.length);
             cacheSection = null;
         }
@@ -145,7 +187,6 @@ let componentOprObj = {
         $.bootstrapLoading.start();
         let me = componentOprObj, that = gljComponentOprObj, re = repositoryGljObj,
             updateArr = [],
-            updateBasePrc = [],
             IDMapping = {};
         let formData = new FormData();
         //当前工料机的工料机类型
@@ -167,24 +208,44 @@ let componentOprObj = {
                         }
                     }
                     if(!isExist){
-                        newComponent.push({ID: selectedComponent.ID, consumeAmt: 0});
+                        let newComponentObj = {ID: selectedComponent.ID};
+                        that.initConsumeAmt(newComponentObj);
+                        newComponent.push(newComponentObj);
                     }
                 }
                 newComponent = newComponent.concat(gljComponent);
             }
             else if(me.insertType === 'batchClear'){//去除消耗量为0的组成物
                 for(let gljPerComponent of gljComponent){
-                    if(gljPerComponent.consumeAmt && gljPerComponent.consumeAmt != 0){
-                        newComponent.push({ID: gljPerComponent.ID, consumeAmt: gljPerComponent.consumeAmt});
+                    if(hasConsumeAmt(gljPerComponent)){
+                        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                            newComponent.push({ID: gljPerComponent.ID, consumeAmt: gljPerComponent.consumeAmt});
+                        }
+                        else {
+                            newComponent.push({ID: gljPerComponent.ID, consumeAmtProperty: gljPerComponent.consumeAmtProperty});
+                        }
                     }
                 }
             }
-            let gljBasePrc = that.reCalGljBasePrc(re.getCurrentComponent(newComponent));
-            if(gljBasePrc != glj.basePrice){
-                updateBasePrc.push({gljId: glj.ID, gljType: currentGljType, basePrice: gljBasePrc});
+            function hasConsumeAmt(component){
+                if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                    if(component.consumeAmt && component.consumeAmt != 0){
+                        return true;
+                    }
+                }
+                else {
+                    if(component.consumeAmtProperty){
+                        for(let field in component.consumeAmtProperty){
+                            if(component.consumeAmtProperty[field] != 0){
+                                return true;
+                            }
+                        }
+                    }
+                }
+                return false;
             }
-            IDMapping[glj.ID] = {component : newComponent, basePrice: gljBasePrc};
-            updateArr.push({ID: glj.ID, component: newComponent, basePrice: gljBasePrc});
+            IDMapping[glj.ID] = {component : newComponent};
+            updateArr.push({ID: glj.ID, component: newComponent});
         }
         formData.append('compressData', LZString.compressToUTF16(JSON.stringify(updateArr)));
         $.ajax({
@@ -201,20 +262,14 @@ let componentOprObj = {
                         if(glj.ID === re.currentGlj.ID){
                             re.currentComponent =  re.getCurrentComponent(IDMapping[glj.ID]['component']);
                             sheetCommonObj.cleanData(that.workBook.getSheet(0), that.setting, -1);
-                            sheetsOprObj.showData(that.workBook.getSheet(0), that.setting, re.currentComponent);
+                            sheetsOprObj.showData(that, that.workBook.getSheet(0), that.setting, re.currentComponent);
                         }
                         glj.component = IDMapping[glj.ID]['component'];
-                        glj.basePrice = IDMapping[glj.ID]['basePrice'];
                     }
-                    re.reSetGljBasePrc(thisTypeGljList);
                     if($('#component').is(':visible')){
                         $('#component').modal('hide');
                     }
                     $.bootstrapLoading.end();
-                    //更新定额
-                    if(updateBasePrc.length > 0){
-                        re.updateRationBasePrcRq(updateBasePrc, that.workBook);
-                    }
                 } else {
                     if($('#component').is(':visible')){
                         $('#component').modal('hide');
@@ -243,27 +298,28 @@ let componentOprObj = {
                     let isExist = false;
                     for(let j = 0, jLen = re.currentGlj.component.length; j < jLen; j++){
                         if(me.selectedList[i].ID === re.currentGlj.component[j].ID){
-                            newComponent.push({ID: me.selectedList[i].ID, consumeAmt: re.currentGlj.component[j].consumeAmt});
+                            if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                                let consumeAmt = typeof re.currentGlj.component[j].consumeAmt !== 'undefined' ? re.currentGlj.component[j].consumeAmt : 0;
+                                newComponent.push({ID: me.selectedList[i].ID, consumeAmt: consumeAmt});
+                            }
+                            else{
+                                let consumeAmtProperty = typeof re.currentGlj.component[j].consumeAmtProperty !== 'undefined' ? re.currentGlj.component[j].consumeAmtProperty : {};
+                                newComponent.push({ID: me.selectedList[i].ID, consumeAmt: 0, consumeAmtProperty: consumeAmtProperty});
+                            }
                             isExist = true;
                             break;
                         }
                     }
                     if(!isExist){
-                        newComponent.push({ID: me.selectedList[i].ID, consumeAmt: 0});
+                        let obj = {ID: me.selectedList[i].ID};
+                        that.initConsumeAmt(obj);
+                        newComponent.push(obj);
                     }
                 }
                 re.currentGlj.component = newComponent;
-                let gljBasePrc = that.reCalGljBasePrc(re.getCurrentComponent(re.currentGlj.component));
-                if(gljBasePrc !== re.currentGlj.basePrice){
-                    re.currentGlj.basePrice = gljBasePrc;
-                    re.reshowGljBasePrc(re.currentGlj);
-                    updateBasePrc.push({gljId: re.currentGlj.ID, gljType: re.currentGlj.gljType, basePrice: gljBasePrc});
-                    re.updateRationBasePrcRq(updateBasePrc, that.workBook);
-                }
                 updateArr.push(re.currentGlj);
                 that.updateComponent(updateArr);
                 $('#component').modal('hide');
-                //$('#componentsCacnel').click();
             }
             else {
                 me.batchUpdateComponent();

+ 407 - 130
web/maintain/std_glj_lib/js/glj.js

@@ -13,6 +13,12 @@ let pageOprObj = {
     initPage : function(container, containerComponent, containerC) {
         let me = this, gljLibId = getQueryString("gljLibId");//获取定额库参数
         me.gljLibId = gljLibId;
+        //生成人材机表格列头
+        repositoryGljObj.setting.header = repositoryGljObj.initHeaders(priceProperties);
+        //生成列映射
+        sheetCommonObj.initColMapping(repositoryGljObj, repositoryGljObj.setting.header);
+        //生成单价列下标数组
+        repositoryGljObj.initPriceCols(priceProperties, repositoryGljObj.colMapping);
         repositoryGljObj.getGljLib(gljLibId, function () {
             repositoryGljObj.buildSheet(container);
             gljComponentOprObj.buildSheet(containerComponent);
@@ -32,6 +38,7 @@ let pageOprObj = {
     }
 };
 let repositoryGljObj = {
+    colMapping: null,
     treeObj : null,
     workBook: null,
     gljCurTypeId: -1,
@@ -68,25 +75,159 @@ let repositoryGljObj = {
             ]
         }
     },
-    existsGljType: function (gljType, v) {
-        for(let attr in gljType){
-            if(gljType[attr] == v){
+    //根据费用定额的单价属性获取人材机的单价属性
+    getPriceProperty: function (priceProperties) {
+        let priceProperty = {};
+        for(let priceProp of priceProperties){
+            priceProperty[priceProp.price.dataCode] = 0;
+        }
+        return priceProperty;
+    },
+    //根据单价字段获取消耗量字段
+    getConsumeAmtField: function (consumeAmtProperties, priceField) {
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            return 'consumeAmt';
+        }
+        for(let consumeAmtProp of consumeAmtProperties){
+            if(consumeAmtProp.consumeAmt.refPrice === priceField){
+                return consumeAmtProp.consumeAmt.dataCode;
+            }
+        }
+        return 'consumeAmt';
+    },
+    //初始单价相关的列(单价列、单价属性列)
+    initPriceCols: function (priceProperties, colMapping) {
+        let priceCols = [],
+            pricePropertyCols = [];
+        if(!priceProperties || priceProperties.length === 0){
+            priceCols.push(colMapping.fieldToCol['basePrice']);
+        }
+        for(let priceProp of priceProperties){
+            pricePropertyCols.push(colMapping.fieldToCol[priceProp.price.dataCode]);
+            priceCols.push(colMapping.fieldToCol[priceProp.price.dataCode]);
+        }
+        this.priceCols = priceCols;
+        this.pricePropertyCols = pricePropertyCols;
+    },
+    getPriceFields: function () {
+        let rst = [];
+        for(let priceCol of this.priceCols){
+            rst.push(this.colMapping.colToField[priceCol]);
+        }
+        return rst;
+    },
+    //获取更新定额价的人材机价格(人材机只有一个单价取basePrice, 人材机有多个单价,取第一个单价)
+    getRationGljPrice: function (glj) {
+        if(glj.priceProperty){
+            let keys = Object.keys(glj.priceProperty);
+            if(keys.length > 0){
+                return glj.priceProperty[keys[0]];
+            }
+        }
+        return glj.basePrice;
+    },
+    //生成列头(多单价)
+    initHeaders: function (priceProperties) {
+        let headers = [
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:160,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"规格型号",headerWidth:120,dataCode:"specs", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"单位",headerWidth:60,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"类型",headerWidth:90,dataCode:"gljType", dataType: "String", hAlign: "center", vAlign: "center"},
+        ];
+        //生成单价列
+        if(!priceProperties || priceProperties.length === 0){
+            headers.push({headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"});
+        }
+        else {
+            for(let priceProp of priceProperties){
+                let colData = {
+                    headerName: priceProp.price.dataName,
+                    headerWidth: 100,
+                    dataCode: priceProp.price.dataCode,
+                    dataType: 'Number',
+                    formatter: '0.00',
+                    hAlign: 'right',
+                    vAlign: 'center'
+                };
+                headers.push(colData);
+            }
+        }
+        let tailHeaders = [
+            {headerName:"调整系数",headerWidth:60,dataCode:"adjCoe", dataType: "Number", hAlign: "center", vAlign: "center"},
+            {headerName:"三材类别",headerWidth:90,dataCode:"materialType", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"三材系数",headerWidth:60,dataCode:"materialCoe", dataType: "Number", hAlign: "center", vAlign: "center"},
+            {headerName:"机型",headerWidth:60,dataCode:"model", dataType: "Number", hAlign: "center", vAlign: "center"}
+        ];
+        headers = headers.concat(tailHeaders);
+        return headers;
+    },
+    //工料机单价赋初始值(没有单价属性,则单价字段为basePrice,否则单价字段为单价属性对象中的属性)
+    initPrice: function (glj) {
+        if(!priceProperties || priceProperties.length === 0){
+            glj.basePrice = glj.basePrice && !isNaN(parseFloat(glj.basePrice)) ? scMathUtil.roundTo(parseFloat(glj.basePrice), -2) : 0;
+        }
+        else {
+            if(!glj.priceProperty){
+                glj.priceProperty = {};
+            }
+            for(let priceProp of priceProperties){
+                let gljPrice = glj['priceProperty'][priceProp.price.dataCode];
+                gljPrice = gljPrice && !isNaN(parseFloat(gljPrice)) ? scMathUtil.roundTo(parseFloat(gljPrice), -2) : 0;
+            }
+        }
+    },
+    //人材机单价是否变化
+    isGljPriceChange: function (glj, newPrice) {
+        //多单价,与人材机单价属性比较
+        if(typeof newPrice === 'object'){
+            return !_.isEqual(glj.priceProperty, newPrice);
+        }
+        return !_.isEqual(glj.basePrice, newPrice);
+    },
+    //粘贴数据含有单价
+    pasteIncludesPrice: function (pasteObj) {
+        let me = repositoryGljObj;
+        for(let priceCol of me.priceCols){
+            let priceField = me.colMapping.colToField[priceCol];
+            if(typeof pasteObj[priceField] !== 'undefined'){
                 return true;
             }
         }
         return false;
     },
+    //获取人材机价格
+    getPrice: function (glj, col) {
+        let me = repositoryGljObj;
+        if(!priceProperties || priceProperties.length === 0){
+            return glj.basePrice;
+        }
+        return glj.priceProperty[me.colMapping.colToField[col]];
+    },
+    //工料机价格是否相同
+    priceIsEqual: function (gljA, gljB) {
+        if(!priceProperties || priceProperties.length === 0){
+            return gljA.basePrice === gljB.basePrice;
+        }
+        return _.isEqual(gljA.priceProperty, gljB.priceProperty);
+    },
+    setGljPrice: function (glj, newPrice, col) {
+        if(!priceProperties || priceProperties.length === 0){
+            glj.basePrice = newPrice;
+        }
+        else {
+            glj.priceProperty[this.colMapping.colToField[col]] = newPrice;
+        }
+    },
     setUnitCombo: function (sheet, headers) {
         let me = this;
         sheet.suspendPaint();
         sheet.suspendEvent();
         let combo = sheetCommonObj.getDynamicCombo();
         combo.items(rationAndGljUnits).itemHeight(10).editable(true);
-        for(let i = 0; i < headers.length; i++){
-            if(headers[i].dataCode === 'unit'){
-                sheet.getRange(-1, i, -1, 1).cellType(combo);
-                break;
-            }
+        let unitCol = me.colMapping.fieldToCol['unit'];
+        if(unitCol){
+            sheet.getRange(-1, unitCol, -1, 1).cellType(combo);
         }
         sheet.resumePaint();
         sheet.resumeEvent();
@@ -105,25 +246,23 @@ let repositoryGljObj = {
                 data: typeData,
                 children: [],
                 parent: null
-            }
-            if(allowGljType.includes(typeData.ID)){
+            };
                 distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
                 distTypeTree.distTypesArr.push(typeObj);
-            }
         });
         gljDistType.forEach(function (typeData) {
-            if(allowGljType.includes(typeData.ID)){
                 distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
                 let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
                 if(parent){
                     distType.parent = parent;
                     parent.children.push(distType);
                 }
-            }
         });
         distTypeTree.distTypesArr.forEach(function (distTypeObj) {
-            if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
+            if(allowGljType.includes(distTypeObj.data.ID)){
+            //if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
                 distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
+         //   }
             }
         });
         return distTypeTree;
@@ -221,10 +360,13 @@ let repositoryGljObj = {
         if (me.workBook) {
             let cacheSection = data;
             sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
-            sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection, me.distTypeTree, me.materialTypeIdx, me.machineModelIdx);
-            sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 5, me.workBook.getActiveSheet().getRowCount(), me.distTypeTree.comboDatas, 10, 'text');
-            sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 7, me.workBook.getActiveSheet().getRowCount(), me.materialType.comboItems, false, 'text');
-            sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 9, me.workBook.getActiveSheet().getRowCount(), me.machineModel.comboItems, false, 'text');
+            sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, cacheSection, me.distTypeTree, me.materialTypeIdx, me.machineModelIdx);
+            let gljTypeCol = me.colMapping.fieldToCol['gljType'],
+                materialTypeCol = me.colMapping.fieldToCol['materialType'],
+                modelCol = me.colMapping.fieldToCol['model'];
+            sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, gljTypeCol, me.workBook.getActiveSheet().getRowCount(), me.distTypeTree.comboDatas, 10, 'text');
+            sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, materialTypeCol, me.workBook.getActiveSheet().getRowCount(), me.materialType.comboItems, false, 'text');
+            sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, modelCol, me.workBook.getActiveSheet().getRowCount(), me.machineModel.comboItems, false, 'text');
             cacheSection = null;
             let selRow =  me.workBook.getActiveSheet().getSelections()[0].row;
             me.initSel(selRow);
@@ -239,7 +381,8 @@ let repositoryGljObj = {
             if(sheet.isEditing()){
                 sheet.endEdit();
             }
-            let code = sheet.getValue(orgRow, 0);
+            let codeCol = me.colMapping.fieldToCol['code'];
+            let code = sheet.getValue(orgRow, codeCol);
             let newRow, newCol;
             if(!me.currentCache[orgRow] && code !== undefined && code !== null && orgCol !== me.setting.header.length - 1){
                 newRow = orgRow;
@@ -270,6 +413,9 @@ let repositoryGljObj = {
         me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
+        if(priceProperties && priceProperties.length > 0){
+            me.workBook.getSheet(0).frozenColumnCount(5);
+        }
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
@@ -305,10 +451,12 @@ let repositoryGljObj = {
                 if(gljComponent[i].ID == me.gljList[j].ID){
                     obj.ID = me.gljList[j].ID;
                     obj.code = me.gljList[j].code;
-                    obj.name = me.gljList[j].name + specs
+                    obj.name = me.gljList[j].name + specs;
                     obj.unit = me.gljList[j].unit;
                     obj.basePrice = me.gljList[j].basePrice;
+                    obj.priceProperty = me.gljList[j].priceProperty ? me.gljList[j].priceProperty : {};
                     obj.consumeAmt = gljComponent[i].consumeAmt;
+                    obj.consumeAmtProperty = gljComponent[i].consumeAmtProperty ? gljComponent[i].consumeAmtProperty : {};
                     rst.push(obj);
                 }
             }
@@ -330,6 +478,7 @@ let repositoryGljObj = {
             for(let i = 0; i < me.gljList.length; i++){
                 if(me.gljList[i].ID === rObj.ID){
                     me.gljList[i].basePrice = rObj.basePrice;
+                    me.gljList[i].priceProperty = rObj.priceProperty ? rObj.priceProperty : {};
                     break;
                 }
             }
@@ -349,11 +498,17 @@ let repositoryGljObj = {
                 }
             }
             if(isChange){//引用了此组成物
-                let gljBasePrc = that.reCalGljBasePrc(me.getCurrentComponent(thisComponent));
+              /*  let gljBasePrc = that.reCalGljBasePrc(me.getCurrentComponent(thisComponent));
                 if(me.gljList[i].basePrice !== gljBasePrc){
                     me.gljList[i].basePrice = gljBasePrc;
                     rst.updateBasePrcArr.push({gljId: me.gljList[i].ID, gljType: me.gljList[i].gljType, basePrice: me.gljList[i].basePrice});
                 }
+                rst.updateArr.push(me.gljList[i]);*/
+             /*   let gljBasePrc = that.reCalGljBasePrc(me.getCurrentComponent(thisComponent));
+                if(me.isGljPriceChange(me.gljList[i], gljBasePrc)){
+                    me.setGljPrice(me.gljList[i], gljBasePrc);
+                    rst.updateBasePrcArr.push({gljId: me.gljList[i].ID, gljType: me.gljList[i].gljType, basePrice: me.getRationGljPrice(me.gljList[i])});
+                }*/
                 rst.updateArr.push(me.gljList[i]);
             }
         }
@@ -362,24 +517,49 @@ let repositoryGljObj = {
     reshowGljBasePrc: function (glj) {
         let me = repositoryGljObj;
         let cacheSection = me.currentCache;
+        let sheet = me.workBook.getActiveSheet();
+        let row = _.findIndex(cacheSection, {ID: glj.ID});
+        sheet.suspendEvent();
+        sheet.suspendPaint();
+        for(let priceCol of me.priceCols){
+            sheet.setValue(row, priceCol, glj[me.colMapping.colToField[priceCol]]);
+        }
+        sheet.resumeEvent();
+        sheet.resumePaint();
+    },
+/*    reshowGljBasePrc: function (glj) {
+        let me = repositoryGljObj;
+        let cacheSection = me.currentCache;
+        let basePriceCol = me.colMapping.fieldToCol['basePrice'];
+        let sheet = me.workBook.getActiveSheet();
         for(let i = 0; i < cacheSection.length; i++){
             if(glj.ID === cacheSection[i].ID){
                 cacheSection[i].basePrice = glj.basePrice;
-                me.workBook.getSheet(0).setValue(i, 4, glj.basePrice);
+                sheet.suspendEvent();
+                sheet.suspendPaint();
+                for(let priceCol of me.priceCols){
+                    sheet.setValue(i, priceCol, glj.basePrice);
+                }
+                sheet.resumeEvent();
+                sheet.resumePaint();
                 break;
             }
         }
-    },
+    },*/
     reSetGljBasePrc: function (gljs) {
         let me = repositoryGljObj;
         let cacheSection = me.currentCache;
         let sheet = me.workBook.getSheet(0);
+        let basePriceCol = me.colMapping.fieldToCol['basePrice'];
         sheet.suspendPaint();
         sheet.suspendEvent();
         for(let i = 0; i < cacheSection.length; i++){
             for(let glj of gljs){
                 if(glj.ID === cacheSection[i].ID){
-                    sheet.setValue(i, 4, glj.basePrice);
+                    for(let priceCol of me.priceCols){
+                        sheet.setValue(i, priceCol, glj[me.colMapping.colToField[priceCol]]);
+                    }
+                    //sheet.setValue(i, basePriceCol, glj.basePrice);
                 }
             }
         }
@@ -401,7 +581,8 @@ let repositoryGljObj = {
                 if(me.currentGlj.component.length > 0){
                     me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
                     if(me.currentComponent.length > 0){
-                        sheetsOprObj.showData(that.workBook.getSheet(0), that.setting, me.currentComponent);
+                        console.log(me.currentComponent);
+                        sheetsOprObj.showData(that, that.workBook.getSheet(0), that.setting, me.currentComponent);
                     }
                 }
             }
@@ -452,17 +633,17 @@ let repositoryGljObj = {
             if(me.editingRowIdx !== me.cellRowIdx) {
                 let focusToCol;
                 function getFocusToCol (me){
-                    if(!me.addGljObj[me.setting.header[0].dataCode]){
+                    if(!me.addGljObj.code){
                         $('#alertGljTxt').text('编号不能为空,继续增加人材机?');
-                        return 0;
+                        return me.colMapping.fieldToCol['code'];
                     }
-                    else if(!me.addGljObj[me.setting.header[1].dataCode]){
+                    else if(!me.addGljObj.name){
                         $('#alertGljTxt').text('名称不能为空,继续增加人材机?');
-                        return 1;
+                        return me.colMapping.fieldToCol['name'];
                     }
-                    else if(!me.addGljObj[me.setting.header[5].dataCode]){
+                    else if(!me.addGljObj.gljType){
                         $('#alertGljTxt').text('类型不能为空,继续增加人材机?');
-                        return 5;
+                        return me.colMapping.fieldToCol['gljType'];
                     }
                     else {
                         return -1;
@@ -482,6 +663,8 @@ let repositoryGljObj = {
                     });
                     $('#aleCanceBtn').click(function () {
                         me.addGljObj = null;
+                        args.sheet.suspendEvent();
+                        args.sheet.suspendPaint();
                         for(let col=0; col<me.setting.header.length; col++){
                             if(col === 0){
                                 me.workBook.getSheet(0).getCell(me.editingRowIdx, 0).formatter("@");
@@ -490,6 +673,8 @@ let repositoryGljObj = {
                         }
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
                         me.workBook.focus(true);
+                        args.sheet.resumeEvent();
+                        args.sheet.resumePaint();
                     });
                 }
             }
@@ -497,18 +682,17 @@ let repositoryGljObj = {
     },
     onCellEditStart: function(sender, args) {
         let me = repositoryGljObj;
-        let rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row);
+        me.orgCode = me.workBook.getSheet(0).getValue(args.row, me.colMapping.fieldToCol['code']);
+        let rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me);
         if(me.prevent){
             args.cancel = true;
             return;
         }
         me.currentEditingGlj = rObj;
-        me.orgCode = me.workBook.getSheet(0).getValue(args.row, 0);
         if(args.row < me.currentCache.length){
             let dataCode = me.setting.header[args.col].dataCode;
             me.currentGlj = me.currentCache[args.row];
-            if(dataCode === 'code' || (dataCode === 'basePrice' && allowComponent.includes(me.currentGlj.gljType)
-                && me.currentGlj.component.length > 0)
+            if(dataCode === 'code'
                 || (dataCode === 'adjCoe' && me.currentGlj.gljType !== 1 && me.currentGlj.gljType !== 303)
                 || (dataCode === 'materialCoe' && !me.currentGlj.materialType)
                 || (dataCode === 'model' && me.currentGlj.gljType !== 301)){
@@ -517,27 +701,38 @@ let repositoryGljObj = {
             else {
                 rObj.ID = me.currentGlj.ID;
                 rObj.gljClass = me.currentGlj.gljClass;
-
             }
         }
         else {
             me.currentGlj = null;
         }
     },
+    dataChanged: function (objA, objB, col) {
+        let me = repositoryGljObj;
+        if(me.priceCols.includes(col)){
+            if(!priceProperties || priceProperties.length === 0){
+                return objA.basePrice !== objB.basePrice;
+            }
+            else {
+                return objA.priceProperty[me.colMapping.colToField[col]] !== objB.priceProperty[me.colMapping.colToField[col]]
+            }
+        }
+        return objA[me.colMapping.colToField[col]] !== objB[[me.colMapping.colToField[col]]];
+    },
     onCellEditEnd: function(sender, args) {
-        console.log(args);
         let me = repositoryGljObj, that = gljComponentOprObj,
             rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
             updateArr = [], addArr = [], updateBasePrcArr = [];
         me.editingRowIdx = args.row;
-        rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
+        //rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
+        me.initPrice(rObj);
         //更新
         if (me.currentEditingGlj["ID"] && me.currentGlj) {
             rObj["ID"] = me.currentEditingGlj["ID"];
             rObj.gljClass = me.currentEditingGlj.gljClass;
-            if(me.currentEditingGlj[me.setting.header[args.col].dataCode] !== rObj[me.setting.header[args.col].dataCode]){
-                if(rObj[me.setting.header[0].dataCode] && rObj[me.setting.header[1].dataCode] && rObj[me.setting.header[5].dataCode] &&
-                    rObj[me.setting.header[0].dataCode].toString().trim().length !== 0 && rObj[me.setting.header[1].dataCode].toString().trim().length !== 0 && rObj[me.setting.header[5].dataCode].toString().trim().length !== 0){
+            if(me.dataChanged(me.currentEditingGlj, rObj, args.col)){
+                if(rObj.code && rObj.name && rObj.gljType &&
+                    rObj.code.toString().trim().length !== 0 && rObj.name.toString().trim().length !== 0 && rObj.gljType.toString().trim().length !== 0){
                    /* if(rObj.gljType !== me.currentEditingGlj.gljType){//修改了工料机类型
                         if(me.currentGlj){
                             me.currentGlj.component = [];
@@ -608,11 +803,12 @@ let repositoryGljObj = {
                             rObj.component = me.currentGlj.component;
                             updateArr.push(rObj);
                             me.mixUpdateRequest(updateArr, [], []);
-                            let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
+                            //let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: rObj.basePrice};
+                       /*     let gljTypeObj = {gljId: me.currentEditingGlj.ID, gljType: rObj.gljType, basePrice: me.getRationGljPrice(rObj)};
                             updateBasePrcArr.push(gljTypeObj);
                             if(me.rationLibs.length > 0){
                                 me.updateRationBasePrcRq(updateBasePrcArr);
-                            }
+                            }*/
                         });
                         $('.typeClose').unbind('click');
                         $('.typeClose').bind('click', function () {
@@ -636,7 +832,7 @@ let repositoryGljObj = {
                         }
                         rObj.materialCoe = scMathUtil.roundTo(parseFloat(rObj.materialCoe), -5);
                     }
-                    else if(rObj.basePrice !== me.currentEditingGlj.basePrice){//修改了单价,可修改单价的必为可成为组成物的
+                    /*else if(rObj.basePrice !== me.currentEditingGlj.basePrice){//修改了单价,可修改单价的必为可成为组成物的
                         //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
                         if(isNaN(parseFloat(rObj.basePrice))){
                             alert('单价只能输入数值!');
@@ -653,6 +849,26 @@ let repositoryGljObj = {
                                 updateArr.push(updateGljs.updateBasePrcArr[i]);
                             }
                         }
+                    }*/
+                    else if(!me.priceIsEqual(rObj, me.currentEditingGlj)){//修改了单价,可修改单价的必为可成为组成物的
+                        let rObjPrice = me.getPrice(rObj, args.col),
+                            editingGljPrice = me.getPrice(me.currentEditingGlj, args.col);
+                        //寻找所有引用了此组成物的工料机,并从组成物中删去此工料机,并重算单价
+                        if(isNaN(parseFloat(rObjPrice))){
+                            alert('单价只能输入数值!');
+                            args.sheet.setValue(args.row, args.col, editingGljPrice ? editingGljPrice : 0);
+                            return;
+                        }
+                        me.setGljPrice(rObj, scMathUtil.roundTo(parseFloat(rObjPrice), -2), args.col);
+                        let updateGljs = me.getUpdateGljs(rObj);
+                        if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
+                            for(let i = 0; i < updateGljs.updateArr.length; i++){
+                                updateArr.push(updateGljs.updateArr[i]);
+                            }
+                            for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
+                                updateArr.push(updateGljs.updateBasePrcArr[i]);
+                            }
+                        }
                     }
                     rObj.component = me.currentGlj.component;
                     updateArr.push(rObj);
@@ -667,7 +883,7 @@ let repositoryGljObj = {
                     }
                 }
             }
-            if(me.currentEditingGlj.basePrice !== rObj.basePrice){
+            /*if(me.currentEditingGlj.basePrice !== rObj.basePrice){
                 //update basePrice of ration when editting basePrice of glj
                 let gljType = -1;
                 let gljTypeParent = me.distTypeTree.distTypes[me.distTypeTree.prefix + me.currentEditingGlj.gljType].parent;
@@ -684,6 +900,25 @@ let repositoryGljObj = {
                         me.updateRationBasePrcRq(updateBasePrcArr);
                     }
                 }
+            }*/
+            if(!me.priceIsEqual(rObj, me.currentEditingGlj)){
+                console.log('df');
+                //update basePrice of ration when editting basePrice of glj
+                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;
+                }
+                if(!gljTypeParent && me.currentEditingGlj.gljType <= 3){
+                    gljType = me.currentEditingGlj.gljType;
+                }
+                let gljBasePrcObj = {gljId: me.currentEditingGlj.ID, gljType: gljType, basePrice: me.getRationGljPrice(rObj)};
+                if(gljBasePrcObj.gljType !== -1){
+                    updateBasePrcArr.push(gljBasePrcObj);
+                    if(me.rationLibs.length > 0){//重算定额单价
+                        me.updateRationBasePrcRq(updateBasePrcArr);
+                    }
+                }
             }
             //update basePrice of ration when editting gljType of glj
          /*   if(me.currentEditingGlj.gljType !== rObj.gljType){
@@ -700,17 +935,14 @@ let repositoryGljObj = {
             if(typeof rObj.code !== 'undefined'){
                 me.addGljObj = rObj;
                 let isCanSav = true;
-                if(!rObj[me.setting.header[0].dataCode] || !rObj[me.setting.header[1].dataCode] || !rObj[me.setting.header[5].dataCode]){
+                if(!rObj.code || !rObj.name || !rObj.gljType){
                     isCanSav = false;
                 }
                 if(isCanSav){
                     me.addGljObj = null;
                     rObj.component = [];
-                    //如果类型为混凝土、砂浆、配合比、机械台班时,添加时填写的单价清空
-                    /*if(me.allowComponent.indexOf(rObj.gljType) !== -1){
-                     rObj.basePrice = 0;
-                     }*/
-                    rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? scMathUtil.roundTo(parseFloat(rObj.basePrice), -2) : 0;
+                    //rObj.basePrice = !isNaN(parseFloat(rObj.basePrice)) && (rObj.basePrice && typeof rObj.basePrice !== 'undefined') ? scMathUtil.roundTo(parseFloat(rObj.basePrice), -2) : 0;
+                    me.initPrice(rObj);
                     addArr.push(rObj);
                 }
             }
@@ -729,29 +961,21 @@ let repositoryGljObj = {
         me.workBook.commandManager().register('repositoryGljDel', function () {
             let sheet = me.workBook.getSheet(0),
                 updateArr = [], removeArr = [],
+                removeIDs = [],
                 removeNames = [],
                 updateBasePrcArr = [],//删除基价单位后重新计算
                 sels = sheet.getSelections(),
                 canUpdate = false,
-                cacheSection = me.currentCache;
+                cacheSection = me.currentCache,
+                updateBackups = [];
             if(sels.length > 0 && cacheSection.length > 0){
                 for(let i = 0; i < sels.length; i++){
                     if(sels[i].colCount === me.setting.header.length){
                         for(let j = 0; j < sels[i].rowCount; j++){
                             if(sels[i].row + j < cacheSection.length){
-                                //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
-                                let updateGljs = me.getUpdateGljs(cacheSection[sels[i].row + j], true);
-                                if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
-                                    for(let i = 0; i < updateGljs.updateArr.length; i++){
-                                        updateArr.push(updateGljs.updateArr[i]);
-                                    }
-                                    for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
-                                        updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
-                                    }
-                                }
-                                removeArr.push(cacheSection[sels[i].row + j].ID);
+                                removeArr.push(cacheSection[sels[i].row + j]);
+                                removeIDs.push(cacheSection[sels[i].row + j].ID);
                                 removeNames.push(cacheSection[sels[i].row + j].name);
-                                //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
                                 //删除后重新计算引用了此工料机的定额单价
                                 updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
                             }
@@ -771,62 +995,58 @@ let repositoryGljObj = {
                                         return false;
                                     }
                                     else {
-                                        if(dataCode === 'basePrice'){
-                                            //如果类型不为混凝土、砂浆、配合比、机械、主材且无组成物,才可删除单价 basePrice = 0
-                                            if(!allowComponent.includes(updateObj.gljType) ||
-                                                (allowComponent.includes(updateObj.gljType) && updateObj.component.length === 0)){
-                                                canUpdate = true;
-                                                updateObj[dataCode] = 0;
-                                                updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
-                                            }
-                                        }
-                                        else{
-                                            if(dataCode === 'materialType'){
-                                                updateObj['materialCoe'] = null;
-                                            }
-                                            canUpdate = true;
-                                            updateObj[dataCode] = '';
-                                        }
+                                        canUpdate = true;
+                                        break;
                                     }
                                 }
-                                if(canUpdate){
-                                    updateArr.push(updateObj);
-                                }
                             }
                         }
                     }
                 }
-             /*   if(removeArr.length > 0 || updateArr.length > 0){
-                    //删除警告
-                    let upAlertText = removeArr.length > 0 ? '可能已有定额引用了当前人材机,导致定额查找不到此人材机。确定要删除吗?' : '确认删除选中字段?';
-                    $('#alertGljTxt').text(upAlertText);
-                    $('#gljAlert').modal('show');
-                    //确认
-                    $('#aleConfBtn').bind('click', function () {
-                        me.mixUpdateRequest(updateArr, [], removeArr);
-                        if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
-                            me.updateRationBasePrcRq(updateBasePrcArr);
-                        }
-                        $('#aleConfBtn').unbind('click');
-                    });
-                }*/
-                if(updateArr.length > 0){
+                if(canUpdate){
                     //删除警告
                     let upAlertText = '确认删除选中字段?';
                     $('#alertGljTxt').text(upAlertText);
                     $('#gljAlert').modal('show');
+                    $('#aleConfBtn').unbind('click');
                     //确认
                     $('#aleConfBtn').bind('click', function () {
+                        for(let i = 0; i < sels.length; i++) {
+                            let maxCol = sels[i].col + sels[i].colCount - 1;
+                            for (let j = 0; j < sels[i].rowCount; j++) {
+                                if (sels[i].row + j < cacheSection.length) {
+                                    let updateObj = cacheSection[sels[i].row + j];
+                                    for (let col = sels[i].col; col <= maxCol; col++) {
+                                        let dataCode = me.setting.header[col].dataCode;
+                                        if (me.priceCols.includes(col)) {
+                                            me.setGljPrice(updateObj, 0, col);
+                                            updateBasePrcArr.push({
+                                                gljId: updateObj.ID,
+                                                gljType: updateObj.gljType,
+                                                basePrice: 0
+                                            });
+                                        }
+                                        else {
+                                            if (dataCode === 'materialType') {
+                                                updateObj['materialCoe'] = null;
+                                            }
+                                            updateObj[dataCode] = '';
+                                        }
+                                    }
+                                    updateArr.push(updateObj);
+                                }
+                            }
+                        }
                         me.mixUpdateRequest(updateArr, [], []);
                         if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
                             me.updateRationBasePrcRq(updateBasePrcArr);
                         }
-                        $('#aleConfBtn').unbind('click');
                     });
+
                 }
                 if(removeArr.length > 0){
                     $.bootstrapLoading.start();
-                    CommonAjax.post('/stdGljRepository/api/isUsed', {gljIds: removeArr}, function (rstData) {
+                    CommonAjax.post('/stdGljRepository/api/isUsed', {gljIds: removeIDs}, function (rstData) {
                         $.bootstrapLoading.end();
                         //存在被引用的人材机(标准/补充定额库)
                         if(rstData.isUsed){
@@ -840,11 +1060,21 @@ let repositoryGljObj = {
                         }
                         else {
                             $('#gljAlert').find('.modal-body h5').text(`确定要删除人材机 “${removeNames.join(',')}” 吗? `);
-                            $('#gljAlert').modal('show');
+                            setTimeout(function () {
+                                $('#gljAlert').modal('show');
+                            }, 200);
                             //确认
                             $('#aleConfBtn').unbind('click');
                             $('#aleConfBtn').bind('click', function () {
-                                me.mixUpdateRequest([], [], removeArr);
+                                for(let removeD of removeArr){
+                                    let updateGljs = me.getUpdateGljs(removeD, true);
+                                    if(updateGljs.updateArr.length > 0){
+                                        for(let i = 0; i < updateGljs.updateArr.length; i++){
+                                            updateArr.push(updateGljs.updateArr[i]);
+                                        }
+                                    }
+                                }
+                                me.mixUpdateRequest(updateArr, [], removeIDs);
                                 if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
                                     me.updateRationBasePrcRq(updateBasePrcArr);
                                     me.workBook.focus(true);
@@ -912,7 +1142,6 @@ let repositoryGljObj = {
                 if(pasteObj.gljType === me.distTypeTree.comboDatas[i].text){
                     pasteObj.gljType = me.distTypeTree.comboDatas[i].value;
                     isExsit = true;
-                    reCalBasePrc = true;
                     //调整系数
                     if(pasteObj.gljType !== 1 && pasteObj.gljType !== 303){
                         tempObj.adjCoe = null;
@@ -959,7 +1188,44 @@ let repositoryGljObj = {
                 isValid = false;
             }
         }
-        if(typeof pasteObj.basePrice !== 'undefined'){
+        //单价相关
+        if(me.pasteIncludesPrice(pasteObj)){
+            if(!priceProperties || priceProperties.length === 0){
+                pasteObj.basePrice = pasteObj.basePrice && !isNaN(parseFloat(pasteObj.basePrice)) ?
+                    scMathUtil.roundTo(parseFloat(pasteObj.basePrice), -2) : me.currentCache[rowIdx].basePrice;
+                if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
+                    reCalBasePrc = true;
+                    tempObj.basePrice = pasteObj.basePrice;
+                }
+            }
+            else {
+                //多单价粘贴
+                let pastePriceProperty = {};
+                let priceFields = me.getPriceFields();
+                for(let priceField of priceFields){
+                    if(typeof pasteObj[priceField] !== 'undefined' && pasteObj[priceField] && !isNaN(parseFloat(pasteObj[priceField]))){
+                        pastePriceProperty[priceField] = scMathUtil.roundTo(parseFloat(pasteObj[priceField]), -2);
+                    }
+                }
+                if(!me.priceIsEqual(tempObj, pasteObj)){
+                    reCalBasePrc = true;
+                    //更新人材机单价
+                    for(let priceField in pastePriceProperty){
+                        tempObj.priceProperty[priceField] = pastePriceProperty[priceField];
+                    }
+                }
+            }
+            let updateGljs = me.getUpdateGljs(tempObj, false);
+            if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
+                for(let i = 0; i < updateGljs.updateArr.length; i++){
+                    rst.updateGlj.push(updateGljs.updateArr[i]);
+                }
+                for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
+                    rst.updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
+                }
+            }
+        }
+        /*if(typeof pasteObj.basePrice !== 'undefined'){
             pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? scMathUtil.roundTo(parseFloat(pasteObj.basePrice), -2) :
                 me.currentCache[rowIdx].basePrice;
             if(pasteObj.basePrice !== me.currentCache[rowIdx].basePrice){
@@ -975,7 +1241,7 @@ let repositoryGljObj = {
                     }
                 }
             }
-        }
+        }*/
         if(typeof pasteObj.materialType !== 'undefined'){
             if(!me.materialType.textArr.includes(pasteObj.materialType)){
                 isValid = false;
@@ -1027,8 +1293,8 @@ let repositoryGljObj = {
             rst.updateGlj.push(tempObj);
             if(reCalBasePrc){
                 //重新计算定额基价对象
-                //rst.updateBasePrc = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
-                let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
+                //let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: tempObj.basePrice};
+                let newReObj = {gljId: tempObj.ID, gljType: tempObj.gljType, basePrice: me.getRationGljPrice(tempObj)};
                 rst.updateBasePrcArr.push(newReObj);
             }
         }
@@ -1099,7 +1365,24 @@ let repositoryGljObj = {
                 }
             });
         }
-        pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
+        if(!priceProperties || priceProperties.length === 0){
+            pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
+
+        }
+        else {
+            let pastePriceProperty = {};
+            let priceFields = me.getPriceFields();
+            for(let priceField of priceFields){
+                if(typeof pasteObj[priceField] !== 'undefined' && pasteObj[priceField] && !isNaN(parseFloat(pasteObj[priceField]))){
+                    pastePriceProperty[priceField] = scMathUtil.roundTo(parseFloat(pasteObj[priceField]), -2);
+                }
+                else {
+                    pastePriceProperty[priceField] = 0;
+                }
+            }
+            pasteObj.priceProperty = pastePriceProperty;
+        }
+        //pasteObj.basePrice = !isNaN(parseFloat(pasteObj.basePrice)) && (pasteObj.basePrice && typeof pasteObj.basePrice !== 'undefined') ? parseFloat(pasteObj.basePrice) : 0;
         if(!me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]){
             pasteObj.gljClass = me.gljCurTypeId;
         }
@@ -1111,6 +1394,7 @@ let repositoryGljObj = {
         if(me.gljCurTypeId < 0){
             return false;
         }
+        //粘贴的最大列下标不超过总列数
         if(info.cellRange.col + info.cellRange.colCount - 1 > me.setting.header.length - 1){
             return false;
         }
@@ -1118,19 +1402,6 @@ let repositoryGljObj = {
             if(info.cellRange.col === 0){
                 return false;
             }
-            else if(info.cellRange.col <= 4 && info.cellRange.col + info.cellRange.colCount - 1 >= 4){
-                for(let i = 0, len = info.cellRange.rowCount; i < len; i++){
-                    let row = i + info.cellRange.row;
-                    if(row < me.currentCache.length){
-                        if(allowComponent.includes(me.currentCache[row].gljType) && me.currentCache[row].component.length > 0){
-                            rst = false;
-                        }
-                    }
-                    else {
-                        break;
-                    }
-                }
-            }
         }
         return rst;
     },
@@ -1151,7 +1422,7 @@ let repositoryGljObj = {
         let items = sheetCommonObj.analyzePasteData(me.setting, info);
         let beginRow = info.cellRange.row, endRow = info.cellRange.row + info.cellRange.rowCount - 1,
             maxRow = me.currentCache.length - 1,
-            updateBasePrcArr = [] ,
+            updateBasePrcArr = [],
             updateCount, resumeArr = [];
         if(endRow <= maxRow){
             //updateItems = items;
@@ -1178,8 +1449,9 @@ let repositoryGljObj = {
                     }
                 }
             }
-            //if(info.cellRange.colCount === me.setting.header.length){
-            if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length){
+            //if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length){
+            //[code, ..., gljType]
+            if(info.cellRange.colCount >= 5 && info.cellRange.colCount <= me.setting.header.length){
                 for(let i = updateCount ; i < items.length; i++){
                     if(me.isValidObj(items[i])){
                         items[i].component = [];
@@ -1193,8 +1465,9 @@ let repositoryGljObj = {
             }
         }
         else{
-            //if(info.cellRange.colCount === me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
-            if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
+            //if(info.cellRange.colCount >= me.setting.header.length - 4 && info.cellRange.colCount <= me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= 5){
+            //粘贴的的最大列至少要等于工料机类型列,因为工料机类型必须有效才可新增
+            if(info.cellRange.colCount >= 5 && info.cellRange.colCount <= me.setting.header.length && info.cellRange.col + info.cellRange.colCount - 1 >= me.colMapping.fieldToCol['gljType']){
                 for(let i = 0; i < items.length; i++){
                     if(me.isValidObj(items[i])){
                         items[i].component = [];
@@ -1216,7 +1489,11 @@ let repositoryGljObj = {
                 if(resumeArr[i] < me.currentCache.length){
                     for(let col = 0; col < me.setting.header.length; col++){
                         let dCode = me.setting.header[col].dataCode;
-                        if(dCode === 'gljType'){
+                        if(me.priceCols.includes(col)){
+                            let price = me.getPrice(me.currentCache[resumeArr[i]], col);
+                            info.sheet.setValue(resumeArr[i], col, price ? price : 0);
+                        }
+                        else if(dCode === 'gljType'){
                             let gljType = me.currentCache[resumeArr[i]][dCode];
                             info.sheet.setValue(resumeArr[i], col, me.distTypeTree.distTypes["gljType" + gljType].data.fullName);
                         }
@@ -1321,7 +1598,7 @@ let repositoryGljObj = {
                     me.currentGlj = row < me.currentCache.length ? me.currentCache[row] : null;
                     me.currentComponent = me.currentGlj ?  me.getCurrentComponent(me.currentGlj.component) : [];
                     sheetCommonObj.cleanData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, -1);
-                    sheetsOprObj.showData(gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, me.currentComponent);
+                    sheetsOprObj.showData(gljComponentOprObj, gljComponentOprObj.workBook.getSheet(0), gljComponentOprObj.setting, me.currentComponent);
                 }
             },
             error:function(err){
@@ -1389,7 +1666,7 @@ let repositoryGljObj = {
         if (result && result.data && result.data.ops && result.data.ops.length > 0) {
             for (let i = 0; i < result.data.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]) {
+                    if (cacheSection[j]['code'] == result.data.ops[i]['code']) {
                         cacheSection[j]["ID"] = result.data.ops[i]["ID"];
                     }
                 }
@@ -1402,7 +1679,7 @@ let repositoryGljObj = {
                         cacheSection[j] = updateArr[i];
                     }
                 } else {
-                    if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
+                    if (cacheSection[j]['code'] == updateArr[i]['code']) {
                         cacheSection[j] = updateArr[i];
                     }
                 }

+ 265 - 94
web/maintain/std_glj_lib/js/gljComponent.js

@@ -18,10 +18,75 @@ let gljComponentOprObj = {
             lockedCols:[1, 2, 3]
         }
     },
+    //生成列头(多单价)(多消耗量)
+    initHeaders: function (priceProperties, consumeAmtProperties) {
+        let headers = [
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:90,dataCode:"name", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"单位",headerWidth:45,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+        ];
+        //生成消耗量列
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            headers.push({headerName:"消耗量",headerWidth:70,dataCode:"consumeAmt", dataType: "Number", formatter: "0.000", hAlign: "right", vAlign: "center"});
+        }
+        else {
+            for(let consumeAmtProp of consumeAmtProperties){
+                let colData = {
+                    headerName: consumeAmtProp.consumeAmt.dataName,
+                    headerWidth: 60,
+                    dataCode: consumeAmtProp.consumeAmt.dataCode,
+                    dataType: 'Number',
+                    formatter: '0.000',
+                    hAlign: 'right',
+                    vAlign: 'center'
+                };
+                headers.push(colData);
+            }
+        }
+        //生成单价列
+        if(!priceProperties || priceProperties.length === 0){
+            headers.push({headerName:"定额价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"});
+        }
+        else {
+            for(let priceProp of priceProperties){
+                let colData = {
+                    headerName: priceProp.price.dataName,
+                    headerWidth: 100,
+                    dataCode: priceProp.price.dataCode,
+                    dataType: 'Number',
+                    formatter: '0.00',
+                    hAlign: 'right',
+                    vAlign: 'center'
+                };
+                headers.push(colData);
+            }
+        }
+        return headers;
+    },
+    setFrozen: function (sheet) {
+        const fixedHeadersLen = 3;
+        let frozenCol = 0;
+        if(consumeAmtProperties && consumeAmtProperties.length > 0){
+            frozenCol = fixedHeadersLen + consumeAmtProperties.length;
+        }
+        else if(priceProperties && priceProperties.length > 0){
+            frozenCol = fixedHeadersLen + 1;
+        }
+        if(frozenCol > 0){
+            sheet.frozenColumnCount(frozenCol);
+        }
+    },
     buildSheet: function(container) {
         let me = gljComponentOprObj;
+        //生成人材机组成物表格列头
+        me.setting.header = me.initHeaders(priceProperties, consumeAmtProperties);
+        //生成人材机组成物列映射
+        sheetCommonObj.initColMapping(me, me.setting.header);
+        repositoryGljObj.initPriceCols.call(me, priceProperties, me.colMapping);
+        me.initConsumeAmtCols(consumeAmtProperties, me.colMapping);
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
-        //sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onCellEditStart, editEnded: me.onCellEditEnd}]);
+        me.setFrozen(me.workBook.getSheet(0));
+        sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onCellEditStart, editEnded: me.onCellEditEnd}]);
         me.workBook.getSheet(0).setColumnWidth(0, 20, GC.Spread.Sheets.SheetArea.rowHeader);
         me.workBook.getSheet(0).setFormatter(-1, 0, "@", GC.Spread.Sheets.SheetArea.viewport);
         sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
@@ -34,9 +99,18 @@ let gljComponentOprObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
     },
     getRowData: function (sheet, row, setting) {
-        let rst = {};
+        let rst = {priceProperty: {}, consumeAmtProperty: {}};
         for(let i = 0; i < setting.header.length; i++){
-            rst[setting.header[i].dataCode] = sheet.getValue(row, i);
+            let v = sheet.getValue(row, i);
+            if(this.pricePropertyCols.includes(i)){
+                rst.priceProperty[setting.header[i].dataCode] = v && v !== '' ? v : 0;
+            }
+            else if(this.consumeAmtPropertyCols.includes(i)){
+                rst.consumeAmtProperty[setting.header[i].dataCode] = v && v !== '' ? v : 0;
+            }
+            else {
+                rst[setting.header[i].dataCode] = v;
+            }
         }
         return rst;
     },
@@ -50,6 +124,63 @@ let gljComponentOprObj = {
         }
         return component;
     },
+    //根据消耗量字段设置组成物消耗量
+    setConsumeAmt: function (component, field, value) {
+        const compareStr = 'consumeAmt';
+        if(field.includes(compareStr)){
+            if(field === compareStr){
+                component[field] = value;
+            }
+            else {
+                component['consumeAmtProperty'][field] = value;
+            }
+        }
+    },
+    initConsumeAmtCols: function (consumeAmtProperties, colMapping) {
+        let consumeAmtCols = [],
+            consumeAmtPropertyCols = [];
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            consumeAmtCols.push(colMapping.fieldToCol['consumeAmt']);
+        }
+        for(let consumeAmtProp of consumeAmtProperties){
+            consumeAmtPropertyCols.push(colMapping.fieldToCol[consumeAmtProp.consumeAmt.dataCode]);
+            consumeAmtCols.push(colMapping.fieldToCol[consumeAmtProp.consumeAmt.dataCode]);
+        }
+        this.consumeAmtCols = consumeAmtCols;
+        this.consumeAmtPropertyCols = consumeAmtPropertyCols;
+    },
+    //消耗量赋初值
+    initConsumeAmt: function (component) {
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            component.consumeAmt = 0;
+        }
+        else {
+            let consumeAmtProperty = {};
+            for(let consumeAmtProp of consumeAmtProperties){
+                consumeAmtProperty[consumeAmtProp.consumeAmt.dataCode] = 0;
+            }
+            component.consumeAmtProperty = consumeAmtProperty;
+        }
+    },
+    consumeAmtChanged: function (component, consumeAmt, col) {
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            if(consumeAmt !== component.consumeAmt){
+                return true;
+            }
+        }
+        else {
+            if(consumeAmt !== component.consumeAmtProperty[this.colMapping.colToField[col]]){
+                return true;
+            }
+        }
+        return false;
+    },
+    consumeAmtIsEqual: function (consumeAmtA, consumeAmtB) {
+        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+            return consumeAmtA.consumeAmt === consumeAmtB.consumeAmt;
+        }
+        return _.isEqual(consumeAmtA.consumeAmtProperty, consumeAmtB.consumeAmtProperty);
+    },
     gljComponentDelOpr: function () {
         let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [], removeArr = [], isUpdate = false, updateBasePrc= [];
         me.workBook.commandManager().register('gljComponentDel', function () {
@@ -57,6 +188,7 @@ let gljComponentOprObj = {
             if(sels.length > 0 && that.currentComponent.length > 0){
                 let component = that.currentGlj.component;
                 for(let i = 0; i < sels.length > 0; i++){
+                    let selField = me.colMapping.colToField(sels[i].col);
                     if(sels[i].colCount === me.setting.header.length){//可删除
                         for(let j = 0; j < sels[i].rowCount; j++){
                             if(sels[i].row + j < that.currentComponent.length){
@@ -65,19 +197,21 @@ let gljComponentOprObj = {
                             }
                         }
                     }
-                    else if(sels[i].col === 0){
+                    else if(selField === 'code'){
                             //编码不可为空
                             alert("编码不可为空!");
 
                     }
-                    else if(sels[i].col === 4){//消耗量修改为0
+                    else if(selField.includes('consumeAmt')){//消耗量修改为0
                         if(sels[i].row === -1){//全修改
                            for(let j = 0; j < that.currentComponent.length; j++){
                                isUpdate = true;
-                               that.currentComponent[j].consumeAmt = 0;
+                               //that.currentComponent[j].consumeAmt = 0;
+                               me.setConsumeAmt(that.currentComponent[j], selField, 0);
                                for(let k = 0; k < component.length; k++){
                                    if(component[k].ID === that.currentComponent[j].ID){
-                                       component[k].consumeAmt = 0;
+                                       //component[k].consumeAmt = 0;
+                                       me.setConsumeAmt(component[k], selField, 0);
                                        break;
                                    }
                                }
@@ -87,10 +221,12 @@ let gljComponentOprObj = {
                             for(let j = 0; j < sels[i].rowCount; j++){
                                 if(sels[i].row + j < that.currentComponent.length){
                                     isUpdate = true;
-                                    that.currentComponent[sels[i].row + j].consumeAmt = 0;
+                                    me.setConsumeAmt(that.currentComponent[sels[i].row + j], selField, 0);
+                                    //that.currentComponent[sels[i].row + j].consumeAmt = 0;
                                     for(let k = 0; k < component.length; k++){
                                         if(component[k].ID === that.currentComponent[sels[i].row + j].ID){
-                                            component[k].consumeAmt = 0;
+                                            //component[k].consumeAmt = 0;
+                                            me.setConsumeAmt(component[k], selField, 0);
                                             break;
                                         }
                                     }
@@ -113,18 +249,8 @@ let gljComponentOprObj = {
                             }
                         }
                     }
-                    //重新计算工料机
-                    let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                    if(gljBasePrc !== that.currentGlj.basePrice){
-                        that.currentGlj.basePrice = gljBasePrc;
-                        that.reshowGljBasePrc(that.currentGlj);
-                        updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                    }
                     updateArr.push(that.currentGlj);
                     me.updateComponent(updateArr);
-                    if(updateBasePrc.length > 0){
-                        that.updateRationBasePrcRq(updateBasePrc, me.workBook);
-                    }
                 }
             }
         });
@@ -195,18 +321,8 @@ let gljComponentOprObj = {
                                         break;
                                     }
                                 }
-                                //重新计算工料机
-                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(gljComponent));
-                                if(gljBasePrc !== that.currentGlj.basePrice){
-                                    that.currentGlj.basePrice = gljBasePrc;
-                                    that.reshowGljBasePrc(that.currentGlj);
-                                    updateBasePrcArr.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                                }
                                 updateArr.push(that.currentGlj);
                                 me.updateComponent(updateArr);
-                                if(updateBasePrcArr.length > 0 && that.rationLibs.length > 0){
-                                    that.updateRationBasePrcRq(updateBasePrcArr, me.workBook);
-                                }
                             }},
                             "batchClear": {name: '批量删除消耗量为0的组成物', disabled: insertDis, icon: 'fa-remove', callback: function (key, opt) {
                                 co.insertType = 'batchClear';
@@ -223,6 +339,7 @@ let gljComponentOprObj = {
     },
     onCellEditStart: function(sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj;
+        console.log(me.colMapping);
         if(me.isPending){
             args.cancel = true;
         }
@@ -231,7 +348,13 @@ let gljComponentOprObj = {
         let thatRow = that.workBook.getSheet(0).getSelections()[0].row;
         if(thatRow < that.currentCache.length){
             that.currentGlj = that.currentCache[thatRow];
-            if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || !allowComponent.includes(that.currentGlj.gljType) ||
+            //编码和消耗量可编辑
+           /* if(me.setting.view.lockedCols.indexOf(args.col) !== -1 || !allowComponent.includes(that.currentGlj.gljType) ||
+                (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList)) ||
+                (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
+                args.cancel = true;
+            }*/
+            if(!(me.colMapping.colToField[args.col] === 'code' || me.colMapping.colToField[args.col].includes('consumeAmt')) || !allowComponent.includes(that.currentGlj.gljType) ||
                 (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList)) ||
                 (args.col === 4 && (!that.currentComponent|| args.row >= that.currentComponent.length))){
                 args.cancel = true;
@@ -244,8 +367,10 @@ let gljComponentOprObj = {
     onCellEditEnd: function (sender, args) {
         let me = gljComponentOprObj, that = repositoryGljObj, updateBasePrc = [];
         let gljList = that.gljList, updateArr = [];
+        let dataCode = me.colMapping.colToField[args.col];
         //if(args.editingText !== me.currentEditingComponent.code){
-        if(args.col === 0 && args.editingText && args.editingText.trim().length > 0 && args.editingText !== me.currentEditingComponent.code){
+        //编辑编码
+        if(dataCode === 'code' && args.editingText && args.editingText.trim().length > 0 && args.editingText !== me.currentEditingComponent.code){
             let component = that.currentGlj.component, hasCode = false;
             for(let i = 0; i < gljList.length; i++){
                 if(gljList[i].code === args.editingText){//有效的组成物
@@ -266,7 +391,13 @@ let gljComponentOprObj = {
                             rObj.ID = gljList[i].ID;
                             //rObj.basePrice = gljList[i].basePrice;
                             if(typeof that.currentComponent[args.row] !== 'undefined'){
-                                rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
+                                if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                                    rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
+                                }
+                                else{
+                                    rObj.consumeAmtProperty = that.currentComponent[args.row].consumeAmtProperty;
+                                }
+                                //rObj.consumeAmt = that.currentComponent[args.row].consumeAmt;
                                 let index;
                                 for(let j = 0; j < component.length; j++){
                                     if(component[j].ID === that.currentComponent[args.row].ID){
@@ -276,27 +407,12 @@ let gljComponentOprObj = {
                                 }
                                 component.splice(index, 1);
                                 component.splice(index, 0, rObj);
-                                //计算工料机单价
-                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                                if(gljBasePrc !== that.currentGlj.basePrice){
-                                    that.currentGlj.basePrice = gljBasePrc;
-                                    that.reshowGljBasePrc(that.currentGlj);
-                                    //工料机单价改变,重算引用了该工料机的定额单价
-                                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                                }
                                 updateArr.push(that.currentGlj);
                             }
                             else{
-                                rObj.consumeAmt = 0;
+                                me.initConsumeAmt(rObj);
+                                //rObj.consumeAmt = 0;
                                 component.push(rObj);
-                                //计算工料机单价
-                                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                                if(gljBasePrc !== that.currentGlj.basePrice){
-                                    that.currentGlj.basePrice = gljBasePrc;
-                                    that.reshowGljBasePrc(that.currentGlj);
-                                    //工料机单价改变,重算引用了该工料机的定额单价
-                                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                                }
                                 updateArr.push(that.currentGlj);
                             }
                             break;
@@ -329,41 +445,38 @@ let gljComponentOprObj = {
                 //不存在
             }
         }
-        else if(args.col === 4 && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
+        //编辑消耗量
+        else if(dataCode.includes('consumeAmt') && me.currentEditingComponent.code && args.editingText && args.editingText.trim().length > 0){//消耗量
             let consumeAmt = parseFloat(args.editingText);
-            if(!isNaN(consumeAmt) && consumeAmt !== me.currentEditingComponent.consumeAmt){
+            if(!isNaN(consumeAmt) && me.consumeAmtChanged(me.currentEditingComponent, consumeAmt, args.col)){
                 let roundCons = scMathUtil.roundTo(parseFloat(consumeAmt), -3);
                 let component = that.currentGlj.component;
                 for(let i = 0; i < component.length; i++){
                     if(component[i].ID === that.currentComponent[args.row].ID){
-                        component[i].consumeAmt = roundCons;
+                        me.setConsumeAmt(component[i], dataCode, roundCons);
+                        //component[i].consumeAmt = roundCons;
                     }
                 }
-                that.currentComponent[args.row].consumeAmt = roundCons;
-                //计算工料机单价
-                let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                if(gljBasePrc !== that.currentGlj.basePrice){
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
-                    //工料机单价改变,重算引用了该工料机的定额单价
-                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                }
+                //that.currentComponent[args.row].consumeAmt = roundCons;
+                me.setConsumeAmt(that.currentComponent[args.row], dataCode, roundCons);
                 updateArr.push(that.currentGlj);
             }
             else{
                 //只能输入数值
-                args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
-                    me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);
+                sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
+            /*    args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+                    me.currentEditingComponent[me.setting.header[args.col].dataCode]: 0);*/
 
             }
         }
         else{
-            args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
-            me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');
+            sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
+           /* args.sheet.setValue(args.row, args.col, me.currentEditingComponent[me.setting.header[args.col].dataCode] ?
+            me.currentEditingComponent[me.setting.header[args.col].dataCode]: '');*/
         }
         if(updateArr.length > 0){
             me.updateComponent(updateArr);
-            if(updateBasePrc.length > 0){
+            if(updateBasePrc.length > 0 && that.rationLibs.length > 0){
                 me.isPending = true;
                 that.updateRationBasePrcRq(updateBasePrc, me.workBook, function () {
                     me.isPending = false;
@@ -384,10 +497,22 @@ let gljComponentOprObj = {
         }
         let that = repositoryGljObj;
         let maxCol = info.cellRange.col + info.cellRange.colCount - 1;
+        //粘贴的字段只能含有编码和消耗量
+        for(let i = 0; i < info.cellRange.colCount; i++){
+            let col = info.cellRange.col + i;
+            let dataCode = me.colMapping.colToField[col];
+            if(dataCode !== 'code' && !dataCode.includes('consumeAmt')){
+                info.cancel = true;
+                return;
+            }
+        }
         //复制的列数超过正确的列数,不可复制
-        if(info.cellRange.col !== 0 && info.cellRange.col !== 4 || info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
+        if(maxCol > me.setting.header.length - 1){
             info.cancel = true;
         }
+       /* if(beginDataCode !== 'code' && !beginDataCode.include('consumeAmt') || info.cellRange.colCount > 1 || (that.currentGlj.gljType === 4 && that.isComponent(that.currentGlj.ID, that.gljList))){
+            info.cancel = true;
+        }*/
     },
     onClipboardPasted: function (sender, info) {
         let me = gljComponentOprObj, that = repositoryGljObj, updateArr = [],
@@ -418,7 +543,13 @@ let gljComponentOprObj = {
                                 let obj = {};
                                 obj.ID = gljCache[j].ID;
                                 if(typeof that.currentComponent[info.cellRange.row + i] !== 'undefined'){//更新
-                                    obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
+                                    //obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
+                                    if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                                        obj.consumeAmt = that.currentComponent[info.cellRange.row + i].consumeAmt;
+                                    }
+                                    else{
+                                        obj.consumeAmtProperty = that.currentComponent[info.cellRange.row + i].consumeAmtProperty;
+                                    }
                                     let index;
                                     for(let k = 0; k < component.length; k++){
                                         if(that.currentComponent[info.cellRange.row + i].ID === component[k].ID){
@@ -430,7 +561,7 @@ let gljComponentOprObj = {
                                     component.splice(index, 0, obj);
                                 }
                                 else{//新增
-                                    obj.consumeAmt = 0;
+                                    me.initConsumeAmt(obj);
                                     component.push(obj);
                                 }
                                 break;
@@ -455,23 +586,45 @@ let gljComponentOprObj = {
                 }
             }
             if(isChange){
-                //计算工料机单价
-                let gljBasePrc = me.reCalGljBasePrc(that.getCurrentComponent(component));
-                if(gljBasePrc !== that.currentGlj.basePrice){
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
-                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                }
                 updateArr.push(that.currentGlj);
             }
         }
-        else if(info.cellRange.col === 4){
+        //消耗量
+        else if(me.colMapping.colToField[info.cellRange.col].includes('consumeAmt')){
             let items = sheetCommonObj.analyzePasteData(me.setting, info);
             let row = info.cellRange.row;
             for(let i = 0; i < items.length; i++){
                 if(row + i < that.currentComponent.length){
                     let currentObj = that.currentComponent[row + i];
-                    if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
+                    if(!me.consumeAmtIsEqual(items[i], currentObj)){
+                        isChange = true;
+                        if(!consumeAmtProperties || consumeAmtProperties.length === 0){
+                            let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), -3);
+                            currentObj.consumeAmt = roundCons;
+                            for(let j = 0; j < component.length; j++){
+                                if(component[j].ID === currentObj.ID){
+                                    component[j].consumeAmt = currentObj.consumeAmt;
+                                    break;
+                                }
+                            }
+                        }
+                        else{
+                            for(let attr in items[i]){
+                                //是消耗量字段
+                                if(attr.includes('consumeAmt') && items[i][attr] && !isNaN(parseFloat(items[i][attr]))){
+                                    let roundCons = scMathUtil.roundTo(parseFloat(items[i][attr]), -3);
+                                    currentObj.consumeAmtProperty[attr] =roundCons;
+                                }
+                            }
+                            for(let j = 0; j < component.length; j++){
+                                if(component[j].ID === currentObj.ID){
+                                    component[j].consumeAmtProperty = currentObj.consumeAmtProperty;
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                    /*if(items[i].consumeAmt.trim().length > 0 && items[i].consumeAmt !== currentObj.consumeAmt){
                         let roundCons = scMathUtil.roundTo(parseFloat(items[i].consumeAmt), -3);
                         isChange = true;
                         currentObj.consumeAmt = roundCons;
@@ -481,9 +634,10 @@ let gljComponentOprObj = {
                                 break;
                             }
                         }
-                    }
+                    }*/
                     else{
-                        me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, currentObj.consumeAmt);
+                        sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
+                        //me.workBook.getSheet(0).setValue(row + i, info.cellRange.col, currentObj.consumeAmt);
                     }
                 }
                 else{
@@ -491,13 +645,6 @@ let gljComponentOprObj = {
                 }
             }
             if(isChange){
-                //计算工料机单价
-                let gljBasePrc = me.reCalGljBasePrc(that.currentComponent);
-                if(gljBasePrc !== that.currentGlj.basePrice){
-                    that.currentGlj.basePrice = gljBasePrc;
-                    that.reshowGljBasePrc(that.currentGlj);
-                    updateBasePrc.push({gljId: that.currentGlj.ID, gljType: that.currentGlj.gljType, basePrice: that.currentGlj.basePrice});
-                }
                 updateArr.push(that.currentGlj);
             }
         }
@@ -512,7 +659,7 @@ let gljComponentOprObj = {
         }
         else {
             sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
-            sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
+            sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
         }
         let focusInter = setInterval(function () {
             if(!$('#loadingPage').is(':visible')){
@@ -534,13 +681,40 @@ let gljComponentOprObj = {
                     if(result.data[0]){
                         that.currentComponent =  that.getCurrentComponent(result.data[0].component);
                         sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
-                        sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, that.currentComponent);
+                        sheetsOprObj.showData(me, me.workBook.getSheet(0), me.setting, that.currentComponent);
                     }
                 }
             }
         })
     },
-    reCalGljBasePrc: function (component) {
+    reCalGljBasePrc: function (components) {
+        let me = gljComponentOprObj, re = repositoryGljObj;
+        //只有一个单价的情况,只有一个单价则只有一个消耗量
+        if(!priceProperties || priceProperties.length === 0){
+            let gljBasePrc = 0;
+            for(let i = 0; i < components.length; i++){
+                let roundBasePrc = scMathUtil.roundTo(parseFloat(components[i].basePrice), -2);
+                let roundConsumeAmt = scMathUtil.roundTo(parseFloat(components[i].consumeAmt), -3);
+                gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljBasePrc, me.processDecimal);
+            }
+            return scMathUtil.roundTo(gljBasePrc, -2);
+        }
+        //多单价的情况
+        else {
+            let gljPriceProperty = re.getPriceProperty(priceProperties);
+            for(let priceProp in gljPriceProperty){
+                let consumeAmtField = re.getConsumeAmtField(consumeAmtProperties, priceProp);
+                for(let component of components){
+                    let roundBasePrc = scMathUtil.roundTo(parseFloat(component['priceProperty'][priceProp]), -2);
+                    let roundConsumeAmt = scMathUtil.roundTo(parseFloat(component['consumeAmtProperty'][consumeAmtField]), -3);
+                    gljPriceProperty[priceProp] = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljPriceProperty[priceProp], me.processDecimal);
+                }
+                scMathUtil.roundTo(gljPriceProperty[priceProp], -2);
+            }
+            return gljPriceProperty;
+        }
+    }
+    /*  reCalGljBasePrc: function (component) {
         let me = gljComponentOprObj, gljBasePrc = 0;
         for(let i = 0; i < component.length; i++){
             let roundBasePrc = scMathUtil.roundTo(parseFloat(component[i].basePrice), -2);
@@ -548,9 +722,6 @@ let gljComponentOprObj = {
             //gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * parseFloat(component[i].consumeAmt), -2) + gljBasePrc, -2); 旧算法
             gljBasePrc = scMathUtil.roundTo(scMathUtil.roundTo(roundBasePrc * roundConsumeAmt, me.processDecimal) + gljBasePrc, me.processDecimal);
         }
-        console.log(`scMathUtil.roundTo(gljBasePrc, -2)`);
-        console.log(scMathUtil.roundTo(gljBasePrc, -2));
-        console.log(scMathUtil.roundTo(gljBasePrc, -3));
         return scMathUtil.roundTo(gljBasePrc, -2);
-    }
+    }*/
 };

+ 30 - 16
web/maintain/std_glj_lib/js/sheetsOpr.js

@@ -22,7 +22,7 @@ let sheetsOprObj = {
             area.vAlign(GC.Spread.Sheets.VerticalAlign.center);
         }
     },
-    showData: function(sheet, setting, data, distTypeTree, materialTypeIdx, machineModelIdx) {
+    showData: function(obj, sheet, setting, data, distTypeTree, materialTypeIdx, machineModelIdx) {
         var me = this, ch = GC.Spread.Sheets.SheetArea.viewport;
         sheet.suspendPaint();
         sheet.suspendEvent();
@@ -45,9 +45,19 @@ let sheetsOprObj = {
                 sheet.setFormatter(-1, col, setting.header[col].formatter, GC.Spread.Sheets.SheetArea.viewport);
             }
             for (var row = 0; row < data.length; row++) {
-               // console.log(row);
-                //var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
-                if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
+                if(obj.pricePropertyCols.includes(col)){
+                    let price = data[row]['priceProperty'] && data[row]['priceProperty'][obj.colMapping.colToField[col]] !== undefined
+                        && data[row]['priceProperty'][obj.colMapping.colToField[col]] !== null
+                        ? data[row]['priceProperty'][obj.colMapping.colToField[col]] : '';
+                    sheet.setValue(row, col, price);
+                }
+                else if(obj.consumeAmtPropertyCols && obj.consumeAmtPropertyCols.includes(col)){
+                    let consumeAmt = data[row]['consumeAmtProperty'] && data[row]['consumeAmtProperty'][obj.colMapping.colToField[col]] !== undefined
+                    && data[row]['consumeAmtProperty'][obj.colMapping.colToField[col]] !== null
+                        ? data[row]['consumeAmtProperty'][obj.colMapping.colToField[col]] : '';
+                    sheet.setValue(row, col, consumeAmt);
+                }
+                else if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
                     let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
                     sheet.setValue(row, col, distTypeVal, ch);
                 }
@@ -73,14 +83,18 @@ let sheetsOprObj = {
     },
     combineRowData: function(sheet, setting, row, repositoryGljObj) {
         let me = this;
-        var rst = {};
-        let comboBoxCellType = sheet.getCellType(row, 5);
-        let items = comboBoxCellType.items();
-        let materialTypeCombo = sheet.getCellType(row, 7);
+        var rst = {priceProperty: {}};
+        let gljTypeCombo = sheet.getCellType(row, repositoryGljObj.colMapping.fieldToCol['gljType']);
+        let items = gljTypeCombo.items();
+        let materialTypeCombo = sheet.getCellType(row, repositoryGljObj.colMapping.fieldToCol['materialType']);
         let materialItems = materialTypeCombo.items();
-        let machineItems = sheet.getCellType(row, 9).items();
+        let machineItems = sheet.getCellType(row, repositoryGljObj.colMapping.fieldToCol['model']).items();
         for (var col = 0; col < setting.header.length; col++) {
-            if(setting.header[col].dataCode === 'gljType'){
+            if(repositoryGljObj.pricePropertyCols.includes(col)){
+                v = sheet.getValue(row, col);
+                rst.priceProperty[setting.header[col].dataCode] = v && v !== '' ? v : 0;
+            }
+            else if(setting.header[col].dataCode === 'gljType'){
                 items.forEach(function(item){
                     if(sheet.getValue(row, col) === item.text){
                         rst[setting.header[col].dataCode] = item.value;
@@ -114,14 +128,14 @@ let sheetsOprObj = {
                             $('#alertText').text("输入的编号已存在,请重新输入!");
                             $('#codeAlertBtn').click();
                             $('#codAleConfBtn').click(function () {
-                                sheet.setValue(row, 0, orgCode);
-                                sheet.getCell(row, 0).formatter("@");
-                                sheet.setActiveCell(row, 0);
+                                sheet.setValue(row, col, orgCode);
+                                sheet.getCell(row, col).formatter("@");
+                                sheet.setActiveCell(row, col);
                             });
                             $('#codAleClose').click(function () {
-                                sheet.setValue(row, 0, orgCode);
-                                sheet.getCell(row, 0).formatter("@");
-                                sheet.setActiveCell(row, 0);
+                                sheet.setValue(row, col, orgCode);
+                                sheet.getCell(row, col).formatter("@");
+                                sheet.setActiveCell(row, col);
                             });
                             isExist = true
                         }

+ 2 - 2
web/over_write/js/jiangxi_2017.js

@@ -37,7 +37,7 @@ const consumeAmtPropertiesTemplate = [
         taxModel: taxModel.common,
         consumeAmt: {
             dataCode: 'consumeAmt1',
-            dataName: '消耗-一般',
+            dataName: '消耗-一般',
             refPrice: 'price1' //关联的单价字段
         }
     },
@@ -46,7 +46,7 @@ const consumeAmtPropertiesTemplate = [
         taxModel: taxModel.simple,
         consumeAmt: {
             dataCode: 'consumeAmt2',
-            dataName: '消耗-简易',
+            dataName: '消耗-简易',
             refPrice: 'price2' //关联的单价字段
         }
     }