瀏覽代碼

数据预处理,提供协作审批意见、日期。

MaiXinRong 4 年之前
父節點
當前提交
8eba099653
共有 2 個文件被更改,包括 118 次插入4 次删除
  1. 55 3
      app/lib/rpt_data_analysis.js
  2. 63 1
      builder_report_index_define.js

+ 55 - 3
app/lib/rpt_data_analysis.js

@@ -1114,7 +1114,7 @@ const datetimeFormat = {
     },
     fun: function (ctx, data, fieldsKey, options, csRela) {
         if (!options.tables) return;
-        const tables = options.tables instanceof Array ? tables : [options.tables];
+        const tables = options.tables instanceof Array ? options.tables : [options.tables];
         if (tables.length === 0) return;
 
         for (const table of tables) {
@@ -1435,7 +1435,12 @@ const loadCooperationData = {
             return '';
         }
     },
+    _completeSign: function (auditor) {
+        if (!auditor) return '';
+        return 'public/upload/sign/' + auditor.sign_path;
+    },
     _loadImCooperationData: function (ctx, data, options, csRela) {
+        console.log(ctx.rpt_roleSign);
         let coSignOrder = [];
         if (csRela && csRela.tplDefine && csRela.tplDefine.audit_select && csRela.cDefine && csRela.cDefine.audit_select) {
             if (csRela.cDefine.audit_select) {
@@ -1461,8 +1466,55 @@ const loadCooperationData = {
             }
 
             for (const [i, cs] of coSignOrder.entries()) {
-                if (data.stage_audit[cs] && data.stage_audit[cs].end_time)
-                    d['co_sign' + (i+1)] = d.cooperation[cs] || (data.stage_audit[cs] ? data.stage_audit[cs].sign_path : '');
+                if (data.stage_audit[cs] && data.stage_audit[cs].end_time) {
+                    d['co_sign' + (i+1)] = d.cooperation[cs] || this._completeSign(data.stage_audit[cs]);
+                    d['co_opinion' + (i+1)] = data.stage_audit[cs].opinion || '';
+                    d['co_time' + (i+1)] = data.stage_audit[cs].end_time;
+                }
+            }
+        }
+    },
+    fun: function (ctx, data, fieldsKey, options, csRela) {
+        if (!options || !options.table) return;
+        if (!data[options.table]) return;
+        if (!data.mem_stage_bills) return;
+        if (!data.stage_audit) return;
+        if (!data.ledger_cooperation) return;
+
+        if (['mem_stage_im_zl', 'mem_stage_im_tz'].indexOf(options.table) >= 0)
+            this._loadImCooperationData(ctx, data, options, csRela);
+    }
+};
+const signSelect = {
+    name: '电子签名',
+    hint: '协作模式下,才需使用,其他情况勿需使用',
+    defaultSetting: {
+        table: 'mem_stage_im_zl',
+    },
+    _findSign: function (relaId, stageCooperation, auditor) {
+        if (!stageCooperation) return '';
+        if (relaId.length > 0) {
+            for (const id of relaId) {
+                const c = stageCooperation.find(x => {return x.ledger_id == id});
+                if (c) return c.sign_path;
+            }
+            return '';
+        } else {
+            return '';
+        }
+    },
+    _loadImCooperationData: function (ctx, data, options, csRela) {
+        const stageCooperation = {};
+        for (const sa of data.stage_audit) {
+            if (sa.end_time) stageCooperation[sa.aid] = data.ledger_cooperation.filter(x => {return x.user_id === sa.aid});
+        }
+        for (const d of data[options.table]) {
+            const bills = data.mem_stage_bills.find(x => {return x.id === d.lid});
+            const relaId = bills ? bills.full_path.split('-').reverse() : [];
+
+            for (const ss of data.sign_select) {
+                if (!ss.co_sign) ss.co_sign = [];
+                ss.co_sign.push(this._findSign(relaId, stageCooperation[ss.id], ss) || 'public/upload/sign/' + ss.sign_path);
             }
         }
     },

+ 63 - 1
builder_report_index_define.js

@@ -687,6 +687,14 @@ const stage_im_zl = {
         { name: '签名2', field: 'co_sign2', type: dataType.str, isPic: true },
         { name: '签名3', field: 'co_sign3', type: dataType.str, isPic: true },
         { name: '签名4', field: 'co_sign4', type: dataType.str, isPic: true },
+        { name: '审批时间1', field: 'co_time1', type: dataType.time },
+        { name: '审批时间2', field: 'co_time2', type: dataType.time },
+        { name: '审批时间3', field: 'co_time3', type: dataType.time },
+        { name: '审批时间4', field: 'co_time4', type: dataType.time },
+        { name: '审批意见1', field: 'co_opinion1', type: dataType.time },
+        { name: '审批意见2', field: 'co_opinion2', type: dataType.time },
+        { name: '审批意见3', field: 'co_opinion3', type: dataType.time },
+        { name: '审批意见4', field: 'co_opinion4', type: dataType.time },
     ],
 };
 const stage_im_tz = {
@@ -728,6 +736,14 @@ const stage_im_tz = {
         { name: '签名2', field: 'co_sign2', type: dataType.str, isPic: true },
         { name: '签名3', field: 'co_sign3', type: dataType.str, isPic: true },
         { name: '签名4', field: 'co_sign4', type: dataType.str, isPic: true },
+        { name: '审批时间1', field: 'co_time1', type: dataType.time },
+        { name: '审批时间2', field: 'co_time2', type: dataType.time },
+        { name: '审批时间3', field: 'co_time3', type: dataType.time },
+        { name: '审批时间4', field: 'co_time4', type: dataType.time },
+        { name: '审批意见1', field: 'co_opinion1', type: dataType.time },
+        { name: '审批意见2', field: 'co_opinion2', type: dataType.time },
+        { name: '审批意见3', field: 'co_opinion3', type: dataType.time },
+        { name: '审批意见4', field: 'co_opinion4', type: dataType.time },
 
     ],
 };
@@ -1191,6 +1207,52 @@ const stage_audit = {
     ],
 };
 
