Sfoglia il codice sorgente

1.完善配合比、机械单价的操作
2.完善项目工料机总消耗的计算

caiaolin 8 anni fa
parent
commit
54baae8785

+ 6 - 6
modules/glj/controllers/glj_controller.js

@@ -240,15 +240,15 @@ class GLJController extends BaseController {
     async test(request, response) {
     async test(request, response) {
         // 从定额库获取的数据
         // 从定额库获取的数据
         let data = {
         let data = {
-            glj_id: 802,
+            glj_id: 803,
             project_id: 1,
             project_id: 1,
-            code: '85030202',
-            name: '履带式起重机 15t',
-            specs: '15t',
+            code: '85011701',
+            name: '电动夯实机 夯能20~62N·m',
+            specs: '夯能20~62N·m',
             unit: '台班',
             unit: '台班',
             type: GLJTypeConst.GENERAL_MACHINE,
             type: GLJTypeConst.GENERAL_MACHINE,
-            base_price: 501.64,
-            market_price: 501.64
+            base_price: 120.45,
+            market_price: 120.45
         };
         };
         try {
         try {
             let gljListModel = new GLJListModel();
             let gljListModel = new GLJListModel();

+ 15 - 6
modules/glj/models/glj_list_model.js

@@ -165,6 +165,17 @@ class GLJListModel extends BaseModel {
      * @return {void}
      * @return {void}
      */
      */
     combineData(gljList, unitPriceList, quantityList = {}, mixRatioData = {}, totalComposition = {}) {
     combineData(gljList, unitPriceList, quantityList = {}, mixRatioData = {}, totalComposition = {}) {
+        // 整理组成物消耗量(只有在总列表显示的时候才需用到,获取单项项目工料机内容则忽略)
+        let compositionConsumption = {};
+        if (Object.keys(mixRatioData).length > 0 && Object.keys(totalComposition).length > 0) {
+            for(let index in mixRatioData) {
+                for(let tmp of mixRatioData[index]) {
+                    compositionConsumption[tmp.glj_id] = compositionConsumption[tmp.glj_id] === undefined ? tmp.consumption :
+                        compositionConsumption[tmp.glj_id] + tmp.consumption;
+                }
+
+            }
+        }
         // 循环组合数据
         // 循环组合数据
         for(let glj of gljList) {
         for(let glj of gljList) {
             if (glj.code === undefined) {
             if (glj.code === undefined) {
@@ -176,15 +187,13 @@ class GLJListModel extends BaseModel {
                 continue;
                 continue;
             }
             }
 
 
+            let gljId = glj.glj_id + '';
             // 消耗量赋值
             // 消耗量赋值
             glj.quantity = quantityList[glj.id] !== undefined ? quantityList[glj.id] : 0;
             glj.quantity = quantityList[glj.id] !== undefined ? quantityList[glj.id] : 0;
             glj.quantity = totalComposition[glj.code] !== undefined ? totalComposition[glj.code] : glj.quantity;
             glj.quantity = totalComposition[glj.code] !== undefined ? totalComposition[glj.code] : glj.quantity;
+            glj.quantity = compositionConsumption[gljId] !== undefined ?  glj.quantity + compositionConsumption[gljId] : glj.quantity;
 
 
-            // 组成物消耗量
-            let gljId = glj.glj_id + '';
-            // glj.consumption = mixRatioData[gljId] !== undefined ? mixRatioData[gljId].consumption : 0;
-            // glj.mix_ratio_id = mixRatioData[gljId] !== undefined ? mixRatioData[gljId].id : 0;
-            // glj.connect_code = mixRatioData[gljId] !== undefined ? mixRatioData[gljId].connect_code : '';
+            // 组成物数据
             glj.ratio_data = mixRatioData[gljId] !== undefined ? mixRatioData[gljId] : [];
             glj.ratio_data = mixRatioData[gljId] !== undefined ? mixRatioData[gljId] : [];
 
 
             // 计算调整基价
             // 计算调整基价
@@ -516,7 +525,7 @@ class GLJListModel extends BaseModel {
 
 
             let allowType = [GLJTypeConst.MIX_RATIO, GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR,
             let allowType = [GLJTypeConst.MIX_RATIO, GLJTypeConst.CONCRETE, GLJTypeConst.MORTAR,
                 GLJTypeConst.GENERAL_MACHINE];
                 GLJTypeConst.GENERAL_MACHINE];
-            console
+
             if (projectGLJData.unit_price === null || allowType.indexOf(projectGLJData.unit_price.type) < 0) {
             if (projectGLJData.unit_price === null || allowType.indexOf(projectGLJData.unit_price.type) < 0) {
                 throw '找不到相关项目工料机';
                 throw '找不到相关项目工料机';
             }
             }

+ 3 - 5
web/glj/js/composition.js

@@ -7,11 +7,9 @@
  */
  */
 let mixRatioSpread = null;
 let mixRatioSpread = null;
 let machineSpread = null;
 let machineSpread = null;
-let mixRatioRightClickTarget = null;
 let isDeleting = false;
 let isDeleting = false;
 $(document).ready(function() {
 $(document).ready(function() {
 
 
-
     // 切换tab触发refresh
     // 切换tab触发refresh
     $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
     $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
         currentTag = $(e.target).data('name');
         currentTag = $(e.target).data('name');
@@ -23,7 +21,7 @@ $(document).ready(function() {
                 mixRatioSpread = new CompositionSpread();
                 mixRatioSpread = new CompositionSpread();
                 mixRatioSpread.init(currentTag);
                 mixRatioSpread.init(currentTag);
                 mixRatioSpread.initRightClick(currentTag);
                 mixRatioSpread.initRightClick(currentTag);
-                mixRatioSpread.successCallback = mixRatioSuccess;
+                mixRatioSpread.successCallback = compositionSuccess;
             }
             }
 
 
             // 筛选数据显示(显示混凝土、砂浆、配合比)
             // 筛选数据显示(显示混凝土、砂浆、配合比)
@@ -40,7 +38,7 @@ $(document).ready(function() {
                 machineSpread = new CompositionSpread();
                 machineSpread = new CompositionSpread();
                 machineSpread.init(currentTag);
                 machineSpread.init(currentTag);
                 machineSpread.initRightClick(currentTag);
                 machineSpread.initRightClick(currentTag);
-                machineSpread.successCallback = mixRatioSuccess;
+                machineSpread.successCallback = compositionSuccess;
             }
             }
 
 
             // 筛选数据显示(显示普通机械)
             // 筛选数据显示(显示普通机械)
@@ -63,7 +61,7 @@ $(document).ready(function() {
  * @param {object} info
  * @param {object} info
  * @return {void}
  * @return {void}
  */
  */
-function mixRatioSuccess(info) {
+function compositionSuccess(info) {
     // 成功则对相应的总消耗量进行设置
     // 成功则对相应的总消耗量进行设置
     projectGLJSheet.setCellByField('quantity', info.change, true);
     projectGLJSheet.setCellByField('quantity', info.change, true);
 
 

+ 13 - 4
web/glj/js/project_glj.js

@@ -19,11 +19,20 @@ $(document).ready(function () {
     let lastRow = 0;
     let lastRow = 0;
     projectGLJSheet.bind(GC.Spread.Sheets.Events.CellClick, function (element, info) {
     projectGLJSheet.bind(GC.Spread.Sheets.Events.CellClick, function (element, info) {
         let currentRow = info.row;
         let currentRow = info.row;
-        if (currentTag === 'mix-ratio' && mixRatioSheet !== null && currentRow != lastRow) {
-            let projectGLJId = projectGLJSheet.getActiveDataByField('id');
-            // 获取数据
-            compositionSpread.getRatioData(projectGLJId);
+        if (currentRow === undefined || currentRow === lastRow) {
+            return;
         }
         }
+        if (currentTag !== 'mix-ratio' && currentTag !== 'machine') {
+            return;
+        }
+
+        let spread = currentTag === 'mix-ratio' ? mixRatioSpread : machineSpread;
+        if (spread === null) {
+            return;
+        }
+        let projectGLJId = projectGLJSheet.getActiveDataByField('id');
+        spread.getRatioData(projectGLJId);
+
         lastRow = currentRow;
         lastRow = currentRow;
     });
     });