Browse Source

1. 资料归集相关
2. 中间计量,计算式说明调整

MaiXinRong 4 days ago
parent
commit
a738c35b63

+ 55 - 2
app/controller/file_controller.js

@@ -320,6 +320,10 @@ module.exports = app => {
                         if (type) a.type_str = type.name;
                     });
                     r.stage = await ctx.service.stage.getAllDataByCondition({ columns: ['id', 'order'], where: { tid: r.id, status: auditConst.stage.status.checked } });
+                    r.change = await ctx.service.change.getAllDataByCondition({ columns: ['cid', 'code'], where: { tid: r.id, status: auditConst.flow.status.checked } });
+                    r.change_apply = await ctx.service.changeApply.getAllDataByCondition({ columns: ['id', 'code'], where: { tid: r.id, status: auditConst.flow.status.checked } });
+                    r.change_plan = await ctx.service.changePlan.getAllDataByCondition({ columns: ['id', 'code'], where: { tid: r.id, status: auditConst.flow.status.checked } });
+                    r.change_project = await ctx.service.changeProject.getAllDataByCondition({ columns: ['id', 'code'], where: { tid: r.id, status: auditConst.flow.status.checked } });
                 }
                 ctx.body = {err: 0, msg: '', data: result };
             } catch (error) {
@@ -332,11 +336,28 @@ module.exports = app => {
             return await this.ctx.service.ledgerAtt.getAllDataByCondition({ where: { tid: data.tender_id }, order: [['id', 'desc']]});
         }
         async _loadStageAtt(data) {
-            if (!data.tender_id || !data.stage) throw '参数错误';
+            if (!data.tender_id || !data.stage || !data.sub_type) throw '参数错误';
+            const stage = await this.ctx.service.stage.getDataById(data.stage);
             switch (data.sub_type) {
                 case 'att':
-                    const stage = await this.ctx.service.stage.getDataById(data.stage);
                     return await this.ctx.service.stageAtt.getAllDataByCondition({ where: { tid: data.tender_id, sid: stage.order }, order: [['id', 'desc']]});
+                case 'dealPay':
+                    const dpFiles = [];
+                    await this.ctx.service.stage.doCheckStage(stage, this.ctx.session.sessionUser.is_admin);
+                    const stagePays = await this.ctx.service.stagePay.getAllDataByCondition({ where: { sid: stage.id, stimes: stage.curTimes, sorder: stage.curOrder } });
+                    stagePays.forEach(x => {
+                        x.attachment = x.attachment ? JSON.parse(x.attachment) : [];
+                        if (x.attachment.length > 0) imFiles.push(...x.attachment);
+                    });
+                    return dpFiles;
+                case 'stageIm':
+                    const imFiles = [];
+                    const stageIm = await this.ctx.service.stageDetailAtt.getAllDataByCondition({ where: { sid: stage.id} });
+                    stageIm.forEach(x => {
+                        x.attachment = x.attachment ? JSON.parse(x.attachment) : [];
+                        if (x.attachment.length > 0) imFiles.push(...x.attachment);
+                    });
+                    return imFiles;
             }
         }
         async _loadAdvanceAtt(data) {
@@ -350,6 +371,26 @@ module.exports = app => {
             });
             return result;
         }
