Bladeren bron

bug fixed

zhangweicheng 7 jaren geleden
bovenliggende
commit
327eaa9cfa

+ 8 - 1
modules/glj/controllers/glj_controller.js

@@ -128,8 +128,15 @@ class GLJController extends BaseController {
                         if (mixRatioData.length <= 0) {
                             break;
                         }
+                        let indexList = ['code','name','specs','unit','type'];
+                        let keyList = mixRatioData.connect_key.split("|-|");
                         // 更新市场单价和基价单价
-                        let condition = {code: mixRatioData.connect_code, unit_price_file_id: mixRatioData.unit_price_file_id};
+                        let condition = {unit_price_file_id: mixRatioData.unit_price_file_id};
+                        for(let i = 1;i<keyList.length;i++){
+                            if(keyList[i]!='null'){
+                                condition[indexList[i]]=keyList[i];
+                            }
+                        }
                         let unitPriceUpdate = {
                             base_price: basePrice,
                             market_price: marketPrice

+ 11 - 4
web/building_saas/glj/js/common_spread.js

@@ -36,7 +36,12 @@ CommonSpreadJs.prototype.init = function(target) {
     for(let tmp of this.header) {
         let width = tmp.width==undefined ? 120 : tmp.width;
         setting.header.push({headerName: tmp.name, headerWidth: width});
-        this.columnInfo.push({name: tmp.field, displayName: tmp.name, visible: tmp.visible, cellType: tmp.cellType, size: width});
+        let options= {name: tmp.field, displayName: tmp.name, visible: tmp.visible, cellType: tmp.cellType, size: width};
+        if(tmp.decimalField){
+            let decimal = getDecimal(tmp.decimalField);
+            options.formatter = getFormatter(decimal);
+        }
+        this.columnInfo.push(options);
     }
 
     this.spread = sheetCommonObj.buildSheet(document.getElementById(target), setting, 10);
@@ -260,11 +265,13 @@ CommonSpreadJs.prototype.checkData = function(column, value) {
  * @param {boolean} appendMode
  * @return {void}
  */
-CommonSpreadJs.prototype.setCellByField = function(field, value, appendMode) {
-    let row = this.sheet.getActiveRowIndex();
+CommonSpreadJs.prototype.setCellByField = function(field, value, appendMode,row) {
+     row = row?row:this.sheet.getActiveRowIndex();
     let columnIndex = this.getFieldColumn(field);
+    let decimal = field=="quantity"?getDecimal("glj.quantity"):getDecimal("glj.unitPrice")
     if (appendMode) {
-        let oldValue = this.sheet.getValue(row, columnIndex);
+        let oldValue = scMathUtil.roundForObj(this.sheet.getValue(row, columnIndex),decimal);
+        value = scMathUtil.roundForObj(value,decimal);
         value = (oldValue + value).toDecimal(2);
     }
     this.sheet.setValue(row, columnIndex, value);

+ 12 - 2
web/building_saas/glj/js/composition.js

@@ -64,13 +64,23 @@ $(document).ready(function() {
  */
 function compositionSuccess(info) {
     // 成功则对相应的总消耗量进行设置
-    projectGLJSheet.setCellByField('quantity', info.change, true);
+    let row= projectGLJSheet.sheet.getActiveRowIndex();//取父机械或组成物的下标
+    let parentData = jsonData[row];
+    let ratioData = _.find(parentData.ratio_data,{"id":info.id});
+    let con_key = gljOprObj.getIndex(ratioData,['code', 'name', 'specs', 'unit', 'type']);
+    for(let i=0;i< jsonData.length;i++){
+        let tem_key = gljOprObj.getIndex(jsonData[i],['code', 'name', 'specs', 'unit', 'type']);
+        if(con_key == tem_key){
+            //乘以父工料机的消耗量得到该组成物总消耗量的改变量
+            info.change = operationWithRound(parentData.quantity,info.change,"glj.quantity","*");
+            projectGLJSheet.setCellByField('quantity', info.change, true,i);
+        }
+    }
 
     // 设置父级3个价格
     projectGLJSheet.setCellByField('unit_price.market_price', info.parentMarketPrice, false);
     projectGLJSheet.setCellByField('unit_price.base_price', info.parentBasePrice, false);
     projectGLJSheet.setCellByField('adjust_price', info.parentMarketPrice, false);
-
     // 更新组成物缓存
     projectObj.project.composition.loadData();
 }

+ 7 - 7
web/building_saas/glj/js/composition_spread.js

@@ -32,10 +32,10 @@ CompositionSpread.prototype.init = function(target) {
         {name: '单位', field: 'unit', visible: true},
         {name: 'ID', field: 'id', visible: false},
         {name: '类型', field: 'unit_price.type', visible: false},
-        {name: '基价单价', field: "unit_price.base_price", visible: true},
-        {name: '调整价', field: 'adjust_price', visible: true},
-        {name: '市场价', field: "unit_price.market_price", visible: true},
-        {name: name, field: 'consumption', visible: true, validator: 'number'},
+        {name: '定额价', field: "unit_price.base_price", visible: true,decimalField:"glj.unitPrice"},
+        {name: '调整价', field: 'adjust_price', visible: true,decimalField:"glj.unitPrice"},
+        {name: '市场价', field: "unit_price.market_price", visible: true,decimalField:"glj.unitPrice"},
+        {name: name, field: 'consumption', visible: true, validator: 'number',decimalField:'glj.quantity'},
         {name: 'CID', field: 'mix_ratio_id', visible: false},
     ];
 
@@ -223,6 +223,7 @@ CompositionSpread.prototype.updateConsumption = function(info, callback) {
                 activeSheet.setValue(row, column, info.oldValue);
                 alert('更改数据失败!');
             } else {
+                info.id = id;
                 info.parentMarketPrice = parentMarketPrice;
                 info.parentBasePrice = parentBasePrice;
                 info.change = info.newValue - info.oldValue;
@@ -265,9 +266,8 @@ CompositionSpread.prototype.getCompositionSumPrice = function(scene, affectRow,
 
         // 获取消耗量(如果是当前修改的行则替换数据)
         let consumption = i === affectRow ? newValue : activeSheet.getValue(i, consumptionColumn);
-
-        parentMarketPrice += consumption * marketPrice;
-        parentBasePrice += consumption * basePrice;
+        parentMarketPrice += operationWithRound(consumption,marketPrice,"glj.unitPrice","*");
+        parentBasePrice += operationWithRound(consumption,basePrice,"glj.unitPrice","*");
     }
 
     parentMarketPrice = parentMarketPrice.toDecimal(2);

+ 26 - 10
web/building_saas/glj/js/project_glj_spread.js

@@ -47,10 +47,10 @@ ProjectGLJSpread.prototype.init = function () {
         {name: '类型', field: 'unit_price.short_name', visible: true,width:45},
         {name: 'ID', field: 'id', visible: false},
         {name: '类型', field: 'unit_price.type', visible: false},
-        {name: '总消耗量', field: 'quantity', visible: true,width:100},
-        {name: '定额价', field: "unit_price.base_price", visible: true,width:70},
-        {name: '调整价', field: 'adjust_price', visible: true,width:70},
-        {name: '市场价', field: "unit_price.market_price", visible: true, validator: 'number',width:70},
+        {name: '总消耗量', field: 'quantity', visible: true,width:100,decimalField:'glj.quantity'},
+        {name: '定额价', field: "unit_price.base_price", visible: true,width:70,decimalField:"glj.unitPrice"},
+        {name: '调整价', field: 'adjust_price', visible: true,width:70,decimalField:"glj.unitPrice"},
+        {name: '市场价', field: "unit_price.market_price", visible: true, validator: 'number',width:70,decimalField:"glj.unitPrice"},
         {
             name: '是否暂估',
             field: 'is_evaluate',
@@ -75,7 +75,7 @@ ProjectGLJSpread.prototype.init = function () {
         {name: '工料机ID', field: 'glj_id', visible: false},
         {name: '组成物消耗量', field: 'consumption', visible: false},
         {name: '父级关联编码', field: 'connect_code', visible: false},
-        {name: '消耗量', field: 'ratio_data', visible: false},
+        {name: '组成物信息', field: 'ratio_data', visible: false},
     ];
     let sourceData = jsonData;
 
@@ -92,6 +92,8 @@ ProjectGLJSpread.prototype.init = function () {
     let marketPriceColumn = this.sheetObj.getFieldColumn('unit_price.market_price');
     let supplyColumn = this.sheetObj.getFieldColumn('supply');
     let shortNameColumn = this.sheetObj.getFieldColumn('unit_price.short_name');
+    let supplyQuantity = this.sheetObj.getFieldColumn('supply_quantity');
+
 
     // 居中样式
     let centerStyleSetting = {hAlign: 1};
@@ -107,6 +109,7 @@ ProjectGLJSpread.prototype.init = function () {
     this.sheetObj.setStyle(-1, adjustPriceColumn, rightStyleSetting);
     this.sheetObj.setStyle(-1, marketPriceColumn, rightStyleSetting);
     this.sheetObj.setStyle(-1, supplyColumn, rightStyleSetting);
+    this.sheetObj.setStyle(-1, supplyQuantity, rightStyleSetting);
 
     // 设置可编辑列
     this.sheetObj.setColumnEditable(marketPriceColumn);
@@ -135,9 +138,14 @@ ProjectGLJSpread.prototype.init = function () {
         let typeColumn = self.sheetObj.getFieldColumn('unit_price.type');
         let type = activeSheet.getValue(row, typeColumn);
 
+        let ratioColumn = self.sheetObj.getFieldColumn('ratio_data');
+        let ratioData = activeSheet.getValue(row, ratioColumn);
+
         // 如果类型为混凝土、砂浆、配合比、机械,则提示
         if (field === 'unit_price.market_price' && canNotChangeTypeId.indexOf(type) >= 0) {
-            alert('当前工料机的市场单价由组成物计算得出,不可直接修改');
+            if(ratioData&&ratioData.length>0){
+                alert('当前工料机的市场单价由组成物计算得出,不可直接修改');
+            }
         }
     });
 
@@ -208,7 +216,9 @@ ProjectGLJSpread.prototype.updateProjectGLJField = function(info, callback) {
     if(field === 'supply_quantity'){//修改数量需做4舍5入
         value= value.toDecimal(getDecimal('glj.quantity'));
     }
-
+    if(field === 'unit_price.market_price'){
+        value= value.toDecimal(getDecimal('glj.unitPrice'));
+    }
     extend = Object.keys(extend).length > 0 ?  JSON.stringify(extend) : '';
     $.ajax({
         url: '/glj/update',
@@ -280,10 +290,14 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
             // 锁定该单元格
             activeSheet.getCell(rowCounter, supplyColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
         }
-        // 如果为部分甲供或者为全部甲供则甲供数量需要可编辑
-        if (data.supply === 1 || data.supply === 2) {
+        // 如果为部分甲供则甲供数量需要可编辑
+        if (data.supply === 1) {
             activeSheet.getCell(rowCounter, supplyQuantity,  GC.Spread.Sheets.SheetArea.viewport).locked(false);
         }
+        //供货方式为完全甲供时设置甲供数量为总消耗量
+        if (data.supply === 2) {
+            activeSheet.setValue(rowCounter, supplyQuantity,  data.quantity);
+        }
         // 供货方式数据
         let supplyIndex = parseInt(data.supply);
         supplyIndex = isNaN(supplyIndex) ? 0 : supplyIndex;
@@ -297,7 +311,9 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
             this.firstMachineRow = this.firstMachineRow === -1 && data.unit_price.type === GLJTypeConst.GENERAL_MACHINE ?
                 rowCounter : this.firstMachineRow;
             // 锁定该单元格
-            activeSheet.getCell(rowCounter, marketPriceColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
+            if (data.ratio_data  && data.ratio_data.length > 0){//有组成物时,市场单价不可修改
+                activeSheet.getCell(rowCounter, marketPriceColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
+            }
             activeSheet.getCell(rowCounter, supplyColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
         }
 

+ 11 - 0
web/building_saas/main/js/models/ration_glj.js

@@ -661,6 +661,7 @@ var ration_glj = {
             return gljOprObj.combineWithProjectGlj(gljList);
         };
         ration_glj.prototype.transferToNodeData = function (data) {
+            data.contain=scMathUtil.roundForObj(data.quantity,getDecimal('glj.quantity'));
             data.subType = data.type;
             data.marketUnitFee = data.marketPrice;
         };
@@ -700,6 +701,16 @@ var ration_glj = {
                     return;
                 }
             } else {
+                if(fieldName == "contain"){
+                    if(value==null){
+                        value="";
+                    }else {
+                        var decimal = getDecimal("glj.quantity");
+                        value = number_util.checkNumberValue(value, decimal);
+                        fieldName="customQuantity";//填入自定义消耗
+                    }
+                }
+
                 if (value !== undefined && value !== null) {
                     if (fieldName == "subType") {
                         node.data.subType = value;

+ 23 - 0
web/building_saas/main/js/views/glj_view.js

@@ -1505,6 +1505,29 @@ $(function () {
     }
 })
 
+
+function  operationWithRound(value1,value2,field,symble) {
+    let decimal = getDecimal(field);
+    value1 = scMathUtil.roundForObj(value1,decimal);
+    value2 = scMathUtil.roundForObj(value2,decimal);
+    let result;
+    switch (symble){
+        case "+" :
+            result=scMathUtil.roundForObj(value1 + value2,decimal);
+            break;
+        case "-":
+            result=scMathUtil.roundForObj(value1 - value2,decimal);
+            break;
+        case "*":
+            result=scMathUtil.roundForObj(value1 * value2,decimal);
+            break;
+        case "/":
+            result=scMathUtil.roundForObj(value1 / value2,decimal);
+            break
+    }
+    return result;
+}
+
 function getDecimal(fieldID, node) {
     if (node) {
         return decimalObj.decimal(fieldID, node);