|
|
@@ -998,65 +998,88 @@ module.exports = app => {
|
|
|
ctx.body = responseData;
|
|
|
}
|
|
|
|
|
|
+ _getSpecShenpiUrl(ctx) {
|
|
|
+ if (ctx.url === `/sp/${ctx.subProject.id}/cost/tender/${ctx.tender.id}/flow`) return 'cost';
|
|
|
+ }
|
|
|
async shenpiSet(ctx) {
|
|
|
- if (ctx.session.sessionUser.is_admin === 0) {
|
|
|
- ctx.request.headers.referer ? ctx.redirect(ctx.request.headers.referer) : ctx.redirect(`/sp/${ctx.subProject.id}/list`);
|
|
|
- }
|
|
|
- // 获取所有项目参与者
|
|
|
- const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
|
|
|
- const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
- const accountGroupList = unitList.map(item => {
|
|
|
- const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
|
- return { groupName: item.name, groupList };
|
|
|
- }).filter(x => { return x.groupList.length > 0; });
|
|
|
- // 获取固定审批流 or 固定终审
|
|
|
- const spConst = ctx.helper._.cloneDeep(shenpiConst);
|
|
|
- for (const sp of spConst.sp_lc) {
|
|
|
- sp.status = ctx.tender.info.shenpi ? ctx.tender.info.shenpi[sp.code] : spConst.sp_status.sqspr;
|
|
|
- if (sp.status === shenpiConst.sp_status.gdspl) {
|
|
|
- sp.groupList = await ctx.service.shenpiGroup.getGroupList(ctx.tender.id, sp.type) || [];
|
|
|
- if (sp.groupList && sp.groupList.length > 0) {
|
|
|
- for (const group of sp.groupList) {
|
|
|
- if (group.change_type) group.change_type = JSON.parse(group.change_type);
|
|
|
- group.auditGroupList = await ctx.service.shenpiAudit.getAuditGroupList(ctx.tender.id, sp.type, sp.status, group.id);
|
|
|
- if (group.is_select) sp.auditGroupList = group.auditGroupList;
|
|
|
+ try {
|
|
|
+ const specShenpiType = this._getSpecShenpiUrl(ctx);
|
|
|
+ // 获取所有项目参与者
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
|
|
|
+ const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
+ const accountGroupList = unitList.map(item => {
|
|
|
+ const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
|
+ return { groupName: item.name, groupList };
|
|
|
+ }).filter(x => { return x.groupList.length > 0; });
|
|
|
+ /**
|
|
|
+ * 如果是期审批流程配置,但是不跟期内审批流程使用同一页面,需:
|
|
|
+ * 1. 在 this._getSpecShenpiUrl 内增加判断审批页面的类型,例如cost
|
|
|
+ * 2. 在 const/shenpi.js 内定义对应的cost_sp_lc和cost_sp_type,
|
|
|
+ * 3. 在 validSubMenu 内定义右侧菜单的ejs文件位置,文件位置基于view/tender路径,需提供相对路径
|
|
|
+ */
|
|
|
+ const validSubMenu = {
|
|
|
+ cost: { common: '../cost/list_menu.ejs', mini: '../cost/list_mini_menu.ejs'},
|
|
|
+ default: { common: './tender_sub_menu.ejs', mini: './tender_sub_mini_menu.ejs'}
|
|
|
+ };
|
|
|
+ const subMenu = specShenpiType ? validSubMenu[specShenpiType] : validSubMenu.default;
|
|
|
+ // 获取固定审批流 or 固定终审
|
|
|
+ const spConst = ctx.helper._.cloneDeep(shenpiConst);
|
|
|
+ if (specShenpiType) {
|
|
|
+ spConst.sp_lc = spConst[specShenpiType + '_sp_lc'];
|
|
|
+ spConst.sp_type = spConst[specShenpiType + '_sp_type'];
|
|
|
+ }
|
|
|
+ for (const sp of spConst.sp_lc) {
|
|
|
+ sp.status = ctx.tender.info.shenpi ? ctx.tender.info.shenpi[sp.code] : spConst.sp_status.sqspr;
|
|
|
+ if (sp.status === shenpiConst.sp_status.gdspl) {
|
|
|
+ sp.groupList = await ctx.service.shenpiGroup.getGroupList(ctx.tender.id, sp.type) || [];
|
|
|
+ if (sp.groupList && sp.groupList.length > 0) {
|
|
|
+ for (const group of sp.groupList) {
|
|
|
+ if (group.change_type) group.change_type = JSON.parse(group.change_type);
|
|
|
+ group.auditGroupList = await ctx.service.shenpiAudit.getAuditGroupList(ctx.tender.id, sp.type, sp.status, group.id);
|
|
|
+ if (group.is_select) sp.auditGroupList = group.auditGroupList;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ sp.auditGroupList = await ctx.service.shenpiAudit.getAuditGroupList(ctx.tender.id, sp.type, sp.status);
|
|
|
}
|
|
|
- } else {
|
|
|
- sp.auditGroupList = await ctx.service.shenpiAudit.getAuditGroupList(ctx.tender.id, sp.type, sp.status);
|
|
|
+ } else if (sp.status === shenpiConst.sp_status.gdzs) {
|
|
|
+ sp.audit = await ctx.service.shenpiAudit.getAudit(ctx.tender.id, sp.type, sp.status);
|
|
|
}
|
|
|
- } else if (sp.status === shenpiConst.sp_status.gdzs) {
|
|
|
- sp.audit = await ctx.service.shenpiAudit.getAudit(ctx.tender.id, sp.type, sp.status);
|
|
|
}
|
|
|
- }
|
|
|
- const tenders = await ctx.service.tender.getList('', null, 1);
|
|
|
- const removeTenders = await ctx.service.shenpiAudit.getRemoveTenders(tenders);
|
|
|
- if (removeTenders.length > 0) {
|
|
|
- ctx.helper._.remove(tenders, function(n) {
|
|
|
- return removeTenders.indexOf(n.id) !== -1;
|
|
|
- });
|
|
|
- }
|
|
|
- const categoryData = await ctx.service.category.getAllCategory(ctx.subProject);
|
|
|
- // 是否修订中
|
|
|
- const lastRevise = await ctx.service.ledgerRevise.getLastestRevise(ctx.tender.id);
|
|
|
- const revising = (lastRevise && lastRevise.status !== auditConst.revise.status.checked) || false;
|
|
|
+ const tenders = await ctx.service.tender.getList('', null, 1);
|
|
|
+ const removeTenders = await ctx.service.shenpiAudit.getRemoveTenders(tenders);
|
|
|
+ if (removeTenders.length > 0) {
|
|
|
+ ctx.helper._.remove(tenders, function(n) {
|
|
|
+ return removeTenders.indexOf(n.id) !== -1;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ const categoryData = await ctx.service.category.getAllCategory(ctx.subProject);
|
|
|
+ // 是否修订中
|
|
|
+ const lastRevise = await ctx.service.ledgerRevise.getLastestRevise(ctx.tender.id);
|
|
|
+ const revising = (lastRevise && lastRevise.status !== auditConst.revise.status.checked) || false;
|
|
|
|
|
|
- const cooperationNum = await ctx.service.ledgerCooperation.count({ tid: ctx.tender.id, status: 1 });
|
|
|
+ const cooperationNum = await ctx.service.ledgerCooperation.count({ tid: ctx.tender.id, status: 1 });
|
|
|
+
|
|
|
+ const renderData = {
|
|
|
+ subMenu,
|
|
|
+ shenpi: spConst,
|
|
|
+ accountList,
|
|
|
+ accountGroup: accountGroupList,
|
|
|
+ tenders,
|
|
|
+ categoryData,
|
|
|
+ auditConst,
|
|
|
+ revising,
|
|
|
+ measureType,
|
|
|
+ cooperationNum,
|
|
|
+ jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.tender.shenpi),
|
|
|
+ auditType: auditConst.auditType,
|
|
|
+ change_type_list: shenpiConst.change_type_list,
|
|
|
+ };
|
|
|
+ await this.layout('tender/shenpi.ejs', renderData, 'tender/shenpi_modal.ejs');
|
|
|
+ } catch (err) {
|
|
|
+ ctx.log(err);
|
|
|
+ ctx.redirect(ctx.request.header.referer || `/sp/${ctx.subProject.id}/list`);
|
|
|
+ }
|
|
|
|
|
|
- const renderData = {
|
|
|
- shenpi: spConst,
|
|
|
- accountList,
|
|
|
- accountGroup: accountGroupList,
|
|
|
- tenders,
|
|
|
- categoryData,
|
|
|
- auditConst,
|
|
|
- revising,
|
|
|
- measureType,
|
|
|
- cooperationNum,
|
|
|
- jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.tender.shenpi),
|
|
|
- auditType: auditConst.auditType,
|
|
|
- change_type_list: shenpiConst.change_type_list,
|
|
|
- };
|
|
|
- await this.layout('tender/shenpi.ejs', renderData, 'tender/shenpi_modal.ejs');
|
|
|
}
|
|
|
|
|
|
async saveTenderInfoShenpi(ctx) {
|