|
@@ -295,95 +295,6 @@ module.exports = app => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async reviseDetail(ctx) {
|
|
|
|
|
- try {
|
|
|
|
|
- const { rid } = ctx.query;
|
|
|
|
|
- const revise = rid
|
|
|
|
|
- ? await ctx.service.ledgerRevise.getRevise(ctx.tender.id, rid)
|
|
|
|
|
- : ctx.service.ledgerRevise.getLastestRevise(ctx.tender.id);
|
|
|
|
|
- revise.preHis = revise.pre_his_id ? await ctx.service.ledgerHistory.getDataById(revise.pre_his_id) : null;
|
|
|
|
|
- revise.curHis = revise.his_id ? await ctx.service.ledgerHistory.getDataById(revise.his_id) : null;
|
|
|
|
|
- await ctx.service.reviseAudit.loadReviseUser(revise);
|
|
|
|
|
- await ctx.service.reviseAudit.loadReviseAuditViewData(revise);
|
|
|
|
|
-
|
|
|
|
|
- revise.auditHistory = revise.auditors.reduce((prev, curr, idx) => {
|
|
|
|
|
- if (idx === 0) {
|
|
|
|
|
- const reportor = {
|
|
|
|
|
- audit_id: revise.uid,
|
|
|
|
|
- audit_order: 0,
|
|
|
|
|
- audit_type: 1,
|
|
|
|
|
- status: revise.status === auditConst.revise.status.uncheck ? auditConst.revise.status.uncheck : auditConst.revise.status.checked,
|
|
|
|
|
- times: curr.times,
|
|
|
|
|
- begin_time: revise.in_time,
|
|
|
|
|
- end_time: revise.auditors.length ? revise.auditors[0].begin_time : null,
|
|
|
|
|
- name: revise.user.name,
|
|
|
|
|
- company: revise.user.company,
|
|
|
|
|
- role: revise.user.role,
|
|
|
|
|
- mobile: '',
|
|
|
|
|
- opinion: '',
|
|
|
|
|
-
|
|
|
|
|
- };
|
|
|
|
|
- prev.push({
|
|
|
|
|
- name: '原报',
|
|
|
|
|
- status: reportor.status,
|
|
|
|
|
- audit_type: reportor.audit_type,
|
|
|
|
|
- auditors: [reportor],
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- const currentOrder = curr.audit_order;
|
|
|
|
|
- prev.push(
|
|
|
|
|
- {
|
|
|
|
|
- name: currentOrder === curr.max_sort ? '终审' : `${currentOrder}审`,
|
|
|
|
|
- status: curr.status,
|
|
|
|
|
- audit_type: 1,
|
|
|
|
|
- auditors: [{
|
|
|
|
|
- audit_id: curr.audit_id,
|
|
|
|
|
- audit_order: curr.audit_order,
|
|
|
|
|
- audit_type: curr.audit_type,
|
|
|
|
|
- status: curr.status,
|
|
|
|
|
- max_sort: curr.max_sort,
|
|
|
|
|
- begin_time: curr.begin_time,
|
|
|
|
|
- end_time: curr.end_time,
|
|
|
|
|
- name: curr.name,
|
|
|
|
|
- company: curr.company,
|
|
|
|
|
- mobile: curr.mobile,
|
|
|
|
|
- opinion: curr.opinion,
|
|
|
|
|
- role: curr.role,
|
|
|
|
|
- times: curr.times,
|
|
|
|
|
- }],
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
- return prev;
|
|
|
|
|
- }, []);
|
|
|
|
|
-
|
|
|
|
|
- const GclGather = require('../lib/gcl_gather');
|
|
|
|
|
- const gclGatherModal = new GclGather.gclCompareGather(this.ctx);
|
|
|
|
|
- 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
|
|
|
|
|
- ? await ctx.helper.loadLedgerDataFromOss(revise.curHis.bills_file)
|
|
|
|
|
- : await ctx.service.reviseBills.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
|
|
|
|
|
- const revisePosData = revise.readOnly && revise.curHis
|
|
|
|
|
- ? await this.ctx.helper.loadLedgerDataFromOss(revise.curHis.pos_file)
|
|
|
|
|
- : await ctx.service.revisePos.getAllDataByCondition({ where: { tid: ctx.tender.id } });
|
|
|
|
|
- const price = await this.ctx.service.revisePrice.getAllDataByCondition({ where: { rid: revise.id } });
|
|
|
|
|
- gclGatherModal.gatherReviseLedgerData(reviseBillsData, revisePosData, { prefix: 'new_' }, price, ctx.tender.info.decimal);
|
|
|
|
|
- const billsData = revise.preHis ? await this.ctx.helper.loadLedgerDataFromOss(revise.preHis.bills_file) : [];
|
|
|
|
|
- const posData = revise.preHis ? await this.ctx.helper.loadLedgerDataFromOss(revise.preHis.pos_file) : [];
|
|
|
|
|
- gclGatherModal.gatherLedgerData(billsData, posData, { prefix: 'org_' });
|
|
|
|
|
- revise.chapterList = gclGatherModal.chapterData();
|
|
|
|
|
- revise.new_tp = gclGatherModal.otherChapter.hj.new_total_price || 0;
|
|
|
|
|
- revise.org_tp = gclGatherModal.otherChapter.hj.org_total_price || 0;
|
|
|
|
|
- console.log(ctx.tender.data.name);
|
|
|
|
|
- revise.tenderName = ctx.tender.data.name;
|
|
|
|
|
- ctx.body = { code: 0, msg: '', data: { revise } };
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- ctx.log(error);
|
|
|
|
|
- ctx.body = { code: -1, msg: error.toString(), data: null };
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
async ledgerAuditCheck(ctx) {
|
|
async ledgerAuditCheck(ctx) {
|
|
|
const tender = ctx.tender.data;
|
|
const tender = ctx.tender.data;
|
|
|
const info = ctx.tender.info;
|
|
const info = ctx.tender.info;
|
|
@@ -779,6 +690,143 @@ module.exports = app => {
|
|
|
ctx.body = { code: -1, msg: error.toString(), data: null };
|
|
ctx.body = { code: -1, msg: error.toString(), data: null };
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ async reviseList(ctx) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const tenderId = ctx.tender.id;
|
|
|
|
|
+ const show_revise_invalid = 0;
|
|
|
|
|
+ const ledgerRevise = await ctx.service.ledgerRevise.getReviseList(tenderId, show_revise_invalid);
|
|
|
|
|
+ ctx.body = { code: 0, msg: '', data: ledgerRevise };
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ this.log(err);
|
|
|
|
|
+ ctx.body = { code: -1, msg: err.toString(), data: null };
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async reviseDetail(ctx) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const { rid } = ctx.query;
|
|
|
|
|
+ const revise = rid
|
|
|
|
|
+ ? await ctx.service.ledgerRevise.getRevise(ctx.tender.id, rid)
|
|
|
|
|
+ : ctx.service.ledgerRevise.getLastestRevise(ctx.tender.id);
|
|
|
|
|
+ revise.preHis = revise.pre_his_id ? await ctx.service.ledgerHistory.getDataById(revise.pre_his_id) : null;
|
|
|
|
|
+ revise.curHis = revise.his_id ? await ctx.service.ledgerHistory.getDataById(revise.his_id) : null;
|
|
|
|
|
+ await ctx.service.reviseAudit.loadReviseUser(revise);
|
|
|
|
|
+ await ctx.service.reviseAudit.loadReviseAuditViewData(revise);
|
|
|
|
|
+
|
|
|
|
|
+ revise.auditHistory = revise.auditors.reduce((prev, curr, idx) => {
|
|
|
|
|
+ if (idx === 0) {
|
|
|
|
|
+ const reportor = {
|
|
|
|
|
+ audit_id: revise.uid,
|
|
|
|
|
+ audit_order: 0,
|
|
|
|
|
+ audit_type: 1,
|
|
|
|
|
+ status: revise.status === auditConst.revise.status.uncheck ? auditConst.revise.status.uncheck : auditConst.revise.status.checked,
|
|
|
|
|
+ times: curr.times,
|
|
|
|
|
+ begin_time: revise.in_time,
|
|
|
|
|
+ end_time: revise.auditors.length ? revise.auditors[0].begin_time : null,
|
|
|
|
|
+ name: revise.user.name,
|
|
|
|
|
+ company: revise.user.company,
|
|
|
|
|
+ role: revise.user.role,
|
|
|
|
|
+ mobile: '',
|
|
|
|
|
+ opinion: '',
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+ prev.push({
|
|
|
|
|
+ name: '原报',
|
|
|
|
|
+ status: reportor.status,
|
|
|
|
|
+ audit_type: reportor.audit_type,
|
|
|
|
|
+ auditors: [reportor],
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ const currentOrder = curr.audit_order;
|
|
|
|
|
+ prev.push(
|
|
|
|
|
+ {
|
|
|
|
|
+ name: currentOrder === curr.max_sort ? '终审' : `${currentOrder}审`,
|
|
|
|
|
+ status: curr.status,
|
|
|
|
|
+ audit_type: 1,
|
|
|
|
|
+ auditors: [{
|
|
|
|
|
+ audit_id: curr.audit_id,
|
|
|
|
|
+ audit_order: curr.audit_order,
|
|
|
|
|
+ audit_type: curr.audit_type,
|
|
|
|
|
+ status: curr.status,
|
|
|
|
|
+ max_sort: curr.max_sort,
|
|
|
|
|
+ begin_time: curr.begin_time,
|
|
|
|
|
+ end_time: curr.end_time,
|
|
|
|
|
+ name: curr.name,
|
|
|
|
|
+ company: curr.company,
|
|
|
|
|
+ mobile: curr.mobile,
|
|
|
|
|
+ opinion: curr.opinion,
|
|
|
|
|
+ role: curr.role,
|
|
|
|
|
+ times: curr.times,
|
|
|
|
|
+ }],
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ return prev;
|
|
|
|
|
+ }, []);
|
|
|
|
|
+
|
|
|
|
|
+ const GclGather = require('../lib/gcl_gather');
|
|
|
|
|
+ const gclGatherModal = new GclGather.gclCompareGather(this.ctx);
|
|
|
|
|
+ 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
|
|
|
|
|
+ ? await ctx.helper.loadLedgerDataFromOss(revise.curHis.bills_file)
|
|
|
|
|
+ : await ctx.service.reviseBills.getAllDataByCondition({ where: { tender_id: ctx.tender.id } });
|
|
|
|
|
+ const revisePosData = revise.readOnly && revise.curHis
|
|
|
|
|
+ ? await this.ctx.helper.loadLedgerDataFromOss(revise.curHis.pos_file)
|
|
|
|
|
+ : await ctx.service.revisePos.getAllDataByCondition({ where: { tid: ctx.tender.id } });
|
|
|
|
|
+ const price = await this.ctx.service.revisePrice.getAllDataByCondition({ where: { rid: revise.id } });
|
|
|
|
|
+ gclGatherModal.gatherReviseLedgerData(reviseBillsData, revisePosData, { prefix: 'new_' }, price, ctx.tender.info.decimal);
|
|
|
|
|
+ const billsData = revise.preHis ? await this.ctx.helper.loadLedgerDataFromOss(revise.preHis.bills_file) : [];
|
|
|
|
|
+ const posData = revise.preHis ? await this.ctx.helper.loadLedgerDataFromOss(revise.preHis.pos_file) : [];
|
|
|
|
|
+ gclGatherModal.gatherLedgerData(billsData, posData, { prefix: 'org_' });
|
|
|
|
|
+ revise.chapterList = gclGatherModal.chapterData();
|
|
|
|
|
+ revise.new_tp = gclGatherModal.otherChapter.hj.new_total_price || 0;
|
|
|
|
|
+ revise.org_tp = gclGatherModal.otherChapter.hj.org_total_price || 0;
|
|
|
|
|
+ revise.tenderName = ctx.tender.data.name;
|
|
|
|
|
+ ctx.body = { code: 0, msg: '', data: { revise } };
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ ctx.log(error);
|
|
|
|
|
+ ctx.body = { code: -1, msg: error.toString(), data: null };
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ async reviseCheck(ctx) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ const reviseId = ctx.params.rid;
|
|
|
|
|
+ const revise = await ctx.service.ledgerRevise.getDataById(reviseId);
|
|
|
|
|
+ if (!revise) {
|
|
|
|
|
+ ctx.body = { code: -1, msg: '修订不存在', data: null };
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (revise.status !== audit.revise.status.checking) {
|
|
|
|
|
+ ctx.body = {
|
|
|
|
|
+ code: -1,
|
|
|
|
|
+ msg: `修订状态不正确,当前状态为"${audit.revise.statusString[revise.status] || '未知'}",无法审批`,
|
|
|
|
|
+ data: { currentStatus: revise.status }
|
|
|
|
|
+ };
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ revise.curHis = revise.his_id ? await ctx.service.ledgerHistory.getDataById(revise.his_id) : null;
|
|
|
|
|
+ const curAudits = await ctx.service.reviseAudit.getCurAuditors(revise.id, revise.times);
|
|
|
|
|
+ const curAuditorIds = curAudits.map(x => { return x.audit_id; });
|
|
|
|
|
+ if (curAuditorIds.indexOf(ctx.session.sessionUser.accountId) < 0) {
|
|
|
|
|
+ ctx.body = { code: -1, msg: '您不是当前审批人,无权进行该操作', data: null };
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const data = ctx.request.body;
|
|
|
|
|
+ const checkType = parseInt(data.checkType);
|
|
|
|
|
+ if (!checkType || isNaN(checkType)) {
|
|
|
|
|
+ ctx.body = { code: -1, msg: '提交数据错误:缺少审批类型参数', data: null };
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const opinion = data.opinion || '';
|
|
|
|
|
+ await ctx.service.reviseAudit.check(revise, checkType, opinion, revise.times);
|
|
|
|
|
+ ctx.body = { code: 0, msg: '审批成功', data: null };
|
|
|
|
|
+ } catch (err) {
|
|
|
|
|
+ ctx.body = { code: -1, msg: err.toString(), data: null };
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return WeappTenderController;
|
|
return WeappTenderController;
|