فهرست منبع

表单数据更新离散数据问题

laiguoran 1 سال پیش
والد
کامیت
0dfbf43382
2فایلهای تغییر یافته به همراه25 افزوده شده و 10 حذف شده
  1. 22 5
      app/controller/payment_controller.js
  2. 3 5
      app/service/payment_detail.js

+ 22 - 5
app/controller/payment_controller.js

@@ -322,9 +322,9 @@ module.exports = app => {
                     (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');
-                        rptTpl.source_type = 101;
-                        const pageRst = await ctx.service.jpcReport.getPreviewPagesWithDiscreteDataCommon(ctx, rptTpl, 'A4', this.app.baseDir, null);
+                        const pageRst = await ctx.service.jpcReport.getAllPreviewPagesCommon(rptTpl, 'A4');
+                        // rptTpl.source_type = 101;
+                        // const pageRst = await ctx.service.jpcReport.getPreviewPagesWithDiscreteDataCommon(ctx, rptTpl, 'A4', this.app.baseDir, null);
                         const rptMsg = pageRst.items[0];
                         // 判断与原有的报表审批人列表是否有区别
                         let difference = false;
@@ -368,6 +368,23 @@ module.exports = app => {
                         }
                     }
                 }
+                // 非审批完成可能要更新离散数据(cells值)
+                if (ctx.detail.status !== auditConst.status.checked) {
+                    const rptTpl = await ctx.service.rptTpl.getDataById(ctx.trInfo.rpt_id);
+                    if (rptTpl) {
+                        rptTpl.source_type = 101;
+                        const pageRst = await ctx.service.jpcReport.getPreviewPagesWithDiscreteDataCommon(ctx, rptTpl, 'A4', this.app.baseDir, null);
+                        const rptMsg = pageRst.items[0];
+                        const report_json = JSON.parse(ctx.detail.report_json);
+                        if (report_json && report_json.items && report_json.items.length > 0 && report_json.items[0].cells &&
+                            !ctx.helper._.isEmpty(ctx.helper._.differenceWith(JSON.parse(JSON.stringify(rptMsg.cells)), report_json.cells, ctx.helper._.isEqual))) {
+                            report_json.items[0].cells = ctx.helper._.cloneDeep(rptMsg.cells);
+                            const newJson = JSON.stringify(report_json);
+                            await this.service.paymentDetail.defaultUpdate({ id: ctx.detail.id, report_json: newJson });
+                            ctx.detail.report_json = newJson;
+                        }
+                    }
+                }
                 const auditIdList = ctx.helper._.map(ctx.detail.auditors, 'aid');
                 const rptAuditIdList = ctx.helper._.map(ctx.detail.rptAudits, 'uid');
                 const uidList = ctx.helper._.uniq([...auditIdList, ...rptAuditIdList]);
@@ -791,7 +808,7 @@ module.exports = app => {
                 if (trInfo.uid === ctx.session.sessionUser.accountId && trInfo.is_del === 0 && trInfo.rpt_id) {
                     const rptTpl = await ctx.service.rptTpl.getDataById(trInfo.rpt_id);
                     if (rptTpl) {
-                        rptTpl.source_type = 101;
+                        // rptTpl.source_type = 101;
                         const pageRst = await ctx.service.jpcReport.getAllPreviewPagesCommon(rptTpl, 'A4');
                         // const pageRst = await ctx.service.jpcReport.getPreviewPagesWithDiscreteDataCommon(ctx, rptTpl, 'A4', this.app.baseDir, null);
                         renderData.rptMsg = pageRst.items[0];
@@ -905,7 +922,7 @@ module.exports = app => {
                         responseData.data = await ctx.service.paymentTenderRpt.updateRptAudit(trInfo, data.rpt_audit);
                         break;
                     case 'add-detail':
-                        responseData.data = await ctx.service.paymentDetail.addDetail(ctx, trInfo, data.code, data.s_time);
+                        responseData.data = await ctx.service.paymentDetail.addDetail(trInfo, data.code, data.s_time);
                         break;
                     default: throw '参数有误';
                 }

+ 3 - 5
app/service/payment_detail.js

@@ -61,7 +61,7 @@ module.exports = app => {
         }
 
         // async addFormDetail(trInfo, code, s_time) {
-        async addFormDetail(ctx, trInfo, code, s_time) {
+        async addFormDetail(trInfo, code, s_time) {
             const transaction = await this.db.beginTransaction();
             try {
                 if (!(trInfo.is_del === 0 && trInfo.rpt_audit)) {
@@ -70,8 +70,6 @@ module.exports = app => {
                 const preDetail = await this.addCommomCheck(trInfo, code);
                 const rptTpl = await this.ctx.service.rptTpl.getDataById(trInfo.rpt_id);
                 const pageRst = await this.ctx.service.jpcReport.getAllPreviewPagesCommon(rptTpl, 'A4');
-                // rptTpl.source_type = 101;
-                // const pageRst = await ctx.service.jpcReport.getPreviewPagesWithDiscreteDataCommon(ctx, rptTpl, 'A4', this.app.baseDir, null);
                 const newDetail = {
                     tender_id: this.ctx.paymentTender.id,
                     tr_id: trInfo.id,
@@ -167,10 +165,10 @@ module.exports = app => {
             }
         }
 
-        async addDetail(ctx, trInfo, code, s_time) {
+        async addDetail(trInfo, code, s_time) {
             switch (trInfo.type) {
                 case paymentConst.modes_value_object.form:
-                    return this.addFormDetail(ctx, trInfo, code, s_time);
+                    return this.addFormDetail(trInfo, code, s_time);
                 case paymentConst.modes_value_object.safe:
                     return this.addSafeDetail(trInfo, code, s_time);
                 default: