Browse Source

项目工料机提供的甲供数据不稳定Bug。

chenshilong 7 years ago
parent
commit
15419c3865

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

@@ -38,7 +38,7 @@ ProjectGLJSpread.prototype.init = function () {
     }
     let selectBox = new GC.Spread.Sheets.CellTypes.ComboBox();
     selectBox.items(supplySelect);
-    selectBox.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.text);
+    selectBox.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
     let header = [
         {name: '编码', field: 'code', visible: true,width:80},
         {name: '名称', field: 'name', visible: true,width:160},
@@ -214,7 +214,7 @@ ProjectGLJSpread.prototype.updateProjectGLJField = function(info, callback) {
 
     // 如果是供货方式则需要处理数据
     if (field === 'supply') {
-        value = this.supplyType.indexOf(value);
+        // value = this.supplyType.indexOf(value);
         extend.supply_quantity = this.getSupplyQuantity(value, activeSheet, info);
     }
     if(field === 'supply_quantity'){//修改数量需做4舍5入
@@ -311,11 +311,11 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
             activeSheet.getCell(rowCounter, supplyColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
         }
         // 如果为部分甲供则甲供数量需要可编辑
-        if (data.supply === 1) {
+        if (data.supply == 1) {
             activeSheet.getCell(rowCounter, supplyQuantity,  GC.Spread.Sheets.SheetArea.viewport).locked(false);
         }
         //供货方式为完全甲供时设置甲供数量为总消耗量
-        if (data.supply === 2) {
+        if (data.supply == 2) {
             activeSheet.setValue(rowCounter, supplyQuantity,  data.quantity);
         }
         // 供货方式数据
@@ -323,6 +323,7 @@ ProjectGLJSpread.prototype.specialColumn = function (sourceData) {
         supplyIndex = isNaN(supplyIndex) ? 0 : supplyIndex;
         let supplyText = this.supplyType[supplyIndex] !== undefined ? this.supplyType[supplyIndex] : '自行采购';
         activeSheet.setValue(rowCounter, supplyColumn, supplyText);
+        // activeSheet.setValue(rowCounter, supplyColumn, supplyIndex);
 
         // 如果类型为混凝土、砂浆、配合比、机械,则市场单价和供货方式不能修改
         if (canNotChangeTypeId.indexOf(data.unit_price.type) >= 0) {
@@ -474,13 +475,14 @@ ProjectGLJSpread.prototype.priceCalculate = function(info) {
  * @return {void}
  */
 ProjectGLJSpread.prototype.changeSupplyType = function(info) {
-    let supply = info.newValue;
-    let supplyNumber = this.supplyType.indexOf(supply) > -1 ? this.supplyType.indexOf(supply) : 0;
+    // let supply = info.newValue;
+    // let supplyNumber = this.supplyType.indexOf(supply) > -1 ? this.supplyType.indexOf(supply) : 0;
+    let supplyNumber = info.newValue;
     let supplyQuantityColumn = this.sheetObj.getFieldColumn('supply_quantity');
     let activeSheet = this.sheetObj.getSheet();
 
     // 部分甲供时可更改甲供数量数据,其余则只读
-    let locked = supplyNumber === 1 ? false : true;
+    let locked = supplyNumber == 1 ? false : true;
     activeSheet.getCell(info.row, supplyQuantityColumn,  GC.Spread.Sheets.SheetArea.viewport).locked(locked);
 
     let supplyQuantity = this.getSupplyQuantity(supplyNumber, activeSheet, info);
@@ -500,7 +502,7 @@ ProjectGLJSpread.prototype.getSupplyQuantity = function(supplyType, activeSheet,
     // 获取总消耗量
     let quantity = activeSheet.getValue(info.row, quantityColumn);
     // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
-    let supplyQuantity = supplyType === 0 || supplyType === 3 ? 0 : quantity;
+    let supplyQuantity = supplyType == 0 || supplyType == 3 ? 0 : quantity;
     supplyQuantity = parseFloat(supplyQuantity);
 
     return supplyQuantity;

+ 1 - 1
web/building_saas/main/js/models/calc_program.js

@@ -434,7 +434,7 @@ let calcTools = {
         else if (baseName == calcBaseNames.JGSBF || baseName == calcBaseNames.JDSBF){
             gljT = [gljType.EQUIPMENT];
         };
-
+        // alert(JSON.stringify(projectGLJ.testGLJs()));
         let supplyProjectGLJs = projectGLJ.getGLJsBySupply(supplyT, gljT);
         if (supplyProjectGLJs.length == 0) return 0;
 

+ 32 - 1
web/building_saas/main/js/models/project_glj.js

@@ -70,11 +70,42 @@ ProjectGLJ.prototype.getDataByID = function (ID) {//根据项目工料机ID取
 
 // CSL, 2018-02-08 甲供、甲定。
 ProjectGLJ.prototype.getGLJsBySupply = function (supplyTypeArr, gljTypeArr) {
+    // 项目工料机采用了内部绑定数据源方式,能够双向同步,但同时带来难干预控制问题。supply值存在混杂情况,如:“2”和“部分甲供”同时存在。
+    // 所以这里要合并处理。
+    let mixSupply = [];
+    for (let s of supplyTypeArr){
+        switch (s) {
+            case 1:
+                mixSupply.push('部分甲供');
+                break;
+            case 2:
+                mixSupply.push('完全甲供');
+                break;
+            case 3:
+                mixSupply.push('甲定乙供');
+                break;
+            default:
+                mixSupply.push('自行采购');
+        }
+    };
+    mixSupply = mixSupply.concat(supplyTypeArr);
+
     return _.filter(this.datas.gljList, function (glj) {
-        return supplyTypeArr.includes(glj.supply) && gljTypeArr.includes(glj.type);
+        return mixSupply.includes(glj.supply) && gljTypeArr.includes(glj.type);
     });
 };
 
+ProjectGLJ.prototype.testGLJs = function () {
+    let gljs = [];
+    for (let glj of this.datas.gljList){
+         let o = new Object();
+         o.name = glj.name;
+         o.supply = glj.supply;
+         gljs.push(o);
+    };
+    return gljs;
+};
+
 /**
  * 修改工料机数据
  *

+ 3 - 3
web/building_saas/main/js/views/project_view.js

@@ -46,9 +46,9 @@ var projectObj = {
                 projectObj.testDisplay('结果', rst);*/
 
         // 基数
-/*        node.data.isSubcontract = true;
-        node.data.gljList = project.ration_glj.getGljArrByRation(node.data.ID);
-        let bname = '甲定额基价材料费';
+        // node.data.isSubcontract = true;
+        /*node.data.gljList = project.ration_glj.getGljArrByRation(node.data.ID);
+        let bname = '甲定额基价材料费';
         projectObj.testDisplay(bname, rationCalcBases[bname](node));*/
 
     },