瀏覽代碼

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

Tony Kang 10 月之前
父節點
當前提交
cba223568f
共有 4 個文件被更改,包括 61 次插入24 次删除
  1. 1 0
      app/controller/change_controller.js
  2. 17 23
      app/lib/rpt_data_analysis.js
  3. 40 0
      app/public/js/change_revise.js
  4. 3 1
      app/service/stage_audit.js

+ 1 - 0
app/controller/change_controller.js

@@ -1733,6 +1733,7 @@ module.exports = app => {
                     default:
                         throw '未知操作';
                 }
+                responseData.data.changeList = await ctx.service.changeAuditList.getList(ctx.change.cid);
                 ctx.body = responseData;
             } catch (err) {
                 console.log(err);

+ 17 - 23
app/lib/rpt_data_analysis.js

@@ -1556,15 +1556,13 @@ const loadCooperationData = {
         }
     },
     _loadImCooperationData(ctx, data, options, csRela) {
-        let coSignOrder = [];
+        const coSignInfo = [];
         if (csRela && csRela.tplDefine && csRela.tplDefine.audit_select && csRela.cDefine && csRela.cDefine.audit_select) {
             if (csRela.cDefine.audit_select) {
                 for (const asc of csRela.cDefine.audit_select) {
-                    coSignOrder.push(asc.order);
+                    coSignInfo.push({ aid: asc.aid, order: asc.order });
                 }
             }
-        } else {
-            coSignOrder = options.co_sign || [];
         }
 
         const stageCooperation = [];
@@ -1609,21 +1607,18 @@ const loadCooperationData = {
 
     },
     _loadImAssistData(ctx, data, options, csRela) {
-        let coSignOrder = [];
+        const coSignInfo = [];
         if (csRela && csRela.tplDefine && csRela.tplDefine.audit_select && csRela.cDefine && csRela.cDefine.audit_select) {
             if (csRela.cDefine.audit_select) {
                 for (const asc of csRela.cDefine.audit_select) {
-                    coSignOrder.push(asc.order);
+                    coSignInfo.push({ aid: asc.aid, order: asc.order });
                 }
             }
-        } else {
-            coSignOrder = options.co_sign || [];
         }
 
-        const stageAuditAss = [];
         let finish = true;
         for (const sa of data.stage_audit) {
-            if (sa.end_time) stageAuditAss.push(data.mem_stage_audit_ass.filter(x => { return x.user_id === sa.aid; }));
+            if (sa.end_time) sa.ass = data.mem_stage_audit_ass.filter(x => { return x.user_id === sa.aid; });
             if (finish && !sa.end_time) finish = false;
         }
 
@@ -1631,19 +1626,18 @@ const loadCooperationData = {
             const bills = data.mem_stage_bills.find(x => { return x.id === d.lid; });
             const relaId = bills ? bills.full_path.split('-').reverse() : [];
 
-            d.ass = [];
-            for (const [i, sa] of data.stage_audit.entries()) {
-                const co = this._findStageAuditAss(relaId, stageAuditAss[i], sa);
-                d.ass.push(co);
-            }
-
-            for (const [i, cs] of coSignOrder.entries()) {
-                if (data.stage_audit[cs] && data.stage_audit[cs].end_time) {
-                    d['co_sign' + (i + 1)] = this._completeSign(d.ass[cs] || data.stage_audit[cs]);
-                    d['co_opinion' + (i + 1)] = data.stage_audit[cs].opinion || '';
-                    d['co_time' + (i + 1)] = data.stage_audit[cs].end_time;
-                    d['co_name' + (i + 1)] = d.ass[cs] ? d.ass[cs].name : data.stage_audit[cs].name;
-                    d['co_company' + (i + 1)] = d.ass[cs] ? d.ass[cs].company : data.stage_audit[cs].company;
+            for (const [i, cs] of coSignInfo.entries()) {
+                const sa = data.stage_audit.find(x => {
+                    if (x.aid !== undefined) return x.aid === cs.aid && x.order === cs.order;
+                    return x.order === cs.order;
+                });
+                if (sa && sa.end_time) {
+                    const co = this._findStageAuditAss(relaId, sa.ass, sa);
+                    d['co_sign' + (i + 1)] = this._completeSign(co || sa);
+                    d['co_opinion' + (i + 1)] = sa.opinion || '';
+                    d['co_time' + (i + 1)] = sa.end_time;
+                    d['co_name' + (i + 1)] = co ? co.name : sa.name;
+                    d['co_company' + (i + 1)] = co ? co.company : sa.company;
                 }
             }
         }

+ 40 - 0
app/public/js/change_revise.js

@@ -565,6 +565,7 @@ $(document).ready(() => {
                             count: type === 'add' ? addCount : count,
                         }
                     }, function (result) {
+                        changeList = result.changeList;
                         const refreshData = tree.loadPostData(result);
                         self.refreshTree(sheet, refreshData);
                         const sel = sheet.getSelections()[0];
@@ -583,6 +584,7 @@ $(document).ready(() => {
                         count: type === 'add' ? addCount : count,
                     }
                 }, function (result) {
+                    changeList = result.changeList;
                     const refreshData = tree.loadPostData(result);
                     self.refreshTree(sheet, refreshData);
                     if (['up-move', 'down-move'].indexOf(type) > -1) {
@@ -783,6 +785,7 @@ $(document).ready(() => {
                 }
                 // 更新至服务器
                 postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
+                    changeList = result.changeList;
                     const refreshNode = billsTree.loadPostData(result);
                     billsTreeSpreadObj.refreshTree(info.sheet, refreshNode);
                 });
@@ -921,6 +924,7 @@ $(document).ready(() => {
             }
             if (datas.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
+                    changeList = result.changeList;
                     const refreshNode = tree.loadPostData(result);
                     if (refreshNode.update) {
                         refreshNode.update = refreshNode.update.concat(filterNodes);
@@ -1017,6 +1021,7 @@ $(document).ready(() => {
             }
             if (datas.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
+                    changeList = result.changeList;
                     const refreshNode = tree.loadPostData(result);
                     if (refreshNode.update) {
                         refreshNode.update = refreshNode.update.concat(filterNodes);
@@ -1058,6 +1063,7 @@ $(document).ready(() => {
             }
             if (datas.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
+                    changeList = result.changeList;
                     const refreshNode = sheet.zh_tree.loadPostData(result);
                     billsTreeSpreadObj.refreshTree(sheet, refreshNode);
                     billsTreeSpreadObj.loadExprToInput(sheet);
@@ -1081,6 +1087,7 @@ $(document).ready(() => {
                     block: copyInfo.block,
                 }
             }, function (data) {
+                changeList = data.changeList;
                 pos.updateDatas(data.pos);
                 const result = tree.loadPostData(data.ledger);
                 self.refreshTree(sheet, result);
@@ -1176,6 +1183,7 @@ $(document).ready(() => {
             if (datas.length > 0) {
                 callback();
                 postData(window.location.pathname + '/update', {postType: 'update', postData: datas}, function (result) {
+                    changeList = result.changeList;
                     const refreshNode = sheet.zh_tree.loadPostData(result);
                     billsTreeSpreadObj.refreshTree(sheet, refreshNode);
                 });
@@ -1207,6 +1215,7 @@ $(document).ready(() => {
             recursiveSortCode(data, select.code, select.children);
             if (data.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
+                    changeList = result.changeList;
                     const refreshNode = tree.loadPostData(result);
                     billsTreeSpreadObj.refreshTree(sheet, refreshNode);
                 })
@@ -1273,6 +1282,7 @@ $(document).ready(() => {
 
             // 更新至服务器
             postData(window.location.pathname + '/update', {postType: 'update', postData: data}, function (result) {
+                changeList = result.changeList;
                 const refreshNode = billsTree.loadPostData(result);
                 billsTreeSpreadObj.refreshTree(billsSheet, refreshNode);
             });
@@ -1721,6 +1731,7 @@ $(document).ready(() => {
             }
             if (data.postData.length > 0) {
                 postData(window.location.pathname + '/update', data, function (result) {
+                    changeList = result.changeList;
                     if (type === 'delete') {
                         pos.removeDatas(result.pos);
                         sheet.deleteRows(row, count);
@@ -1960,6 +1971,7 @@ $(document).ready(() => {
                 }
             }
             postData(window.location.pathname + '/update', data, function (result) {
+                changeList = result.changeList;
                 const updateRst = pos.updateDatas(result.pos);
                 // 刷新当前行, 不适用于新增(在非下一空白行新增)
                 if (updateRst.create.length > 0) {
@@ -1968,6 +1980,15 @@ $(document).ready(() => {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                 }
                 const loadResult = billsTree.loadPostData(result.ledger);
+                // 判断是否只剩一个,并同步去勾
+                const billsNode = SpreadJsObj.getSelectObject(billsSheet);
+                billsNode.is_change = _.findIndex(changeList, { gcl_id: billsNode.id }) > -1 ? 1 : 0;
+                if (loadResult.update) {
+                    const r = _.find(loadResult.update, { id: billsNode.id });
+                    r.is_change = billsNode.is_change;
+                } else {
+                    loadResult.update = [billsNode];
+                }
                 billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
                 billsTreeSpreadObj.refreshOperationValid(billsSheet);
             }, function () {
@@ -2019,6 +2040,7 @@ $(document).ready(() => {
             }
             if (datas.length > 0) {
                 postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'update', postData: datas}, function (result) {
+                    changeList = result.changeList;
                     pos.updateDatas(result.pos);
                     posSpreadObj.loadCurPosData();
                     const loadResult = billsTree.loadPostData(result.ledger);
@@ -2058,9 +2080,19 @@ $(document).ready(() => {
             }
             if (data.postData.length > 0) {
                 postData(window.location.pathname + '/update', data, function (result) {
+                    changeList = result.changeList;
                     pos.removeDatas(result.pos);
                     sheet.deleteRows(row, count);
                     const loadResult = billsTree.loadPostData(result.ledger);
+                    // 判断是否只剩一个,并同步去勾
+                    const billsNode = SpreadJsObj.getSelectObject(billsSheet);
+                    billsNode.is_change = _.findIndex(changeList, { gcl_id: billsNode.id }) > -1 ? 1 : 0;
+                    if (loadResult.update) {
+                        const r = _.find(loadResult.update, { id: billsNode.id });
+                        r.is_change = billsNode.is_change;
+                    } else {
+                        loadResult.update = [billsNode];
+                    }
                     billsTreeSpreadObj.refreshTree(billsSheet, loadResult);
                     billsTreeSpreadObj.refreshOperationValid(billsSheet);
                 });
@@ -2170,6 +2202,7 @@ $(document).ready(() => {
                 return;
             }
             postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'paste', postData: data}, function (result) {
+                changeList = result.changeList;
                 pos.updateDatas(result.pos);
                 posSpreadObj.loadCurPosData();
                 const loadResult = billsTree.loadPostData(result.ledger);
@@ -2195,6 +2228,7 @@ $(document).ready(() => {
             pegs.forEach(function (p) {p.porder = ++order; p.lid = node.id});
 
             postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'paste', postData: pegs}, function (result) {
+                changeList = result.changeList;
                 pos.updateDatas(result.pos);
                 posSpreadObj.loadCurPosData();
                 billsTreeSpreadObj.refreshOperationValid(billsSheet);
@@ -2240,6 +2274,7 @@ $(document).ready(() => {
 
             // 更新至服务器
             postData(window.location.pathname + '/update', {postType: 'pos', posPostType: 'update', postData: data}, function (result) {
+                changeList = result.changeList;
                 const updateRst = pos.updateDatas(result.pos);
                 // 刷新当前行, 不适用于新增(在非下一空白行新增)
                 SpreadJsObj.reLoadRowData(posSheet, row);
@@ -2378,6 +2413,7 @@ $(document).ready(() => {
                             }
                         },
                     }, function (result) {
+                        changeList = result.changeList;
                         const refreshData = mainTree.loadPostData(result);
                         billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
                         const sel = mainSheet.getSelections()[0];
@@ -2575,6 +2611,7 @@ $(document).ready(() => {
                             postType: 'batch-insert',
                             postData: insertData
                         }, function (data) {
+                            changeList = result.changeList;
                             pos.updateDatas(data.pos);
                             const result = billsTree.loadPostData(data.ledger);
                             billsTreeSpreadObj.refreshTree(billsSheet, result);
@@ -2787,6 +2824,7 @@ $(document).ready(() => {
                             }
                         },
                     }, function (result) {
+                        changeList = result.changeList;
                         const refreshData = mainTree.loadPostData(result);
                         billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
                         const sel = mainSheet.getSelections()[0];
@@ -3012,6 +3050,7 @@ $(document).ready(() => {
                             dealBills: oneBills,
                         },
                     }, function (result) {
+                        changeList = result.changeList;
                         const refreshData = mainTree.loadPostData(result);
                         billsTreeSpreadObj.refreshTree(mainSheet, refreshData);
                         const sel = mainSheet.getSelections()[0];
@@ -3322,6 +3361,7 @@ $(document).ready(() => {
                 stdNode: stdTree.getNodeKey(stdNode)
             }
         }, function (result) {
+            changeList = result.changeList;
             const refreshNode = mainTree.loadPostData(result);
             billsTreeSpreadObj.refreshTree(mainSheet, refreshNode);
             if (sel) {

+ 3 - 1
app/service/stage_audit.js

@@ -2015,13 +2015,15 @@ module.exports = app => {
 
         async getFinalAuditGroup(stageId, times) {
             const sql =
-                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`, la.`times`, la.`sid`, Max(la.`order`) as max_order ' +
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`,' +
+                '  la.`times`, la.`sid`, la.`audit_order`, la.`audit_type`, Max(la.`order`) as max_order ' +
                 '  FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id`' +
                 '  WHERE la.`sid` = ? and la.`times` = ? GROUP BY la.`aid` ORDER BY la.`order`';
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, times];
             const result = await this.db.query(sql, sqlParam);
             for (const r of result) {
                 const auditor = await this.getDataByCondition({sid: stageId, times: r.times, order: r.max_order});
+                r.order = auditor.order;
                 r.status = auditor.status;
                 r.opinion = auditor.opinion;
                 r.begin_time = auditor.begin_time;