laiguoran 4 éve
szülő
commit
6344f871af
1 módosított fájl, 3 hozzáadás és 3 törlés
  1. 3 3
      app/service/material_audit.js

+ 3 - 3
app/service/material_audit.js

@@ -213,8 +213,9 @@ 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 materialExponentData = await this.ctx.service.materialExponent.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
+                if (materialBillsData.length === 0 && materialExponentData.length === 0) {
+                    throw '请至少使用一种调差方式';
                 }
                 const mbhList = [];
                 for (const mb of materialBillsData) {
@@ -242,7 +243,6 @@ module.exports = app => {
                 }
                 await transaction.insert(this.ctx.service.materialBillsHistory.tableName, mbhList);
 
-                const materialExponentData = await this.ctx.service.materialExponent.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
                 const mehList = [];
                 for (const me of materialExponentData) {
                     const newMeh = {