|
@@ -252,7 +252,7 @@ module.exports = app => {
|
|
|
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;
|
|
|
+ modes[m].can_check = !detailCount && modes[m].value !== 1;
|
|
|
}
|
|
|
const renderData = {
|
|
|
setting_modes: paymentConst.setting_modes,
|
|
@@ -305,6 +305,55 @@ module.exports = app => {
|
|
|
async detail(ctx) {
|
|
|
try {
|
|
|
await this._getDetailAuditViewData(ctx);
|
|
|
+ // 报表信息实时更新
|
|
|
+ if (ctx.trInfo.uid === ctx.session.sessionUser.accountId && ctx.trInfo.is_del === 0 && ctx.trInfo.rpt_id &&
|
|
|
+ (ctx.detail.status === auditConst.status.uncheck || ctx.detail.status === auditConst.status.checkNo)) {
|
|
|
+ const rptTpl = await ctx.service.rptTpl.getDataById(ctx.trInfo.rpt_id);
|
|
|
+ if (rptTpl) {
|
|
|
+ const pageRst = await ctx.service.jpcReport.getAllPreviewPagesCommon(rptTpl, 'A4');
|
|
|
+ const rptMsg = pageRst.items[0];
|
|
|
+ // 判断与原有的报表审批人列表是否有区别
|
|
|
+ let difference = false;
|
|
|
+ let auditDifference = false;
|
|
|
+ let needChange = false;
|
|
|
+ if (ctx.trInfo.report_items_json) {
|
|
|
+ const report_items_json = JSON.parse(ctx.trInfo.report_items_json);
|
|
|
+ const items = ['cells', 'signature_audit_cells', 'signature_cells', 'signature_date_cells', 'interact_cells'];
|
|
|
+ for (const item of items) {
|
|
|
+ if (report_items_json[item] &&
|
|
|
+ !ctx.helper._.isEmpty(ctx.helper._.differenceWith(JSON.parse(JSON.stringify(rptMsg[item])), report_items_json[item], ctx.helper._.isEqual))) {
|
|
|
+ // 因为interact_cells里存在undefind值,必须先用JSON.parse和JSON.stringify转义才能对比
|
|
|
+ difference = true;
|
|
|
+ needChange = true;
|
|
|
+ if (item === 'signature_cells') {
|
|
|
+ auditDifference = true;
|
|
|
+ }
|
|
|
+ // break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ difference = true;
|
|
|
+ }
|
|
|
+ if (difference) {
|
|
|
+ // 删除rpt_audit重新配置
|
|
|
+ const updateData = {
|
|
|
+ id: ctx.trInfo.id,
|
|
|
+ report_items_json: JSON.stringify(ctx.helper._.cloneDeep(rptMsg)),
|
|
|
+ };
|
|
|
+ // 删除rpt_audit重新配置
|
|
|
+ if (auditDifference) {
|
|
|
+ updateData.rpt_audit = null;
|
|
|
+ ctx.trInfo.rpt_audit = null;
|
|
|
+ }
|
|
|
+ if (needChange) {
|
|
|
+ updateData.is_change = 1;
|
|
|
+ ctx.trInfo.is_change = 1;
|
|
|
+ }
|
|
|
+ await ctx.service.paymentTenderRpt.defaultUpdate(updateData);
|
|
|
+ ctx.trInfo.report_items_json = rptMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
const renderData = {
|
|
|
trInfo: ctx.trInfo,
|
|
|
paymentConst,
|
|
@@ -375,7 +424,6 @@ module.exports = app => {
|
|
|
const groupList = accountList.filter(item => item.account_group === idx);
|
|
|
return { groupName: item, groupList };
|
|
|
});
|
|
|
- renderData.rptAuditList = await ctx.service.paymentRptAudit.getAllDataByCondition({ where: { td_id: ctx.detail.id } });
|
|
|
}
|
|
|
await this.layout('payment/detail.ejs', renderData, 'payment/detail_modal.ejs');
|
|
|
} catch (err) {
|
|
@@ -399,7 +447,7 @@ module.exports = app => {
|
|
|
if (ctx.detail.uid !== ctx.session.sessionUser.accountId && data.type !== 'update_sign') {
|
|
|
throw '您无权操作';
|
|
|
}
|
|
|
- if (data.type !== 'update_sign' && (ctx.detail.status === auditConst.status.checking || ctx.detail.status === auditConst.status.checked)) {
|
|
|
+ if (data.type !== 'update_sign' && ctx.detail.status !== auditConst.status.uncheck && ctx.detail.status !== auditConst.status.checkNo) {
|
|
|
throw '您无权操作';
|
|
|
}
|
|
|
const responseData = {
|
|
@@ -451,6 +499,16 @@ module.exports = app => {
|
|
|
}
|
|
|
responseData.data = await ctx.service.paymentDetailAudit.getAuditors(ctx.detail.id, ctx.detail.times);
|
|
|
break;
|
|
|
+ case 'follow_rpt_audit':
|
|
|
+ if (ctx.trInfo.shenpi_status === shenpiConst.sp_status.gdspl) {
|
|
|
+ throw '当前表单已设置为固定审批流,无法同步';
|
|
|
+ }
|
|
|
+ const result3 = await ctx.service.paymentDetailAudit.followAuditByRptAudit(ctx.detail);
|
|
|
+ if (!result3) {
|
|
|
+ throw '同步表单角色失败';
|
|
|
+ }
|
|
|
+ responseData.data = await ctx.service.paymentDetailAudit.getAuditorsWithOwner(ctx.detail.id, ctx.detail.times);
|
|
|
+ break;
|
|
|
default: throw '参数有误';
|
|
|
}
|
|
|
ctx.body = responseData;
|
|
@@ -529,7 +587,7 @@ module.exports = app => {
|
|
|
await this.getNewRptProjectList(ctx, newRptList, rptProjectList, 1);
|
|
|
const tenderRptList = await ctx.service.paymentTenderRpt.getProcessList(ctx.tender.id);
|
|
|
if (tenderRptList === -1) {
|
|
|
- throw '未配置审批模块,请联系管理员处理';
|
|
|
+ throw '未配置表单设置,请联系管理员处理';
|
|
|
}
|
|
|
return await ctx.service.paymentTenderRpt.checkAndUpdateList(tenderRptList, rptProjectList, formProcess);
|
|
|
}
|
|
@@ -636,7 +694,7 @@ module.exports = app => {
|
|
|
try {
|
|
|
const tenderRptList = await this._returnRptProjectList(ctx);
|
|
|
if (tenderRptList === -1) {
|
|
|
- throw '未配置审批模块,请联系管理员处理';
|
|
|
+ throw '未配置表单设置,请联系管理员处理';
|
|
|
}
|
|
|
if (tenderRptList.length === 0) {
|
|
|
throw '未配置表单设置,请联系管理员处理';
|
|
@@ -684,6 +742,8 @@ module.exports = app => {
|
|
|
renderData.rptMsg = pageRst.items[0];
|
|
|
// 判断与原有的报表审批人列表是否有区别
|
|
|
let difference = false;
|
|
|
+ let auditDifference = false;
|
|
|
+ let needChange = false;
|
|
|
if (trInfo.report_items_json) {
|
|
|
const report_items_json = JSON.parse(trInfo.report_items_json);
|
|
|
const items = ['cells', 'signature_audit_cells', 'signature_cells', 'signature_date_cells', 'interact_cells'];
|
|
@@ -692,20 +752,32 @@ module.exports = app => {
|
|
|
!ctx.helper._.isEmpty(ctx.helper._.differenceWith(JSON.parse(JSON.stringify(renderData.rptMsg[item])), report_items_json[item], ctx.helper._.isEqual))) {
|
|
|
// 因为interact_cells里存在undefind值,必须先用JSON.parse和JSON.stringify转义才能对比
|
|
|
difference = true;
|
|
|
- break;
|
|
|
+ needChange = true;
|
|
|
+ if (item === 'signature_cells') {
|
|
|
+ auditDifference = true;
|
|
|
+ }
|
|
|
+ // break;
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ difference = true;
|
|
|
}
|
|
|
if (difference) {
|
|
|
// 删除rpt_audit重新配置
|
|
|
- await ctx.service.paymentTenderRpt.defaultUpdate({
|
|
|
+ const updateData = {
|
|
|
id: trInfo.id,
|
|
|
report_items_json: JSON.stringify(ctx.helper._.cloneDeep(renderData.rptMsg)),
|
|
|
- rpt_audit: null,
|
|
|
- is_change: 1,
|
|
|
- });
|
|
|
- trInfo.rpt_audit = null;
|
|
|
- trInfo.is_change = 1;
|
|
|
+ };
|
|
|
+ // 删除rpt_audit重新配置
|
|
|
+ if (auditDifference) {
|
|
|
+ updateData.rpt_audit = null;
|
|
|
+ trInfo.rpt_audit = null;
|
|
|
+ }
|
|
|
+ if (needChange) {
|
|
|
+ updateData.is_change = 1;
|
|
|
+ trInfo.is_change = 1;
|
|
|
+ }
|
|
|
+ await ctx.service.paymentTenderRpt.defaultUpdate(updateData);
|
|
|
trInfo.report_items_json = renderData.rptMsg;
|
|
|
}
|
|
|
if (trInfo.rpt_audit) {
|