|
@@ -243,14 +243,20 @@ module.exports = app => {
|
|
|
async detail(ctx) {
|
|
|
try {
|
|
|
await this._getDetailAuditViewData(ctx);
|
|
|
- const report_json = JSON.parse(ctx.detail.report_json);
|
|
|
+ const renderData = {
|
|
|
+ trInfo: ctx.trInfo,
|
|
|
+ paymentConst,
|
|
|
+ jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.payment.detail),
|
|
|
+ auditConst,
|
|
|
+ shenpiConst,
|
|
|
+ preUrl: '/payment/' + ctx.tender.id + '/detail/' + ctx.detail.id,
|
|
|
+ OSS_PATH: ctx.app.config.fujianOssPath,
|
|
|
+ };
|
|
|
+
|
|
|
+ let report_json = JSON.parse(ctx.detail.report_json);
|
|
|
const content = [];
|
|
|
// 获取当前报表人
|
|
|
const rptAudit = await ctx.service.paymentRptAudit.getDataByCondition({ td_id: ctx.detail.id, uid: ctx.session.sessionUser.accountId });
|
|
|
- // 获取个人签字,单位章,个人章地址
|
|
|
- const userInfo = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
|
|
|
- const stampPathList = userInfo.stamp_path ? userInfo.stamp_path.split('!;!') : [];
|
|
|
- const companyInfo = userInfo.company ? await ctx.service.constructionUnit.getDataByCondition({ pid: ctx.session.sessionProject.id, name: userInfo.company }) : {};
|
|
|
if (report_json.items[0].interact_cells.length > 0) {
|
|
|
for (const [i, cell] of report_json.items[0].interact_cells.entries()) {
|
|
|
const push_item = {
|
|
@@ -271,50 +277,28 @@ module.exports = app => {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- if (rptAudit.signature_msg) {
|
|
|
- const sign_msg = JSON.parse(rptAudit.signature_msg);
|
|
|
- // 签名签章
|
|
|
- const signCells = ctx.helper._.find(report_json.items[0].signature_cells, { signature_name: rptAudit.signature_name });
|
|
|
- if (signCells && signCells.path === null && (sign_msg.sign_path || sign_msg.company_stamp || sign_msg.stamp_path)) {
|
|
|
- const signArray = [];
|
|
|
- if (sign_msg.sign_path) signArray.push(sign_msg.sign_path);
|
|
|
- if (sign_msg.company_stamp) signArray.push(sign_msg.company_stamp);
|
|
|
- if (sign_msg.stamp_path) signArray.push(sign_msg.stamp_path);
|
|
|
- signCells.path = signArray.join('!;!');
|
|
|
- }
|
|
|
- console.log(signCells);
|
|
|
- // 日期
|
|
|
- const dateCells = ctx.helper._.find(report_json.items[0].signature_date_cells, { signature_name: rptAudit.signature_name + '_签字日期' });
|
|
|
- if (dateCells && dateCells.Value === '' && sign_msg.date) {
|
|
|
- dateCells.Value = sign_msg.date;
|
|
|
- }
|
|
|
- // 意见
|
|
|
- const contentCells = ctx.helper._.find(report_json.items[0].signature_audit_cells, { signature_name: rptAudit.signature_name + '_审核意见' });
|
|
|
- if (contentCells && contentCells.Value === '' && sign_msg.content) {
|
|
|
- contentCells.Value = sign_msg.content;
|
|
|
+ if (ctx.detail.status !== auditConst.status.checked) {
|
|
|
+ // 获取个人签字,单位章,个人章地址
|
|
|
+ const userInfo = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
|
|
|
+ const stampPathList = userInfo.stamp_path ? userInfo.stamp_path.split('!;!') : [];
|
|
|
+ const companyInfo = userInfo.company ? await ctx.service.constructionUnit.getDataByCondition({ pid: ctx.session.sessionProject.id, name: userInfo.company }) : {};
|
|
|
+ if (rptAudit.signature_msg) {
|
|
|
+ const sign_msg = JSON.parse(rptAudit.signature_msg);
|
|
|
+ report_json = await ctx.service.paymentDetail.signOneSignatureData(report_json, rptAudit.signature_name, sign_msg);
|
|
|
+ rptAudit.signature_msg = sign_msg;
|
|
|
+ } else {
|
|
|
+ rptAudit.signature_msg = paymentConst.signature_msg;
|
|
|
+ rptAudit.signature_msg.sign_path = userInfo.sign_path ? userInfo.sign_path : '';
|
|
|
}
|
|
|
- rptAudit.signature_msg = sign_msg;
|
|
|
- } else {
|
|
|
- rptAudit.signature_msg = paymentConst.signature_msg;
|
|
|
- rptAudit.signature_msg.sign_path = userInfo.sign_path ? userInfo.sign_path : '';
|
|
|
+ renderData.signPath = userInfo.sign_path ? userInfo.sign_path : '';
|
|
|
+ renderData.stampPathList = stampPathList;
|
|
|
+ renderData.currentStamp = rptAudit && rptAudit.signature_msg.stamp_path ? rptAudit.signature_msg.stamp_path : (stampPathList.length > 0 ? stampPathList[0] : '');
|
|
|
+ renderData.companyStamp = companyInfo && companyInfo.sign_path ? companyInfo.sign_path : '';
|
|
|
}
|
|
|
}
|
|
|
- const renderData = {
|
|
|
- trInfo: ctx.trInfo,
|
|
|
- report_json,
|
|
|
- paymentConst,
|
|
|
- content,
|
|
|
- jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.payment.detail),
|
|
|
- rptAudit,
|
|
|
- auditConst,
|
|
|
- shenpiConst,
|
|
|
- signPath: userInfo.sign_path ? userInfo.sign_path : '',
|
|
|
- stampPathList,
|
|
|
- currentStamp: rptAudit && rptAudit.signature_msg.stamp_path ? rptAudit.signature_msg.stamp_path : (stampPathList.length > 0 ? stampPathList[0] : ''),
|
|
|
- companyStamp: companyInfo && companyInfo.sign_path ? companyInfo.sign_path : '',
|
|
|
- preUrl: '/payment/' + ctx.tender.id + '/detail/' + ctx.detail.id,
|
|
|
- OSS_PATH: ctx.app.config.fujianOssPath,
|
|
|
- };
|
|
|
+ renderData.rptAudit = rptAudit;
|
|
|
+ renderData.content = content;
|
|
|
+ renderData.report_json = report_json;
|
|
|
if ((ctx.detail.status === auditConst.status.uncheck || ctx.detail.status === auditConst.status.checkNo) && ctx.session.sessionUser.accountId === ctx.detail.uid) {
|
|
|
// data.accountGroup = accountGroup;
|
|
|
// 获取所有项目参与者
|
|
@@ -327,6 +311,7 @@ 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) {
|
|
@@ -338,26 +323,29 @@ module.exports = app => {
|
|
|
|
|
|
async detailSave(ctx) {
|
|
|
try {
|
|
|
+ const data = JSON.parse(ctx.request.body.data);
|
|
|
+ if (!data.type) {
|
|
|
+ throw '提交数据错误';
|
|
|
+ }
|
|
|
// 检查权限等
|
|
|
- if (ctx.detail.uid !== ctx.session.sessionUser.accountId) {
|
|
|
+ if (ctx.detail.uid !== ctx.session.sessionUser.accountId && data.type !== 'update_sign') {
|
|
|
throw '您无权操作';
|
|
|
}
|
|
|
- if (ctx.detail.status === auditConst.status.checking || ctx.detail.status === auditConst.status.checked) {
|
|
|
+ if (data.type !== 'update_sign' && (ctx.detail.status === auditConst.status.checking || ctx.detail.status === auditConst.status.checked)) {
|
|
|
throw '您无权操作';
|
|
|
}
|
|
|
const responseData = {
|
|
|
err: 0, msg: '', data: {},
|
|
|
};
|
|
|
|
|
|
- const data = JSON.parse(ctx.request.body.data);
|
|
|
- if (!data.type) {
|
|
|
- throw '提交数据错误';
|
|
|
- }
|
|
|
switch (data.type) {
|
|
|
case 'update_rpt':
|
|
|
responseData.data = await ctx.service.paymentDetail.updateReportJson(ctx.detail.id, data.report_json);
|
|
|
break;
|
|
|
case 'update_sign':
|
|
|
+ if (ctx.detail.status === auditConst.status.checked) {
|
|
|
+ throw '您无法操作签字/签章';
|
|
|
+ }
|
|
|
responseData.data = await ctx.service.paymentRptAudit.updateSignatureMsg(ctx.detail.id, ctx.session.sessionUser.accountId, data.signature_msg);
|
|
|
break;
|
|
|
case 'add_audit':
|
|
@@ -474,7 +462,7 @@ module.exports = app => {
|
|
|
if (!auditPermission || !auditPermission.process) {
|
|
|
throw '权限不足';
|
|
|
}
|
|
|
- let [tenderRptList, rptProjectList] = await this._returnRptProjectList(ctx);
|
|
|
+ let [tenderRptList, rptProjectList] = await this._returnRptProjectList(ctx, true);
|
|
|
tenderRptList = ctx.helper._.filter(tenderRptList, { is_const: 0, is_del: 0 });
|
|
|
// for (const tr of tenderRptList) {
|
|
|
// if (tr.status === shenpiConst.sp_status.gdspl) {
|
|
@@ -585,18 +573,30 @@ module.exports = app => {
|
|
|
const pageRst = await ctx.service.jpcReport.getAllPreviewPagesCommon(rptTpl, 'A4');
|
|
|
renderData.rptMsg = pageRst.items[0];
|
|
|
// 判断与原有的报表审批人列表是否有区别
|
|
|
- const deffierence = ctx.helper._.differenceWith(renderData.rptMsg.signature_cells, JSON.parse(trInfo.signature_cells), ctx.helper._.isEqual);
|
|
|
- if (!ctx.helper._.isEmpty(deffierence)) {
|
|
|
+ let difference = 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'];
|
|
|
+ for (const item of items) {
|
|
|
+ if (!difference && report_items_json[item] &&
|
|
|
+ !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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (difference) {
|
|
|
// 删除rpt_audit重新配置
|
|
|
await ctx.service.paymentTenderRpt.defaultUpdate({
|
|
|
id: trInfo.id,
|
|
|
- signature_cells: JSON.stringify(renderData.rptMsg.signature_cells),
|
|
|
+ report_items_json: JSON.stringify(ctx.helper._.cloneDeep(renderData.rptMsg)),
|
|
|
rpt_audit: null,
|
|
|
- is_first: 1,
|
|
|
+ is_change: 1,
|
|
|
});
|
|
|
trInfo.rpt_audit = null;
|
|
|
- trInfo.is_first = 1;
|
|
|
- trInfo.signature_cells = renderData.rptMsg.signature_cells;
|
|
|
+ trInfo.is_change = 1;
|
|
|
+ trInfo.report_items_json = renderData.rptMsg;
|
|
|
}
|
|
|
if (trInfo.rpt_audit) {
|
|
|
trInfo.rpt_audit = JSON.parse(trInfo.rpt_audit);
|
|
@@ -663,7 +663,7 @@ module.exports = app => {
|
|
|
}
|
|
|
switch (data.type) {
|
|
|
case 'rpt_audit':
|
|
|
- responseData.data = await ctx.service.paymentTenderRpt.updateRptAudit(trInfo.id, data.rpt_audit);
|
|
|
+ responseData.data = await ctx.service.paymentTenderRpt.updateRptAudit(trInfo, data.rpt_audit);
|
|
|
break;
|
|
|
case 'add-detail':
|
|
|
responseData.data = await ctx.service.paymentDetail.addDetail(trInfo, data.code, data.s_time);
|