|
|
@@ -307,7 +307,7 @@ module.exports = app => {
|
|
|
|
|
|
const GclGather = require('../lib/gcl_gather');
|
|
|
const gclGatherModal = new GclGather.gclCompareGather(this.ctx);
|
|
|
- const spec = {zlj: stdConst.zlj, jrg: stdConst.jrg};
|
|
|
+ const spec = { zlj: stdConst.zlj, jrg: stdConst.jrg };
|
|
|
spec.zlj.deal_bills_tp = ctx.tender.info.deal_param.zanLiePrice;
|
|
|
gclGatherModal.init(ctx.tender.info.chapter, spec);
|
|
|
const reviseBillsData = revise.readOnly && revise.curHis
|
|
|
@@ -326,11 +326,125 @@ module.exports = app => {
|
|
|
revise.org_tp = gclGatherModal.otherChapter.hj.org_total_price || 0;
|
|
|
|
|
|
ctx.body = { code: 0, msg: '', data: { revise } };
|
|
|
- } catch(error) {
|
|
|
+ } catch (error) {
|
|
|
ctx.log(error);
|
|
|
ctx.body = { code: -1, msg: error.toString(), data: null };
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ async ledgerAuditCheck(ctx) {
|
|
|
+ const tender = ctx.tender.data;
|
|
|
+ const info = ctx.tender.info;
|
|
|
+ if (info.shenpi.ledger === shenpiConst.sp_status.sqspr) return;
|
|
|
+ if (tender.ledger_status !== auditConst.ledger.status.uncheck && tender.ledger_status !== auditConst.ledger.status.checkNo) return;
|
|
|
+
|
|
|
+ const shenpi_status = info.shenpi.ledger;
|
|
|
+ // 进一步比较审批流是否与审批流程设置的相同,不同则替换为固定审批流或固定的终审
|
|
|
+ const auditList = await ctx.service.ledgerAudit.getAuditors(tender.id, tender.ledger_times);
|
|
|
+ if (shenpi_status === shenpiConst.sp_status.gdspl) {
|
|
|
+ const shenpiList = await ctx.service.shenpiAudit.getAllDataByCondition({ where: { tid: tender.id, sp_type: shenpiConst.sp_type.ledger, sp_status: shenpi_status } });
|
|
|
+ // 判断2个id数组是否相同,不同则删除原审批流,切换成固定的审批流
|
|
|
+ let sameAudit = auditList.length === shenpiList.length;
|
|
|
+ if (sameAudit) {
|
|
|
+ for (const audit of auditList) {
|
|
|
+ const shenpi = shenpiList.find(x => { return x.audit_id === audit.audit_id; });
|
|
|
+ if (!shenpi || shenpi.audit_order !== audit.audit_order || shenpi.audit_type !== audit.audit_type || shenpi.audit_ledger_id !== audit.audit_ledger_id) {
|
|
|
+ sameAudit = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!sameAudit) await ctx.service.ledgerAudit.updateNewAuditList(tender, shenpiList);
|
|
|
+ } else if (shenpi_status === shenpiConst.sp_status.gdzs) {
|
|
|
+ const shenpiInfo = await ctx.service.shenpiAudit.getDataByCondition({ tid: tender.id, sp_type: shenpiConst.sp_type.ledger, sp_status: shenpi_status });
|
|
|
+ // 判断最后一个id是否与固定终审id相同,不同则删除原审批流中如果存在的id和添加终审
|
|
|
+ const lastAuditors = auditList.filter(x => { x.audit_order === auditList[auditList.length - 1].audit_order; });
|
|
|
+ if (shenpiInfo && (lastAuditors.length === 0 || (lastAuditors.length > 1 || shenpiInfo.audit_id !== lastAuditors[0].audit_id))) {
|
|
|
+ await ctx.service.ledgerAudit.updateLastAudit(tender, auditList, shenpiInfo.audit_id);
|
|
|
+ } else if (!shenpiInfo) {
|
|
|
+ // 不存在终审人的状态下这里恢复为授权审批人
|
|
|
+ info.shenpi.ledger = shenpiConst.sp_status.sqspr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async ledgerDetail(ctx) {
|
|
|
+ try {
|
|
|
+ await this.ledgerAuditCheck(ctx);
|
|
|
+
|
|
|
+ const tender = ctx.tender.data;
|
|
|
+ await ctx.service.ledgerAudit.loadLedgerUser(tender);
|
|
|
+ await ctx.service.ledgerAudit.loadLedgerAuditViewData(tender);
|
|
|
+ const auditHistory = tender.auditHistory && tender.auditHistory.length && tender.auditHistory[tender.auditHistory.length - 1].reduce((prev, curr, idx) => {
|
|
|
+ if (idx === 0) {
|
|
|
+ const reportor = {
|
|
|
+ audit_id: tender.user.id,
|
|
|
+ audit_order: 0,
|
|
|
+ audit_type: 1,
|
|
|
+ status: tender.ledger_status === auditConst.ledger.status.uncheck ? auditConst.ledger.status.uncheck : auditConst.ledger.status.checked,
|
|
|
+ times: tender.ledger_status === auditConst.ledger.status.checkNo ? tender.ledger_times - 1 : tender.ledger_times,
|
|
|
+ begin_time: curr.begin_time,
|
|
|
+ end_time: curr.begin_time,
|
|
|
+ name: tender.user.name,
|
|
|
+ company: tender.user.company,
|
|
|
+ role: tender.user.role,
|
|
|
+ mobile: '',
|
|
|
+ opinion: '',
|
|
|
+
|
|
|
+ };
|
|
|
+ prev.push({
|
|
|
+ name: '原报',
|
|
|
+ status: reportor.status,
|
|
|
+ audit_type: reportor.audit_type,
|
|
|
+ auditors: [reportor],
|
|
|
+ });
|
|
|
+ }
|
|
|
+ prev.push({
|
|
|
+ name: curr.is_final ? '终审' : `${curr.order}审`,
|
|
|
+ audit_type: curr.audit_type,
|
|
|
+ status: curr.status,
|
|
|
+ auditors: curr.auditors,
|
|
|
+ });
|
|
|
+ return prev;
|
|
|
+ }, []);
|
|
|
+ const curAuditors = tender.curAuditors;
|
|
|
+ const ledger = {
|
|
|
+ contractPrice: ctx.tender.info.deal_param.contractPrice,
|
|
|
+ totalPrice: tender.total_price || 0,
|
|
|
+ auditHistory,
|
|
|
+ curAuditors,
|
|
|
+ };
|
|
|
+ ctx.body = { code: 0, msg: '', data: { ledger } };
|
|
|
+ } catch (error) {
|
|
|
+ this.log(error);
|
|
|
+ ctx.body = { code: -1, msg: error.toString(), data: null };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async ledgerAudit(ctx) {
|
|
|
+ try {
|
|
|
+ await this.ledgerAuditCheck(ctx);
|
|
|
+ const tender = ctx.tender;
|
|
|
+ if (!tender.data || tender.data.ledger_status !== auditConst.ledger.status.checking) {
|
|
|
+ throw '当前标段数据有误';
|
|
|
+ }
|
|
|
+ const curAudits = await ctx.service.ledgerAudit.getCurAuditors(tender.id, tender.data.ledger_times);
|
|
|
+ const curAuditIds = curAudits.map(x => { return x.audit_id; });
|
|
|
+ if (curAuditIds.indexOf(ctx.session.sessionUser.accountId) < 0) {
|
|
|
+ throw '审批失败';
|
|
|
+ }
|
|
|
+ const checkType = parseInt(ctx.request.body.checkType);
|
|
|
+ if (!checkType || isNaN(checkType)) {
|
|
|
+ throw '提交数据错误';
|
|
|
+ }
|
|
|
+
|
|
|
+ await ctx.service.ledgerAudit.check(tender.id, checkType, ctx.request.body.opinion, tender.data.ledger_times);
|
|
|
+ ctx.body = { code: 0, msg: '操作成功', data: null };
|
|
|
+ } catch (error) {
|
|
|
+ this.log(error);
|
|
|
+ ctx.body = { code: -1, msg: error.toString(), data: null };
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return WeappTenderController;
|