|
@@ -2536,7 +2536,7 @@ module.exports = app => {
|
|
|
let page_total = 0;
|
|
|
const tp = await ctx.service.changeApply.getTp(tender.id, status);
|
|
|
for (const c of changes) {
|
|
|
- c.curAuditor = await ctx.service.changeApplyAudit.getAuditorByStatus(c.id, c.status, c.times);
|
|
|
+ c.curAuditors = await ctx.service.changeApplyAudit.getAuditorsByStatus(c.id, c.status, c.times);
|
|
|
page_total = ctx.helper.add(page_total, c.total_price);
|
|
|
}
|
|
|
const tender_userInfo = await ctx.service.projectAccount.getDataById(ctx.tender.data.user_id);
|
|
@@ -2613,6 +2613,7 @@ module.exports = app => {
|
|
|
auditConst: audit.changeApply,
|
|
|
ruleConst: codeRuleConst.measure,
|
|
|
changeConst,
|
|
|
+ auditType,
|
|
|
changeProjectList,
|
|
|
pcLists,
|
|
|
tp,
|
|
@@ -2655,6 +2656,56 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 审批流程(Get)
|
|
|
+ * @param ctx
|
|
|
+ * @return {Promise<void>}
|
|
|
+ */
|
|
|
+ async changeApplyAuditors(ctx) {
|
|
|
+ try {
|
|
|
+ const id = JSON.parse(ctx.request.body.data).id;
|
|
|
+ const tenderId = ctx.params.id;
|
|
|
+ const changeInfo = await ctx.service.changeApply.getDataById(id);
|
|
|
+ await ctx.service.changeApply.loadChangeUser(changeInfo);
|
|
|
+ await ctx.service.changeApply.loadChangeAuditViewData(changeInfo);
|
|
|
+ ctx.body = { err: 0, msg: '', data: changeInfo };
|
|
|
+ } catch (error) {
|
|
|
+ this.log(error);
|
|
|
+ ctx.body = { err: 1, msg: error.toString(), data: null };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async changeApplySpGroup(ctx) {
|
|
|
+ try {
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ const result = await ctx.service.changeApplyAudit.changeSpGroup(ctx.change, data.sp_group);
|
|
|
+ if (!result) {
|
|
|
+ throw '切换审批组失败';
|
|
|
+ }
|
|
|
+ const auditors = await ctx.service.changeApplyAudit.getUserGroup(ctx.change.id, ctx.change.times);
|
|
|
+ ctx.body = { err: 0, msg: '', data: auditors };
|
|
|
+ } catch (err) {
|
|
|
+ ctx.body = { err: 1, msg: err.toString(), data: null };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 撤回审批
|
|
|
+ * @param ctx
|
|
|
+ * @return {Promise<void>}
|
|
|
+ */
|
|
|
+ async checkApplyAuditCancel(ctx) {
|
|
|
+ try {
|
|
|
+ if (!ctx.change.cancancel) throw '您无权进行该操作';
|
|
|
+
|
|
|
+ await ctx.service.changeApplyAudit.checkCancel(ctx.change);
|
|
|
+ ctx.body = { err: 0, url: ctx.request.header.referer, msg: '' };
|
|
|
+ } catch (err) {
|
|
|
+ this.log(err);
|
|
|
+ ctx.body = { err: 1, msg: err };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 新增变更申请 (Post)
|
|
|
*
|
|
|
* @param {Object} ctx - egg全局变量
|
|
@@ -2708,22 +2759,7 @@ module.exports = app => {
|
|
|
* @private
|
|
|
*/
|
|
|
async _getChangeApplyAuditViewData(ctx) {
|
|
|
- const auditConst = audit.changeApply;
|
|
|
- const times = ctx.change.status === auditConst.status.checkNo || ctx.change.status === auditConst.status.revise ? ctx.change.times - 1 : ctx.change.times;
|
|
|
- ctx.change.user = await ctx.service.projectAccount.getAccountInfoById(ctx.change.uid);
|
|
|
- ctx.change.auditHistory = [];
|
|
|
- if (times >= 1) {
|
|
|
- for (let i = 1; i <= times; i++) {
|
|
|
- ctx.change.auditHistory.push(await ctx.service.changeApplyAudit.getAuditors(ctx.change.id, i));
|
|
|
- }
|
|
|
- }
|
|
|
- // 获取审批流程中左边列表
|
|
|
- ctx.change.auditors2 = (ctx.change.status === auditConst.status.checkNo || ctx.change.status === auditConst.status.revise) && ctx.change.uid !== ctx.session.sessionUser.accountId ?
|
|
|
- await ctx.service.changeApplyAudit.getAuditorsWithOwner(ctx.change.id, times) :
|
|
|
- await ctx.service.changeApplyAudit.getAuditorsWithOwner(ctx.change.id, ctx.change.times);
|
|
|
- if (ctx.change.status === auditConst.status.uncheck || ctx.change.status === auditConst.status.checkNo || ctx.change.status === auditConst.status.revise) {
|
|
|
- ctx.change.auditorList = await ctx.service.changeApplyAudit.getAuditors(ctx.change.id, ctx.change.times);
|
|
|
- }
|
|
|
+ await ctx.service.changeApply.loadChangeAuditViewData(ctx.change);
|
|
|
}
|
|
|
|
|
|
async applyInformation(ctx) {
|
|
@@ -2750,6 +2786,8 @@ module.exports = app => {
|
|
|
fileList,
|
|
|
whiteList,
|
|
|
authMobile: auth_mobile,
|
|
|
+ auditType,
|
|
|
+ shenpiConst,
|
|
|
tpUnit: ctx.change.decimal ? ctx.change.decimal.tp : ctx.tender.info.decimal.tp,
|
|
|
upUnit: ctx.change.decimal ? ctx.change.decimal.up : ctx.tender.info.decimal.up,
|
|
|
changeUnits: changeConst.units,
|
|
@@ -2758,19 +2796,23 @@ module.exports = app => {
|
|
|
jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.change.apply_information),
|
|
|
preUrl: '/tender/' + ctx.tender.id + '/change/apply/' + ctx.change.id + '/information',
|
|
|
};
|
|
|
- if ((ctx.change.status === audit.changeApply.status.uncheck || ctx.change.status === audit.changeApply.status.checkNo || ctx.change.status === audit.changeApply.status.revise) && (ctx.session.sessionUser.accountId === ctx.change.uid || ctx.tender.isTourist)) {
|
|
|
- // data.accountGroup = accountGroup;
|
|
|
- // 获取所有项目参与者
|
|
|
- const accountList = await ctx.service.projectAccount.getAllDataByCondition({
|
|
|
- where: { project_id: ctx.session.sessionProject.id, enable: 1 },
|
|
|
- columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
|
|
|
- });
|
|
|
- renderData.accountList = accountList;
|
|
|
- const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
- renderData.accountGroup = unitList.map(item => {
|
|
|
- const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
|
- return { groupName: item.name, groupList };
|
|
|
- });
|
|
|
+ // if ((ctx.change.status === audit.changeApply.status.uncheck || ctx.change.status === audit.changeApply.status.checkNo || ctx.change.status === audit.changeApply.status.revise) && (ctx.session.sessionUser.accountId === ctx.change.uid || ctx.tender.isTourist)) {
|
|
|
+ // data.accountGroup = accountGroup;
|
|
|
+ // 获取所有项目参与者
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllDataByCondition({
|
|
|
+ where: { project_id: ctx.session.sessionProject.id, enable: 1 },
|
|
|
+ columns: ['id', 'name', 'company', 'role', 'enable', 'is_admin', 'account_group', 'mobile'],
|
|
|
+ });
|
|
|
+ renderData.accountList = accountList;
|
|
|
+ const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
+ renderData.accountGroup = unitList.map(item => {
|
|
|
+ const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
|
+ return { groupName: item.name, groupList };
|
|
|
+ });
|
|
|
+ // }
|
|
|
+ // 获取固定审批流列表
|
|
|
+ if (ctx.tender.info.shenpi.change === shenpiConst.sp_status.gdspl) {
|
|
|
+ renderData.spGroupList = await ctx.service.shenpiGroup.getGroupListByChangeType(ctx.tender.id, shenpiConst.sp_type.change, 'changeApply');
|
|
|
}
|
|
|
await this.layout('change/apply_information.ejs', renderData, 'change/apply_information_modal.ejs');
|
|
|
} catch (err) {
|
|
@@ -2838,7 +2880,7 @@ module.exports = app => {
|
|
|
throw '添加审核人失败';
|
|
|
}
|
|
|
|
|
|
- const auditors = await ctx.service.changeApplyAudit.getAuditorsWithOwner(ctx.change.id, ctx.change.times);
|
|
|
+ const auditors = await ctx.service.changeApplyAudit.getUserGroup(ctx.change.id, ctx.change.times);
|
|
|
ctx.body = { err: 0, msg: '', data: auditors };
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
@@ -2871,6 +2913,31 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async saveApplyAudit(ctx) {
|
|
|
+ try {
|
|
|
+ // if (ctx.change.revising) {
|
|
|
+ // throw '台账修订中,请勿修改提交期数据';
|
|
|
+ // }
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ if (ctx.session.sessionUser.is_admin && ctx.change.status !== audit.change.status.checked) {
|
|
|
+ await ctx.service.changeApplyAudit.saveAudit(ctx.change.id, ctx.change.times, ctx.change.sp_group, data);
|
|
|
+ const auditors = await ctx.service.changeApplyAudit.getUniqUserGroup(ctx.change.id, ctx.change.times);
|
|
|
+ ctx.body = { err: 0, msg: '', data: auditors };
|
|
|
+ } else {
|
|
|
+ throw '您无权进行该操作';
|
|
|
+ }
|
|
|
+ } catch (err) {
|
|
|
+ this.log(err);
|
|
|
+ // ctx.session.postError = err.toString();
|
|
|
+ // ctx.redirect(ctx.request.header.referer);
|
|
|
+ ctx.body = {
|
|
|
+ err: 1,
|
|
|
+ // url: ctx.request.header.referer,
|
|
|
+ msg: err,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 上传附件
|
|
|
* @param {*} ctx 上下文
|
|
@@ -3059,7 +3126,7 @@ module.exports = app => {
|
|
|
if (!ctx.change || ctx.change.status !== auditConst.status.checking) {
|
|
|
throw '当前材料调差期数据有误';
|
|
|
}
|
|
|
- if (!ctx.change.curAuditor || ctx.change.curAuditor.aid !== ctx.session.sessionUser.accountId) {
|
|
|
+ if (ctx.change.curAuditorIds.length === 0 || ctx.change.curAuditorIds.indexOf(ctx.session.sessionUser.accountId) === -1) {
|
|
|
throw '您无权进行该操作';
|
|
|
}
|
|
|
const data = {
|