소스 검색

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 4 년 전
부모
커밋
9b352dd514

+ 12 - 10
app/lib/rpt_data_analysis.js

@@ -1400,8 +1400,6 @@ const stageSelectConverse = {
         if (!gsDefine || !gsDefine.enable || !gsDefine.setting || gsDefine.setting === '') return;
         const gsCustom = csRela.cDefine ? csRela.cDefine.stage_select : null;
         if (gsCustom) {
-            console.log(gsCustom[0]);
-            console.log(data.mem_stage_sum_bills[0]);
             for (const t of options.table) {
                 switch (t) {
                     case 'mem_stage_sum_bills':
@@ -1436,11 +1434,11 @@ const loadCooperationData = {
         }
     },
     _completeSign: function (auditor) {
-        if (!auditor) return '';
-        return 'public/upload/sign/' + auditor.sign_path;
+        if (!auditor || !auditor.end_time) return '';
+        return auditor.sign_path ? '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) {
@@ -1453,8 +1451,10 @@ const loadCooperationData = {
         }
 
         const stageCooperation = [];
+        let finish = true;
         for (const sa of data.stage_audit) {
             if (sa.end_time) stageCooperation.push(data.ledger_cooperation.filter(x => {return x.user_id === sa.aid}));
+            if (finish && !sa.end_time) finish = false;
         }
         for (const d of data[options.table]) {
             const bills = data.mem_stage_bills.find(x => {return x.id === d.lid});
@@ -1465,11 +1465,13 @@ const loadCooperationData = {
                 d.cooperation.push(this._findSign(relaId, stageCooperation[i], sa));
             }
 
-            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] || 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;
+            if (finish) {
+                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] || 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;
+                    }
                 }
             }
         }

+ 1 - 1
app/public/js/stage.js