+const sign_select = {
+    name: '电子签名(mem_sign_select)',
+    remark: '',
+    id: 47,
+    key: 'mem_sign_select',
+    prefix: '电子签名',
+    cols: [
+        { name: 'id-1', field: 'sign1.id', type: dataType.int },
+        { name: '名字-1', field: 'sign1.name', type: dataType.str },
+        { name: '审批意见-1', field: 'sign1.opinion', type: dataType.str },
+        { name: '审批时间-1', field: 'sign1.end_time', type: dataType.str },
+        { name: '签名-1', field: 'sign1.sign_path', type: dataType.str, isPic: true },
+        { name: '协作签名-1', field: 'sign1.co_sign', type: dataType.str, isPic: true },
+        { name: 'id-2', field: 'sign2.id', type: dataType.int },
+        { name: '名字-2', field: 'sign2.name', type: dataType.str },
+        { name: '审批意见-2', field: 'sign2.opinion', type: dataType.str },
+        { name: '审批时间-2', field: 'sign2.end_time', type: dataType.str },
+        { name: '签名-2', field: 'sign2.sign_path', type: dataType.str, isPic: true },
+        { name: '协作签名-2', field: 'sign2.co_sign', type: dataType.str, isPic: true },
+        { name: 'id-3', field: 'sign3.id', type: dataType.int },
+        { name: '名字-3', field: 'sign3.name', type: dataType.str },
+        { name: '审批意见-3', field: 'sign3.opinion', type: dataType.str },
+        { name: '审批时间-3', field: 'sign3.end_time', type: dataType.str },
+        { name: '签名-3', field: 'sign3.sign_path', type: dataType.str, isPic: true },
+        { name: '协作签名-3', field: 'sign3.co_sign', type: dataType.str, isPic: true },
+        { name: 'id-4', field: 'sign4.id', type: dataType.int },
+        { name: '名字-4', field: 'sign4.name', type: dataType.str },
+        { name: '审批意见-4', field: 'sign4.opinion', type: dataType.str },
+        { name: '审批时间-4', field: 'sign4.end_time', type: dataType.str },
+        { name: '签名-4', field: 'sign4.sign_path', type: dataType.str, isPic: true },
+        { name: '协作签名-4', field: 'sign4.co_sign', type: dataType.str, isPic: true },
+        { name: 'id-5', field: 'sign5.id', type: dataType.int },
+        { name: '名字-5', field: 'sign5.name', type: dataType.str },
+        { name: '审批意见-5', field: 'sign5.opinion', type: dataType.str },
+        { name: '审批时间-5', field: 'sign5.end_time', type: dataType.str },
+        { name: '签名-5', field: 'sign5.sign_path', type: dataType.str, isPic: true },
+        { name: '协作签名-5', field: 'sign5.co_sign', type: dataType.str, isPic: true },
+        { name: 'id-6', field: 'sign6.id', type: dataType.int },
+        { name: '名字-6', field: 'sign6.name', type: dataType.str },
+        { name: '审批意见-6', field: 'sign6.opinion', type: dataType.str },
+        { name: '审批时间-6', field: 'sign6.end_time', type: dataType.str },
+        { name: '签名-6', field: 'sign6.sign_path', type: dataType.str, isPic: true },
+        { name: '协作签名-6', field: 'sign6.co_sign', type: dataType.str, isPic: true },
+    ],
+};
+
 const recursiveMkdirSync = async function(pathName) {
     if (!fs.existsSync(pathName)) {
         const upperPath = path.dirname(pathName);
@@ -1294,7 +1356,7 @@ const defines = [
     stage_im_zl, stage_im_tz, stage_im_tz_bills,
     gather_stage_bills, gather_tender_info, gather_stage_pay, gather_deal_bills,
     material, materialGl,
-    stage_sum_bills, stage_sum_pay, stage_audit,
+    stage_sum_bills, stage_sum_pay, stage_audit, sign_select,
 ];
 for (const d of defines) {
     exportTableDefine(d);