Browse Source

变更bug修复,金额模式部分数据

laiguoran 4 years ago
parent
commit
25b70ded59

+ 5 - 0
app/controller/change_controller.js

@@ -746,6 +746,11 @@ module.exports = app => {
                         // 取所有工料表
                         // 取所有工料表
                         responseData.data = await ctx.service.changeAuditList.getList(ctx.change.cid);
                         responseData.data = await ctx.service.changeAuditList.getList(ctx.change.cid);
                         break;
                         break;
+                    case 'remove_list':
+                        await ctx.service.changeAuditList.removeLedgerListDatas(data.updateData);
+                        // 取所有工料表
+                        responseData.data = await ctx.service.changeAuditList.getList(ctx.change.cid);
+                        break;
                     case 'info':
                     case 'info':
                         await ctx.service.change.saveInfo(data.updateData);
                         await ctx.service.change.saveInfo(data.updateData);
                         // 取所有工料表
                         // 取所有工料表

+ 30 - 3
app/controller/schedule_controller.js

@@ -77,12 +77,35 @@ module.exports = app => {
             const tender = ctx.tender;
             const tender = ctx.tender;
             const schedule = await ctx.service.schedule.getDataByCondition({ tid: tender.id });
             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 scheduleMonth = await ctx.service.scheduleMonth.getAllDataByCondition({ where: { tid: tender.id }, orders: [['yearmonth', 'asc']] });
-            const stageOrderList = await ctx.service.stage.getAllDataByCondition({ columns: ['id', 'order'], where: { tid: tender.id } });
-            const scheduleStage = await ctx.service.scheduleStage.getAllDataByCondition({ where: { tid: tender.id } });
-            let curScheduleStage = scheduleStage.length > 0 ? scheduleStage[scheduleStage.length - 1] : null;
+            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;
+            let slmList = [];
+            let nextSlmList = [];
+            let endSlmList = [];
+            let yearSlmList = [];
             if (ctx.params.order && scheduleStage.length > 0) {
             if (ctx.params.order && scheduleStage.length > 0) {
                 curScheduleStage = _.find(scheduleStage, { order: parseInt(ctx.params.order) });
                 curScheduleStage = _.find(scheduleStage, { order: parseInt(ctx.params.order) });
             }
             }
+            if (curScheduleStage) {
+                const newSS = _.sortBy(scheduleStage, 'yearmonth');
+                const nowScheduleStage = _.findIndex(newSS, { yearmonth: curScheduleStage.yearmonth });
+                slmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: curScheduleStage.yearmonth } });
+                const nextScheduleStage = nowScheduleStage >= 0 && nowScheduleStage + 1 <= newSS.length - 1 ? newSS[nowScheduleStage + 1] : null;
+                if (nextScheduleStage) nextSlmList = await ctx.service.scheduleLedgerMonth.getAllDataByCondition({ where: { tid: tender.id, yearmonth: nextScheduleStage.yearmonth } });
+                if (nowScheduleStage === 0) {
+                    endSlmList = slmList;
+                } else if (nowScheduleStage > 0) {
+                    const endYearmonthCollection = _.map(_.take(newSS, nowScheduleStage + 1), 'yearmonth');
+                    endSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, endYearmonthCollection);
+                }
+                const yearConllection = _.map(_.filter(newSS, function(item) {
+                    return item.yearmonth.indexOf(curScheduleStage.yearmonth.split('-')[0]) !== -1;
+                }), 'yearmonth');
+                yearSlmList = await ctx.service.scheduleLedgerMonth.getConllectionList(tender.id, yearConllection);
+            }
+            // 获取本年完成计量数据
+
             const renderData = {
             const renderData = {
                 tender: tender.data,
                 tender: tender.data,
                 tenderInfo: tender.info,
                 tenderInfo: tender.info,
@@ -92,6 +115,10 @@ module.exports = app => {
                 stageOrderList,
                 stageOrderList,
                 scheduleStage,
                 scheduleStage,
                 curScheduleStage,
                 curScheduleStage,
+                slmList,
+                nextSlmList,
+                endSlmList,
+                yearSlmList,
                 scheduleLedgerList: await this._getSelectedLedgerList(ctx),
                 scheduleLedgerList: await this._getSelectedLedgerList(ctx),
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.schedule.stageTp),
                 jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.schedule.stageTp),
             };
             };