+        async _loadChangeAtt(data) {
+            if (!data.selectId) throw '参数错误';
+            const result = await this.ctx.service.changeAtt.getAllDataByCondition({ where: { cid: data.selectId }, order: [['id', 'desc']]});
+            return result;
+        }
+        async _loadChangePlanAtt(data) {
+            if (!data.selectId) throw '参数错误';
+            const result = await this.ctx.service.changeAtt.getAllDataByCondition({ where: { cpid: data.selectId }, order: [['id', 'desc']]});
+            return result;
+        }
+        async _loadChangeProjectAtt(data) {
+            if (!data.selectId) throw '参数错误';
+            const result = await this.ctx.service.changeAtt.getAllDataByCondition({ where: { cpid: data.selectId }, order: [['id', 'desc']]});
+            return result;
+        }
+        async _loadChangeApplyAtt(data) {
+            if (!data.selectId) throw '参数错误';
+            const result = await this.ctx.service.changeAtt.getAllDataByCondition({ where: { caid: data.selectId }, order: [['id', 'desc']]});
+            return result;
+        }
         async loadRelaFiles(ctx) {
             try {
                 const data = JSON.parse(ctx.request.body.data);
@@ -366,6 +407,18 @@ module.exports = app => {
                     case 'advance':
                         files = await this._loadAdvanceAtt(data);
                         break;
+                    case 'change':
+                        files = await this._loadChangeAtt(data);
+                        break;
+                    case 'change_plan':
+                        files = await this._loadChangePlanAtt(data);
+                        break;
+                    case 'change_project':
+                        files = await this._loadChangeProjectAtt(data);
+                        break;
+                    case 'change_apply':
+                        files = await this._loadChangeApplyAtt(data);
+                        break;
                     default: throw '未知文件类型';
                 }
                 ctx.body = {err: 0, msg: '', data: files };

+ 109 - 7
app/public/js/file_detail.js

@@ -371,11 +371,11 @@ $(document).ready(function() {
                 await filingObj.loadFiles(node, 1);
                 filingObj.refreshFilesTable();
             }
-            if (filingObj.curFiling.source_node.filing_type === 5) {
-                $('#rela-file-btn').show();
-            } else {
-                $('#rela-file-btn').hide();
-            }
+            // if (filingObj.curFiling.source_node.filing_type === 5) {
+            //     $('#rela-file-btn').show();
+            // } else {
+            //     $('#rela-file-btn').hide();
+            // }
             setLocalCache(this.curFilingKey, filingObj.curFiling.id);
         }
         findFiling(id) {
@@ -969,6 +969,9 @@ $(document).ready(function() {
             $('#tf-stage').change(function() {
                 self.selectTfStage(this.value);
             });
+            $('#tf-select').change(function() {
+                self.selectTfId(this.value);
+            });
             $('#rela-file-ok').click(function() {
                 const selectFiles = self.getSelectRelaFile();
                 filingObj.relaFiles(selectFiles, function() {
@@ -1041,9 +1044,19 @@ $(document).ready(function() {
                 await this.setCurTender(firstNode);
             }
         }
+        refreshTenderFileSelectId() {
+            if (['change', 'change_apply', 'change_plan', 'change_project'].indexOf(this.rfType.type) >= 0) {
+                const type = this.tenderFileType.find(x => { return x.value === this.rfType.type; });
+                const html = type.select.map(x => { return `<option value="${x.value}">${x.text}</option>`});
+                $('#tf-select').html(html.join('')).show();
+                this.rfType.selectId = type.select[0].value;
+            } else {
+                $('#tf-select').html('').hide();
+            }
+        }
         refreshTenderFileStage() {
             if (this.rfType.sub_type) {
-                const type = this.tenderFileType.find(x => { return x.value === this.rfType.type});
+                const type = this.tenderFileType.find(x => { return x.value === this.rfType.type; });
                 const subType = type.subType ? type.subType.find(x => { return x.value === this.rfType.sub_type; }) : null;
                 if (subType) {
                     this.rfType.stage = subType.stage[0].value;
@@ -1088,6 +1101,8 @@ $(document).ready(function() {
                     value: 'stage', text: '计量期',
                     subType: [
                         { value: 'att', text: '计量附件', stage: JSON.parse(JSON.stringify(stages)) },
+                        { value: 'dealPay', text: '合同支付', stage: JSON.parse(JSON.stringify(stages)) },
+                        { value: 'stageIm', text: '中间计量', stage: JSON.parse(JSON.stringify(stages)) },
                     ],
                 });
             }
@@ -1105,10 +1120,44 @@ $(document).ready(function() {
                     value: 'advance', text: '预付款', subType: advanceType
                 });
             }
+            if (tender.change && tender.change.length > 0) {
+                const selects = [];
+                tender.change.forEach(x => {
+                    selects.push({ value: x.cid, text: x.code })
+                });
+                this.tenderFileType.push({ value: 'change', text: '变更令', select: selects });
+            }
+            if (tender.change_plan && tender.change_plan.length > 0) {
+                const selects = [];
+                tender.change_plan.forEach(x => {
+                    selects.push({ value: x.cpid, text: x.code })
+                });
+                this.tenderFileType.push({ value: 'change_plan', text: '变更方案', select: selects });
+            }
+            if (tender.change_project && tender.change_project.length > 0) {
+                const selects = [];
+                tender.change_project.forEach(x => {
+                    selects.push({ value: x.cid, text: x.code })
+                });
+                this.tenderFileType.push({ value: 'change_project', text: '变更立项', select: selects });
+            }
+            if (tender.change_apply && tender.change_apply.length > 0) {
+                const selects = [];
+                tender.change_apply.forEach(x => {
+                    selects.push({ value: x.cid, text: x.code })
+                });
+                this.tenderFileType.push({ value: 'change_apply', text: '变更申请', select: selects });
+            }
             this.rfType = { type: this.tenderFileType[0].value };
             this.refreshTenderFileType();
             this.refreshTenderFileSubType();
             this.refreshTenderFileStage();
+            this.refreshTenderFileSelectId();
+        }
+        async selectTfId(id) {
+            this.rfType.selectId = id;
+            await this.loadFiles();
+            this.refreshFileTable();
         }
         async selectTfStage(stage){
             this.rfType.stage = stage;
@@ -1125,13 +1174,14 @@ $(document).ready(function() {
             this.rfType.type = type;
             this.refreshTenderFileSubType();
             this.refreshTenderFileStage();
+            this.refreshTenderFileSelectId();
             await this.loadFiles();
             this.refreshFileTable();
         }
         refreshFileTable() {
             const html = [];
             const typeStr = [];
-            const selectOption = $('option:selected');
+            const selectOption = $('option:selected', '#rela-file');
             selectOption.each((i, x) => {
                typeStr.push(x.innerText);
             });
@@ -1186,11 +1236,63 @@ $(document).ready(function() {
             if (!advance.files) advance.files = await this._loadRelaFiles(rfType);
             this.curFiles = advance.files;
         }
+        async _loadChangeFile() {
+            const rfType = this.rfType;
+            const change = this.curTender.source_node.change.find(x => {
+                return x.cid === rfType.selectId;
+            });
+            if (!change) {
+                this.curFiles = [];
+                return;
+            }
+            if (!change.files) change.files = await this._loadRelaFiles(rfType);
+            this.curFiles = change.files;
+        }
+        async _loadChangePlanFile() {
+            const rfType = this.rfType;
+            const change = this.curTender.source_node.change_plan.find(x => {
+                return x.id === rfType.selectId;
+            });
+            if (!change) {
+                this.curFiles = [];
+                return;
+            }
+            if (!change.files) change.files = await this._loadRelaFiles(rfType);
+            this.curFiles = change.files;
+        }
+        async _loadChangeProjectFile() {
+            const rfType = this.rfType;
+            const change = this.curTender.source_node.change_project.find(x => {
+                return x.id === rfType.selectId;
+            });
+            if (!change) {
+                this.curFiles = [];
+                return;
+            }
+            if (!change.files) change.files = await this._loadRelaFiles(rfType);
+            this.curFiles = change.files;
+        }
+        async _loadChangeApplyFile() {
+            const rfType = this.rfType;
+            const change = this.curTender.source_node.change_apply.find(x => {
+                return x.id === rfType.selectId;
+            });
+            if (!change) {
+                this.curFiles = [];
+                return;
+            }
+            if (!change.files) change.files = await this._loadRelaFiles(rfType);
+            this.curFiles = change.files;
+        }
         async loadFiles() {
             switch (this.rfType.type) {
                 case 'ledger': await this._loadLedgerFile(); break;
                 case 'stage': await this._loadStageFile(); break;
                 case 'advance': await this._loadAdvanceFile(); break;
+                case 'change': await this._loadChangeFile(); break;
+                case 'change_plan': await this._loadChangePlanFile(); break;
+                case 'change_project': await this._loadChangeProjectFile(); break;
+                case 'change_apply': await this._loadChangeApplyFile(); break;
             }
             this.initFilesId(this.curFiles);
         }

+ 55 - 4
app/public/js/stage_im.js

@@ -3,6 +3,13 @@
 /**
  *
  *
+ * const imType = {
+     zl: { value: 0, name: '总量控制' },
+     tz: { value: 1, name: '项目节-清单' },
+     bw: { value: 2, name: '清单-计量单元' },
+     bb: { value: 3, name: '计量单元-清单' },
+   };
+ *
  * @author Mai
  * @date
  * @version
@@ -789,7 +796,9 @@ const stageIm = (function () {
             lx = {
                 lxid: leafXmj.id,
                 code: leafXmj.code,
-                name: leafXmj.name
+                name: leafXmj.name,
+                contract_expr: [],
+                qc_expr: [],
             };
             im.leafXmjs.push(lx);
         }
@@ -797,6 +806,8 @@ const stageIm = (function () {
         lx.contract_jl = ZhCalc.add(lx.contract_jl, node.contract_qty);
         lx.qc_jl = ZhCalc.add(lx.qc_jl, node.qc_qty);
         lx.qc_minus_jl = ZhCalc.add(lx.qc_minus_jl, node.qc_minus_qty);
+        lx.contract_expr.push(node.contract_expr);
+        lx.qc_expr.push(node.qc_qty);
         generateZlPosData(node, lx);
     }
     function generateZlChangeData(node, im) {
@@ -901,13 +912,33 @@ const stageIm = (function () {
                         im_type: imType.bw.value,
                         visible: !node.filter,
                     };
-                    im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                     ImData.push(im);
                     for (const c of changes) {
                         if (c.lid === p.id && c.pid === pp.id && c.qty && c.qty !== 0) {
                             im.changes.push(c);
                         }
                     }
+                    const calc_memo = [];
+                    calc_memo.push('本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit);
+                    const contract_expr = pp.contract_expr ? pp.contract_qty + '=' + pp.contract_expr : (pp.contract_qty || 0);
+                    let qc_expr = '', minus_qc_expr = '';
+                    im.changes.forEach(x => {
+                        if (x.no_value) {
+                            if (minus_qc_expr) {
+                                minus_qc_expr = minus_qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                            } else {
+                                minus_qc_expr = minus_qc_expr + x.qty;
+                            }
+                        } else {
+                            if (qc_expr) {
+                                qc_expr = qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                            } else {
+                                qc_expr = qc_expr + x.qty;
+                            }
+                        }
+                    });
+                    calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr || '0'};变更不计价:${minus_qc_expr || '0'}`);
+                    im.calc_memo =  calc_memo.join('\n');
                 }
             } else {
                 if (checkZero(p.gather_qty) && checkZero(p.gather_tp) && checkZero(p.qc_minus_qty)) { continue }
@@ -928,14 +959,34 @@ const stageIm = (function () {
                     im_type: imType.bw.value,
                     visible: !node.filter,
                 };
-                im.calc_memo = '本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit;
                 ImData.push(im);
                 for (const c of changes) {
                     if (c.lid === p.id && c.pid == -1 && c.qty && c.qty !== 0) {
                         im.changes.push(c);
                     }
                 }
-                importChanges.forEach(x => { if (x.lid === p.id) im.changes.push(x); });
+                importChanges.forEach(x => { if (x.lid === p.id && x.qty) im.changes.push(x); });
+                const calc_memo = [];
+                calc_memo.push('本期计量:' + (checkZero(im.jl) ? 0 : im.jl) + (im.qc_minus_jl ? (` (不计价 ${im.qc_minus_jl}) `) : ' ') + im.unit);
+                const contract_expr = p.contract_expr ? p.contract_qty + '=' + p.contract_expr : (p.contract_qty || 0);
+                let qc_expr = '', minus_qc_expr = '';
+                im.changes.forEach(x => {
+                    if (x.no_value) {
+                        if (minus_qc_expr) {
+                            minus_qc_expr = minus_qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                        } else {
+                            minus_qc_expr = minus_qc_expr + x.qty;
+                        }
+                    } else {
+                        if (qc_expr) {
+                            qc_expr = qc_expr + (x.qty > 0 ? '+' + x.qty : x.qty);
+                        } else {
+                            qc_expr = qc_expr + x.qty;
+                        }
+                    }
+                });
+                calc_memo.push(`其中合同计量:${contract_expr};变更计量:${qc_expr || '0'};变更不计价:${minus_qc_expr || '0'}`);
+                im.calc_memo = calc_memo.join('\n');
             }
         }
     }

+ 1 - 1
app/view/file/file.ejs

@@ -38,7 +38,7 @@
                             <% if (canUpload) { %>
                             <div class="py-2 pr-2"><a href="#add-file" data-toggle="modal" data-target="#add-file">上传文件</a></div>
                             <div class="py-2 pr-2"><a href="#add-big-file" data-toggle="modal" data-target="#add-big-file">大文件上传</a></div>
-                            <div class="p-2" id="rela-file-btn"><a href="#rela-file" data-toggle="modal" data-target="#rela-file">导入文件</a></div>
+                            <div class="p-2" id="rela-file-btn"><a href="#rela-file" data-toggle="modal" data-target="#rela-file">引用文件</a></div>
                             <div class="p-2"><a href="javascript: void(0)" id="batch-del-file-btn">批量删除</a></div>
                             <% } %>
                             <div class="p-2"><a href="javascript: void(0)" id="batch-download">批量下载</a></div>

+ 4 - 2
app/view/file/file_modal.ejs

@@ -142,9 +142,11 @@
                                 <div class="d-flex flex-row">
                                     <select class="form-control form-control-sm mr-2" id="tf-type" style="width: 100px">
                                     </select>
-                                    <select class="form-control form-control-sm mr-2" id="tf-sub-type" style="width: 120px">
+                                    <select class="form-control form-control-sm mr-2" id="tf-sub-type" style="width: 120px; display: none">
                                     </select>
-                                    <select class="form-control form-control-sm" id="tf-stage" style="width: 80px">
+                                    <select class="form-control form-control-sm mr-2" id="tf-stage" style="width: 80px; display: none">
+                                    </select>
+                                    <select class="form-control form-control-sm mr-2" id="tf-select" style="width: 120px; display: none">
                                     </select>
                                 </div>
                             </div>