瀏覽代碼

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

Tony Kang 2 年之前
父節點
當前提交
c8bf257a42

+ 4 - 3
app/controller/payment_controller.js

@@ -252,7 +252,7 @@ module.exports = app => {
                     preUrl: '/payment/' + ctx.tender.id + '/detail/' + ctx.detail.id,
                     OSS_PATH: ctx.app.config.fujianOssPath,
                 };
-
+                renderData.nextDetail = await ctx.service.paymentDetail.getDataByCondition({ tr_id: ctx.trInfo.id, order: ctx.detail.order + 1 });
                 let report_json = JSON.parse(ctx.detail.report_json);
                 const content = [];
                 // 获取当前报表人
@@ -277,7 +277,9 @@ module.exports = app => {
                             });
                         }
                     }
-                    if (ctx.detail.status !== auditConst.status.checked) {
+                    if (rptAudit && ((ctx.detail.status !== auditConst.status.checkNo && ctx.detail.status !== auditConst.status.checked) ||
+                        (ctx.detail.status === auditConst.status.checked && !renderData.nextDetail) ||
+                        (ctx.detail.status === auditConst.status.checkNo && ctx.detail.uid === ctx.session.sessionUser.accountId))) {
                         // 获取个人签字,单位章,个人章地址
                         const userInfo = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                         const stampPathList = userInfo.stamp_path ? userInfo.stamp_path.split('!;!') : [];
@@ -299,7 +301,6 @@ module.exports = app => {
                 renderData.rptAudit = rptAudit;
                 renderData.content = content;
                 renderData.report_json = report_json;
-                renderData.nextDetail = await ctx.service.paymentDetail.getDataByCondition({ tr_id: ctx.trInfo.id, order: ctx.detail.order + 1 });
                 if ((ctx.detail.status === auditConst.status.uncheck || ctx.detail.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.detail.uid) {
                     // data.accountGroup = accountGroup;
                     // 获取所有项目参与者

+ 15 - 2
app/controller/revise_controller.js

@@ -91,8 +91,11 @@ module.exports = app => {
         async index(ctx) {
             try {
                 // 分页相关
-                const count = await ctx.service.ledgerRevise.count({ tid: ctx.tender.id });
-                const ledgerRevise = await ctx.service.ledgerRevise.getReviseList(ctx.tender.id);
+                const user = await this.ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
+                const condition = { tid: ctx.tender.id };
+                if (!user.show_revise_invalid) condition.valid = 1;
+                const count = await ctx.service.ledgerRevise.count(condition);
+                const ledgerRevise = await ctx.service.ledgerRevise.getReviseList(ctx.tender.id, user.show_revise_invalid);
                 if (ledgerRevise.length > 0) {
                     const revise = ledgerRevise[0];
                     if (ctx.page === 1) {
@@ -131,6 +134,7 @@ module.exports = app => {
                     auditConst2: JSON.stringify(audit.revise),
                     stdBills,
                     stdChapters,
+                    show_invalid: user.show_revise_invalid,
                 };
                 await this.layout('revise/index.ejs', renderData, 'revise/modal.ejs');
             } catch (err) {
@@ -139,6 +143,15 @@ module.exports = app => {
             }
         }
 
+        async showInvalid(ctx) {
+            try {
+                await ctx.service.projectAccount.defaultUpdate({ id: ctx.session.sessionUser.accountId, show_revise_invalid: ctx.query.show });
+            } catch (err) {
+                this.log(err);
+            }
+            ctx.redirect(ctx.request.header.referer);
+        }
+
         /**
          * 修订审批流程(Get)
          * @param ctx

+ 1 - 1
app/controller/tender_controller.js

@@ -1425,7 +1425,7 @@ module.exports = app => {
                         ctx.body = {err: 0, msg: '', data: reviseData};
                         break;
                     case 'stage':
-                        const stageData = await this.ctx.service.stageBills.sumLoad(data.lid, data.tenders, data.cover);
+                        const stageData = await this.ctx.service.stageBills.sumLoad(data.lid, data.tenders, data.cover, data.ignore);
                         stageData.import_change = { target: { import_lid: data.lid } };
                         stageData.import_change.data = await this.ctx.service.stageImportChange.getLeafXmjStageImportData(ctx.stage, data.lid);
                         await ctx.service.stage.updateCheckCalcFlag(ctx.stage, true);

+ 7 - 4
app/lib/sum_load.js

@@ -29,6 +29,7 @@ class loadGclBaseTree {
         this.baseNodes = [];
 
         this.ignoreParent = setting.ignoreParent;
+        this.ignoreNotFind = setting.ignoreNotFind;
 
         // 缓存
         this.keyNodeId = setting.maxId ? setting.maxId + 1 : 1;
@@ -432,8 +433,10 @@ class gatherStageGclTree extends loadGclBaseTree {
                 }
             }
         }
-        for (const i of this.items) {
-            result.errors.push({ b_code: i.b_code, name: i.name, unit: i.unit, qty: i.contract_qty, qc_qty: i.qc_qty, qc_minus_qty: i.qc_minus_qty, type: 'miss' });
+        if (!this.ignoreNotFind) {
+            for (const i of this.items) {
+                result.errors.push({ b_code: i.b_code, name: i.name, unit: i.unit, qty: i.contract_qty, qc_qty: i.qc_qty, qc_minus_qty: i.qc_minus_qty, type: 'miss' });
+            }
         }
         return result;
     }
@@ -541,10 +544,10 @@ class sumLoad {
         }
     }
 
-    async stageGatherGcl(select, maxId, tenders, defaultData, cover) {
+    async stageGatherGcl(select, maxId, tenders, defaultData, cover, ignore) {
         const ignoreParent = this.ctx.tender.info.fun_rela.sum_load.ignoreParent;
         this.loadTree = new gatherStageGclTree(this.ctx, {
-            parent: select, maxId, type: 'ledger', defaultData, ignoreParent, cover,
+            parent: select, maxId, type: 'ledger', defaultData, ignoreParent, cover, ignoreNotFind: ignore,
         });
         const posterity = await this.ctx.service.ledger.getPosterityByParentId(this.ctx.tender.id, select.ledger_id);
         const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);

+ 7 - 1
app/middleware/payment_detail_check.js

@@ -37,9 +37,11 @@ module.exports = options => {
             // 读取原报、审核人数据
             detail.auditors = yield this.service.paymentDetailAudit.getAuditors(detail.id, detail.times);
             detail.curAuditor = yield this.service.paymentDetailAudit.getCurAuditor(detail.id, detail.times);
+            const rptAudits = yield this.service.paymentRptAudit.getAllDataByCondition({ where: { td_id: detail.id } });
 
             const accountId = this.session.sessionUser.accountId,
-                auditorIds = _.map(detail.auditors, 'aid');
+                auditorIds = _.map(detail.auditors, 'aid'),
+                rptAuditIds = _.map(rptAudits, 'uid');
             if (accountId === detail.uid) { // 原报
                 detail.curTimes = detail.times;
                 if (detail.status === status.uncheck || detail.status === status.checkNo) {
@@ -74,6 +76,10 @@ module.exports = options => {
                 } else {
                     detail.curOrder = accountId === detail.curAuditor.aid ? detail.curAuditor.order : detail.curAuditor.order - 1;
                 }
+            } else if (rptAuditIds.indexOf(accountId) !== -1) {
+                if (detail.status === status.uncheck || detail.status === status.checkNo) {
+                    throw '您无权查看该数据';
+                }
             } else { // 其他不可见
                 throw '您无权查看该数据';
             }

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

@@ -74,9 +74,9 @@ $(function () {
         $('#stamp_path').prop('checked', rptAudit.signature_msg.stamp_path !== null);
         $('#signature_date').val(rptAudit.signature_msg.date ? rptAudit.signature_msg.date : '');
         signatureDate = !signatureDate ? $('#signature_date').datepicker().data('datepicker') : signatureDate;
-        if (rptAudit.signature_msg.date) {
+        if (signatureDate && rptAudit.signature_msg.date) {
             signatureDate.selectDate(new Date(rptAudit.signature_msg.date));
-        } else {
+        } else if (signatureDate) {
             signatureDate.clear();
         }
         $('#signature_content').val(rptAudit.signature_msg.content ? rptAudit.signature_msg.content : '');

+ 5 - 4
app/public/js/shares/batch_import.js

@@ -128,8 +128,8 @@ const BatchImportStageGcl = function (setting) {
                 $('#bi-download-error').hide();
             }
         },
-        importStageGcl: async function (node, cover) {
-            const updateData = { lid: node.lid, type: 'stage', cover, tenders: [] };
+        importStageGcl: async function (node, cover, ignore) {
+            const updateData = { lid: node.lid, type: 'stage', cover, ignore, tenders: [] };
             for (const tender of node.children) {
                 updateData.tenders.push({ tid: tender.tid, name: tender.name, stageCount: tender.stageCount, stage: tender.stage });
             }
@@ -152,6 +152,7 @@ const BatchImportStageGcl = function (setting) {
             biObj.batching = true;
             this.beforeBatchImport();
             const cover = $('#bi-cover')[0].checked;
+            const ignore = $('#bi-ignore')[0].checked;
             for (const node of this.batchTree.children) {
                 if (!node.selected) continue;
 
@@ -162,7 +163,7 @@ const BatchImportStageGcl = function (setting) {
                     try {
                         node.status = '开始导入';
                         SpreadJsObj.reLoadRowData(biObj.sheet, row);
-                        await biObj.importStageGcl(node, cover);
+                        await biObj.importStageGcl(node, cover, ignore);
                         node.status = '导入完成';
                     } catch(err) {
                         console.log(err);
@@ -214,7 +215,7 @@ const BatchImportStageGcl = function (setting) {
             const sheets = [];
             for (const node of this.batchTree.children) {
                 if (node.error > 0) {
-                    sheets.push({ name: node.code, setting, data: node.errors });
+                    sheets.push({ name: node.code || node.name, setting, data: node.errors });
                 }
             }
             SpreadExcelObj.exportSimpleXlsxSheets(sheets, '批量导入错误.xlsx');

+ 4 - 1
app/public/js/shares/tender_select.js

@@ -181,7 +181,10 @@ const TenderSelect = function (setting) {
 
             $('#tender-select-ok').click(() => {
                 const updateData = { lid: tsObj.select.id, type: tsObj.setting.type, tenders: tsObj.trArray };
-                if (tsObj.setting.type === 'stage') updateData.cover = $('#ts-cover')[0].checked;
+                if (tsObj.setting.type === 'stage') {
+                    updateData.cover = $('#ts-cover')[0].checked;
+                    updateData.ignore = $('#ts-ignore')[0].checked;
+                }
                 if (updateData.tenders.length > 0) {
                     postData(window.location.pathname + '/sumLoad', updateData, result => {
                         tsObj.setting.afterLoad(result, tsObj.select);

+ 7 - 7
app/public/report/js/rpt_custom.js

@@ -310,13 +310,13 @@ const rptCustomObj = (function () {
         if (gsObj.setting.type === 'zone') $('#gather-by-zone').show();
         if (gsObj.setting.type === 'stage') $('#gather-by-stage').show();
         if (gsObj.setting.type === 'stage-zone') $('#gather-by-stage-zone').show();
-        if (gsObj.setting.type === 'checked-zone') $('#gather-by-checked-zone').show();
+        if (gsObj.setting.type === 'custom-zone') $('#gather-by-custom-zone').show();
 
         if (gsSelect) {
             if (gsSelect.zone) {
                 $('#gather-zone').val(gsSelect.zone ? gsSelect.zone : '');
-            } else if (gsSelect.checked_zone) {
-                $('#gather-checked-zone').val(gsSelect.checked_zone ? gsSelect.checked_zone : '');
+            } else if (gsSelect.custom_zone) {
+                $('#gather-custom-zone').val(gsSelect.custom_zone ? gsSelect.custom_zone : '');
             } else if (gsSelect.month) {
                 $('#gather-month').val(gsSelect.month ? gsSelect.month: '');
             } else if (gsSelect.stage) {
@@ -618,12 +618,12 @@ const rptCustomObj = (function () {
                 return;
             }
             data[sGatherSelect].stage_zone = stageBegin + ':' + stageEnd;
-        } else if (gsObj.setting.type === 'checked-zone') {
-            data[sGatherSelect].checked_zone = $('#gather-checked-zone').val();
-            if (data[sGatherSelect].checked_zone === '') {
+        } else if (gsObj.setting.type === 'custom-zone') {
+            data[sGatherSelect].custom_zone = $('#gather-custom-zone').val();
+            if (data[sGatherSelect].custom_zone === '') {
                 hintObj.html('请选择 汇总周期').show();
                 return;
-            } else if(data[sGatherSelect].checked_zone.indexOf(' - ') < 0) {
+            } else if(data[sGatherSelect].custom_zone.indexOf(' - ') < 0) {
                 hintObj.html('请选择 完整汇总周期').show();
                 return;
             }

+ 1 - 0
app/router.js

@@ -239,6 +239,7 @@ module.exports = app => {
     app.post('/tender/:id/revise/add', sessionAuth, tenderCheck, uncheckTenderCheck, 'reviseController.add');
     app.post('/tender/:id/revise/cancel', sessionAuth, tenderCheck, uncheckTenderCheck, 'reviseController.cancel');
     app.post('/tender/:id/revise/save', sessionAuth, tenderCheck, uncheckTenderCheck, 'reviseController.save');
+    app.post('/setting/revise/show-invalid', sessionAuth, 'reviseController.showInvalid');
 
     // 台账修订页面
     app.get('/tender/:id/revise/:rid/info', sessionAuth, tenderCheck, uncheckTenderCheck, reviseCheck, reviseAuditCheck, 'reviseController.info');

+ 2 - 2
app/service/ledger_revise.js

@@ -37,12 +37,12 @@ module.exports = app => {
          * @param {Number}tid - 标段id
          * @returns {Promise<*>} - ledger_change下所有数据,并关联 project_account(读取提交人名称、单位、公司)
          */
-        async getReviseList (tid) {
+        async getReviseList (tid, show_revise_invalid) {
             const sql = 'SELECT lc.id, lc.tid, lc.corder, lc.in_time, lc.uid, lc.begin_time, lc.end_time, lc.times, lc.status, lc.valid, lc.content, lc.pre_his_id, lc.his_id,' +
                 '    pa.name As user_name, pa.role As user_role, pa.company As user_company' +
                 '  FROM ' + this.tableName + ' As lc' +
                 '  INNER JOIN ' + this.ctx.service.projectAccount.tableName + ' As pa ON lc.uid = pa.id' +
-                '  WHERE lc.tid = ?' +
+                '  WHERE lc.tid = ?' + (show_revise_invalid ? '' : ' AND lc.valid = 1') +
                 '  ORDER BY lc.in_time DESC' +
                 '  LIMIT ?, ?';
             const Len = this.app.config.pageSize;

+ 6 - 1
app/service/material.js

@@ -72,7 +72,12 @@ module.exports = app => {
         async checkMaterial(tid, order) {
             if (this.ctx.material) return;
             const materials = await this.getSelectMaterial(tid, order);
-            this.ctx.material = materials[0]
+            this.ctx.material = materials[0];
+            if (this.ctx.session.sessionUser.accountId === this.ctx.material.user_id) {
+                this.ctx.material.curTimes = this.ctx.material.times;
+            } else {
+                this.ctx.material.curTimes = this.ctx.material.status === status.checkNo ? this.ctx.material.times - 1 : this.ctx.material.times;
+            }
         }
 
         /**

+ 12 - 8
app/service/payment_detail.js

@@ -195,22 +195,26 @@ module.exports = app => {
 
         async haveNotice2Tender(tid, uid) {
             const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pda' +
-                ' ON pd.`id` = pda.`td_id` WHERE pd.`tender_id` = ? AND (pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
-                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)';
-            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, tid,
+                ' ON pd.`id` = pda.`td_id` LEFT JOIN ?? as pra ON pd.`id` = pra.`td_id` WHERE pd.`tender_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
+                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)' +
+                ' OR (pra.`uid` = ? AND pra.`signature_msg` is null AND pd.`status` != ? AND pd.`status` != ?))';
+            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentRptAudit.tableName, tid,
                 uid, auditConst.status.uncheck, auditConst.status.checkNo,
-                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking];
+                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking,
+                uid, auditConst.status.uncheck, auditConst.status.checkNo];
             const result = await this.db.queryOne(sql, params);
             return result ? result.count : 0;
         }
 
         async haveNotice2TenderRpt(tr_id, uid) {
             const sql = 'SELECT count(pd.`id`) as count FROM ?? as pd LEFT JOIN ?? as pda' +
-                ' ON pd.`id` = pda.`td_id` WHERE pd.`tr_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
-                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?))';
-            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, tr_id,
+                ' ON pd.`id` = pda.`tr_id` LEFT JOIN ?? as pra ON pd.`id` = pra.`td_id` WHERE pd.`tr_id` = ? AND ((pd.`uid` = ? AND (pd.`status` = ? OR pd.`status` = ?))' +
+                ' OR ((pd.`status` = ? OR pd.`status` = ?) AND pda.aid = ? AND pda.`status` = ?)' +
+                ' OR (pra.`uid` = ? AND pra.`signature_msg` is null AND pd.`status` != ? AND pd.`status` != ?))';
+            const params = [this.tableName, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentRptAudit.tableName, tr_id,
                 uid, auditConst.status.uncheck, auditConst.status.checkNo,
-                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking];
+                auditConst.status.checking, auditConst.status.checkNoPre, uid, auditConst.status.checking,
+                uid, auditConst.status.uncheck, auditConst.status.checkNo];
             const result = await this.db.queryOne(sql, params);
             return result ? result.count : 0;
         }

+ 1 - 1
app/service/payment_detail_audit.js

@@ -394,7 +394,7 @@ module.exports = app => {
                 const updateDetailData = {
                     id: detailId,
                 };
-                const rptAudit = await this.getDataByCondition({ detailId, uid: audit.aid });
+                const rptAudit = await this.ctx.service.paymentRptAudit.getDataByCondition({ td_id: detailId, uid: audit.aid });
                 if (rptAudit && rptAudit.signature_msg) {
                     const report_json = JSON.parse(this.ctx.detail.report_json);
                     const sign_msg = JSON.parse(rptAudit.signature_msg);

+ 6 - 2
app/service/payment_tender.js

@@ -19,9 +19,13 @@ module.exports = app => {
 
         async getList(uid) {
             const sql = 'SELECT pt.*, pa.name as user_name FROM ?? as pt LEFT JOIN ?? as pa ON pt.`uid` = pa.`id` WHERE pt.`uid` = ? ' +
-                'OR pt.`id` in (SELECT pda.`tender_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tender_id` = pd.`tender_id` WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)';
+                'OR pt.`id` in (SELECT pda.`tender_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tender_id` = pd.`tender_id` ' +
+                'WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)' +
+                'OR pt.`id` in (SELECT pra.`tender_id` FROM ?? as pra LEFT JOIN ?? as pd ON pra.`tender_id` = pd.`tender_id` ' +
+                'WHERE (pd.`status` != ' + auditConst.status.uncheck + ' OR pd.`status` !=' + auditConst.status.checkNo + ') AND pra.`uid` = ?)';
             const params = [this.tableName, this.ctx.service.projectAccount.tableName, uid,
-                this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
+                this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid,
+                this.ctx.service.paymentRptAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
             return await this.db.query(sql, params);
         }
 

+ 4 - 2
app/service/payment_tender_rpt.js

@@ -19,8 +19,10 @@ module.exports = app => {
 
         async getList(tid, uid) {
             const sql = 'SELECT * FROM ?? WHERE `tender_id` = ?' +
-                ' AND `id` in (SELECT pda.`tr_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tr_id` = pd.`tr_id` WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)';
-            const params = [this.tableName, tid, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
+                ' AND (`id` in (SELECT pda.`tr_id` FROM ?? as pda LEFT JOIN ?? as pd ON pda.`tr_id` = pd.`tr_id` WHERE pd.`status` != ' + auditConst.status.uncheck + ' AND pda.`aid` = ?)' +
+                ' OR `id` in (SELECT pra.`tr_id` FROM ?? as pra LEFT JOIN ?? as pd ON pra.`tr_id` = pd.`tr_id` WHERE (pd.`status` != ' + auditConst.status.uncheck + ' OR pd.`status` != ' + auditConst.status.checkNo + ') AND pra.`uid` = ?))';
+            const params = [this.tableName, tid, this.ctx.service.paymentDetailAudit.tableName, this.ctx.service.paymentDetail.tableName, uid,
+                this.ctx.service.paymentRptAudit.tableName, this.ctx.service.paymentDetail.tableName, uid];
             return await this.db.query(sql, params);
         }
 

+ 32 - 24
app/service/rpt_gather_memory.js

@@ -314,7 +314,7 @@ module.exports = app => {
             }
             return [validStages, preStage, endStage];
         }
-        async _getCheckedZoneStages(tender, zone) {
+        async _getCustomZoneStages(tender, zone, timeType) {
             const times = zone.split(' - ');
             if (times.length !== 2) throw '选择的汇总周期无效';
             const beginTime = moment(times[0], 'YYYY-MM-DD');
@@ -323,20 +323,29 @@ module.exports = app => {
             const stages = await this._getValidStages(tender.id, 'asc'), validStages = [];
             let preStage, endStage;
             for (const stage of stages) {
-                if (stage.status !== auditConst.stage.status.checked) continue;
+                let sTime;
+                switch (timeType) {
+                    case 'final-checked':
+                        if (stage.status !== auditConst.stage.status.checked) continue;
 
-                // const finalAudit = await this.ctx.service.stageAudit.getLastestAuditor(stage.id, stage.times, stage.status);
-                // if (!finalAudit) continue;
-                //
-                // const sTime = moment(moment(finalAudit.end_time).format('YYYY-MM-DD'), 'YYYY-MM-DD');
-                const sTime = stage.period ? (stage.period.split(' ~ ')[1] ? stage.period.split(' ~ ')[1] : s.period)  : '';
+                        const finalAudit = await this.ctx.service.stageAudit.getLastestAuditor(stage.id, stage.times, stage.status);
+                        if (!finalAudit) continue;
+
+                        sTime = moment(finalAudit.end_time).format('YYYY-MM-DD');
+                        break;
+                    case 'period-end':
+                        sTime = stage.period ? (stage.period.split(' ~ ')[1] ? stage.period.split(' ~ ')[1] : stage.period)  : '';
+                        break;
+                    default:
+                        throw '配置参数错误';
+                }
                 stage.checked_day = sTime;
-                stage.checked_time = moment(finalAudit.end_time);
-                if (sTime.isBetween(beginTime, endTime, null, '[]')) {
+                stage.checked_time = moment(sTime, 'YYYY-MM-DD');
+                if (stage.checked_time.isBetween(beginTime, endTime, null, '[]')) {
                     validStages.push(stage);
-                } else if (sTime.isBefore(beginTime)) {
+                } else if (stage.checked_time.isBefore(beginTime)) {
                     if (!preStage || preStage.checked_time.isBefore(stage.checked_time)) preStage = stage;
-                } else if (sTime.isAfter(endTime)) {
+                } else if (stage.checked_time.isAfter(endTime)) {
                     if (!endStage || endStage.checked_time.isAfter(stage.checked_time)) endStage = stage;
                 }
             }
@@ -486,8 +495,8 @@ module.exports = app => {
             const [stages, preStage, endStage] = await this._getOrderZoneStages(tender, stageZone);
             await this._gatherStagesData(completeData, tender, stages, preStage);
         }
-        async _gatherCheckedZoneData(tender, completeData, zone) {
-            const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
+        async _gatherCustomZoneData(tender, completeData, zone, timeType) {
+            const [stages, preStage, endStage] = await this._getCustomZoneStages(tender, zone, timeType);
             await this._gatherStagesData(completeData, tender, stages, preStage);
         }
         async _gatherMonthsData(tender, completeData, month) {
@@ -701,8 +710,8 @@ module.exports = app => {
                         case 'stage-zone':
                             await this._gatherIndexZoneData(tender, completeData, gsCustom.stage_zone);
                             break;
-                        case 'checked-zone':
-                            await this._gatherCheckedZoneData(tender, completeData, gsCustom.checked_zone);
+                        case 'custom-zone':
+                            await this._gatherCustomZoneData(tender, completeData, gsCustom.custom_zone, gsSetting.timeType);
                             break;
                     }
                     commonIndex++;
@@ -819,9 +828,9 @@ module.exports = app => {
             await this._getStagesTenderInfo(stages, info, preStage);
             this.resultTenderInfo.push(info);
         }
-        async _gatherCheckedZoneTenderInfo(tender, index, zone) {
+        async _gatherCustomZoneTenderInfo(tender, index, zone, timeType) {
             const info = await this._getBaseTenderInfo(tender);
-            const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
+            const [stages, preStage, endStage] = await this._getCustomZoneStages(tender, zone, timeType);
             await this._getStagesTenderInfo(stages, info, preStage);
             this.resultTenderInfo.push(info);
         }
@@ -894,8 +903,8 @@ module.exports = app => {
                         case 'stage-zone':
                             await this._gatherOrderZoneTenderInfo(tender, commonIndex, gsCustom.stage_zone);
                             break;
-                        case 'checked-zone':
-                            await this._gatherCheckedZoneTenderInfo(tender, commonIndex, gsCustom.checked_zone);
+                        case 'custom-zone':
+                            await this._gatherCustomZoneTenderInfo(tender, commonIndex, gsCustom.custom_zone, gsSetting.timeType);
                             break;
                     }
                     commonIndex++;
@@ -1016,9 +1025,9 @@ module.exports = app => {
             const [stages, preStage, endStage] = await this._getOrderZoneStages(tender, stageZone);
             await this._gatherStagesPay(completeData, tender, stages, preStage);
         }
-        async _gatherCheckedZoneStagePay(sTender, completeData, zone) {
+        async _gatherCustomZoneStagePay(sTender, completeData, zone, timeType) {
             const tender = await this.ctx.service.tender.getCheckTender(sTender.tid);
-            const [stages, preStage, endStage] = await this._getCheckedZoneStages(tender, zone);
+            const [stages, preStage, endStage] = await this._getCustomZoneStages(tender, zone, timeType);
             await this._gatherStagesPay(completeData, tender, stages, preStage);
         }
 
@@ -1078,8 +1087,8 @@ module.exports = app => {
                         case 'stage-zone':
                             await this._gatherOrderZoneStagePay(tender, completeData, gsCustom.stage_zone);
                             break;
-                        case 'checked-zone':
-                            await this._gatherCheckedZoneStagePay(tender, completeData, gsCustom.checked_zone);
+                        case 'custom-zone':
+                            await this._gatherCustomZoneStagePay(tender, completeData, gsCustom.custom_zone, gsSetting.timeType);
                             break;
                     }
                     commonIndex++;
@@ -1382,7 +1391,6 @@ module.exports = app => {
             this.resultStageBonus = [];
             const gsSetting = JSON.parse(gsDefine.setting);
             for (const tender of gsCustom.tenders) {
-                console.log(tender, gsSetting.type);
                 switch (gsSetting.type) {
                     case 'month':
                         await this._gatherMonthStageBonus(tender, gsCustom.month);

+ 3 - 3
app/service/stage.js

@@ -299,9 +299,6 @@ module.exports = app => {
                 orders: [['order', 'desc']],
             });
             for (const s of stages) {
-                s.tp = this.ctx.helper.sum([s.contract_tp, s.qc_tp, s.pc_tp]);
-                s.pre_tp = this.ctx.helper.add(s.pre_contract_tp, s.pre_qc_tp);
-                s.end_tp = this.ctx.helper.add(s.pre_tp, s.tp);
                 s.tp_history = s.tp_history ? JSON.parse(s.tp_history) : [];
             }
             if (stages.length !== 0 && !this.ctx.session.sessionUser.is_admin) {
@@ -319,6 +316,9 @@ module.exports = app => {
 
             await this.checkStageGatherData(stages[0], true);
             for (const s of stages) {
+                s.tp = this.ctx.helper.sum([s.contract_tp, s.qc_tp, s.pc_tp]);
+                s.pre_tp = this.ctx.helper.add(s.pre_contract_tp, s.pre_qc_tp);
+                s.end_tp = this.ctx.helper.add(s.pre_tp, s.tp);
                 if (s.yf_tp && s.sf_tp === 0) {
                     const sf = await this.ctx.service.stagePay.getHistorySf(s);
                     if (sf && s.readOnly) {

+ 2 - 2
app/service/stage_bills.js

@@ -517,13 +517,13 @@ module.exports = app => {
             return { contract_tp, qc_tp };
         }
 
-        async sumLoad(lid, tenders, cover) {
+        async sumLoad(lid, tenders, cover, ignore) {
             const conn = await this.db.beginTransaction();
             try {
                 const maxId = await this.ctx.service.ledger._getMaxLid(this.ctx.tender.id);
                 const select = await this.ctx.service.ledger.getCompleteDataById(lid);
                 const sumLoad = new SumLoad(this.ctx);
-                const loadTree = await sumLoad.stageGatherGcl(select, maxId, tenders, null, cover);
+                const loadTree = await sumLoad.stageGatherGcl(select, maxId, tenders, null, cover, ignore);
                 const result = loadTree.getUpdateData();
                 // if (result.errors.length > 100) throw '您导入的数据存在大量数据错误,请您仔细检查';
 

+ 2 - 2
app/view/payment/list.ejs

@@ -4,10 +4,10 @@
             <div><%- ctx.tender.name %></div>
             <div>
                 <% if (ctx.session.sessionUser.accountId === trInfo.uid && trInfo.is_del === 0 && rptMsg) { %>
-                <% if (trDetailList.length === 0 || trDetailList[0].status === auditConst.status.checked) { %>
+                <% if (trDetailList.length === 0 || (trDetailList.length !== 0 && trDetailList[0].status === auditConst.status.checked)) { %>
                 <a href="javascript:void(0);" id="show-add-btn" class="btn btn-sm btn-primary pull-right ml-2">新建审批</a>
                 <% } %>
-                <% if (trDetailList.length === 0 || trDetailList[0].status === auditConst.status.uncheck || trDetailList[0].status === auditConst.status.checkNo) { %>
+                <% if (trDetailList.length === 0 || trDetailList[0].status === auditConst.status.checked || trDetailList[0].status === auditConst.status.uncheck || trDetailList[0].status === auditConst.status.checkNo) { %>
                 <a href="#set-bdjs" data-toggle="modal" data-target="#set-bdjs" class="btn btn-sm btn-primary pull-right">绑定表单角色</a>
                 <span class="text-danger pull-right" id="first_msg" <% if (trInfo.is_first === 0) { %>style="display:none;" <% } %>>第一次新建审批,请点击右侧的“绑定表单角色” &nbsp; &nbsp; </span>
                 <% } %>

+ 2 - 2
app/view/report/rpt_all_popup.ejs

@@ -398,12 +398,12 @@
                                 <input id="gather-zone" class="datepicker-here form-control mt-0" placeholder="点击选择周期" data-range="true" data-multiple-dates-separator=" - "  data-min-view="months" data-view="months" data-date-format="yyyy-MM" data-language="zh" type="text" autocomplete="off">
                             </div>
                         </div>
-                        <div id="gather-by-checked-zone" name="gather-type">
+                        <div id="gather-by-custom-zone" name="gather-type">
                             <div class="input-group input-group-sm">
                                 <div class="input-group-prepend">
                                     <span class="input-group-text">汇总周期</span>
                                 </div>
-                                <input id="gather-checked-zone" class="datepicker-here form-control mt-0" placeholder="点击选择周期" data-range="true" data-multiple-dates-separator=" - "  data-min-view="days" data-view="days" data-date-format="yyyy-MM-dd" data-language="zh" type="text" autocomplete="off">
+                                <input id="gather-custom-zone" class="datepicker-here form-control mt-0" placeholder="点击选择周期" data-range="true" data-multiple-dates-separator=" - "  data-min-view="days" data-view="days" data-date-format="yyyy-MM-dd" data-language="zh" type="text" autocomplete="off">
                             </div>
                         </div>
                         <div id="gather-by-stage" name="gather-type">

+ 11 - 0
app/view/revise/index.ejs

@@ -12,6 +12,17 @@
                         </div>
                     </div>
                 </div>
+                <div class="d-inline-block ml-2">
+                    <div class="input-group input-group-sm">
+                        <form action="/setting/revise/show-invalid?show=<%- (show_invalid ? 0 : 1) %>" method="post" onchange="submit();">
+                        <div class="form-group form-check">
+                            <input type="checkbox" class="form-check-input group-checkbox" id="show-revise-invalid" <%- (show_invalid ? '' : 'checked')%>>
+                            <label class="form-check-label" for="show-revise-invalid">不显示作废修订</label>
+                        </div>
+                            <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>">
+                        </form>
+                    </div>
+                </div>
             </div>
             <div class="ml-auto">
                 <% if (addVisible) { %>

+ 4 - 0
app/view/shares/batch_import_modal.ejs

@@ -15,6 +15,10 @@
                                 <input class="form-check-input" type="checkbox" id="bi-cover">
                                 <label class="form-check-label" for="bi-cover">覆盖数据</label>
                             </div>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="bi-ignore">
+                                <label class="form-check-label" for="bi-ignore">以本标段清单为准</label>
+                            </div>
                         </div>
                         <div class="ml-auto">
                             <button class="btn btn-sm btn-primary" id="bi-start">导入</button>

+ 4 - 0
app/view/shares/tender_select_modal.ejs

@@ -23,6 +23,10 @@
                                 <input class="form-check-input" type="checkbox" id="ts-cover">
                                 <label class="form-check-label" for="ts-cover">覆盖数据</label>
                             </div>
+                            <div class="form-check form-check-inline">
+                                <input class="form-check-input" type="checkbox" id="ts-ignore">
+                                <label class="form-check-label" for="ts-ignore">以本标段清单为准</label>
+                            </div>
                         </div>
                     </div>
                     <div id="tender-select-hint">

+ 7 - 7
config/menu.js

@@ -57,13 +57,6 @@ const menu = {
         children: null,
         caption: '动态投资',
     },
-    management: {
-        name: '项目管理系统',
-        icon: 'fa-cubes',
-        display: false,
-        caption: '项目管理系统',
-        children: null,
-    },
     payment: {
         name: '支付审批',
         icon: 'fa-handshake-o',
@@ -72,6 +65,13 @@ const menu = {
         caption: '支付审批',
         children: null,
     },
+    management: {
+        name: '项目管理系统',
+        icon: 'fa-cubes',
+        display: false,
+        caption: '项目管理系统',
+        children: null,
+    },
     // sum: {
     //     name: '总分包',
     //     icon: 'fa-sitemap',

+ 2 - 0
sql/update.sql

@@ -5,6 +5,8 @@ where userId='Administrator';
 ALTER TABLE `zh_project_account`
 ADD COLUMN `self_category_level`  varchar(255) NOT NULL DEFAULT '' AFTER `invalid_time`;
 
+ALTER TABLE `zh_project_account`
+ADD COLUMN `show_revise_invalid`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否显示,台账修订作废' AFTER `self_category_level`;
 
 
 -- 很重要!!!!