Sfoglia il codice sorgente

工料机汇总修改数据后联动操作

olym 7 anni fa
parent
commit
5ccab3840f

+ 3 - 2
modules/glj/models/glj_list_model.js

@@ -9,7 +9,6 @@ import BaseModel from "../../common/base/base_model";
 import {default as GLJSchemas, collectionName as gljCollectionName} from "./schemas/glj";
 import CounterModel from "./counter_model";
 import UnitPriceModel from "./unit_price_model";
-import STDMixRatioModel from "../../common/std/std_mix_ratio_model";
 import UnitPriceFileModel from "./unit_price_file_model";
 import GLJTypeConst from "../../common/const/glj_type_const";
 import RationGLJFacade from "../../ration_glj/facade/ration_glj_facade";
@@ -110,7 +109,9 @@ class GLJListModel extends BaseModel {
             let quantityList = {};
             // 整理数据
             for (let tmp of quantityData) {
-                quantityList[tmp.projectGLJID] = tmp.quantity;
+                // 解决js小数点bug
+                let tmpQuantity = tmp.quantity + '';
+                quantityList[tmp.projectGLJID] = parseFloat(tmpQuantity.toFixed(2));
             }
 
             // 查找组成物的消耗量

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

@@ -253,13 +253,19 @@ function unitPriceFileInit(name, data) {
  * @return {void}
  */
 function successTrigger(field, info) {
+    let updateData = {};
     switch (field) {
         case 'unit_price.market_price':
             // 计算价格
-            projectGLJSpread.priceCalculate(info);
+            updateData = projectGLJSpread.priceCalculate(info);
 
             // 触发websocket通知
             socket.emit('dataNotify', JSON.stringify(info));
             break;
     }
+    // 重新加载数据到缓存
+    projectObj.project.projectGLJ.loadData();
+
+    // 更新定额工料机
+    gljOprObj.refreshView();
 }

+ 50 - 2
web/building_saas/main/js/models/project_glj.js

@@ -33,6 +33,7 @@ ProjectGLJ.prototype.loadData = function () {
             self.isLoading = true;
         },
         success: function(response) {
+            self.isLoading = false;
             if (response.err === 1) {
                 let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取工料机数据失败!';
                 alert(msg);
@@ -75,10 +76,57 @@ ProjectGLJ.prototype.getDataByCode = function (code) {
 /**
  * 修改工料机数据
  *
- * @param {String} code
+ * @param {Number} id
  * @param {Object} data
  * @return {boolean}
  */
-ProjectGLJ.prototype.updateData = function(code, data) {
+ProjectGLJ.prototype.updateData = function(id, data) {
+    let result = false;
+    if (this.datas === null) {
+        return result;
+    }
+
+    let gljList = this.datas.gljList;
+    if (gljList === undefined) {
+        return result;
+    }
+
+    // 查找对应的index
+    let index = -1;
+    for(let tmp in gljList) {
+        if (gljList[tmp].id === id) {
+            index = tmp;
+            break;
+        }
+    }
+
+    if (index < 0) {
+        return result;
+    }
+
+    // 修改数据
+    for(let tmpIndex in data) {
+        if(tmpIndex.indexOf('_price') >= 0) {
+            // 修改unit_price中的对象
+            this.datas.gljList[index]['unit_price'][tmpIndex] = data[tmpIndex];
+        } else {
+            this.datas.gljList[index][tmpIndex] = data[tmpIndex];
+        }
+    }
 
 };
+
+/**
+ * 加载缓存数据到spread
+ *
+ * @return {void}
+ */
+ProjectGLJ.prototype.loadCacheData = function() {
+    // 加载工料机数据
+    let data = this.datas === null ? null : this.datas;
+    if (data === null) {
+        return;
+    }
+    jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
+    projectGLJSheet.setData(jsonData);
+};