浏览代码

修复批量添加bug,取消单独工料bug

laiguoran 2 年之前
父节点
当前提交
fe51629c9c
共有 3 个文件被更改,包括 35 次插入23 次删除
  1. 10 5
      app/public/js/material_checklist.js
  2. 6 1
      app/public/js/material_list.js
  3. 19 17
      app/service/material_list_self.js

+ 10 - 5
app/public/js/material_checklist.js

@@ -140,7 +140,9 @@ $(document).ready(() => {
             for (const [index, s] of result.ledgerListData.entries()) {
                 gclGatherModel.loadLedgerData(ledger, s);
                 gclGatherModel.loadPosData(pos, result.posListData[index]);
-                const oneGclGatherData = gclGatherModel.gatherGclData();
+                const oneGclGatherData = gclGatherModel.gatherGclData().filter(item => {
+                    return item.qc_qty || item.contract_qty
+                });
                 newGclGatherListData.push(oneGclGatherData);
             }
             gclGatherListData = newGclGatherListData;
@@ -419,7 +421,7 @@ $(document).ready(() => {
         const select = SpreadJsObj.getSelectObject(sheet);
         const gclIndex = _.findIndex(gclGatherData, { b_code: select.b_code, name: select.name, unit: select.unit, unit_price: select.unit_price });
         const gcl = gclGatherData[gclIndex].leafXmjs;
-        const ms_id = isStageSelf ? parseInt($('#myTab').find('.active').data('msid')) : null;
+        const ms_id = isStageSelf ? materialStageData[0].id : null;
         const index = materialChecklistData.indexOf(select);
         const datas = [];
         for (const xmj of gcl) {
@@ -482,16 +484,17 @@ $(document).ready(() => {
                 const gclIndex = _.findIndex(gclGatherData, { b_code: select.b_code, name: select.name, unit: select.unit, unit_price: select.unit_price });
                 const gcl = gclGatherData[gclIndex].leafXmjs;
                 const datas = [];
+                const ms_id = isStageSelf ? materialStageData[0].id : null;
                 for (const xmj of gcl) {
                     const data = {
                         xmj_id: xmj.id,
                         gcl_id: xmj.gcl_id,
                         mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
                     };
+                    if (ms_id) data.ms_id = ms_id;
                     datas.push(data);
                 }
                 if (isStageSelf) {
-                    const ms_id = isStageSelf ? materialStageData[0].id : null;
                     // 取所有的gclGatherData才行,然后获取下的值
                     const gclData = gclGatherData[gclIndex];
                     for (const [index, ms] of materialStageData.entries()) {
@@ -591,16 +594,17 @@ $(document).ready(() => {
                     const gclIndex = _.findIndex(gclGatherData, { b_code: ledgerSelect.b_code, name: ledgerSelect.name, unit: ledgerSelect.unit, unit_price: ledgerSelect.unit_price });
                     const gcl = gclGatherData[gclIndex].leafXmjs;
                     const datas = [];
+                    const ms_id = isStageSelf ? materialStageData[0].id : null;
                     for (const xmj of gcl) {
                         const data = {
                             xmj_id: xmj.id,
                             gcl_id: xmj.gcl_id,
                             mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
                         };
+                        if (ms_id) data.ms_id = ms_id;
                         datas.push(data);
                     }
                     if (isStageSelf) {
-                        const ms_id = isStageSelf ? materialStageData[0].id : null;
                         // 取所有的gclGatherData才行,然后获取下的值
                         const gclData = gclGatherData[gclIndex];
                         for (const [index, ms] of materialStageData.entries()) {
@@ -712,16 +716,17 @@ $(document).ready(() => {
                 const gclIndex = _.findIndex(gclGatherData, { b_code: ledgerSelect.b_code, name: ledgerSelect.name, unit: ledgerSelect.unit, unit_price: ledgerSelect.unit_price });
                 const gcl = gclGatherData[gclIndex].leafXmjs;
                 const datas = [];
+                const ms_id = isStageSelf ? materialStageData[0].id : null;
                 for (const xmj of gcl) {
                     const data2 = {
                         xmj_id: xmj.id,
                         gcl_id: xmj.gcl_id,
                         mx_id: xmj.mx_id !== undefined ? xmj.mx_id : '',
                     };
+                    if (ms_id) data2.ms_id = ms_id;
                     datas.push(data2);
                 }
                 if (isStageSelf) {
-                    const ms_id = isStageSelf ? materialStageData[0].id : null;
                     // 取所有的gclGatherData才行,然后获取下的值
                     const gclData = gclGatherData[gclIndex];
                     for (const [index, ms] of materialStageData.entries()) {

+ 6 - 1
app/public/js/material_list.js

@@ -853,6 +853,10 @@ $(document).ready(() => {
             };
             if (type === 'noself') {
                 if (isStageSelf) {
+                    data.select.gather_qty = {};
+                    const ledgerSheet = ledgerSpread.getActiveSheet();
+                    const ledgerSelect = SpreadJsObj.getSelectObject(ledgerSheet);
+                    const index = gclGatherData.indexOf(ledgerSelect);
                     // 取所有的gclGatherData才行,然后获取下的值
                     const gclData = gclGatherData[index];
                     for (const [index, ms] of materialStageData.entries()) {
@@ -865,12 +869,13 @@ $(document).ready(() => {
                             });
                             if (oneXmj) gather_qty = oneXmj.gather_qty;
                         }
-                        data.select.gather_qty[ms.id] = gather_qty;
+                        data.select.gather_qty['ms_id_' + ms.id] = gather_qty;
                     }
                 } else {
                     data.select.gather_qty = select.gather_qty ? select.gather_qty : null;
                 }
             }
+            console.log(data);
             // 添加到
             postData(window.location.pathname + '/save', data, function (result) {
                 if (type === 'noself') {

+ 19 - 17
app/service/material_list_self.js

@@ -135,23 +135,25 @@ module.exports = app => {
                     // const oneML = this._.filter(materialListData, { ms_id: ms.id });
                     // const gather_qty = oneML[0].gather_qty;
                     // const is_join = oneML[0].is_join;
-                    for (const m of materialListGclData) {
-                        insertList.push({
-                            tid: this.ctx.tender.id,
-                            order: m.order,
-                            mid: this.ctx.material.id,
-                            mb_id: m.mb_id,
-                            gcl_id: data.gcl_id,
-                            xmj_id: data.xmj_id,
-                            mx_id: data.mx_id,
-                            ms_id: ms.id,
-                            gather_qty: data.gather_qty[ms.id],
-                            quantity: m.quantity,
-                            expr: m.expr,
-                            is_join,
-                            is_self: 0,
-                            in_time: new Date(),
-                        });
+                    if (data.gather_qty['ms_id_' + ms.id] !== null) {
+                        for (const m of materialListGclData) {
+                            insertList.push({
+                                tid: this.ctx.tender.id,
+                                order: m.order,
+                                mid: this.ctx.material.id,
+                                mb_id: m.mb_id,
+                                gcl_id: data.gcl_id,
+                                xmj_id: data.xmj_id,
+                                mx_id: data.mx_id,
+                                ms_id: ms.id,
+                                gather_qty: data.gather_qty['ms_id_' + ms.id],
+                                quantity: m.quantity,
+                                expr: m.expr,
+                                is_join,
+                                is_self: 0,
+                                in_time: new Date(),
+                            });
+                        }
                     }
                 }
             } else {