+ 13 - 3
app/public/js/change_information_set.js

@@ -806,6 +806,7 @@ function tableDataRemake(changeListData) {
     $('#code-list').html('');
     $('#code-list').html('');
     // 根据已添加的清单显示
     // 根据已添加的清单显示
     if (changeList.length > 0 && changeList[0]) {
     if (changeList.length > 0 && changeList[0]) {
+        const removeList = [];
         for (const [index,clinfo] of changeList.entries()) {
         for (const [index,clinfo] of changeList.entries()) {
             if (clinfo.lid != 0) {
             if (clinfo.lid != 0) {
                 let listinfo = changeListData.find(function (item) {
                 let listinfo = changeListData.find(function (item) {
@@ -816,7 +817,8 @@ function tableDataRemake(changeListData) {
                     listinfo = changeListData[clinfo.lid - 1];
                     listinfo = changeListData[clinfo.lid - 1];
                     if (listinfo === undefined) {
                     if (listinfo === undefined) {
                         toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
                         toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
-                        changeList.splice(index, 1);
+                        // changeList.splice(index, 1);
+                        removeList.push(clinfo);
                         continue;
                         continue;
                     }
                     }
                     $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').addClass('table-success');
                     $('#table-list-select tr[data-index="'+ clinfo.lid +'"]').addClass('table-success');
@@ -835,7 +837,8 @@ function tableDataRemake(changeListData) {
                                 (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy !== undefined ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                                 (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy !== undefined ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                         } else {
                         } else {
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
-                            changeList.splice(index, 1);
+                            // changeList.splice(index, 1);
+                            removeList.push(clinfo);
                             continue;
                             continue;
                         }
                         }
                     } else {
                     } else {
@@ -865,7 +868,8 @@ function tableDataRemake(changeListData) {
                                 (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy !== undefined ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                                 (leafInfo.bwmx !== undefined ? leafInfo.bwmx : (leafInfo.jldy !== undefined ? leafInfo.jldy : '')) + '*;*' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
                         } else {
                         } else {
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
                             toastr.warning('台账清单列表已不存在'+ clinfo.code +',已更新变更清单列表');
-                            changeList.splice(index, 1);
+                            // changeList.splice(index, 1);
+                            removeList.push(clinfo);
                             continue;
                             continue;
                         }
                         }
                     } else {
                     } else {
@@ -882,6 +886,12 @@ function tableDataRemake(changeListData) {
                 }
                 }
             }
             }
         }
         }
+        if(removeList.length > 0) {
+            _.pullAll(changeList, removeList);
+            postData(window.location.pathname + '/save', { type:'remove_list', updateData: removeList }, function (result) {
+            }, function () {
+            });
+        }
     }
     }
 }
 }
 
 

+ 47 - 21
app/public/js/schedule_stage_tp.js

@@ -32,20 +32,20 @@ $(function () {
         {title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 60, type: 'Number', readOnly: true},
         {title: '经济指标', colSpan: '1', rowSpan: '2', field: 'dgn_price', hAlign: 2, width: 60, type: 'Number', readOnly: true},
         {title: '总设计|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '总设计|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '自开工至本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {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: '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: '|1', rowSpan: '|1', field: 'end_gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '本年计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', 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: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '本年累计完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '本月计划完成|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', 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: 'contract_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '本期完成计量|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'contract_qty', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
         {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'gather_tp', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '下月计划|工程量', colSpan: '2|1', rowSpan: '1|1', field: 'dgn_qty1', hAlign: 2, width: 70, type: 'Number', readOnly: true},
-        {title: '|金额(万元)', colSpan: '|1', rowSpan: '|1', field: 'total_price', 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},
     ];
     ];
 
 
     const ledgerSpreadSetting = {
     const ledgerSpreadSetting = {
@@ -70,9 +70,10 @@ $(function () {
 
 
     if (curScheduleStage && curScheduleStage.order) {
     if (curScheduleStage && curScheduleStage.order) {
         postData('/tender/' + getTenderId() + '/measure/stage/' + curScheduleStage.order + '/load', { filter: 'ledger' }, function (data) {
         postData('/tender/' + getTenderId() + '/measure/stage/' + curScheduleStage.order + '/load', { filter: 'ledger' }, function (data) {
-            const calcList = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'total_price', 'contract_tp', 'qc_tp', 'gather_tp',
+            const calcList = ['contract_qty', 'end_gather_qty', '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'];
                 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
-            const showList = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'ledger_id', 'ledger_pid', 'order', 'level', 'tender_id', 'full_path',
+            const showList = ['plan_gcl', 'plan_tp', 'next_plan_gcl', 'next_plan_tp', 'end_plan_gcl', 'end_plan_tp', 'year_plan_gcl', 'year_plan_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',
                 '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'];
                 'pre_contract_tp', 'pre_qc_tp', 'pre_gather_tp', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'];
             const baseLedgerTreeSetting = {
             const baseLedgerTreeSetting = {
@@ -84,7 +85,7 @@ $(function () {
                 fullPath: 'full_path',
                 fullPath: 'full_path',
                 calcFields: calcList,
                 calcFields: calcList,
             };
             };
-            baseLedgerTreeSetting.updateFields = ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
+            baseLedgerTreeSetting.updateFields = ['contract_qty', 'end_gather_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'postil', 'used', 'contract_expr'];
             baseLedgerTreeSetting.calcFun = function (node) {
             baseLedgerTreeSetting.calcFun = function (node) {
                 if (!node.children || node.children.length === 0) {
                 if (!node.children || node.children.length === 0) {
                     node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
                     node.pre_gather_qty = ZhCalc.add(node.pre_contract_qty, node.pre_qc_qty);
@@ -112,8 +113,9 @@ $(function () {
                 node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
                 node.dgn_price = ZhCalc.round(ZhCalc.div(node.total_price, node.dgn_qty1), 2);
             };
             };
             const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
             const baseLedgerTree = createNewPathTree('base', baseLedgerTreeSetting);
-            // const newLedgerList = setMonthToLedger(data.bills, data.slm);
-            baseLedgerTree.loadDatas(data.ledgerData);
+            const newLedgerList = setMonthToLedger(data.ledgerData, slmList, nextSlmList, endSlmList, yearSlmList);
+            console.log(newLedgerList);
+            baseLedgerTree.loadDatas(newLedgerList);
             treeCalc.calculateAll(baseLedgerTree);
             treeCalc.calculateAll(baseLedgerTree);
             console.log(baseLedgerTree);
             console.log(baseLedgerTree);
             for (const d of baseLedgerTree.nodes) {
             for (const d of baseLedgerTree.nodes) {
@@ -197,7 +199,7 @@ $(function () {
             return;
             return;
         }
         }
         const _self = $(this);
         const _self = $(this);
-        postData(window.location.pathname + '/save', {type: 'add_stage', postData: { yearmonth, order }}, function (result) {
+        postData('/tender/'+ getTenderId() + '/schedule/stage/save', {type: 'add_stage', postData: { yearmonth, order }}, function (result) {
             _self.addClass('disabled').attr('disabled', true);
             _self.addClass('disabled').attr('disabled', true);
             toastr.success('新增成功');
             toastr.success('新增成功');
             setTimeout(function () {
             setTimeout(function () {
@@ -265,16 +267,40 @@ function setLeafData(tree) {
     return newtree;
     return newtree;
 }
 }
 
 
-function setMonthToLedger(ledgerList, slm) {
+function setMonthToLedger(ledgerList, slm, nextSlm, endSlm, yearSlm) {
     if (slm.length > 0) {
     if (slm.length > 0) {
         for(const s of slm) {
         for(const s of slm) {
             const index = _.findIndex(ledgerList, { 'ledger_id': s.lid });
             const index = _.findIndex(ledgerList, { 'ledger_id': s.lid });
-            const canCalc = _.find(scheduleMonth, { 'yearmonth': s.yearmonth, 'stage_used': 1});
-            if (index && index !== -1 && canCalc) {
-                ledgerList[index][s.yearmonth + '_plan_tp'] = s.plan_tp;
-                ledgerList[index][s.yearmonth + '_plan_gcl'] = s.plan_gcl;
-                ledgerList[index][s.yearmonth + '_sj_tp'] = s.sj_tp;
-                ledgerList[index][s.yearmonth + '_sj_gcl'] = s.sj_gcl;
+            if (index && index !== -1) {
+                ledgerList[index].plan_tp = s.plan_tp;
+                ledgerList[index].plan_gcl = s.plan_gcl;
+            }
+        }
+    }
+    if (nextSlm.length > 0) {
+        for (const ns of nextSlm) {
+            const index = _.findIndex(ledgerList, {'ledger_id': ns.lid});
+            if (index && index !== -1) {
+                ledgerList[index].next_plan_tp = ns.plan_tp;
+                ledgerList[index].next_plan_gcl = ns.plan_gcl;
+            }
+        }
+    }
+    if (endSlm.length > 0) {
+        for (const es of endSlm) {
+            const index = _.findIndex(ledgerList, {'ledger_id': es.lid});
+            if (index && index !== -1) {
+                ledgerList[index].end_plan_tp = es.plan_tp;
+                ledgerList[index].end_plan_gcl = es.plan_gcl;
+            }
+        }
+    }
+    if (yearSlm.length > 0) {
+        for (const ys of yearSlm) {
+            const index = _.findIndex(ledgerList, {'ledger_id': ys.lid});
+            if (index && index !== -1) {
+                ledgerList[index].year_plan_tp = ys.plan_tp;
+                ledgerList[index].year_plan_gcl = ys.plan_gcl;
             }
             }
         }
         }
     }
     }

+ 36 - 0
app/service/change_audit_list.js

@@ -183,6 +183,42 @@ module.exports = app => {
             }
             }
         }
         }
 
 
+        /**
+         * 台账数据清单 清除部分并重新算原设计总金额
+         * @param {Object} datas 内容
+         * @return {void}
+         */
+        async removeLedgerListDatas(datas) {
+            if (!this.ctx.tender || !this.ctx.change) {
+                throw '数据错误';
+            }
+            // 判断是否可修改
+            // 判断t_type是否为费用
+            const transaction = await this.db.beginTransaction();
+            try {
+                // 先删除原本的台账清单数据
+                // const sql = 'DELETE FROM ?? WHERE cid = ? and lid != "0"';
+                // const sqlParam = [this.tableName, this.ctx.change.cid];
+                // await transaction.query(sql, sqlParam);
+                // const insertDatas = [];
+                for (const data of datas) {
+                    // data.tid = this.ctx.tender.id;
+                    // data.cid = this.ctx.change.cid;
+                    // data.spamount = data.camount;
+                    // data.samount = '';
+                    // insertDatas.push(data);
+                    await transaction.delete(this.tableName, { id: data.id });
+                }
+                // if (insertDatas.length > 0) await transaction.insert(this.tableName, insertDatas);
+                await this.calcCamountSum(transaction);
+                await transaction.commit();
+                return true;
+            } catch (err) {
+                await transaction.rollback();
+                throw err;
+            }
+        }
+
         async calcCamountSum(transaction) {
         async calcCamountSum(transaction) {
             // const sql = 'SELECT SUM(ROUND(`camount`*`unit_price`, )) as total_price FROM ?? WHERE cid = ?';
             // const sql = 'SELECT SUM(ROUND(`camount`*`unit_price`, )) as total_price FROM ?? WHERE cid = ?';
             // const sqlParam = [this.tableName, this.change.cid];
             // const sqlParam = [this.tableName, this.change.cid];

+ 8 - 0
app/service/schedule_ledger_month.js

@@ -114,6 +114,14 @@ module.exports = app => {
             };
             };
             return await transaction.update(this.ctx.service.scheduleMonth.tableName, updateData, option);
             return await transaction.update(this.ctx.service.scheduleMonth.tableName, updateData, option);
         }
         }
+
+        async getConllectionList(tid, yearmonthArray) {
+            const sql = 'SELECT tid, lid, SUM(`plan_gcl`) as plan_gcl, SUM(`plan_tp`) as plan_tp' +
+                ' FROM ?? WHERE `tid` = ? AND `yearmonth` in (?) GROUP BY `lid`';
+            const sqlParam = [this.tableName, tid, yearmonthArray];
+            const result = await this.db.query(sql, sqlParam);
+            return result;
+        }
     }
     }
     return ScheduleLedgerMonth;
     return ScheduleLedgerMonth;
 };
 };

+ 1 - 1
app/view/schedule/plan_modal.ejs

@@ -33,7 +33,7 @@
                     <% for (const m of scheduleMonth) { %>
                     <% for (const m of scheduleMonth) { %>
                     <tr>
                     <tr>
                         <td><%- m.yearmonth %></td>
                         <td><%- m.yearmonth %></td>
-                        <td><% if (m.stage_gcl_used === 0 && m.stage_tp_used) { %><label></label><input type="checkbox" value="<%- m.id %>"><% } %></td>
+                        <td><% if (m.stage_gcl_used === 0 && m.stage_tp_used === 0) { %><label></label><input type="checkbox" value="<%- m.id %>"><% } %></td>
                     </tr>
                     </tr>
                     <% } %>
                     <% } %>
                 </table>
                 </table>

+ 4 - 0
app/view/schedule/stage_tp.ejs

@@ -58,4 +58,8 @@
     const scheduleMonth = JSON.parse('<%- JSON.stringify(scheduleMonth) %>');
     const scheduleMonth = JSON.parse('<%- JSON.stringify(scheduleMonth) %>');
     const curScheduleStage = JSON.parse('<%- JSON.stringify(curScheduleStage) %>');
     const curScheduleStage = JSON.parse('<%- JSON.stringify(curScheduleStage) %>');
     const monthList = _.map(scheduleMonth, 'yearmonth');
     const monthList = _.map(scheduleMonth, 'yearmonth');
+    const slmList = JSON.parse('<%- JSON.stringify(slmList) %>');
+    const nextSlmList = JSON.parse('<%- JSON.stringify(nextSlmList) %>');
+    const endSlmList = JSON.parse('<%- JSON.stringify(endSlmList) %>');
+    const yearSlmList = JSON.parse('<%- JSON.stringify(yearSlmList) %>');
 </script>
 </script>

+ 13 - 13
app/view/schedule/stage_tp_modal.ejs

@@ -3,28 +3,28 @@
     <div class="modal-dialog" role="document">
     <div class="modal-dialog" role="document">
         <div class="modal-content">
         <div class="modal-content">
             <div class="modal-header">
             <div class="modal-header">
-                <h5 class="modal-title">创建实际计量</h5>
+                <h5 class="modal-title">创建新计量进度</h5>
             </div>
             </div>
             <div class="modal-body">
             <div class="modal-body">
                 <div class="form-group">
                 <div class="form-group">
-                    <label>计划进度月</label>
-                    <select class="form-control" id="month_list">
-                        <option value="0">选择计划进度月</option>
-                        <% for (const m of scheduleMonth) { %>
-                        <% if (!ctx.helper._.find(scheduleStage, { yearmonth: m.yearmonth })) { %>
-                        <option value="<%- m.yearmonth %>"><%- m.yearmonth.split('-')[0] %>年<%- parseInt(m.yearmonth.split('-')[1]) %>月 %></option>
-                        <% } %>
-                        <% } %>
-                    </select>
-                </div>
-                <div class="form-group">
                     <label>计量期</label>
                     <label>计量期</label>
                     <select class="form-control" id="stage_list">
                     <select class="form-control" id="stage_list">
                         <option value="0">选择计量期</option>
                         <option value="0">选择计量期</option>
                         <% for (const so of stageOrderList) { %>
                         <% for (const so of stageOrderList) { %>
                         <% if (!ctx.helper._.find(scheduleStage, { order: so.order })) { %>
                         <% if (!ctx.helper._.find(scheduleStage, { order: so.order })) { %>
-                        <option value="<%- so.order %>">第<%- so.order %>期</option>
+                        <option value="<%- so.order %>">第<%- so.order %>期(<%- so.s_time %>)</option>
+                        <% } %>
                         <% } %>
                         <% } %>
+                    </select>
+                </div>
+                <div class="form-group">
+                    <label>计划进度月</label>
+                    <select class="form-control" id="month_list">
+                        <option value="0">选择计划进度月</option>
+                        <% for (const m of scheduleMonth) { %>
+                            <% if (!ctx.helper._.find(scheduleStage, { yearmonth: m.yearmonth })) { %>
+                                <option value="<%- m.yearmonth %>"><%- m.yearmonth.split('-')[0] %>年<%- parseInt(m.yearmonth.split('-')[1]) %>月 %></option>
+                            <% } %>
                         <% } %>
                         <% } %>
                     </select>
                     </select>
                 </div>
                 </div>