瀏覽代碼

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

Tony Kang 10 月之前
父節點
當前提交
0434ab3bb9

+ 1 - 2
app/controller/ledger_audit_controller.js

@@ -63,8 +63,7 @@ module.exports = app => {
                     throw '添加审核人失败';
                 }
 
-                // responseData.data = await ctx.service.ledgerAudit.getAuditor(ctx.tender.id, id, ctx.tender.data.ledger_times);
-                responseData.data = await ctx.service.ledgerAudit.getAuditorsWithOwner(ctx.tender.id, ctx.tender.data.ledger_times);
+                responseData.data = await ctx.service.ledgerAudit.getUserGroup(ctx.tender.id, ctx.tender.data.ledger_times);
             } catch (err) {
                 responseData.err = 1;
                 responseData.msg = err.toString();

+ 1 - 1
app/controller/revise_controller.js

@@ -755,7 +755,7 @@ module.exports = app => {
                 const result = await ctx.service.reviseAudit.addAuditor(revise, id, is_gdzs);
                 if (!result) throw '添加审核人失败';
 
-                const resultData = await ctx.service.reviseAudit.getAuditorsWithOwner(revise.id, revise.times);
+                const resultData = await ctx.service.reviseAudit.getUserGroup(revise.id, revise.times);
                 ctx.body = { err: 0, msg: '', data: resultData };
             } catch (err) {
                 this.log(err, '数据错误');

+ 11 - 2
app/controller/tender_controller.js

@@ -436,8 +436,17 @@ module.exports = app => {
                     }
                     tender.sum = ctx.helper.add(tender.total_price, tender.change_tp);
                     if (tender.ledger_status !== auditConst.ledger.status.uncheck) {
-                        const status_name = await this.ctx.service.ledgerAudit.getStatusName(tender.id, tender.ledger_times);
-                        tender.status_users = status_name ? status_name.name : '';
+                        let cur;
+                        if (tender.ledger_status === auditConst.ledger.status.checked) {
+                            cur = await this.ctx.service.ledgerAudit.getLastestAuditors(tender.id, tender.ledger_times, auditConst.ledger.status.checked);
+                        } else if (tender.ledger_status === auditConst.ledger.status.checking) {
+                            cur = await this.ctx.service.ledgerAudit.getCurAuditors(tender.id, tender.ledger_times);
+                        } else {
+                            cur = await this.ctx.service.ledgerAudit.getAuditorsByStatus(tender.id, tender.ledger_status, tender.ledger_times);
+                        }
+                        // const status_name = await this.ctx.service.ledgerAudit.getStatusName(tender.id, tender.ledger_times);
+                        // tender.status_users = status_name ? status_name.name : '';
+                        tender.status_users = cur.length > 0 ? (cur[0].audit_type === auditConst.auditType.key.common ? cur[0].name : ctx.helper.transFormToChinese(cur[0].audit_order) + '审') : '';
                         const times = tender.ledger_status === auditConst.ledger.status.checkNo ? tender.ledger_times - 1 : tender.ledger_times;
                         const history = await ctx.service.ledgerAudit.getAuditorHistory(tender.id, times);
                         tender.auditors = history[history.length - 1];

+ 38 - 34
app/public/js/ledger.js

@@ -4151,42 +4151,46 @@ $(document).ready(function() {
 
     // 添加到审批流程中
     $('#book-list').on('click', 'dd', function () {
-        const auditorId = parseInt($(this).data('id'))
-        if (auditorId) {
-            postData('/tender/' + getTenderId() + '/ledger/audit/add', { auditorId }, (datas) => {
-                const html = [];
-                // 如果是重新上报,添加到重新上报列表中
-                const auditorshtml = [];
-                for (const [index,data] of datas.entries()) {
-                    if (index !== 0) {
-                        html.push('<li class="list-group-item" auditorId="' + data.audit_id + '">');
-                        if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
-                            html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
-                        }
-                        html.push('<span>');
-                        html.push(data.audit_order + ' ');
-                        html.push(data.name + ' ');
-                        html.push('</span>');
-                        html.push('<small class="text-muted">');
-                        html.push(data.role);
-                        html.push('</small></li>');
+        const auditorId = parseInt($(this).data('id'));
+        if (!auditorId) return;
+
+        postData('/tender/' + getTenderId() + '/ledger/audit/add', { auditorId }, (datas) => {
+            const html = [];
+            // 如果是重新上报,添加到重新上报列表中
+            const auditorshtml = [];
+            for (const [index,data] of datas.entries()) {
+                if (index !== 0) {
+                    html.push('<li class="list-group-item d-flex" auditorId="'+ data[0].audit_id +'">');
+                    html.push(`<div class="col-auto">${index}</div>`);
+                    html.push('<div class="col">');
+                    for (const auditor of data) {
+                        html.push(`<div class="d-inline-block mx-1"><i class="fa fa-user text-muted"></i> ${auditor.name} <small class="text-muted">${auditor.role}</small></div>`);
                     }
-                    auditorshtml.push('<li class="list-group-item" ' + (index !== 0 ? 'data-auditorid="' + data.audit_id + '"' : '') + '>');
-                    auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
-                    auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
-                    if (index === 0) {
-                        auditorshtml.push('<span class="pull-right">原报</span>');
-                    } else if (index+1 === datas.length) {
-                        auditorshtml.push('<span class="pull-right">终审</span>');
-                    } else {
-                        auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                    html.push('</div>');
+                    html.push('<div class="col-auto">');
+                    // todo 添加会签或签时
+                    // html.push('<span class="badge badge-pill badge-primary badge-bg-small"><small></small></span>');
+                    if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
+                        html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
                     }
-                    auditorshtml.push('</li>');
+                    html.push('</div>');
+                    html.push('</li>');
                 }
-                $('#auditors').html(html.join(''));
-                $('#auditors-list').html(auditorshtml.join(''));
-            });
-        }
+                auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.audit_id + '">');
+                auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
+                auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
+                if (index === 0) {
+                    auditorshtml.push('<span class="pull-right">原报</span>');
+                } else if (index+1 === datas.length) {
+                    auditorshtml.push('<span class="pull-right">终审</span>');
+                } else {
+                    auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                }
+                auditorshtml.push('</li>');
+            }
+            $('#auditors').html(html.join(''));
+            $('#auditors-list').html(auditorshtml.join(''));
+        });
     });
     $('body').on('click', '#auditors li>div>a', function () {
         const li = $(this).parent().parent();
@@ -4197,7 +4201,7 @@ $(document).ready(function() {
             li.remove();
             for (const a of data2) {
                 const aLi = $('li[auditorId=' + a.audit_id + ']');
-                $('span', aLi).text(a.audit_order + ' ' + a.name + ' ');
+                $('div:first', aLi).text(a.audit_order);
             }
 
             // 如果是重新上报

+ 0 - 2
app/public/js/ledger_gather.js

@@ -211,7 +211,6 @@ $(document).ready(() => {
     function loadGatherAncGclData(iGclRow) {
         const gcl = iGclRow ? gclGatherData[iGclRow] : SpreadJsObj.getSelectObject(gclSheet);
         SpreadJsObj.resetTopAndSelect(gatherAncGclSheet);
-        console.log(gcl.ancGcl, gcl.gatherAncGcl);
         if (gcl) {
             SpreadJsObj.loadSheetData(gatherAncGclSheet, SpreadJsObj.DataType.Data, gcl.gatherAncGcl);
         } else {
@@ -222,7 +221,6 @@ $(document).ready(() => {
         const gcl = iGclRow ? gclGatherData[iGclRow] : SpreadJsObj.getSelectObject(gclSheet);
         SpreadJsObj.resetTopAndSelect(changeSheet);
         if (gcl) {
-            console.log(gcl.change);
             SpreadJsObj.loadSheetData(changeSheet, SpreadJsObj.DataType.Data, gcl.change);
         } else {
             SpreadJsObj.loadSheetData(changeSheet, SpreadJsObj.DataType.Data, []);

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

@@ -178,7 +178,7 @@ $(document).ready(function () {
             li.remove();
             for (const rst of result) {
                 const aLi = $('li[auditorId=' + rst.aid + ']');
-                $('span', aLi).text(rst.order + ' ' + rst.name + ' ');
+                $('div:first', aLi).text(rst.order);
             }
 
             // 如果是重新上报

+ 49 - 3
app/service/ledger_audit.js

@@ -94,6 +94,40 @@ module.exports = app => {
             return result.filter(x => { return x.audit_order === result[0].audit_order });
         }
 
+        async getAuditorsByStatus(tenderId, status, times = 1) {
+            let auditor = [];
+            let sql = '';
+            let sqlParam = '';
+            let cur;
+            switch (status) {
+                case auditConst.status.checking:
+                case auditConst.status.checked:
+                    cur = await this.db.queryOne(`SELECT * From ${this.tableName} where tender_id = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`order` DESC', [tenderId, times, status]);
+                    if (!cur) return [];
+
+                    sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.audit_order, la.audit_type, la.audit_ledger_id ' +
+                        '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id` ' +
+                        '  WHERE la.`tender_id` = ? and la.`audit_order` = ? and la.`times` = ?';
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, cur.order, times];
+                    auditor = await this.db.query(sql, sqlParam);
+                    break;
+                case auditConst.status.checkNo:
+                    cur = await this.db.queryOne(`SELECT * From ${this.tableName} where tender_id = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`order` DESC', [tenderId, parseInt(times) - 1, status]);
+                    if (!cur) return [];
+
+                    sql = 'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`tender_id`, la.audit_order, la.audit_type, la.audit_ledger_id ' +
+                        '  FROM ?? AS la Left Join ?? AS pa On la.`audit_id` = pa.`id` ' +
+                        '  WHERE la.`sid` = ? and la.`audit_order` = ? and la.`times` = ?';
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, cur.order, parseInt(times) - 1];
+                    auditor = await this.db.query(sql, sqlParam);
+                    break;
+                case auditConst.status.uncheck:
+                default:
+                    break;
+            }
+            return auditor;
+        }
+
         /**
          * 获取标段审核列表信息
          *
@@ -198,13 +232,22 @@ module.exports = app => {
                     const auditors = await this.getAuditors(tenderId, i);
                     const group = this.ctx.helper.groupAuditors(auditors, 'audit_order');
                     const historyGroup = [];
-                    const max_order = group.length > 0 && group[group.length - 1].length > 0 ? group[group.length - 1][0].audit_order : -1;
+                    let max_order = 0;
                     for (const g of group) {
                         const his = {
                             beginYear: '', beginDate: '', beginTime: '', endYear: '', endDate: '', endTime: '', begin_time: null, end_time: null,
-                            audit_type: g[0].audit_type, audit_order: g[0].audit_order,
+                            audit_type: g[0].audit_type, order: g[0].audit_order,
                             auditors: g
                         };
+                        const curAuditId = g.map(x => { return x.audit_id; });
+                        const sameHis = historyGroup.find(x => {
+                            if (x.audit_type !== his.audit_type) return false;
+                            const auditId = x.auditors.map(xa => { return xa.audit_id; });
+                            this.ctx.helper._.remove(auditId, function(a) { return curAuditId.indexOf(a) >= 0; });
+                            return auditId.length === 0;
+                        });
+                        his.audit_order = sameHis ? sameHis.audit_order : his.order;
+                        if (!sameHis && his.audit_order > max_order) max_order = his.audit_order;
                         if (his.audit_type === auditType.key.common) {
                             his.name = g[0].name;
                         } else {
@@ -236,6 +279,9 @@ module.exports = app => {
                         }
                         historyGroup.push(his);
                     }
+                    historyGroup.forEach(hg => {
+                        hg.is_final = hg.audit_order === max_order;
+                    });
                     if (reverse) {
                         history.push(historyGroup.reverse());
                     } else {
@@ -442,7 +488,7 @@ module.exports = app => {
                 if (!auditor) {
                     throw '该审核人不存在';
                 }
-                await transaction.delete(this.tableName, { tid: tenderId, audit_order: auditor.audit_order, times});
+                await transaction.delete(this.tableName, { tender_id: tenderId, audit_order: auditor.audit_order, times});
                 await this._syncOrderByDelete(transaction, tenderId, auditor.audit_order, times);
                 await transaction.delete(this.tableName, condition);
                 await transaction.commit();

+ 1 - 1
app/service/ledger_revise.js

@@ -157,7 +157,7 @@ module.exports = app => {
                     tender_id: this.ctx.tender.id,
                     rid: rid,
                     in_time: inTime,
-                    audit_order: newAuditors.length + 1,
+                    audit_order: a.audit_order,
                     audit_id: a.audit_id,
                     audit_type: a.audit_type,
                     audit_ledger_id: a.audit_ledger_id,

+ 41 - 36
app/view/revise/info_modal.ejs

@@ -730,46 +730,50 @@
         });
 
         $('dl').on('click', 'dd', function () {
-            const auditorId = parseInt($(this).data('id'))
-            if (auditorId) {
-                postData('/tender/<%- ctx.tender.id %>/revise/audit/add', { auditorId }, (datas) => {
-                    const html = [];
-                    // 如果是重新上报,添加到重新上报列表中
-                    const auditorshtml = [];
-                    for (const [index,data] of datas.entries()) {
-                        if (index !== 0) {
-                            html.push('<li class="list-group-item" auditorId="' + data.audit_id + '">');
-                            if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
-                                html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
-                            }
-                            html.push('<span>');
-                            html.push(data.audit_order + ' ');
-                            html.push(data.name + ' ');
-                            html.push('</span>');
-                            html.push('<small class="text-muted">');
-                            html.push(data.role);
-                            html.push('</small></li>');
+            const auditorId = parseInt($(this).data('id'));
+            if (!auditorId) return;
+
+            postData('/tender/<%- ctx.tender.id %>/revise/audit/add', { auditorId }, (datas) => {
+                const html = [];
+                // 如果是重新上报,添加到重新上报列表中
+                const auditorshtml = [];
+                for (const [index,data] of datas.entries()) {
+                    if (index !== 0) {
+                        html.push('<li class="list-group-item d-flex" auditorId="'+ data[0].audit_id +'">');
+                        html.push(`<div class="col-auto">${index}</div>`);
+                        html.push('<div class="col">');
+                        for (const auditor of data) {
+                            html.push(`<div class="d-inline-block mx-1"><i class="fa fa-user text-muted"></i> ${auditor.name} <small class="text-muted">${auditor.role}</small></div>`);
                         }
-                        auditorshtml.push('<li class="list-group-item" ' + (index !== 0 ? 'data-auditorid="' + data.audit_id + '"' : '') + '>');
-                        auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
-                        auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
-                        if (index === 0) {
-                            auditorshtml.push('<span class="pull-right">原报</span>');
-                        } else if (index+1 === datas.length) {
-                            auditorshtml.push('<span class="pull-right">终审</span>');
-                        } else {
-                            auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                        html.push('</div>');
+                        html.push('<div class="col-auto">');
+                        // todo 添加会签或签时
+                        // html.push('<span class="badge badge-pill badge-primary badge-bg-small"><small></small></span>');
+                        if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
+                            html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
                         }
-                        auditorshtml.push('</li>');
+                        html.push('</div>');
+                        html.push('</li>');
                     }
-                    $('#auditors').html(html.join(''));
-                    $('#auditors-list').html(auditorshtml.join(''));
-                });
-            }
+                    auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.audit_id + '">');
+                    auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
+                    auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
+                    if (index === 0) {
+                        auditorshtml.push('<span class="pull-right">原报</span>');
+                    } else if (index+1 === datas.length) {
+                        auditorshtml.push('<span class="pull-right">终审</span>');
+                    } else {
+                        auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
+                    }
+                    auditorshtml.push('</li>');
+                }
+                $('#auditors').html(html.join(''));
+                $('#auditors-list').html(auditorshtml.join(''));
+            });
         });
 
-        $('body').on('click', '#auditors li>a', function () {
-            const li = $(this).parent();
+        $('body').on('click', '#auditors li>div>a', function () {
+            const li = $(this).parent().parent();
             const data = {
                 auditorId: parseInt(li.attr('auditorId')),
             };
@@ -777,7 +781,8 @@
                 li.remove();
                 for (const a of data2) {
                     const aLi = $('li[auditorId=' + a.audit_id + ']');
-                    $('span', aLi).text(a.audit_order + ' ' + a.name + ' ');
+                    aLi.children
+                    $('div:first', aLi).text(a.audit_order);
                 }
 
                 // 如果是重新上报