Quellcode durchsuchen

变更清单模式添加当前新增清单功能

ellisran vor 1 Jahr
Ursprung
Commit
bb6cae9f02
2 geänderte Dateien mit 55 neuen und 38 gelöschten Zeilen
  1. 52 37
      app/public/js/change_information_add_list.js
  2. 3 1
      app/view/change/addlist.ejs

+ 52 - 37
app/public/js/change_information_add_list.js

@@ -358,7 +358,7 @@ $(document).ready(() => {
                 const changePos = _.find(result.changePosList, { id: xmj.mx_id, lid: xmj.gcl_id });
                 if (changeLedger || changePos) {
                     xmj.cid = 1;
-                    xmj.ccid = changeLedger ? changeLedger.ccid : changePos.ccid;
+                    xmj.ccid = changePos ? changePos.ccid : changeLedger ? changeLedger.ccid : 0;
                     hadcid = 1;
                 }
             }
@@ -568,6 +568,7 @@ $(document).ready(() => {
                 }, function (result) {
                     changeList = result.changeList;
                     const gclIndex = changeListData.indexOf(data);
+                    console.log(gclIndex, data);
                     data.is_change = 1;
                     changeListData[gclIndex].is_change = 1;
                     SpreadJsObj.reLoadRowData(gclSpreadSheet, gclIndex);
@@ -615,44 +616,58 @@ $(document).ready(() => {
         }
     });
     // 选中所有新增部位/清单
-    $('#select-all-revise').click(function() {
-        const qtySpr = '*;*', infoSpr = '!_!', recSpr = '$#$';
-        const gclTr = $('#table-list-select tr');
-        for (const tr of gclTr) {
-            const lid = $(tr).data('lid');
-            let gcl = _.find(gclGatherData, function (item) {
-                return item.leafXmjs && item.leafXmjs[0].gcl_id === lid;
-            });
-            if (!gcl) gcl = gclGatherData[$(this).data('gcl')];
-            if (!gcl || !gcl.cid) continue;
-
-            let data_bwmx = [];
-            if ($(tr).attr('data-bwmx') !== '') {
-                data_bwmx = $(tr).attr('data-bwmx').split(recSpr);
-                data_bwmx = data_bwmx.filter(x => {
-                    const rec = x.split(qtySpr);
-                    const info = rec[0].split(infoSpr);
-                    if (info.length < 8) return true;
-
-                    const leaf = gcl.leafXmjs.find(lx => { return lx.mx_id === info[6]});
-                    return !leaf || !leaf.cid || leaf.ccid !== window.location.pathname.split('/')[4];
-                });
-            }
-            let hasNew = false;
-            for (const [index, leaf] of gcl.leafXmjs.entries()) {
-                if (!leaf.cid || leaf.ccid !== window.location.pathname.split('/')[4]) continue;
-                const bwmx = [leaf.code, leaf.jldy || '', leaf.dwgc || '', leaf.fbgc || '', leaf.fxgc || '', leaf.gcl_id, leaf.mx_id, leaf.bwmx || leaf.jldy || ''];
-                const de_qu = bwmx.join(infoSpr) + qtySpr + (leaf.quantity || 0);
-                if (data_bwmx.indexOf(de_qu) < 0) data_bwmx.push(de_qu);
-                hasNew = true;
+    $('#add-all-revise').click(function() {
+        const this_cid = window.location.pathname.split('/')[4];
+        const addDatas = [];
+        const refreshIndexs = [];
+        for (const gclInfo of _.filter(changeListData, { cid: 1 })) {
+            const leafXmjs = _.filter(gclInfo.leafXmjs, { ccid: this_cid });
+            if (leafXmjs.length > 0) {
+                gclInfo.is_change = 1;
+                refreshIndexs.push(changeListData.indexOf(gclInfo));
+                for (const xmj of leafXmjs) {
+                    if (_.findIndex(changeList, function (item) {
+                        return item.gcl_id === xmj.gcl_id && item.mx_id === (xmj.mx_id || '');
+                    }) === -1) {
+                        addDatas.push({
+                            lid: xmj.gcl_id,
+                            code: gclInfo.code,
+                            name: gclInfo.name || '',
+                            unit: gclInfo.unit || '',
+                            unit_price: gclInfo.unit_price,
+                            oamount: xmj.quantity,
+                            oamount2: xmj.quantity,
+                            bwmx: xmj.bwmx || xmj.jldy || '',
+                            xmj_code: xmj.code || '',
+                            xmj_jldy: xmj.jldy || '',
+                            xmj_dwgc: xmj.dwgc || '',
+                            xmj_fbgc: xmj.fbgc || '',
+                            xmj_fxgc: xmj.fxgc || '',
+                            gcl_id: xmj.gcl_id,
+                            mx_id: xmj.mx_id || '',
+                        });
+                    }
+                }
             }
-            if (hasNew) $(tr).attr('data-bwmx', data_bwmx.join(recSpr)).addClass('table-success');
         }
-
-        // 触发点击当前清单,重载当前全部部位
-        const dataIndex = $('#code-list').attr('data-index');
-        if (dataIndex) {
-            $(`tr[data-index=${dataIndex}]`).trigger('click');
+        console.log(addDatas);
+        if (addDatas.length > 0) {
+            // 更新至服务器
+            postData('/tender/' + window.location.pathname.split('/')[2] + '/change/' + window.location.pathname.split('/')[4] + '/information/save', {
+                type: 'add-change-list',
+                postData: addDatas,
+            }, function (result) {
+                toastr.success('已新增当前变更令新增的所有部位/清单');
+                changeList = result.changeList;
+                refreshIndexs.forEach(function (index) {
+                    changeListData[index].is_change = 1;
+                    SpreadJsObj.reLoadRowData(gclSpreadSheet, index);
+                });
+                const data = SpreadJsObj.getSelectObject(gclSpreadSheet);
+                gclSpreadObj.resetXmjSpread(data);
+            });
+        } else {
+            toastr.warning('未存在当前变更令新增的部位/清单');
         }
     });
 });

+ 3 - 1
app/view/change/addlist.ejs

@@ -3,9 +3,11 @@
     <div class="panel-title">
         <div class="title-main  d-flex">
             <% include ./sub_mini_menu.ejs %>
+            <% if (ctx.session.sessionProject.page_show.openChangeRevise) { %>
             <div class="ml-auto">
-                <a class="btn btn-sm btn-primary mr-1" id="select-all-revise" href="javascript: void(0);">添加当前新增部位/清单</a>
+                <a class="btn btn-sm btn-primary mr-1" id="add-all-revise" href="javascript: void(0);">添加当前新增部位/清单</a>
             </div>
+            <% } %>
         </div>
     </div>
     <div class="content-wrap row pr-46">