Преглед на файлове

材料调差导入清单工料过滤消耗量为0的工料

ellisran преди 1 година
родител
ревизия
c4e4974f11
променени са 1 файла, в които са добавени 13 реда и са изтрити 9 реда
  1. 13 9
      app/public/js/material_checklist.js

+ 13 - 9
app/public/js/material_checklist.js

@@ -1186,7 +1186,8 @@ $(document).ready(() => {
                     if (!ignoreUnitPrice) findObject.unit_price = t.unit_price ? parseFloat(t.unit_price) : null;
                     const order = _.findIndex(gclGatherData, findObject);
                     const mlOrder = _.findIndex(materialChecklistData, findObject);
-                    if (mlOrder === -1 && order !== -1 && _.findIndex(pushChecklist, findObject) === -1) {
+                    const haveQuantity = _.find(t.children, function (item) { return item.quantity && item.quantity !== 0 }) ? 1 : 0;
+                    if (mlOrder === -1 && order !== -1 && haveQuantity && _.findIndex(pushChecklist, findObject) === -1) {
                         pushChecklist.push({
                             b_code: gclGatherData[order].b_code,
                             name: gclGatherData[order].name,
@@ -1198,6 +1199,8 @@ $(document).ready(() => {
                         });
                     } else if (mlOrder === -1 && order === -1) {
                         continue;
+                    } else if (!haveQuantity) {
+                        continue;
                     }
                     needPushTree.push(t);
                     // for (const c of t.children) {
@@ -1215,7 +1218,6 @@ $(document).ready(() => {
                 if (needPushTree.length === 0) {
                     throw '不存在需要导入的工料清单含量';
                 }
-                console.log(needPushTree);
                 // 先上传需要生成的清单及工料
                 if (pushChecklist.length > 0 || pushBillsData.length > 0) {
                     postData(window.location.pathname + '/save', { type:'exportCB', addChecklist: pushChecklist, addBillsList: pushBillsData }, async function (result) {
@@ -1330,14 +1332,16 @@ $(document).ready(() => {
                 }
                 const mbList = [];
                 for (const mb of t.children) {
-                    const mbInfo = _.find(materialBillsData, { code: mb.gljcode+'', name: mb.name+'', unit: mb.unit+'' });
-                    if (mbInfo) {
-                        const num = parseFloat(mb.quantity);
-                        if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
-                            // toastr.warning('已保留6位小数');
-                            mb.quantity = ZhCalc.round(num, 6);
+                    if (mb.quantity) {
+                        const mbInfo = _.find(materialBillsData, { code: mb.gljcode+'', name: mb.name+'', unit: mb.unit+'' });
+                        if (mbInfo) {
+                            const num = parseFloat(mb.quantity);
+                            if (num < 0 || !/^\d+(\.\d{1,6})?$/.test(num)) {
+                                // toastr.warning('已保留6位小数');
+                                mb.quantity = ZhCalc.round(num, 6);
+                            }
+                            mbList.push({ id: mbInfo.id, quantity: mb.quantity });
                         }
-                        mbList.push({ id: mbInfo.id, quantity: mb.quantity ? mb.quantity : 0 });
                     }
                 }
                 if (mbList.length === 0 && i+1 === tree.length) {