|
@@ -34,7 +34,7 @@ module.exports = app => {
|
|
|
if (!ctx.session.sessionProject.showPayment) {
|
|
|
throw '该功能已关闭或无法查看';
|
|
|
}
|
|
|
- const auditPermission = await this.ctx.service.paymentPermissionAudit.getOnePermission(ctx.session.sessionUser.is_admin, ctx.session.sessionUser.accountId);
|
|
|
+ const auditPermission = await ctx.service.subProjPermission.getPaymentPermission(ctx.subProject.permission.payment_permission);
|
|
|
if (!auditPermission) {
|
|
|
throw '权限不足';
|
|
|
}
|
|
@@ -46,12 +46,9 @@ module.exports = app => {
|
|
|
};
|
|
|
if (ctx.session.sessionUser.is_admin) {
|
|
|
const projectId = ctx.session.sessionProject.id;
|
|
|
- const permissionAudits = await ctx.service.paymentPermissionAudit.getList(projectId);
|
|
|
+ const permissionAudits = await ctx.service.subProjPermission.getPaymentAuditList(ctx.subProject.id);
|
|
|
// 获取所有项目参与者
|
|
|
- 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'],
|
|
|
- });
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
|
|
|
const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: projectId } });
|
|
|
const accountGroupList = unitList.map(item => {
|
|
|
const groupList = accountList.filter(item1 => item1.company === item.name);
|
|
@@ -64,7 +61,12 @@ module.exports = app => {
|
|
|
renderData.permissionAudits = permissionAudits;
|
|
|
renderData.accountList = accountList;
|
|
|
renderData.accountGroup = accountGroupList;
|
|
|
+ // 整理未分类的支付审批标段
|
|
|
+ const noSpFolderList = await ctx.service.paymentFolder.getNoSpList(ctx.session.sessionProject.id);
|
|
|
+ renderData.noSpFolderList = ctx.helper._.orderBy(noSpFolderList, ['in_time'], ['asc']);
|
|
|
}
|
|
|
+ const noSpTenderList = await ctx.service.paymentTender.getNoSpList(ctx.session.sessionProject.id);
|
|
|
+ renderData.noSpTenderList = ctx.helper._.orderBy(noSpTenderList, ['in_time'], ['asc']);
|
|
|
await this.layout('payment/index.ejs', renderData, 'payment/modal.ejs');
|
|
|
} catch (err) {
|
|
|
console.log(err);
|
|
@@ -78,7 +80,7 @@ module.exports = app => {
|
|
|
const responseData = {
|
|
|
err: 0, msg: '', data: {},
|
|
|
};
|
|
|
- const auditPermission = await this.ctx.service.paymentPermissionAudit.getOnePermission(ctx.session.sessionUser.is_admin, ctx.session.sessionUser.accountId);
|
|
|
+ const auditPermission = await ctx.service.subProjPermission.getPaymentPermission(ctx.subProject.permission.payment_permission);
|
|
|
if (!auditPermission) {
|
|
|
throw '权限不足';
|
|
|
}
|
|
@@ -120,30 +122,33 @@ module.exports = app => {
|
|
|
// 判断用户是单个还是数组
|
|
|
uids = data.id instanceof Array ? data.id : [data.id];
|
|
|
// 判断该用户的组是否已加入到表中,已加入则提示无需添加
|
|
|
- auditList = await ctx.service.paymentPermissionAudit.getAllDataByCondition({ where: { pid: projectId, uid: uids } });
|
|
|
+ auditList = await ctx.service.subProjPermission.getPaymentAuditList(ctx.subProject.id, uids);
|
|
|
const addAidList = ctx.helper._.difference(uids, ctx.helper._.map(auditList, 'uid'));
|
|
|
if (addAidList.length === 0) {
|
|
|
throw '用户已存在权限中,无需重复添加';
|
|
|
}
|
|
|
- const accountList = await ctx.service.projectAccount.getAllDataByCondition({ where: { id: addAidList } });
|
|
|
- await ctx.service.paymentPermissionAudit.saveAudits(projectId, accountList);
|
|
|
- responseData.data = await ctx.service.paymentPermissionAudit.getList(projectId);
|
|
|
+ // const accountList = await ctx.service.projectAccount.getAllDataByCondition({ where: { id: addAidList } });
|
|
|
+ await ctx.service.subProjPermission.savePaymentPermissionAudits(ctx.subProject.id, addAidList, 'add');
|
|
|
+ responseData.data = await ctx.service.subProjPermission.getPaymentAuditList(ctx.subProject.id);
|
|
|
break;
|
|
|
case 'del-audit':
|
|
|
uids = data.id instanceof Array ? data.id : [data.id];
|
|
|
- auditList = await ctx.service.paymentPermissionAudit.getAllDataByCondition({ where: { id: uids } });
|
|
|
+ auditList = await ctx.service.subProjPermission.getPaymentAuditList(ctx.subProject.id, uids);
|
|
|
if (auditList.length !== uids.length) {
|
|
|
throw '该用户已不存在权限中,移除失败';
|
|
|
}
|
|
|
- await ctx.service.paymentPermissionAudit.delAudit(uids);
|
|
|
- responseData.data = await ctx.service.paymentPermissionAudit.getList(projectId);
|
|
|
+ await ctx.service.subProjPermission.savePaymentPermissionAudits(ctx.subProject.id, uids, 'del');
|
|
|
+ responseData.data = await ctx.service.subProjPermission.getPaymentAuditList(ctx.subProject.id);
|
|
|
break;
|
|
|
case 'save-permission-one':
|
|
|
- result = await ctx.service.paymentPermissionAudit.updateOnePermission(data.updateData);
|
|
|
+ result = await ctx.service.subProjPermission.updateOnePaymentPermission(ctx.subProject.id, data.updateData);
|
|
|
if (!result) {
|
|
|
throw '修改权限失败';
|
|
|
}
|
|
|
break;
|
|
|
+ case 'bind-sp':
|
|
|
+ result = await ctx.service.paymentTender.bindSp(data.tids);
|
|
|
+ break;
|
|
|
// case 'save-permission-all':
|
|
|
// result = await ctx.service.paymentPermissionAudit.updateAllPermission(projectId, data.permission_type, data.value);
|
|
|
// if (!result) {
|
|
@@ -187,7 +192,7 @@ module.exports = app => {
|
|
|
throw '该功能已关闭或无法查看';
|
|
|
}
|
|
|
const projectId = ctx.session.sessionProject.id;
|
|
|
- const auditPermission = await this.ctx.service.paymentPermissionAudit.getOnePermission(ctx.session.sessionUser.is_admin, ctx.session.sessionUser.accountId);
|
|
|
+ const auditPermission = await ctx.service.subProjPermission.getPaymentPermission(ctx.subProject.permission.payment_permission);
|
|
|
if (!auditPermission) {
|
|
|
throw '权限不足';
|
|
|
}
|
|
@@ -246,8 +251,7 @@ module.exports = app => {
|
|
|
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);
|
|
|
+ const modes = ctx.subProject.payment_setting ? JSON.parse(ctx.subProject.payment_setting) : ctx.helper._.cloneDeep(paymentConst.setting_modes);
|
|
|
const checked = data.checked;
|
|
|
if (modes[data.mode_type]) {
|
|
|
const detailCount = await ctx.service.paymentDetail.getCountByPidType(ctx.session.sessionProject.id, modes[data.mode_type].value);
|
|
@@ -265,7 +269,7 @@ module.exports = app => {
|
|
|
} else {
|
|
|
throw '该模块不存在';
|
|
|
}
|
|
|
- await ctx.service.project.defaultUpdate({ id: ctx.session.sessionProject.id, payment_setting: JSON.stringify(modes) });
|
|
|
+ await ctx.service.subProject.defaultUpdate({ id: ctx.subProject.id, payment_setting: JSON.stringify(modes) });
|
|
|
break;
|
|
|
case 'info':
|
|
|
await ctx.service.paymentTenderInfo.saveTenderInfo(data.postData.id, data.postData.info);
|
|
@@ -290,8 +294,7 @@ module.exports = app => {
|
|
|
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);
|
|
|
+ const modes = ctx.subProject.payment_setting ? JSON.parse(ctx.subProject.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;
|
|
@@ -306,7 +309,7 @@ module.exports = app => {
|
|
|
console.log(err);
|
|
|
this.log(err);
|
|
|
ctx.session.postError = err.toString();
|
|
|
- ctx.redirect('/payment');
|
|
|
+ ctx.redirect(`/sp/${ctx.subProject.id}/payment`);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -431,7 +434,7 @@ module.exports = app => {
|
|
|
moment,
|
|
|
whiteList: ctx.app.config.multipart.whitelist,
|
|
|
uidList,
|
|
|
- preUrl: '/payment/' + ctx.paymentTender.id + '/detail/' + ctx.detail.id,
|
|
|
+ preUrl: '/sp/' + ctx.subProject.id + '/payment/' + ctx.paymentTender.id + '/detail/' + ctx.detail.id,
|
|
|
OSS_PATH: ctx.app.config.fujianOssPath,
|
|
|
};
|
|
|
renderData.nextDetail = await ctx.service.paymentDetail.getDataByCondition({ tr_id: ctx.trInfo.id, order: ctx.detail.order + 1 });
|
|
@@ -503,10 +506,7 @@ module.exports = app => {
|
|
|
if ((ctx.detail.status === auditConst.status.uncheck || ctx.detail.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.detail.uid) {
|
|
|
// 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'],
|
|
|
- });
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
|
|
|
renderData.accountList = accountList;
|
|
|
const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
const accountGroupList = unitList.map(item => {
|
|
@@ -521,7 +521,7 @@ module.exports = app => {
|
|
|
this.log(err);
|
|
|
ctx.session.postError = err.toString();
|
|
|
if (ctx.detail.tender_id && ctx.detail.tr_id) {
|
|
|
- ctx.redirect('/payment' + ctx.detail.tender_id + '/list/' + ctx.detail.tr_id);
|
|
|
+ ctx.redirect('/sp/' + ctx.subProject.id + '/payment' + ctx.detail.tender_id + '/list/' + ctx.detail.tr_id);
|
|
|
}
|
|
|
ctx.redirect(this.menu.menu.dashboard.url);
|
|
|
}
|
|
@@ -626,7 +626,7 @@ module.exports = app => {
|
|
|
if (!result) {
|
|
|
throw '删除报表表单详情失败,请重试';
|
|
|
}
|
|
|
- ctx.redirect('/payment/' + ctx.paymentTender.id + '/list/' + detailInfo.tr_id);
|
|
|
+ ctx.redirect('/sp/' + ctx.subProject.id + '/payment/' + ctx.paymentTender.id + '/list/' + detailInfo.tr_id);
|
|
|
} catch (err) {
|
|
|
this.log(err);
|
|
|
ctx.session.postError = err.toString();
|
|
@@ -714,10 +714,7 @@ module.exports = app => {
|
|
|
// }
|
|
|
// }
|
|
|
// 获取所有项目参与者
|
|
|
- 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'],
|
|
|
- });
|
|
|
+ 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);
|
|
@@ -738,7 +735,7 @@ module.exports = app => {
|
|
|
console.log(err);
|
|
|
this.log(err);
|
|
|
ctx.session.postError = err.toString();
|
|
|
- ctx.redirect(this.request && this.request.headers && this.request.headers.referer ? this.request.headers.referer : '/payment');
|
|
|
+ ctx.redirect(this.request && this.request.headers && this.request.headers.referer ? this.request.headers.referer : '/sp/' + ctx.subProject.id + '/payment');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -803,10 +800,7 @@ module.exports = app => {
|
|
|
|
|
|
// 获取列表
|
|
|
const trDetailList = await ctx.service.paymentDetail.getValidDetails(trInfo.id);
|
|
|
- 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'],
|
|
|
- });
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
|
|
|
if (trDetailList.length > 0) {
|
|
|
for (const s of trDetailList) {
|
|
|
// s.curAuditor = null;
|
|
@@ -831,7 +825,7 @@ module.exports = app => {
|
|
|
accountGroup: [],
|
|
|
accountList: [],
|
|
|
paymentConst,
|
|
|
- preUrl: '/payment/' + ctx.paymentTender.id + '/list/' + trInfo.id,
|
|
|
+ preUrl: '/sp/' + ctx.subProject.id + '/payment/' + ctx.paymentTender.id + '/list/' + trInfo.id,
|
|
|
categoryData,
|
|
|
tenderInfo,
|
|
|
};
|
|
@@ -905,10 +899,7 @@ module.exports = app => {
|
|
|
}
|
|
|
if (renderData.rptMsg) {
|
|
|
// 获取所有项目参与者
|
|
|
- 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'],
|
|
|
- });
|
|
|
+ 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);
|
|
@@ -923,7 +914,7 @@ module.exports = app => {
|
|
|
console.log(err);
|
|
|
this.log(err);
|
|
|
ctx.session.postError = err.toString();
|
|
|
- ctx.redirect(this.request && this.request.headers && this.request.headers.referer ? this.request.headers.referer : '/payment');
|
|
|
+ ctx.redirect(this.request && this.request.headers && this.request.headers.referer ? this.request.headers.referer : '/sp/' + ctx.subProject.id + '/payment');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1075,7 +1066,7 @@ module.exports = app => {
|
|
|
fileData.orginpath = ctx.app.config.fujianOssPath + filepath;
|
|
|
delete fileData.filepath;
|
|
|
if (!ctx.helper.canPreview(fileData.fileext)) {
|
|
|
- fileData.filepath = `/payment/${original_data.tender_id}/detail/${original_data.td_id}/file/${fileData.id}/download`;
|
|
|
+ fileData.filepath = `/sp/${ctx.subProject.id}/payment/${original_data.tender_id}/detail/${original_data.td_id}/file/${fileData.id}/download`;
|
|
|
} else {
|
|
|
fileData.filepath = ctx.app.config.fujianOssPath + filepath;
|
|
|
fileData.viewpath = ctx.app.config.fujianOssPath + filepath;
|
|
@@ -1191,7 +1182,7 @@ module.exports = app => {
|
|
|
moment,
|
|
|
whiteList: ctx.app.config.multipart.whitelist,
|
|
|
uidList,
|
|
|
- preUrl: '/payment/' + ctx.paymentTender.id + '/detail/' + ctx.detail.id,
|
|
|
+ preUrl: '/sp/' + ctx.subProject.id + '/payment/' + ctx.paymentTender.id + '/detail/' + ctx.detail.id,
|
|
|
OSS_PATH: ctx.app.config.fujianOssPath,
|
|
|
stdBills,
|
|
|
};
|
|
@@ -1200,10 +1191,7 @@ module.exports = app => {
|
|
|
renderData.content = content;
|
|
|
if ((ctx.detail.status === auditConst.status.uncheck || ctx.detail.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.detail.uid) {
|
|
|
// 获取所有项目参与者
|
|
|
- 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'],
|
|
|
- });
|
|
|
+ const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
|
|
|
renderData.accountList = accountList;
|
|
|
const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
|
|
|
const accountGroupList = unitList.map(item => {
|
|
@@ -1217,7 +1205,7 @@ module.exports = app => {
|
|
|
this.log(err);
|
|
|
this.ctx.postError(err, '读取安全生产费错误');
|
|
|
if (ctx.detail.tender_id && ctx.detail.tr_id) {
|
|
|
- ctx.redirect('/payment' + ctx.detail.tender_id + '/list');
|
|
|
+ ctx.redirect('/sp/' + ctx.subProject.id + '/payment' + ctx.detail.tender_id + '/list');
|
|
|
} else {
|
|
|
ctx.redirect(this.menu.menu.dashboard.url);
|
|
|
}
|
|
@@ -1237,7 +1225,7 @@ module.exports = app => {
|
|
|
this.log(err);
|
|
|
this.ctx.postError(err, '读取安全生产费错误');
|
|
|
if (ctx.detail.tender_id && ctx.detail.tr_id) {
|
|
|
- ctx.redirect('/payment' + ctx.detail.tender_id + '/list');
|
|
|
+ ctx.redirect('/sp/' + ctx.subProject.id + '/payment' + ctx.detail.tender_id + '/list');
|
|
|
} else {
|
|
|
ctx.redirect(this.menu.menu.dashboard.url);
|
|
|
}
|