@@ -880,7 +880,7 @@ $(document).ready(() => {
                 const datas = [], dgnDatas = [], mainDatas = [];
                 for (let iRow = sel.row; iRow < sel.row + sel.rowCount; iRow++) {
                     const node = sortData[iRow];
-                    if (node) {
+                    if (node && !node.lock) {
                         const data = { lid: node.id }, dgnData = { id: node.id }, mainData = { id: node.id };
                         let filter = true, filterDgn = true, filterMain = true;
                         for (const iCol of validCols) {

+ 1 - 0
app/public/report/js/rpt_custom.js

@@ -188,6 +188,7 @@ const rptCustomObj = (function () {
         } else {
             $('#pnl_eSignature').show();
         }
+        $('#pnl_audit_select div button').html('<i class="fa fa-pencil"></i><br>' + (setting.caption || '审批人选择'));
         const html = [];
         for (const [i, s] of setting.select.entries()) {
             html.push('<tr>');

+ 1 - 1
app/service/change_audit.js

@@ -382,7 +382,7 @@ module.exports = app => {
                     order++;
                     uSort++;
                 }
-                await transaction.insert(this.tableName, newAuditors);
+                if (newAuditors.length > 0) await transaction.insert(this.tableName, newAuditors);
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();

+ 8 - 11
app/service/report.js

@@ -85,7 +85,7 @@ module.exports = app => {
                             runnableKey.push(filter);
                             break;
                         case 'stage_audit':
-                            runnableRst.push(service.reportMemory.getStageAuditors(params.tender_id, params.stage_id), memFieldKeys[filter]);
+                            runnableRst.push(service.reportMemory.getStageAuditors(params.tender_id, params.stage_id));
                             runnableKey.push(filter);
                             break;
                         case 'mem_stage_bills':
@@ -115,6 +115,7 @@ module.exports = app => {
                         case 'change_audit_list':
                             runnableRst.push(service.changeAuditList.getChangeAuditBills(params.tender_id)); // 获取所有审核通过的变更清单
                             runnableKey.push(filter);
+                            console.log(filter);
                             break;
                         case 'mem_stage_jgcl':
                             runnableRst.push(service.reportMemory.getStageJgcl(params.tender_id, params.stage_id, memFieldKeys[filter]));
@@ -170,6 +171,10 @@ module.exports = app => {
                             runnableRst.push(service.ledgerCooperation.getValidData(params.tender_id));
                             runnableKey.push(filter);
                             break;
+                        case 'mem_sign_select':
+                            runnableRst.push(service.reportMemory.getSignSelect(params.tender_id, params.stage_id, customSelect));
+                            runnableKey.push(filter);
+                            break;
                         default:
                             break;
                     }
@@ -179,18 +184,10 @@ module.exports = app => {
             for (let idx = 0; idx < runnableKey.length; idx++) {
                 rst[runnableKey[idx]] = queryRst[idx];
             }
+            this.ctx.helper.saveBufferFile(JSON.stringify(queryRst, '', '\t'), this.ctx.app.baseDir + '/reportDataOrg.json');
+            this.ctx.helper.saveBufferFile(JSON.stringify(rst, '', '\t'), this.ctx.app.baseDir + '/reportData.json');
             for (const filter of filters) {
                 switch (filter) {
-                    // test模式下,上方Promise.all的方式,取不到以下3个数据
-                    // case 'ledger_cooperation':
-                    //     rst[filter] = await service.ledgerCooperation.getValidData(params.tender_id);
-                    //     break;
-                    // case 'stage_audit':
-                    //     rst[filter] = await service.reportMemory.getStageAuditors(params.tender_id, params.stage_id), memFieldKeys[filter];
-                    //     break;
-                    // case 'mem_stage_im_zl':
-                    //     rst[filter] = await service.reportMemory.getStageImZlData(params.tender_id, params.stage_id, memFieldKeys[filter]);
-                    //     break;
                     case 'mem_stage_im_tz':
                         rst[filter] = await service.reportMemory.getStageImTzData(params.tender_id, params.stage_id, memFieldKeys[filter]);
                         break;

+ 29 - 3
app/service/report_memory.js

@@ -979,9 +979,10 @@ module.exports = app => {
         async getStageAuditors(tid, sid) {
             await this.ctx.service.tender.checkTender(tid);
             await this.ctx.service.stage.checkStage(sid);
+
+            const auditors = await this.ctx.service.stageAudit.getFinalAuditGroup(this.ctx.stage.id, this.ctx.stage.curTimes);
             const user = await this.ctx.service.projectAccount.getDataById(this.ctx.stage.user_id);
-            const auditors = this.ctx.stage.auditors;
-            return [{
+            const result = [{
                 aid: user.id,
                 name: user.name,
                 company: user.company,
@@ -989,9 +990,34 @@ module.exports = app => {
                 mobile: user.mobile,
                 telephone: user.telephone,
                 sign_path: user.sign_path,
+                opinion: user.opinion,
                 end_time: auditors && auditors.length > 0 ? auditors[0].begin_time : null,
                 sort: 0,
-            }, ...this.ctx.stage.auditors];
+            }, ...auditors];
+            return result;
+        }
+
+        async getSignSelect(tid, sid, customSelect) {
+            await this.ctx.service.tender.checkTender(tid);
+            await this.ctx.service.stage.checkStage(sid);
+
+            const signSelect = customSelect.sign_select, result = {};
+            for (const [i, ss] of signSelect.entries()) {
+                const user = await this.ctx.service.projectAccount.getDataById(ss.id);
+                const sign = {
+                    id: ss.id, name: user.name, company: user.company, role: user.role,
+                    mobile: user.mobile, telephone: user.telephone,
+                };
+                if (ss.id !== this.ctx.stage.user_id) {
+                    const audit = this.ctx.stage.auditors.find(x => {return x.aid === ss.id});
+                    user.end_time = audit ? audit.end_time : ss.audit_time;
+                } else {
+                    user.end_time = this.ctx.stage.auditors[0].end_time;
+                }
+                if (user.end_time) sign.sign_path = user.sign_path;
+                result['sign' + (i+1)] = sign;
+            }
+            return result;
         }
     }
 

+ 16 - 0
app/service/stage_audit.js

@@ -1306,6 +1306,22 @@ module.exports = app => {
                 throw err;
             }
         }
+
+        async getFinalAuditGroup(stageId, times) {
+            const sql =
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`, la.`times`, la.`sid`, la.`aid`, Max(la.`order`) as max_order ' +
+                'FROM ?? AS la, ?? AS pa ' +
+                'WHERE la.`sid` = ? and la.`times` = ? and la.`aid` = pa.`id` GROUP BY la.`aid` ORDER BY la.`order`';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, times];
+            const result = await this.db.query(sql, sqlParam);
+            for (const r of result) {
+                const auditor = await this.getDataByCondition({sid: stageId, times: r.times, order: r.max_order});
+                r.opinion = auditor.opinion;
+                r.begin_time = auditor.begin_time;
+                r.end_time = auditor.end_time;
+            }
+            return result;
+        }
     }
 
     return StageAudit;

+ 0 - 1
builder_report_index_define.js

@@ -744,7 +744,6 @@ const stage_im_tz = {
         { 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_bills = {