Browse Source

1. 期计量,报表未归档提示
2. 中间计量,计量单元类定位
3. 其他台账,中间计量加载问题

MaiXinRong 1 year ago
parent
commit
415d77678f

+ 4 - 0
app/controller/measure_controller.js

@@ -49,6 +49,10 @@ module.exports = app => {
                 };
                 };
                 renderData.stages = await ctx.service.stage.getValidStages(ctx.tender.id, this.ctx.session.sessionUser.is_admin);
                 renderData.stages = await ctx.service.stage.getValidStages(ctx.tender.id, this.ctx.session.sessionUser.is_admin);
                 for (const s of renderData.stages) {
                 for (const s of renderData.stages) {
+                    if (!s.rpt_filed) {
+                        s.rpt_filed = await ctx.service.rptArchive.count({ stage_id: s.id });
+                        if (s.rpt_filed) await ctx.service.stage.defaultUpdate({ id: s.id, rpt_filed: 1});
+                    }
                     if (!s.final_auditor_str || s.status !== auditConst.status.checked) {
                     if (!s.final_auditor_str || s.status !== auditConst.status.checked) {
                         // 根据期状态返回展示用户
                         // 根据期状态返回展示用户
                         s.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(s.id, s.status, s.times);
                         s.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(s.id, s.status, s.times);

+ 6 - 0
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -1121,6 +1121,12 @@ const SpreadJsObj = {
         sheet.getParent().focus();
         sheet.getParent().focus();
         sheet.showRow(row, spreadNS.VerticalPosition.center);
         sheet.showRow(row, spreadNS.VerticalPosition.center);
     },
     },
+    locateDataBy: function(sheet, fun) {
+        if (!sheet.zh_data) { return }
+        const index = sheet.zh_data.findIndex(d => { return fun(d); });
+        if (index < 0) return;
+        this.locateRow(sheet, index);
+    },
     saveTopAndSelect: function (sheet, cacheKey) {
     saveTopAndSelect: function (sheet, cacheKey) {
         const sel = sheet.getSelections()[0];
         const sel = sheet.getSelections()[0];
         const top = sheet.getViewportTopRow(1);
         const top = sheet.getViewportTopRow(1);

+ 2 - 2
app/public/js/sr_detail.js

@@ -545,8 +545,8 @@ $(document).ready(() => {
         stagePosSpreadObj.loadCurPosData();
         stagePosSpreadObj.loadCurPosData();
         SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
         SpreadJsObj.resetTopAndSelect(spSpread.getActiveSheet());
         // 加载中间计量
         // 加载中间计量
-        stageIm.init(relaStage, imType, tenderInfo.decimal);
-        stageIm.loadData4Rela(result.ledgerData, result.posData, result.detailData, result.stageChange, result.detailAtt);
+        stageIm.init(tenderInfo, relaStage, imType, tenderInfo.decimal);
+        stageIm.loadData4Rela(result.ledgerData, result.posData, result.detailData, result.stageChange || [], result.detailAtt);
     }, null, true);
     }, null, true);
     spSpread.bind(spreadNS.Events.SelectionChanged, stagePosSpreadObj.selectionChanged);
     spSpread.bind(spreadNS.Events.SelectionChanged, stagePosSpreadObj.selectionChanged);
 
 

+ 3 - 0
app/public/js/stage.js

@@ -3530,6 +3530,9 @@ $(document).ready(() => {
                 if (select && select.source) {
                 if (select && select.source) {
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[curIndex-1].id, true);
                     SpreadJsObj.locateTreeNode(slSpread.getActiveSheet(), select.source[curIndex-1].id, true);
                     stagePosSpreadObj.loadCurPosData();
                     stagePosSpreadObj.loadCurPosData();
+                    if (select.source[curIndex-1].pos_id) {
+                        SpreadJsObj.locateDataBy(spSpread.getActiveSheet(), function(data){ return data.id === select.source[curIndex-1].pos_id});
+                    }
                 }
                 }
             });
             });
             $('#im-locate-pre').click(function () {
             $('#im-locate-pre').click(function () {

+ 2 - 2
app/public/js/stage_im.js

@@ -700,7 +700,7 @@ const stageIm = (function () {
                             };
                             };
                             nodeImData.push(im);
                             nodeImData.push(im);
                         }
                         }
-                        im.source.push({id: p.ledger_id, code: p.code, b_code: p.b_code});
+                        im.source.push({id: p.ledger_id, code: p.code, b_code: p.b_code, pos_id: pp.id, pos_name: pp.name});
 
 
                         for (const c of changes) {
                         for (const c of changes) {
                             if (c.lid === p.id && c.pid == pp.id && c.qty && c.qty !== 0) {
                             if (c.lid === p.id && c.pid == pp.id && c.qty && c.qty !== 0) {
@@ -889,7 +889,7 @@ const stageIm = (function () {
                         position: pp.position,
                         position: pp.position,
                         lIndex: nodeIndex,
                         lIndex: nodeIndex,
                         custom_define: [],
                         custom_define: [],
-                        source: [{id: p.ledger_id, code: p.code, b_code: p.b_code}],
+                        source: [{id: p.ledger_id, code: p.code, b_code: p.b_code, pos_id: pp.id, pos_name: pp.name}],
                         im_type: imType.bw.value,
                         im_type: imType.bw.value,
                     };
                     };
                     im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                     im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;

+ 53 - 1
app/service/rpt_gather_memory.js

@@ -1343,6 +1343,55 @@ module.exports = app => {
             return result;
             return result;
         }
         }
 
 
+        async _gatherStagesChange(completeData, tender, stages, preStage, gatherType = 'flow'){
+            const result = [];
+            const findR = function(source) {
+                let r = result.find(x => { return x.cbid === source.cbid});
+                if (!r) {
+                    r = { cid: source.cid, cbid: source.cbid, qty: 0, pre_qty: 0 };
+                    result.push(r);
+                }
+                return r;
+            };
+            const helper = this.ctx.helper;
+
+            if (preStage) {
+                const preStageChange = await this.ctx.service.stageChangeFinal.getEndStageData(stage.tid, preStage.order);
+                if (gatherType === 'flow') {
+                    result.push(...preStageChange);
+                } else {
+                    preStageChange.forEach(sc => {
+                        const r = findR(sc);
+                        r.pre_qty = helper.add(r.pre_qty, sc.qty);
+                    });
+                }
+            }
+
+            for (const stage of stages) {
+                let curStageChange;
+                if (stage.status === auditConst.stage.status.checked) {
+                    curStageChange = await this.ctx.service.stageChangeFinal.getAllDataByCondition({ where: { tid: stage.tid, sid: stage.id } });
+                } else {
+                    await this.ctx.service.stage.doCheckStage(stage);
+                    curStageChange = await this.ctx.service.stageChange.getCurStageData(stage.tid, stage.id, stage.curTimes, stage.curOrder);
+                }
+                if (gatherType === 'flow') {
+                    result.push(...curStageChange);
+                } else {
+                    curStageChange.forEach(sc => {
+                        const r = findR(sc);
+                        r.qty = helper.add(r.qty, sc.qty);
+                    });
+                }
+            }
+
+            result.forEach(r => { r.end_qty = helper.add(r.pre_qty, r.qty); });
+            return result;
+        }
+        async _gatherCustomZoneStageChange(sTender, completeData, timeType, gatherType) {
+            const [stages, preStage, endStage] = await this._getCustomZoneStages(tender, zone, timeType);
+            await this._gatherStagesChange(completeData, tender, stages, preStage, gatherType);
+        }
         async _gatherStageChange(completeData, tender, stage, hasPre, gatherType = 'flow'){
         async _gatherStageChange(completeData, tender, stage, hasPre, gatherType = 'flow'){
             if (!stage) return [];
             if (!stage) return [];
             const helper = this.ctx.helper;
             const helper = this.ctx.helper;
@@ -1350,7 +1399,7 @@ module.exports = app => {
 
 
             const curStageChange = await this.ctx.service.stageChange.getCurStageData(stage.tid, stage.id, stage.curTimes, stage.curOrder);
             const curStageChange = await this.ctx.service.stageChange.getCurStageData(stage.tid, stage.id, stage.curTimes, stage.curOrder);
             const preStageChange = hasPre && stage.preCheckedStage ? await this.ctx.service.stageChangeFinal.getEndStageData(stage.tid, stage.preCheckedStage.order) : [];
             const preStageChange = hasPre && stage.preCheckedStage ? await this.ctx.service.stageChangeFinal.getEndStageData(stage.tid, stage.preCheckedStage.order) : [];
-            if (gatherType === 'flow') return [...curStageChange, ...preStageChange];
+            if (gatherType === 'flow') return [...preStageChange, ...curStageChange];
 
 
             const result = [];
             const result = [];
             const findR = function(source) {
             const findR = function(source) {
@@ -1419,6 +1468,9 @@ module.exports = app => {
                     case 'stage':
                     case 'stage':
                         await this._gatherOrderStageChange(tender, completeData, gsCustom.stage, gsSetting.hasPre, gsSetting.gather);
                         await this._gatherOrderStageChange(tender, completeData, gsCustom.stage, gsSetting.hasPre, gsSetting.gather);
                         break;
                         break;
+                    case 'custom-zone':
+                        await this._gatherCustomZoneStageChange(tender, completeData, gsCustom.custom_zone, gsSetting.timeType, gsSetting.gather);
+                        break;
                 }
                 }
                 commonIndex++;
                 commonIndex++;
             }
             }

+ 6 - 1
app/view/measure/stage.ejs

@@ -30,7 +30,7 @@
                 <table class="table table-bordered table-hover">
                 <table class="table table-bordered table-hover">
                     <thead>
                     <thead>
                     <tr>
                     <tr>
-                        <th class="text-center" width="70px">计量期数</th>
+                        <th class="text-center" width="80px">计量期数</th>
                         <th class="text-center" width="70px">计量月份</th>
                         <th class="text-center" width="70px">计量月份</th>
                         <th class="text-center" width="70px">截止日期</th>
                         <th class="text-center" width="70px">截止日期</th>
                         <th class="text-center" width="100px" name="contract_tp">本期合同计量</th>
                         <th class="text-center" width="100px" name="contract_tp">本期合同计量</th>
@@ -55,6 +55,11 @@
                             <% if ((i === 0 || (stages[i-1] && stages[i-1].status !== auditConst.status.checked)) && s.user_id === ctx.session.sessionUser.accountId) { %>
                             <% if ((i === 0 || (stages[i-1] && stages[i-1].status !== auditConst.status.checked)) && s.user_id === ctx.session.sessionUser.accountId) { %>
                             <a href="#edit" class="edit-stage" data-index="<%- i %>" data-toggle="modal" data-target="#edit"><i class="fa fa-pencil-square-o "></i></a>
                             <a href="#edit" class="edit-stage" data-index="<%- i %>" data-toggle="modal" data-target="#edit"><i class="fa fa-pencil-square-o "></i></a>
                             <% } %>
                             <% } %>
+                            <% if (!s.rpt_filed) { %>
+                            <a data-toggle="tooltip" data-placement="top" data-original-title="报表未归档">
+                                <i class="fa fa-file-pdf-o text-danger"></i>
+                            </a>
+                            <% } %>
                         </td>
                         </td>
                         <td class="text-center"><%- s.s_time %></td>
                         <td class="text-center"><%- s.s_time %></td>
                         <td class="text-center">
                         <td class="text-center">