Browse Source

导入功能调整

laiguoran 2 years ago
parent
commit
fbca893723
1 changed files with 21 additions and 17 deletions
  1. 21 17
      app/public/js/material_checklist.js

+ 21 - 17
app/public/js/material_checklist.js

@@ -1085,10 +1085,10 @@ $(document).ready(() => {
     // 导入功能
     // 上传图片
     $('#upload-list').click(function () {
-        // if (materialChecklistData.length === 0) {
-        //     toastr.error('请选择调差清单再导入。');
-        //     return
-        // }
+        if (materialBillsData.length === 0) {
+            toastr.error('请添加工料再导入。');
+            return
+        }
         $(this).siblings('input').trigger('click');
     });
     $('#upload-list-file').change(function () {
@@ -1163,21 +1163,22 @@ $(document).ready(() => {
                         continue;
                     }
                     needPushTree.push(t);
-                    for (const c of t.children) {
-                        const mbOrder = _.findIndex(materialBillsData, { code: c.GLJcode, name: c.name, unit: c.unit });
-                        if (c.b_code !== null && mbOrder === -1 && _.findIndex(pushBillsData, { code: c.GLJcode, name: c.name, unit: c.unit }) === -1) {
-                            pushBillsData.push({
-                                code: c.GLJcode,
-                                name: c.name,
-                                unit: c.unit,
-                                spec: c.specs,
-                            })
-                        }
-                    }
+                    // for (const c of t.children) {
+                    //     const mbOrder = _.findIndex(materialBillsData, { code: c.GLJcode, name: c.name, unit: c.unit });
+                    //     if (c.b_code !== null && mbOrder === -1 && _.findIndex(pushBillsData, { code: c.GLJcode, name: c.name, unit: c.unit }) === -1) {
+                    //         pushBillsData.push({
+                    //             code: c.GLJcode,
+                    //             name: c.name,
+                    //             unit: c.unit,
+                    //             spec: c.specs,
+                    //         })
+                    //     }
+                    // }
                 }
                 console.log(pushChecklist, pushBillsData);
-                // stopProgress($('#bill-progress'));
-                // await pushListData(needPushTree);
+                if (needPushTree.length === 0) {
+                    throw '不存在需要导入的工料清单含量';
+                }
                 // 先上传需要生成的清单及工料
                 if (pushChecklist.length > 0 || pushBillsData.length > 0) {
                     postData(window.location.pathname + '/save', { type:'exportCB', addChecklist: pushChecklist, addBillsList: pushBillsData }, async function (result) {
@@ -1296,6 +1297,9 @@ $(document).ready(() => {
                         mbList.push({ id: mbInfo.id, quantity: mb.quantity });
                     }
                 }
+                if (mbList.length === 0) {
+                    continue;
+                }
 
                 const gclIndex = _.findIndex(gclGatherData, { b_code: t.b_code, name: t.name, unit: t.unit, unit_price: t.unit_price ? parseFloat(t.unit_price) : null });
                 const gcl = gclGatherData[gclIndex].leafXmjs;