|
@@ -2,6 +2,7 @@
|
|
|
const accountGroup = require('../const/account_group').group;
|
|
|
const auditConst = require('../const/audit').advance;
|
|
|
const shenpiConst = require('../const/shenpi');
|
|
|
+const typeConsts = require('../const/advance');
|
|
|
const sendToWormhole = require('stream-wormhole');
|
|
|
const path = require('path');
|
|
|
const fs = require('fs');
|
|
@@ -18,8 +19,9 @@ module.exports = app => {
|
|
|
* @param {Object} ctx 全局上下文
|
|
|
*/
|
|
|
async index(ctx) {
|
|
|
- const type = auditConst.type.start;
|
|
|
- const advancePayTotal = ctx.tender.info.deal_param.startAdvance;
|
|
|
+ const advanceType = typeConsts.typeCol.find(item => item.key === ctx.params.type);
|
|
|
+ const type = advanceType.type;
|
|
|
+ const advancePayTotal = ctx.tender.info.deal_param[`${advanceType.key}Advance`];
|
|
|
const advanceList = await ctx.service.advance.getAdvanceList(ctx.tender.id, type, this.decimal, advancePayTotal);
|
|
|
const latestOrder = await ctx.service.advance.getLastestAdvance(ctx.tender.id, type, true);
|
|
|
const progress = await ctx.service.advance.calcProgress(latestOrder, advancePayTotal);
|
|
@@ -31,6 +33,7 @@ module.exports = app => {
|
|
|
advanceList,
|
|
|
latestOrder,
|
|
|
auditConst,
|
|
|
+ typeColMap: typeConsts.typeColMap,
|
|
|
preUrl: `/tender/${ctx.tender.id}/advance/${type}/create`,
|
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.advance.main),
|
|
|
advancePayTotal,
|
|
@@ -43,27 +46,27 @@ module.exports = app => {
|
|
|
* 材料预付款页面(AJAX) GET
|
|
|
* @param {Object} ctx 全局上下文
|
|
|
*/
|
|
|
- async materialList(ctx) {
|
|
|
- const type = auditConst.type.material;
|
|
|
- const advancePayTotal = ctx.tender.info.deal_param.materialAdvance;
|
|
|
- const advanceList = await ctx.service.advance.getAdvanceList(ctx.tender.id, type, this.decimal, advancePayTotal);
|
|
|
- const latestOrder = await ctx.service.advance.getLastestAdvance(ctx.tender.id, type, true);
|
|
|
- const progress = await ctx.service.advance.calcProgress(latestOrder, advancePayTotal);
|
|
|
- const showAddBtn = ctx.tender.data.user_id === ctx.session.sessionUser.accountId ? !latestOrder || (latestOrder.status === auditConst.status.checked && latestOrder.prev_total_amount < advancePayTotal) : false;
|
|
|
- const renderData = {
|
|
|
- type,
|
|
|
- decimal: this.decimal,
|
|
|
- showAddBtn,
|
|
|
- advanceList,
|
|
|
- latestOrder,
|
|
|
- auditConst,
|
|
|
- preUrl: `/tender/${ctx.tender.id}/advance/${type}/create`,
|
|
|
- jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.advance.main),
|
|
|
- advancePayTotal,
|
|
|
- progress,
|
|
|
- };
|
|
|
- await this.layout('advance/index.ejs', renderData, 'advance/modal.ejs');
|
|
|
- }
|
|
|
+ // async materialList(ctx) {
|
|
|
+ // const type = auditConst.type.material;
|
|
|
+ // const advancePayTotal = ctx.tender.info.deal_param.materialAdvance;
|
|
|
+ // const advanceList = await ctx.service.advance.getAdvanceList(ctx.tender.id, type, this.decimal, advancePayTotal);
|
|
|
+ // const latestOrder = await ctx.service.advance.getLastestAdvance(ctx.tender.id, type, true);
|
|
|
+ // const progress = await ctx.service.advance.calcProgress(latestOrder, advancePayTotal);
|
|
|
+ // const showAddBtn = ctx.tender.data.user_id === ctx.session.sessionUser.accountId ? !latestOrder || (latestOrder.status === auditConst.status.checked && latestOrder.prev_total_amount < advancePayTotal) : false;
|
|
|
+ // const renderData = {
|
|
|
+ // type,
|
|
|
+ // decimal: this.decimal,
|
|
|
+ // showAddBtn,
|
|
|
+ // advanceList,
|
|
|
+ // latestOrder,
|
|
|
+ // auditConst,
|
|
|
+ // preUrl: `/tender/${ctx.tender.id}/advance/${type}/create`,
|
|
|
+ // jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.advance.main),
|
|
|
+ // advancePayTotal,
|
|
|
+ // progress,
|
|
|
+ // };
|
|
|
+ // await this.layout('advance/index.ejs', renderData, 'advance/modal.ejs');
|
|
|
+ // }
|
|
|
|
|
|
/**
|
|
|
* 获取通用的renderData(用于layout, Menu, subMenu部分)
|
|
@@ -142,7 +145,7 @@ module.exports = app => {
|
|
|
* @param {Object} ctx 全局上下文
|
|
|
*/
|
|
|
async detail(ctx) {
|
|
|
- const advancePayTotal = ctx.advance.type === 0 ? ctx.tender.info.deal_param.startAdvance : ctx.tender.info.deal_param.materialAdvance;
|
|
|
+ const advancePayTotal = ctx.tender.info.deal_param[`${typeConsts.typeColMap[ctx.advance.type].value}startAdvance`];
|
|
|
try {
|
|
|
await this._checkCanEntry(ctx);
|
|
|
const { uncheck, checkNo } = auditConst.status;
|
|
@@ -178,12 +181,13 @@ module.exports = app => {
|
|
|
renderData.prev_total_amount = prev_total_amount;
|
|
|
renderData.max_pr = max_pr;
|
|
|
renderData.decimal = 2;
|
|
|
+ renderData.typeColMap = typeConsts.typeColMap;
|
|
|
renderData.advancePayTotal = advancePayTotal;
|
|
|
renderData.prevAdvance = prevAdvance;
|
|
|
await this.layout('advance/detail.ejs', renderData, 'advance/modal_audit.ejs');
|
|
|
} catch (error) {
|
|
|
this.log(error);
|
|
|
- ctx.redirect('/tender/' + ctx.tender.id + '/advance');
|
|
|
+ ctx.redirect('/tender/' + ctx.tender.id + '/advance/' + typeConsts.typeColMap[ctx.advance.type].value);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -222,7 +226,7 @@ module.exports = app => {
|
|
|
ctx.redirect(`/tender/${ctx.tender.id}/advance/${record.id}/detail`);
|
|
|
} catch (error) {
|
|
|
this.log(error);
|
|
|
- ctx.redirect(`/tender/${ctx.tender.id}/advance`);
|
|
|
+ ctx.redirect(`/tender/${ctx.tender.id}/advance/${typeConsts.typeColMap[ctx.advance.type].value}`);
|
|
|
}
|
|
|
}
|
|
|
|