Tony Kang 20 часов назад
Родитель
Сommit
40da955bbe

+ 5 - 5
app/controller/report_controller.js

@@ -1699,19 +1699,19 @@ module.exports = app => {
             const roleRel = await ctx.service.roleRptRel.getRoleRptRelByDetailIds(params.tender_id, params.rpt_tpl_id, params.stage_id, params.business_id); // 新需求中,允许在非审核状态下设置签名
 
             let stgAudit = null,
-                stgAuditForOrg = null,
+                // stgAuditForOrg = null,
                 stageFlow = null,
                 stageList = [],
                 ledger = [];
             if (params.stage_id > 0) {
                 stgAudit = await ctx.service.stageAudit.getStageAudit(params.stage_id, params.stage_times);
-                stgAuditForOrg = await ctx.service.stageAudit.getStageAudit(params.stage_id, 1);
+                // stgAuditForOrg = await ctx.service.stageAudit.getStageAudit(params.stage_id, 1);
                 stageList = await ctx.service.stage.getValidStagesShort(params.tender_id);
                 stageFlow = await ctx.service.stageAudit.getAuditGroupByListWithOwner(params.stage_id, params.stage_times);
                 ledger = await ctx.service.ledger.getDataOnlyByNodeId(params.tender_id);
             } else if ([-100, -200].includes(params.stage_id)) {
                 stgAudit = await ctx.service.paymentDetailAudit.getAuditors(params.detail_id, params.stage_times);
-                stgAuditForOrg = await ctx.service.paymentDetailAudit.getAuditors(params.detail_id, 1);
+                // stgAuditForOrg = await ctx.service.paymentDetailAudit.getAuditors(params.detail_id, 1);
                 stageFlow = await ctx.service.paymentDetailAudit.getAuditorsWithOwner(params.detail_id);
                 const paymentDetailList = await ctx.service.paymentDetail.getDetail(params.detail_id);
                 if (paymentDetailList && paymentDetailList.length > 0) {
@@ -1721,7 +1721,7 @@ module.exports = app => {
             } else if ([-150, -300, -301, -302, -303, -400, -500, -600, -700].includes(params.stage_id)) {
                 // 变更令、预付款、材差相关的
                 stgAudit = [];
-                stgAuditForOrg = [];
+                // stgAuditForOrg = [];
                 stageFlow = [];
                 await this._commonGetAudit(ctx, params, stgAudit, stageFlow);
                 stgAudit.sort(function(stg1, stg2) {
@@ -1750,7 +1750,7 @@ module.exports = app => {
                 data: pageRst,
                 signatureRelInfo: roleRel,
                 stageAudit: stgAudit,
-                stageAuditOrg: stgAuditForOrg,
+                // stageAuditOrg: stgAuditForOrg,
                 debugInfo: ctx.session.sessionUser.loginStatus ? ctx.debugInfo : null,
                 customDefine: rptTpl[JV.NODE_CUSTOM_DEFINE],
                 stageFlow,

+ 42 - 34
app/controller/stage_controller.js

@@ -65,7 +65,7 @@ module.exports = app => {
                     dagl: ctx.session.sessionProject.dagl_status,
                 },
                 shenpiConst,
-                auditType
+                auditType,
             };
             if (((ctx.stage.status === auditConst.status.uncheck || ctx.stage.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.stage.user_id) || ctx.session.sessionUser.is_admin) {
                 // data.accountGroup = accountGroup;
@@ -272,7 +272,7 @@ module.exports = app => {
                 }
             }
             // 结算状态
-            const settleStatus = ctx.stage.readySettle ? await ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: ctx.stage.readySettle.id }}) : [];
+            const settleStatus = ctx.stage.readySettle ? await ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: ctx.stage.readySettle.id } }) : [];
             // 查询截止上期数据
             const preStageData = ctx.stage.preCheckedStage ? await ctx.service.stageBillsFinal.getFinalData(ctx.tender.data, ctx.stage.preCheckedStage.order) : [];
             const exprData = await ctx.service.expr.getAllDataByCondition({ where: { tid: ctx.stage.tid, calc_module: 'stage' } });
@@ -309,12 +309,12 @@ module.exports = app => {
                 }
             }
             // 结算状态
