Переглянути джерело

修复独立单价删除工料bug,及隐藏导入工料数据

laiguoran 1 рік тому
батько
коміт
c79d8e3c4c

+ 1 - 0
app/public/js/material.js

@@ -440,6 +440,7 @@ $(document).ready(() => {
                     newIndex = _.findIndex(newMaterialBillsData, { id: select.id });
                 }
                 sheet.deleteRows(newIndex, 1);
+                sheet.zh_data.splice(newIndex, 1);
 
                 resetTpTable();
                 // SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());

+ 5 - 4
app/service/material_bills.js

@@ -88,11 +88,12 @@ module.exports = app => {
             try {
                 const resultData = {};
                 let needUpdateTp = false;
-                // 找出需要导入的工料
+                // 找出需要导入的工料 (隐藏未存在的工料导入问题)
                 const bills = await this.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
-                const newBills = this._.differenceWith(datas, bills, function(item1, item2) {
-                    return item1.code.toString() === item2.code.toString() && item1.name === item2.name && item1.unit === item2.unit && (!includeSpec || (includeSpec && item1.spec.toString() === item2.spec.toString()));
-                });
+                // const newBills = this._.differenceWith(datas, bills, function(item1, item2) {
+                //     return item1.code.toString() === item2.code.toString() && item1.name === item2.name && item1.unit === item2.unit && (!includeSpec || (includeSpec && item1.spec.toString() === item2.spec.toString()));
+                // });
+                const newBills = [];
                 const material_month = this.ctx.material.months ? this.ctx.material.months.split(',') : [];
                 if (newBills.length !== 0) {
                     const newBillsData = [];

+ 4 - 2
app/service/material_stage_bills.js

@@ -111,9 +111,10 @@ module.exports = app => {
 
         // 批量添加工料时同步生成
         async adds(transaction, billsList, remark = null, ms_id = null) {
-            const insertList = [];
+            // 这里有坑!必须按独立期分开入库才行,不然会出现第二期之后msg_tp的数据无法入库的情况,奇怪的bug
             for (const sid of this.ctx.material.stage_id.split(',')) {
                 const msInfo = await transaction.get(this.ctx.service.materialStage.tableName, { tid: this.ctx.tender.id, sid });
+                const insertList = [];
                 for (const b of billsList) {
                     const insertData = {
                         tid: this.ctx.tender.id,
@@ -134,8 +135,9 @@ module.exports = app => {
                     }
                     insertList.push(insertData);
                 }
+                if (insertList.length > 0) await transaction.insert(this.tableName, insertList);
             }
-            if (insertList.length > 0) await transaction.insert(this.tableName, insertList);
+            return true;
         }
 
         async updateByExport(transaction, bills, datas, includeSpec, ms_id) {