Browse Source

变更页更新升降级数据影响

laiguoran 3 years ago
parent
commit
2cc2c57d31

+ 35 - 0
app/public/js/change_information_set.js

@@ -1005,11 +1005,13 @@ function tableDataRemake(changeListData) {
     if (changeList.length > 0 && changeList[0]) {
         const removeList = [];
         const updateList = [];
+        const updateGclIdList = [];
         for (const [index,clinfo] of changeList.entries()) {
             if (clinfo.lid != 0) {
                 let listinfo = changeListData.find(function (item) {
                     return (item.id !== undefined && item.id == clinfo.lid) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo.lid);
                 });
+                let info = '';
                 if (listinfo === undefined || (clinfo.lid && clinfo.gcl_id && clinfo.lid !== clinfo.gcl_id)) {
                     // 有可能这部分台账发生变化,此时要更新清单lid信息,防止数据丢失
                     const newlistinfo = changeListData.find(function (item) {
@@ -1042,6 +1044,7 @@ function tableDataRemake(changeListData) {
                             return flag;
                         });
                         if (leafInfo) {
+                            info = leafInfo;
                             pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
                                 (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
                                 (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
@@ -1078,6 +1081,7 @@ function tableDataRemake(changeListData) {
                             return flag;
                         });
                         if (leafInfo) {
+                            info = leafInfo;
                             pushbwmx = leafInfo.code + '!_!' + (leafInfo.jldy !== undefined ? leafInfo.jldy : '') + '!_!' +
                                 (leafInfo.dwgc ? leafInfo.dwgc : '') + '!_!' +
                                 (leafInfo.fbgc ? leafInfo.fbgc : '') + '!_!' +
@@ -1104,9 +1108,40 @@ function tableDataRemake(changeListData) {
                         $('#table-list-select tr[data-lid="'+ clinfo.lid +'"]').attr('data-bwmx', pushbwmx);
                     }
                 }
+
+                if (info && _.findIndex(changeLedgerList, { id: clinfo.gcl_id }) !== -1) {
+                    // 可能因为升降级关系:细目,分部分项等会发生变化,更新清单
+                    const updateInfo = {};
+                    if (info.code !== clinfo.xmj_code) {
+                        updateInfo.xmj_code = info.code;
+                        changeList[index].xmj_code = info.code;
+                    }
+                    if (info.jldy !== clinfo.xmj_jldy) {
+                        updateInfo.xmj_jldy = info.jldy;
+                        changeList[index].xmj_jldy = info.jldy;
+                    }
+                    if (info.dwgc !== clinfo.xmj_dwgc) {
+                        updateInfo.xmj_dwgc = info.dwgc;
+                        changeList[index].xmj_dwgc = info.dwgc;
+                    }
+                    if (info.fbgc !== clinfo.xmj_fbgc) {
+                        updateInfo.xmj_fbgc = info.fbgc;
+                        changeList[index].xmj_fbgc = info.fbgc;
+                    }
+                    if (info.fxgc !== clinfo.xmj_fxgc) {
+                        updateInfo.xmj_fxgc = info.fxgc;
+                        changeList[index].xmj_fxgc = info.fxgc;
+                    }
+                    if (!_.isEmpty(updateInfo) && _.indexOf(updateGclIdList, clinfo.gcl_id) === -1) {
+                        updateGclIdList.push(clinfo.gcl_id);
+                        // updateInfo.gcl_id = info.id;
+                        updateList.push({ row: updateInfo, where: { tid: tenderId, gcl_id: clinfo.gcl_id } });
+                    }
+                }
             }
         }
         if(updateList.length > 0) {
+            console.log(updateList);
             postData(window.location.pathname + '/save', { type:'update_list', updateData: updateList }, function (result) {
             }, function () {
             });

+ 0 - 3
app/service/change_ledger.js

@@ -1117,9 +1117,6 @@ module.exports = app => {
                 this.clearParentingData(updateData2);
                 await this.transaction.update(this.tableName, updateData2);
                 await this._deleteChangeAuditListData(mid, [pre]);
-                // if (selects) {
-                //     throw '阻断';
-                // }
                 await this.transaction.commit();
                 this.transaction = null;
             } catch (err) {

+ 1 - 0
app/view/change/information.ejs

@@ -384,6 +384,7 @@
 </div>
 <script>
     const tenderName = '<%- tender.name %>';
+    const tenderId = '<%- tender.id %>';
     const totalPriceUnit = '<%- tpUnit %>';
     const unitPriceUnit = '<%- upUnit %>';
     const accountId = parseInt('<%- ctx.session.sessionUser.accountId %>');