Browse Source

判断机制bug修复

laiguoran 2 năm trước cách đây
mục cha
commit
4efd6cc971
1 tập tin đã thay đổi với 50 bổ sung1 xóa
  1. 50 1
      app/controller/payment_controller.js

+ 50 - 1
app/controller/payment_controller.js

@@ -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 (!difference && 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,
@@ -704,7 +753,7 @@ module.exports = app => {
                                     // 因为interact_cells里存在undefind值,必须先用JSON.parse和JSON.stringify转义才能对比
                                     difference = true;
                                     needChange = true;
-                                    if (item === 'signature_audit_cells') {
+                                    if (item === 'signature_cells') {
                                         auditDifference = true;
                                     }
                                     break;