-            const settleStatus = ctx.stage.readySettle ? await ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: ctx.stage.readySettle.id }}) : [];
+            const settleStatus = ctx.stage.readySettle ? await ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: ctx.stage.readySettle.id } }) : [];
             // 查询截止上期数据
             const preStageData = ctx.stage.preCheckedStage ? await ctx.service.stagePosFinal.getFinalData(ctx.tender.data, ctx.stage.preCheckedStage.order) : [];
             this.ctx.helper.assignRelaData(posData, [
-                { data: memoData, fields: this.posMemoColumn, prefix: '', relaId: 'id'},
-                { data: extraData, fields: this.posExtraColumn, prefix: '', relaId: 'id'},
+                { data: memoData, fields: this.posMemoColumn, prefix: '', relaId: 'id' },
+                { data: extraData, fields: this.posExtraColumn, prefix: '', relaId: 'id' },
                 { data: curStageData, fields: ['contract_qty', 'contract_expr', 'qc_qty', 'qc_minus_qty', 'postil', 'ex_stage_qty1'], prefix: '', relaId: 'pid' },
                 { data: preStageData, fields: ['contract_qty', 'qc_qty', 'qc_minus_qty', 'ex_stage_qty1', 'used_time', 'update_time'], prefix: 'pre_', relaId: 'pid' },
                 { data: settleStatus, fields: ['settle_status'], prefix: '', relaId: 'pid' },
@@ -337,16 +337,16 @@ module.exports = app => {
 
         async _getChangeData(ctx) {
             const change = await ctx.service.change.getAllDataByCondition({
-                columns: [ 'cid', 'code', 'name', 'w_code' ],
+                columns: ['cid', 'code', 'name', 'w_code'],
                 where: { tid: ctx.tender.id, valid: 1, status: changeAudit.status.checked },
                 orders: [['code', 'asc']],
             });
             const changeBills = await ctx.service.changeAuditList.getAllDataByCondition({
-                columns: [ 'id', 'cid', 'code', 'name', 'unit', 'unit_price', 'oamount2', 'checked_amount', 'checked_price', 'is_valuation', 'gcl_id', 'bwmx', 'mx_id'],
-                where: { tid: ctx.tender.id }
+                columns: ['id', 'cid', 'code', 'name', 'unit', 'unit_price', 'oamount2', 'checked_amount', 'checked_price', 'is_valuation', 'gcl_id', 'bwmx', 'mx_id'],
+                where: { tid: ctx.tender.id },
             });
             const changeIndex = {};
-            change.forEach(x => { changeIndex[x.cid] = x; x.bills = [] });
+            change.forEach(x => { changeIndex[x.cid] = x; x.bills = []; });
             changeBills.forEach(cb => {
                 const c = changeIndex[cb.cid];
                 if (!c) return;
@@ -354,23 +354,23 @@ module.exports = app => {
             });
             const helper = ctx.helper;
             change.forEach(x => {
-                x.bills.sort((a, b) => { return helper.compareCode(a.code, b.code)});
+                x.bills.sort((a, b) => { return helper.compareCode(a.code, b.code); });
             });
             return change;
         }
 
         async _getReCalcChangeData(ctx) {
             const change = await ctx.service.change.getAllDataByCondition({
-                columns: [ 'cid', 'code', 'name', 'w_code', 'tp_decimal', 'up_decimal' ],
+                columns: ['cid', 'code', 'name', 'w_code', 'tp_decimal', 'up_decimal'],
                 where: { tid: ctx.tender.id, valid: 1, status: changeAudit.status.checked },
                 orders: [['code', 'asc']],
             });
             const changeBills = await ctx.service.changeAuditList.getAllDataByCondition({
-                columns: [ 'id', 'cid', 'code', 'name', 'unit', 'unit_price', 'oamount2', 'checked_amount', 'checked_price', 'is_valuation', 'gcl_id', 'bwmx', 'mx_id'],
-                where: { tid: ctx.tender.id }
+                columns: ['id', 'cid', 'code', 'name', 'unit', 'unit_price', 'oamount2', 'checked_amount', 'checked_price', 'is_valuation', 'gcl_id', 'bwmx', 'mx_id'],
+                where: { tid: ctx.tender.id },
             });
             const changeIndex = {};
-            change.forEach(x => { changeIndex[x.cid] = x; x.bills = [] });
+            change.forEach(x => { changeIndex[x.cid] = x; x.bills = []; });
             changeBills.forEach(cb => {
                 const c = changeIndex[cb.cid];
                 if (!c) return;
@@ -406,7 +406,7 @@ module.exports = app => {
                     b.tp = helper.mul(b.unit_price, b.qty, tpDecimal);
                     b.minus_tp = helper.mul(b.unit_price, b.minus_qty, tpDecimal);
                 });
-                x.bills.sort((a, b) => { return helper.compareCode(a.code, b.code)});
+                x.bills.sort((a, b) => { return helper.compareCode(a.code, b.code); });
             });
             return change;
         }
@@ -483,7 +483,7 @@ module.exports = app => {
                             responseData.data.cooperationConfirm = await ctx.service.cooperationConfirm.getValidData(ctx.tender.id, ctx.stage.id, ctx.stage.times, ctx.session.sessionUser.accountId);
                             break;
                         case 'spec':
-                            const spec = {zlj: JSON.parse(JSON.stringify(stdConst.zlj)), jrg: stdConst.jrg};
+                            const spec = { zlj: JSON.parse(JSON.stringify(stdConst.zlj)), jrg: stdConst.jrg };
                             spec.zlj.deal_bills_tp = ctx.tender.info.deal_param.zanLiePrice;
                             responseData.data.spec = spec;
                             break;
@@ -502,7 +502,7 @@ module.exports = app => {
         }
 
         async _innerCheckChangeBillsOver(ctx, checkData) {
-            const change = await this.ctx.service.change.getAllDataByCondition({ where: { tid: ctx.tender.id }});
+            const change = await this.ctx.service.change.getAllDataByCondition({ where: { tid: ctx.tender.id } });
             if (change.length > 0) {
                 const cid = change.map(x => { return x.cid; });
                 const changeBills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid } });
@@ -565,7 +565,7 @@ module.exports = app => {
                 if (!ctx.stage.update_expr_calc_time || (ctx.stage.update_calc_time && ctx.stage.update_expr_calc_time < ctx.stage.update_calc_time)) {
                     const exprCount = await ctx.service.expr.count({ tid: ctx.stage.tid, calc_module: 'stage' });
                     if (exprCount > 0) {
-                        checkData.checkResult.error.push({ errorType: 'expr_no_calc', name: '修改数据后,未计算本期合同计量' })
+                        checkData.checkResult.error.push({ errorType: 'expr_no_calc', name: '修改数据后,未计算本期合同计量' });
                     }
                 }
                 ctx.body = { err: 0, msg: '', data: checkData.checkResult };
@@ -615,9 +615,11 @@ module.exports = app => {
                 ? await ctx.service.stageChange.getAuditorAllStageData(ctx.tender.id, ctx.stage.id, ctx.stage.curTimes, ctx.stage.curOrder)
                 : await ctx.service.stageChange.getLastestAllStageData(ctx.tender.id, ctx.stage.id);
             for (const cb of checkBills) {
-                const useChanges = stageChange.filter(sc => { return sc.lid === cb.lid && sc.pid === '-1'});
-                const checkQcQty = cb.qc_qty || 0, checkQcMinusQty = cb.qc_minus_qty || 0;
-                let qc_qty = 0, qc_minus_qty = 0;
+                const useChanges = stageChange.filter(sc => { return sc.lid === cb.lid && sc.pid === '-1'; });
+                const checkQcQty = cb.qc_qty || 0,
+                    checkQcMinusQty = cb.qc_minus_qty || 0;
+                let qc_qty = 0,
+                    qc_minus_qty = 0;
                 for (const uc of useChanges) {
                     if (uc.no_value) {
                         qc_minus_qty = this.ctx.helper.add(qc_minus_qty, uc.qty);
@@ -629,8 +631,10 @@ module.exports = app => {
             }
             for (const cb of checkPos) {
                 const useChanges = stageChange.filter(sc => { return sc.lid === cb.lid && sc.pid === cb.pid; });
-                const checkQcQty = cb.qc_qty || 0, checkQcMinusQty = cb.qc_minus_qty || 0;
-                let qc_qty = 0, qc_minus_qty = 0;
+                const checkQcQty = cb.qc_qty || 0,
+                    checkQcMinusQty = cb.qc_minus_qty || 0;
+                let qc_qty = 0,
+                    qc_minus_qty = 0;
                 for (const uc of useChanges) {
                     if (uc.no_value) {
                         qc_minus_qty = this.ctx.helper.add(qc_minus_qty, uc.qty);
@@ -1151,7 +1155,7 @@ module.exports = app => {
                 const payAtt = await ctx.service.payAtt.getStageData({ sid: ctx.stage.id });
                 // 附件不取下载地址
                 for (const dp of renderData.dealPay) {
-                    dp.attachment = payAtt.filter(x => { return x.pid === dp.pid });
+                    dp.attachment = payAtt.filter(x => { return x.pid === dp.pid; });
                 }
                 renderData.calcBase = await ctx.service.stage.getStagePayCalcBase(ctx.stage, ctx.tender.info);
                 renderData.jsFiles = this.app.jsFiles.common.concat(this.app.jsFiles.stage.pay);
@@ -1324,7 +1328,7 @@ module.exports = app => {
             const helper = this.ctx.helper;
             data.attachments = await this.ctx.service.changeAtt.getChangeAttachment(cid);
             data.bills = await this.ctx.service.changeAuditList.getAllDataByCondition({ where: { cid } });
-            data.bills.sort((a, b) => { return helper.compareCode(a.code, b.code)});
+            data.bills.sort((a, b) => { return helper.compareCode(a.code, b.code); });
             if (isImport) {
                 data.endUsedBills = await this.ctx.service.stageImportChange.getChangeEndUsedData(tid, cid);
                 data.curUsedBills = await this.ctx.service.stageImportChange.getChangeUsedData(sid, cid);
@@ -1520,6 +1524,9 @@ module.exports = app => {
                 }
 
                 await ctx.service.stageAudit.check(ctx.stage.id, data, ctx.stage.times);
+                // // 这里要调用签名的service,重设签名日期
+                // const rstMsg = await ctx.service.roleRptRel.refreshSignatureDate(ctx.tender.data.id, ctx.stage.id, 'stage', -1);
+                // console.log(rstMsg);
                 ctx.body = { err: 0, msg: '', data: [] };
             } catch (err) {
                 this.log(err);
@@ -1691,7 +1698,7 @@ module.exports = app => {
                 for (const order of data.roles) {
                     const data = { order, bills: [], pos: [] };
                     const compareTimes = ctx.stage.status === auditConst.status.checkNo && !ctx.stage.readOnly
-                        ? ( order === 0 ? ctx.stage.curTimes : ctx.stage.curTimes - 1)
+                        ? (order === 0 ? ctx.stage.curTimes : ctx.stage.curTimes - 1)
                         : ctx.stage.curTimes;
                     data.bills = await ctx.service.stageBills.getAuditorStageData2(ctx.tender.id, ctx.stage.id, compareTimes, order);
                     data.pos = await ctx.service.stagePos.getAuditorStageData2(ctx.tender.id, ctx.stage.id, compareTimes, order);
@@ -2436,7 +2443,7 @@ module.exports = app => {
             try {
                 const ledgerData = await ctx.service.ledger.getAllDataByCondition({
                     columns: ['id', 'ledger_id', 'ledger_pid', 'level', 'order', 'full_path', 'is_leaf', 'code', 'b_code', 'name', 'unit', 'unit_price', 'node_type'],
-                    where: { tender_id: ctx.tender.id }
+                    where: { tender_id: ctx.tender.id },
                 });
                 const extraLedgerData = await ctx.service.ledgerExtra.getData(ctx.tender.id, this.ledgerExtraColumn);
                 const dgnData = await ctx.service.stageBillsDgn.getDgnData(ctx.tender.id);
@@ -2451,7 +2458,7 @@ module.exports = app => {
 
                 const posData = await ctx.service.pos.getAllDataByCondition({
                     columns: ['id', 'lid', 'name', 'position', 'porder'],
-                    where: { tid: ctx.tender.id }
+                    where: { tid: ctx.tender.id },
                 });
                 // 根据当前人,或指定对象查询数据
                 const curStagePosData = ctx.stage.readOnly
@@ -2481,7 +2488,7 @@ module.exports = app => {
                     'Content-Disposition': disposition,
                 });
                 ctx.body = await fs.readFileSync(filepath);
-            } catch(err) {
+            } catch (err) {
                 ctx.log(err);
                 ctx.postError(err, '导出计量数据失败');
             }
@@ -2490,7 +2497,8 @@ module.exports = app => {
         async importStageData(ctx) {
             const create_time = Date.parse(new Date()) / 1000;
             const filepath = path.join(this.ctx.app.baseDir, 'temp', `计量数据${create_time}.cpd`);
-            let stream, index = 0;
+            let stream,
+                index = 0;
             try {
                 const parts = ctx.multipart({ autoFields: true });
                 stream = await parts();
@@ -2528,7 +2536,7 @@ module.exports = app => {
                 if (!result) {
                     throw '切换审批组失败';
                 }
-                
+
                 const auditors = await ctx.service.stageAudit.getUserGroup(ctx.stage.id, ctx.stage.times);
                 ctx.body = { err: 0, msg: '', data: auditors };
             } catch (err) {
@@ -2544,7 +2552,7 @@ module.exports = app => {
 
                 let result;
                 const fileInfo = path.parse(data.fileInfo.filename);
-                switch(data.type) {
+                switch (data.type) {
                     case 'begin':
                         const create_time = Date.parse(new Date()) / 1000;
                         result = {
@@ -2563,7 +2571,7 @@ module.exports = app => {
                             filename: fileInfo.name, fileext: fileInfo.ext, filesize: data.fileInfo.filesize,
                             extra_upload,
                         };
-                        result = await ctx.service.stageAtt.save({ lid: data.lid}, fileData, ctx.session.sessionUser.accountId);
+                        result = await ctx.service.stageAtt.save({ lid: data.lid }, fileData, ctx.session.sessionUser.accountId);
                         if (!result) {
                             throw '导入数据库保存失败';
                         }
@@ -2571,7 +2579,7 @@ module.exports = app => {
                         result = [result];
                         break;
                 }
-                ctx.body = {err: 0, msg: '', data: result };
+                ctx.body = { err: 0, msg: '', data: result };
             } catch (error) {
                 ctx.log(error);
                 ctx.body = this.ajaxErrorBody(error, '上传附件失败,请重试');

+ 2 - 1
app/public/report/js/rpt_main.js

@@ -540,7 +540,8 @@ let zTreeOprObj = {
                 let pageRst = result.data;
                 if (params.needWaterMark) COMMON_WATER_MARK_PIC_DATA = result.waterMarkStr;
                 STAGE_AUDIT = result.stageAudit || [];
-                STAGE_AUDIT_ORG = result.stageAuditOrg || [];
+                // STAGE_AUDIT_ORG = result.stageAuditOrg || [];
+                STAGE_AUDIT_ORG = JSON.parse(JSON.stringify(STAGE_AUDIT));
                 STAGE_FLOW = result.stageFlow || [];
                 LEDGER_LIST = result.ledger || [];
                 //stageAuditOrg

+ 60 - 0
app/service/role_rpt_rel.js

@@ -325,6 +325,66 @@ module.exports = app => {
             }
             if (updateData.length > 0) await transaction.updateRows(this.tableName, updateData);
         }
+
+        // 此方法是给审批退回后,更新签名日期用的(因为审批退回后,之前的签名日期就废了,需要重新通过)
+        async refreshSignatureDate(tender_id, sid, business_type, business_id, rpt_id = null) {
+            this.initSqlBuilder();
+            this.sqlBuilder.setAndWhere('tender_id', {
+                value: tender_id,
+                operate: '=',
+            });
+            this.sqlBuilder.setAndWhere('sid', {
+                value: sid,
+                operate: '=',
+            });
+            this.sqlBuilder.setAndWhere('business_type', {
+                value: `"${business_type}"`,
+                operate: '=',
+            });
+            this.sqlBuilder.setAndWhere('business_id', {
+                value: `"${business_id}"`,
+                operate: '=',
+            });
+            if (rpt_id !== null && rpt_id !== '') {
+                this.sqlBuilder.setAndWhere('rpt_id', {
+                    value: rpt_id,
+                    operate: '=',
+                });
+            }
+            this.sqlBuilder.columns = ['id', 'tender_id', 'rpt_id', 'sid', 'business_id', 'rel_content'];
+            const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
+            const list = await this.db.query(sql, sqlParam);
+            const rstMsg = [];
+            // const updateObj = {};
+            for (let idx = 0; idx < list.length; idx++) {
+                const ud_rpt_id = list[idx].rpt_id;
+                const ud_rel_content = JSON.parse(list[idx].rel_content);
+                for (let rIdx = 0; rIdx < ud_rel_content.length; rIdx++) {
+                    ud_rel_content[rIdx].sign_date = '';
+                }
+                const data = {
+                    id: list[idx].id,
+                    tender_id,
+                    rpt_id: ud_rpt_id,
+                    sid,
+                    business_id,
+                    business_type,
+                    rel_content: JSON.stringify(ud_rel_content),
+                };
+                this.transaction = await this.db.beginTransaction();
+                try {
+                    await this.transaction.update(this.tableName, data);
+                    await this.transaction.commit();
+                    rstMsg.push({ tender_id, sid, business_type, business_id, rpt_id: ud_rpt_id, msg: '更新成功' });
+                } catch (ex) {
+                    console.log(ex);
+                    rstMsg.push({ tender_id, sid, business_type, business_id, rpt_id: ud_rpt_id, errMsg: ex.toString(), msg: '更新失败' });
+                    // 回滚
+                    await this.transaction.rollback();
+                }
+            }
+            return rstMsg;
+        }
     }
     return RoleRptRel;
 };