|
@@ -62,39 +62,18 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async setting(ctx) {
|
|
|
- try {
|
|
|
- if (!ctx.session.sessionUser.is_admin) {
|
|
|
- throw '您无权打开此页';
|
|
|
- }
|
|
|
- const projectInfo = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
|
|
|
- const modes = projectInfo.payment_setting ? JSON.parse(projectInfo.payment_setting) : ctx.helper._.cloneDeep(paymentConst.setting_modes);
|
|
|
- for (const m in modes) {
|
|
|
- const detailCount = await ctx.service.paymentDetail.getCountByPidType(ctx.session.sessionProject.id, modes[m].value);
|
|
|
- modes[m].can_check = !detailCount;
|
|
|
- }
|
|
|
- const renderData = {
|
|
|
- setting_modes: paymentConst.setting_modes,
|
|
|
- modes,
|
|
|
- jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.payment.setting),
|
|
|
- };
|
|
|
- await this.layout('payment/setting.ejs', renderData);
|
|
|
- } catch (err) {
|
|
|
- console.log(err);
|
|
|
- this.log(err);
|
|
|
- ctx.session.postError = err.toString();
|
|
|
- ctx.redirect('/payment');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
async listLoad(ctx) {
|
|
|
const responseData = {
|
|
|
err: 0, msg: '', data: {},
|
|
|
};
|
|
|
+ const auditPermission = await this.ctx.service.paymentPermissionAudit.getOnePermission(ctx.session.sessionUser.is_admin, ctx.session.sessionUser.accountId);
|
|
|
+ if (!auditPermission) {
|
|
|
+ throw '权限不足';
|
|
|
+ }
|
|
|
// 先获取你创建的标段及参与的标段
|
|
|
- const tenderList = await ctx.service.paymentTender.getList(ctx.session.sessionUser.accountId);
|
|
|
+ const tenderList = await ctx.service.paymentTender.getList(ctx.session.sessionUser.accountId, auditPermission);
|
|
|
// 获取你创建的目录及对应目录下的所有目录
|
|
|
- const folderList = await ctx.service.paymentFolder.getList(ctx.session.sessionUser.accountId, tenderList);
|
|
|
+ const folderList = await ctx.service.paymentFolder.getList(ctx.session.sessionUser.accountId, tenderList, auditPermission);
|
|
|
if (tenderList.length > 0) {
|
|
|
for (const t of tenderList) {
|
|
|
t.have_notice = await ctx.service.paymentDetail.haveNotice2Tender(t.id, ctx.session.sessionUser.accountId);
|
|
@@ -150,13 +129,13 @@ module.exports = app => {
|
|
|
throw '修改权限失败';
|
|
|
}
|
|
|
break;
|
|
|
- case 'save-permission-all':
|
|
|
- result = await ctx.service.paymentPermissionAudit.updateAllPermission(projectId, data.permission_type, data.value);
|
|
|
- if (!result) {
|
|
|
- throw '修改权限失败';
|
|
|
- }
|
|
|
- responseData.data = await ctx.service.paymentPermissionAudit.getList(projectId);
|
|
|
- break;
|
|
|
+ // case 'save-permission-all':
|
|
|
+ // result = await ctx.service.paymentPermissionAudit.updateAllPermission(projectId, data.permission_type, data.value);
|
|
|
+ // if (!result) {
|
|
|
+ // throw '修改权限失败';
|
|
|
+ // }
|
|
|
+ // responseData.data = await ctx.service.paymentPermissionAudit.getList(projectId);
|
|
|
+ // break;
|
|
|
default: throw '参数有误';
|
|
|
}
|
|
|
ctx.body = responseData;
|
|
@@ -181,18 +160,15 @@ module.exports = app => {
|
|
|
if (!data.type) {
|
|
|
throw '提交数据错误';
|
|
|
}
|
|
|
+ if (!auditPermission.admin) {
|
|
|
+ throw '您没有权限操作此功能';
|
|
|
+ }
|
|
|
let type = '';
|
|
|
switch (data.type) {
|
|
|
case 'add-folder':
|
|
|
- if (!auditPermission.folder) {
|
|
|
- throw '没有权限新建目录';
|
|
|
- }
|
|
|
await ctx.service.paymentFolder.addFolder(projectId, ctx.session.sessionUser.accountId, data.parentId, data.name);
|
|
|
break;
|
|
|
case 'add-tender':
|
|
|
- if (!auditPermission.tender) {
|
|
|
- throw '没有权限新建标段';
|
|
|
- }
|
|
|
await ctx.service.paymentTender.addTender(projectId, ctx.session.sessionUser.accountId, data.folderId, data.name);
|
|
|
break;
|
|
|
case 'edit-name':
|
|
@@ -245,9 +221,9 @@ module.exports = app => {
|
|
|
default: throw '参数有误';
|
|
|
}
|
|
|
// 先获取你创建的标段及参与的标段
|
|
|
- const tenderList = await ctx.service.paymentTender.getList(ctx.session.sessionUser.accountId);
|
|
|
+ const tenderList = await ctx.service.paymentTender.getList(ctx.session.sessionUser.accountId, auditPermission);
|
|
|
// 获取你创建的目录及对应目录下的所有目录
|
|
|
- const folderList = await ctx.service.paymentFolder.getList(ctx.session.sessionUser.accountId, tenderList);
|
|
|
+ const folderList = await ctx.service.paymentFolder.getList(ctx.session.sessionUser.accountId, tenderList, auditPermission);
|
|
|
responseData.data.folderList = folderList;
|
|
|
responseData.data.tenderList = tenderList;
|
|
|
ctx.body = responseData;
|
|
@@ -257,6 +233,31 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ async setting(ctx) {
|
|
|
+ try {
|
|
|
+ if (!ctx.session.sessionUser.is_admin) {
|
|
|
+ throw '您无权打开此页';
|
|
|
+ }
|
|
|
+ const projectInfo = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
|
|
|
+ const modes = projectInfo.payment_setting ? JSON.parse(projectInfo.payment_setting) : ctx.helper._.cloneDeep(paymentConst.setting_modes);
|
|
|
+ for (const m in modes) {
|
|
|
+ const detailCount = await ctx.service.paymentDetail.getCountByPidType(ctx.session.sessionProject.id, modes[m].value);
|
|
|
+ modes[m].can_check = !detailCount;
|
|
|
+ }
|
|
|
+ const renderData = {
|
|
|
+ setting_modes: paymentConst.setting_modes,
|
|
|
+ modes,
|
|
|
+ jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.payment.setting),
|
|
|
+ };
|
|
|
+ await this.layout('payment/setting.ejs', renderData);
|
|
|
+ } catch (err) {
|
|
|
+ console.log(err);
|
|
|
+ this.log(err);
|
|
|
+ ctx.session.postError = err.toString();
|
|
|
+ ctx.redirect('/payment');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取审批界面所需的 原报、审批人数据等
|
|
|
* @param ctx
|
|
@@ -505,7 +506,7 @@ module.exports = app => {
|
|
|
|
|
|
async _returnRptProjectList(ctx, formProcess = false) {
|
|
|
// 获取报表表单列表
|
|
|
- if (ctx.tender.uid === ctx.session.sessionUser.accountId || formProcess) {
|
|
|
+ if (ctx.payment.auditPermission.view_all || ctx.tender.uid === ctx.session.sessionUser.accountId || formProcess) {
|
|
|
const rptProject = await ctx.service.rptTreeNode.getDataByCondition({ pid: ctx.session.sessionProject.id, name: '01.支付审批报表' });
|
|
|
const rptProjectList = rptProject && rptProject.items ? JSON.parse(rptProject.items) : [];
|
|
|
const tenderRptList = await ctx.service.paymentTenderRpt.getProcessList(ctx.tender.id);
|
|
@@ -516,8 +517,7 @@ module.exports = app => {
|
|
|
|
|
|
async process(ctx) {
|
|
|
try {
|
|
|
- const auditPermission = await this.ctx.service.paymentPermissionAudit.getOnePermission(ctx.session.sessionUser.is_admin, ctx.session.sessionUser.accountId);
|
|
|
- if (!auditPermission || !auditPermission.process) {
|
|
|
+ if (!ctx.payment.auditPermission || !ctx.payment.auditPermission.admin) {
|
|
|
throw '权限不足';
|
|
|
}
|
|
|
let [tenderRptList, rptProjectList] = await this._returnRptProjectList(ctx, true);
|
|
@@ -558,8 +558,7 @@ module.exports = app => {
|
|
|
|
|
|
async processSave(ctx) {
|
|
|
try {
|
|
|
- const auditPermission = await this.ctx.service.paymentPermissionAudit.getOnePermission(ctx.session.sessionUser.is_admin, ctx.session.sessionUser.accountId);
|
|
|
- if (!auditPermission || !auditPermission.process) {
|
|
|
+ if (!ctx.payment.auditPermission || !ctx.payment.auditPermission.admin) {
|
|
|
throw '权限不足';
|
|
|
}
|
|
|
const responseData = {
|