Kaynağa Gözat

调差上报和新增清单为空判断

laiguoran 5 yıl önce
ebeveyn
işleme
415b34e7d7
2 değiştirilmiş dosya ile 7 ekleme ve 1 silme
  1. 6 0
      app/service/material_audit.js
  2. 1 1
      app/service/material_list.js

+ 6 - 0
app/service/material_audit.js

@@ -198,8 +198,14 @@ module.exports = app => {
 
                 // 本期一些必要数据(如应耗数量和上期调差金额)插入到material_bills_history表里
                 const materialBillsData = await this.ctx.service.materialBills.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
+                if (materialBillsData.length === 0) {
+                    throw '调差工料不能为空';
+                }
                 const mbhList = [];
                 for (const mb of materialBillsData) {
+                    if (mb.code === '') {
+                        throw '调差工料编号不能为空';
+                    }
                     const newMbh = {
                         tid: this.ctx.tender.id,
                         mid: this.ctx.material.id,

+ 1 - 1
app/service/material_list.js

@@ -253,7 +253,7 @@ module.exports = app => {
                 };
                 copyMLArray.push(newMaterialList);
             }
-            return await transaction.insert(this.tableName, copyMLArray);
+            return copyMLArray.length !== 0 ? await transaction.insert(this.tableName, copyMLArray) : true;
         }
     }
     return MaterialList;