Quellcode durchsuchen

形象进度一些修正

laiguoran vor 4 Jahren
Ursprung
Commit
cf768b802e

+ 65 - 6
app/controller/schedule_controller.js

@@ -157,16 +157,18 @@ module.exports = app => {
             const tender = ctx.tender;
             const schedule = await ctx.service.schedule.getDataByCondition({ tid: tender.id });
             const scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'asc']] });
-            const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id }, orders: [['order', 'desc']] });
-            const curScheduleStage = scheduleStage.length > 0 ? _.maxBy(scheduleStage, 'order') : null;
+            // const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id }, orders: [['order', 'desc']] });
+            const gclScheduleMonth = _.filter(scheduleMonth, { stage_gcl_used: 1 });
+            const curScheduleMonth = scheduleMonth.length > 0 ? _.maxBy(gclScheduleMonth, 'yearmonth') : null;
             const renderData = {
                 tender: tender.data,
                 tenderInfo: tender.info,
                 schedule,
                 scheduleMonth,
                 measureType,
-                scheduleStage,
-                curScheduleStage,
+                // scheduleStage,
+                curScheduleMonth,
+                gclScheduleMonth,
                 scheduleLedgerList: await this._getSelectedLedgerList(ctx),
                 revising: await this._getLastReviseStatus(ctx),
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.schedule.stageGcl),
@@ -195,6 +197,25 @@ module.exports = app => {
                 ctx.body = { err: 1, msg: err.toString(), data: [] };
             }
         }
+        /**
+         * 获取工程量模式下台账数据(Ajax)
+         *
+         * @param ctx
+         * @return {Promise<void>}
+         */
+        async loadGclLedgerData(ctx) {
+            try {
+                const ledgerData = await ctx.service.ledger.getData(ctx.tender.id);
+                const postData = { ledgerData };
+                const { slmList, nextSlmList, endSlmList, yearSlmList } = await this._getGclAndPlanData(ctx);
+                _.assignIn(postData, { slmList, nextSlmList, endSlmList, yearSlmList });
+                ctx.body = { err: 0, msg: '', data: postData };
+            } catch (err) {
+                this.log(err);
+                ctx.body = { err: 1, msg: err.toString(), data: [] };
+            }
+        }
+
 
         /**
          * 获取所有期下台账数据(Ajax)
@@ -271,8 +292,8 @@ module.exports = app => {
             const tender = ctx.tender;
             const scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'asc']] });
             const stageOrderList = await ctx.service.stage.getAllDataByCondition({ columns: ['id', 's_time', 'order'], where: { tid: tender.id } });
-            const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id }, orders: [['order', 'desc']] });
-            let curScheduleStage = scheduleStage.length > 0 ? _.maxBy(scheduleStage, 'order') : null;
+            const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'desc']] });
+            let curScheduleStage = scheduleStage.length > 0 ? _.maxBy(scheduleStage, 'yearmonth') : null;
             if (ctx.params.order && scheduleStage.length > 0) {
                 curScheduleStage = _.find(scheduleStage, { order: parseInt(ctx.params.order) });
             }
@@ -313,6 +334,44 @@ module.exports = app => {
         }
 
         /**
+         * 获取工程量模式汇总下台账的计划数据(Ajax)
+         *
+         * @param ctx
+         * @return {Promise<void>}
+         */
+        async _getGclAndPlanData(ctx) {
+            const tender = ctx.tender;
+            const scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'asc']] });
+            let curScheduleMonth = scheduleMonth.length > 0 ? _.maxBy(scheduleMonth, 'order') : null;
+            const gclScheduleMonth = _.filter(scheduleMonth, { stage_gcl_used: 1 });
+            if (ctx.params.order && gclScheduleMonth.length > 0) {
+                curScheduleMonth = _.find(gclScheduleMonth, { id: parseInt(ctx.params.order) });
+            }
+            let slmList = [];
+            let nextSlmList = [];
+            let endSlmList = [];
+            let yearSlmList = [];
+            if (curScheduleMonth) {
+                const newSM = _.sortBy(scheduleMonth, 'yearmonth');
+                const nowScheduleMonth = _.findIndex(newSM, { yearmonth: curScheduleMonth.yearmonth });
+                slmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: curScheduleMonth.yearmonth } });
+                const nextScheduleMonth = nowScheduleMonth >= 0 && nowScheduleMonth + 1 <= newSM.length - 1 ? newSM[nowScheduleMonth + 1] : null;
+                if (nextScheduleMonth) nextSlmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: nextScheduleMonth.yearmonth } });
+                if (nowScheduleMonth === 0) {
+                    endSlmList = slmList;
+                } else if (nowScheduleMonth > 0) {
+                    const endYearmonthCollection = _.map(_.take(newSM, nowScheduleMonth + 1), 'yearmonth');
+                    endSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, endYearmonthCollection);
+                }
+                const yearConllection = _.map(_.filter(newSM, function(item) {
+                    return item.yearmonth.indexOf(curScheduleMonth.yearmonth.split('-')[0]) !== -1;
+                }), 'yearmonth');
+                yearSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, yearConllection);
+            }
+            return { slmList, nextSlmList, endSlmList, yearSlmList, scheduleMonth, curScheduleMonth };
+        }
+
+        /**
          * 获取台账数据(Ajax)
          *
          * @param ctx

+ 110 - 57
app/public/js/schedule_stage_gcl.js

@@ -200,6 +200,27 @@ $(function () {
                 }
             });
         },
+        reCalcHuizong: function(row, yearmonth, orgValue, validText) {
+            // 下方汇总sjs实时更新计量数据
+            // 先判断当前修改月份与汇总sjs月份是否一致或更大,获取修改的对应台账行
+            const huizongSelect = SpreadJsObj.getRowObject(huizongSpread.getActiveSheet(), row);
+            if (yearmonth.split('-')[0] === curScheduleMonth.yearmonth.split('-')[0]) {
+                huizongSelect.year_sj_gcl = ZhCalc.add(ZhCalc.sub(huizongSelect.year_sj_gcl, orgValue), validText);
+                huizongSelect.year_sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.year_sj_gcl, huizongSelect.dgn_price), 0) : 0;
+            }
+            if (yearmonth === curScheduleMonth.yearmonth) {
+                // 判断是否同年同月,是则修改本年,截至本月,本月计量数据,否则只修改截至本月计量数据
+                huizongSelect.sj_gcl = validText;
+                huizongSelect.sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.sj_gcl, huizongSelect.dgn_price), 0) : 0;
+            }
+            if (yearmonth <= curScheduleMonth.yearmonth) {
+                huizongSelect.end_sj_gcl = ZhCalc.add(ZhCalc.sub(huizongSelect.end_sj_gcl, orgValue), validText);
+                huizongSelect.end_sj_tp = huizongSelect.dgn_price && huizongSelect.dgn_price !== 0 ? ZhCalc.round(ZhCalc.mul(huizongSelect.end_sj_gcl, huizongSelect.dgn_price), 0) : 0;
+            }
+            const nodes = treeCalc.calculateParent(huizongSpread.getActiveSheet().zh_tree, huizongSelect);
+            const refreshNode = huizongTree.loadPostData({update: nodes});
+            huizongObj.refreshTree(huizongSpread.getActiveSheet(), refreshNode);
+        },
         editEnded: function (e, info) {
             if (info.sheet.zh_setting) {
                 const select = SpreadJsObj.getSelectObject(info.sheet);
@@ -239,6 +260,7 @@ $(function () {
                     const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
                     const refreshNode = ledgerTree.loadPostData({update: nodes});
                     ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
+                    ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
                 },function () {
                     select[col.field] = orgValue;
                     const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
@@ -279,6 +301,7 @@ $(function () {
                     const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
                     const refreshNode = ledgerTree.loadPostData({update: nodes});
                     ledgerSpreadObj.refreshTree(sheet, refreshNode);
+                    ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
                 },function () {
                     select[col.field] = orgValue;
                     const nodes = treeCalc.calculateParent(sheet.zh_tree, select);
@@ -336,6 +359,7 @@ $(function () {
                 const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
                 const refreshNode = ledgerTree.loadPostData({update: nodes});
                 ledgerSpreadObj.refreshTree(info.sheet, refreshNode);
+                ledgerSpreadObj.reCalcHuizong(info.row, yearmonth, orgValue, validText);
             },function () {
                 select[col.field] = orgValue;
                 const nodes = treeCalc.calculateParent(info.sheet.zh_tree, select);
@@ -362,7 +386,7 @@ $(function () {
         calcFun: function (node) {
             node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
         },
-        calcFields: ['plan_tp', 'next_plan_tp', 'end_plan_tp', 'year_plan_tp', 'total_price', 'end_gather_tp', 'year_gather_tp', 'gather_tp'],
+        calcFields: ['plan_tp', 'next_plan_tp', 'end_plan_tp', 'year_plan_tp', 'total_price', 'end_sj_tp', 'year_sj_tp', 'sj_tp'],
     };
 
     const huizong_static_cols = [
@@ -374,14 +398,16 @@ $(function () {
         {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '自开工至本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '截止本月完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_gather_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
+        {title: '截止本月完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'end_sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
+        {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'end_sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '本年计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_contract_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
+        {title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'year_sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
+        {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'year_sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
+        {title: '本月计量完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'sj_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
+        {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'sj_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '下月计划|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'next_plan_gcl', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(元)', colSpan: '|1', rowSpan: '|1', field: 'next_plan_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
     ];
@@ -408,17 +434,65 @@ $(function () {
     huizongSpread.getActiveSheet().frozenColumnCount(6);
     huizongSpread.getActiveSheet().options.frozenlineColor = '#93b5e4';
 
+    let huizongTree = '';
+
     const huizongObj = {
+        refreshTree: function (sheet, data) {
+            SpreadJsObj.massOperationSheet(sheet, function () {
+                const tree = sheet.zh_tree;
+                // 处理删除
+                if (data.delete) {
+                    data.delete.sort(function (x, y) {
+                        return y.deleteIndex - x.deleteIndex;
+                    });
+                    for (const d of data.delete) {
+                        sheet.deleteRows(d.deleteIndex, 1);
+                    }
+                }
+                // 处理新增
+                if (data.create) {
+                    const newNodes = data.create;
+                    if (newNodes) {
+                        newNodes.sort(function (a, b) {
+                            return a.index - b.index;
+                        });
+
+                        for (const node of newNodes) {
+                            sheet.addRows(node.index, 1);
+                            SpreadJsObj.reLoadRowData(sheet, tree.nodes.indexOf(node), 1);
+                        }
+                    }
+                }
+                // 处理更新
+                if (data.update) {
+                    const rows = [];
+                    for (const u of data.update) {
+                        rows.push(tree.nodes.indexOf(u));
+                    }
+                    SpreadJsObj.reLoadRowsData(sheet, rows);
+                }
+                // 处理展开
+                if (data.expand) {
+                    const expanded = [];
+                    for (const e of data.expand) {
+                        if (expanded.indexOf(e) === -1) {
+                            const posterity = tree.getPosterity(e);
+                            for (const p of posterity) {
+                                sheet.setRowVisible(tree.nodes.indexOf(p), p.visible);
+                                expanded.push(p);
+                            }
+                        }
+                    }
+                }
+            });
+        },
         setSjs: function (order) {
-            postData('/tender/' + getTenderId() + '/schedule/stage/' + order + '/load', {filter: 'gcl' }, function (data) {
-                const calcList = ['year_gather_tp',
-                    'contract_tp', 'qc_qty', 'qc_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
-                    'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
+            postData('/tender/' + getTenderId() + '/schedule/stage/gcl/' + order + '/load', {}, function (data) {
+                const calcList = ['total_price'];
                 const showList = ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_tp',
-                    'year_contract_qty', 'year_gather_tp',
-                    'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
-                    'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
-                    'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
+                    'sj_gcl', 'sj_tp', 'year_sj_gcl', 'year_sj_tp', 'end_sj_gcl', 'end_sj_tp',
+                    'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
+                    'code', 'name', 'unit', 'dgn_qty1', 'dgn_qty2', 'dgn_price', 'quantity', 'total_price'];
                 const baseLedgerTreeSetting = {
                     id: 'ledger_id',
                     pid: 'ledger_pid',
@@ -428,38 +502,16 @@ $(function () {
                     fullPath: 'full_path',
                     calcFields: calcList,
                 };
-                baseLedgerTreeSetting.updateFields = ['year_contract_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
+                // baseLedgerTreeSetting.updateFields = ['year_sj_qty', 'year_gather_tp', 'contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
                 baseLedgerTreeSetting.calcFun = function (node) {
-                    if (!node.children || node.children.length === 0) {
-                        node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
-                        node.gather_qty = ZhCalc.add(node.contract_qty, node.qc_qty);
-                        node.end_contract_qty = ZhCalc.add(node.pre_contract_qty, node.contract_qty);
-                        node.end_qc_qty = ZhCalc.add(node.pre_qc_qty, node.qc_qty);
-                        node.end_gather_qty = ZhCalc.add(node.pre_gather_qty, node.gather_qty);
-                    }
-                    node.pre_gather_tp = ZhCalc.add(node.pre_contract_tp, node.pre_qc_tp);
-                    node.gather_tp = ZhCalc.add(node.contract_tp, node.qc_tp);
-                    node.end_contract_tp = ZhCalc.add(node.pre_contract_tp, node.contract_tp);
-                    node.end_qc_tp = ZhCalc.add(node.pre_qc_tp, node.qc_tp);
-                    node.end_gather_tp = ZhCalc.add(node.pre_gather_tp, node.gather_tp);
-                    node.end_final_tp = ZhCalc.add(node.end_qc_tp, node.total_price);
-                    if (!node.children || node.children.length === 0) {
-                        if (node.end_contract_qty) {
-                            node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
-                        } else {
-                            node.end_correct_tp = node.end_gather_tp;
-                        }
-                    }
-                    node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
-                    node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
-                    node.final_dgn_price = ZhCalc.round(ZhCalc.div(node.end_gather_tp, ZhCalc.add(node.deal_dgn_qty1, node.c_dgn_qty1)), tenderInfo.decimal.up);
                     node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
                 };
                 const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
-                const newLedgerList = setTpMonthToLedger(data.ledgerData, data.slmList, data.nextSlmList, data.endSlmList, data.yearSlmList, data.curYearStageData);
+                console.log(data.slmList);
+                const newLedgerList = setGclMonthToLedger(data.ledgerData, data.slmList, data.nextSlmList, data.endSlmList, data.yearSlmList);
                 baseLedgerTree.loadDatas(newLedgerList);
                 treeCalc.calculateAll(baseLedgerTree);
-                const huizongTree = createNewPathTree('filter', huizongTreeSetting);
+                huizongTree = createNewPathTree('filter', huizongTreeSetting);
                 for (const d of baseLedgerTree.nodes) {
                     if (!d.b_code) {
                         const one = _.find(selectedLedgerList, function (item) {
@@ -474,26 +526,29 @@ $(function () {
                 treeCalc.calculateAll(huizongTree);
                 console.log(huizongTree);
                 SpreadJsObj.loadSheetData(huizongSpread.getActiveSheet(), SpreadJsObj.DataType.Tree, huizongTree);
+                // huizongSpread.refresh();
             }, null, true);
         },
         dropDownHtml: function (order) {
             let html = '';
-            for (const ss of scheduleStage) {
-                if (ss.order !== order) {
-                    html += '<a class="dropdown-item change-tp" data-order="'+ ss.order +'" href="javascript:void(0);">'+ ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月(第'+ ss.order +'期)</a>';
+            for (const ss of gclScheduleMonth) {
+                if (ss.id !== order) {
+                    html += '<a class="dropdown-item change-tp" data-order="'+ ss.id +'" href="javascript:void(0);">'+ ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月</a>';
                 } else {
-                    $('#stageDropdownMenuButton').text(ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月(第'+ ss.order +'期)');
+                    $('#stageDropdownMenuButton').text(ss.yearmonth.split('-')[0] + '年' + parseInt(ss.yearmonth.split('-')[1]) +'月');
                 }
             }
             $('#stageDropdownMenu').html(html);
         }
     };
 
-    if (curScheduleStage && curScheduleStage.order) {
-        let order = parseInt(localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') ? localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') : curScheduleStage.order);
-        const ssinfo = _.find(scheduleStage, { order });
+    if (curScheduleMonth && curScheduleMonth.id) {
+        let order = parseInt(localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') ? localStorage.getItem('tender_' + getTenderId() + '_schedule_tp_sjs') : curScheduleMonth.id);
+        const ssinfo = _.find(gclScheduleMonth, { id: order });
         if (!ssinfo) {
-            order = curScheduleStage.order;
+            order = curScheduleMonth.id;
+        } else {
+            curScheduleMonth = ssinfo;
         }
         huizongObj.dropDownHtml(order);
         huizongObj.setSjs(order);
@@ -505,6 +560,7 @@ $(function () {
         huizongObj.dropDownHtml(order);
         huizongObj.setSjs(order);
         localStorage.setItem('tender_' + getTenderId() + '_schedule_tp_sjs', order);
+        curScheduleMonth = _.find(gclScheduleMonth, { id: order });
     });
 
     // 月份添加
@@ -616,13 +672,15 @@ function setMonthToLedger(ledgerList, slm) {
     }
     return ledgerList;
 }
-function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedgerData) {
+function setGclMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm) {
     if (slm.length > 0) {
         for(const s of slm) {
             const index = _.findIndex(ledgerList, { 'ledger_id': s.lid });
             if (index && index !== -1) {
                 ledgerList[index].plan_tp = s.plan_tp;
                 ledgerList[index].plan_gcl = s.plan_gcl;
+                ledgerList[index].sj_tp = s.sj_tp;
+                ledgerList[index].sj_gcl = s.sj_gcl;
             }
         }
     }
@@ -641,6 +699,8 @@ function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedge
             if (index && index !== -1) {
                 ledgerList[index].end_plan_tp = es.plan_tp;
                 ledgerList[index].end_plan_gcl = es.plan_gcl;
+                ledgerList[index].end_sj_tp = es.sj_tp;
+                ledgerList[index].end_sj_gcl = es.sj_gcl;
             }
         }
     }
@@ -650,15 +710,8 @@ function setTpMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm, yearLedge
             if (index && index !== -1) {
                 ledgerList[index].year_plan_tp = ys.plan_tp;
                 ledgerList[index].year_plan_gcl = ys.plan_gcl;
-            }
-        }
-    }
-    if (yearLedgerData.length > 0) {
-        for (const yl of yearLedgerData) {
-            const index = _.findIndex(ledgerList, {'id': yl.lid});
-            if (index && index !== -1) {
-                ledgerList[index].year_contract_qty = ZhCalc.add(yl.contract_qty, yl.qc_qty);
-                ledgerList[index].year_gather_tp = ZhCalc.add(yl.contract_tp, yl.qc_tp);
+                ledgerList[index].year_sj_tp = ys.sj_tp;
+                ledgerList[index].year_sj_gcl = ys.sj_gcl;
             }
         }
     }

+ 1 - 0
app/router.js

@@ -450,6 +450,7 @@ module.exports = app => {
     app.get('/tender/:id/schedule/stage/gcl', sessionAuth, tenderCheck, uncheckTenderCheck, 'scheduleController.stageGcl');
     app.post('/tender/:id/schedule/stage/gcl/save', sessionAuth, tenderCheck, uncheckTenderCheck, 'scheduleController.saveStageGcl');
     app.post('/tender/:id/schedule/stage/:order/load', sessionAuth, tenderCheck, uncheckTenderCheck, 'scheduleController.loadTpLedgerData');
+    app.post('/tender/:id/schedule/stage/gcl/:order/load', sessionAuth, tenderCheck, uncheckTenderCheck, 'scheduleController.loadGclLedgerData');
 
     // 书签
     app.post('/tender/:id/ledger/tag', sessionAuth, tenderCheck, uncheckTenderCheck, 'tenderController.billsTag');

+ 1 - 1
app/service/schedule_ledger_month.js

@@ -116,7 +116,7 @@ module.exports = app => {
         }
 
         async getConllectionList(tid, yearmonthArray) {
-            const sql = 'SELECT tid, lid, SUM(`plan_gcl`) as plan_gcl, SUM(`plan_tp`) as plan_tp' +
+            const sql = 'SELECT tid, lid, SUM(`plan_gcl`) as plan_gcl, SUM(`plan_tp`) as plan_tp, SUM(`sj_gcl`) as sj_gcl, SUM(`sj_tp`) as sj_tp' +
                 ' FROM ?? WHERE `tid` = ? AND `yearmonth` in (?) GROUP BY `lid`';
             const sqlParam = [this.tableName, tid, yearmonthArray];
             const result = await this.db.query(sql, sqlParam);

+ 7 - 7
app/view/schedule/stage_gcl.ejs

@@ -35,16 +35,16 @@
                             <a class="nav-link active" data-toggle="tab" href="#huizong" role="tab">汇总</a>
                         </li>
                         <li class="nav-item">
-                            <% if (scheduleStage.length > 0) { %>
+                            <% if (gclScheduleMonth.length > 0) { %>
                                 <div class="d-inline-block ml-2">
                                     <div class="dropdown">
                                         <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="stageDropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
-                                            <%- curScheduleStage.yearmonth.split('-')[0] %>年<%- parseInt(curScheduleStage.yearmonth.split('-')[1]) %>月(第<%- curScheduleStage.order %>期)
+                                            <%- curScheduleMonth.yearmonth.split('-')[0] %>年<%- parseInt(curScheduleMonth.yearmonth.split('-')[1]) %>月
                                         </button>
                                         <div class="dropdown-menu" id="stageDropdownMenu" aria-labelledby="stageDropdownMenuButton" x-placement="bottom-start" style="position: absolute; transform: translate3d(0px, 26px, 0px); top: 0px; left: 0px; will-change: transform;">
-                                            <% for (const s of scheduleStage) { %>
-                                                <% if (s.id !== curScheduleStage.id) { %>
-                                                    <a class="dropdown-item change-tp" data-order="<%- s.order %>" href="javascript:void(0);"><%- s.yearmonth.split('-')[0] %>年<%- parseInt(s.yearmonth.split('-')[1]) %>月(第<%- s.order %>期)</a>
+                                            <% for (const s of gclScheduleMonth) { %>
+                                                <% if (s.id !== curScheduleMonth.id) { %>
+                                                    <a class="dropdown-item change-tp" data-order="<%- s.id %>" href="javascript:void(0);"><%- s.yearmonth.split('-')[0] %>年<%- parseInt(s.yearmonth.split('-')[1]) %>月</a>
                                                 <% } %>
                                             <% } %>
                                         </div>
@@ -67,7 +67,7 @@
     const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');
     const schedule = JSON.parse('<%- JSON.stringify(schedule) %>');
     const scheduleMonth = JSON.parse('<%- JSON.stringify(scheduleMonth) %>');
+    const gclScheduleMonth = JSON.parse('<%- JSON.stringify(gclScheduleMonth) %>');
     const monthList = _.map(scheduleMonth, 'yearmonth');
-    const scheduleStage = JSON.parse('<%- JSON.stringify(scheduleStage) %>');
-    const curScheduleStage = JSON.parse('<%- JSON.stringify(curScheduleStage) %>');
+    let curScheduleMonth = gclScheduleMonth.length > 0 ? JSON.parse('<%- JSON.stringify(curScheduleMonth) %>') : null;
 </script>