فهرست منبع

金额概况,去掉计量期数、审批状态,新增计量进度,当前流程,上一流程数据

MaiXinRong 4 سال پیش
والد
کامیت
5f30fd31a0
6فایلهای تغییر یافته به همراه231 افزوده شده و 64 حذف شده
  1. 33 10
      app/const/audit.js
  2. 108 16
      app/controller/tender_controller.js
  3. 40 31
      app/public/js/tender_list_info.js
  4. 22 0
      app/service/ledger_audit.js
  5. 27 6
      app/service/stage_audit.js
  6. 1 1
      config/web.js

+ 33 - 10
app/const/audit.js

@@ -41,7 +41,20 @@ const ledger = (function() {
     auditStringClass[status.checking] = 'text-warning';
     auditStringClass[status.checked] = 'text-success';
     auditStringClass[status.checkNo] = 'text-warning';
-    return { status, statusString, statusClass, auditString, auditStringClass };
+
+    // 金额概况
+
+    const tiStatusString = [];
+    tiStatusString[status.uncheck] = '未上报';
+    tiStatusString[status.checking] = '审批中';
+    tiStatusString[status.checked] = '审批通过';
+    tiStatusString[status.checkNo] = '审批退回';
+    const tiStatusStringClass = [];
+    tiStatusStringClass[status.uncheck] = '';
+    tiStatusStringClass[status.checking] = 'text-warning';
+    tiStatusStringClass[status.checked] = 'text-success';
+    tiStatusStringClass[status.checkNo] = 'text-warning';
+    return { status, statusString, statusClass, auditString, auditStringClass, tiStatusString, tiStatusStringClass };
 })();
 
 // 台账修订 审批流程
@@ -180,22 +193,32 @@ const stage = (function() {
     auditProgressClass[status.checkAgain] = 'text-warning';
     /* ------------------------------------------------------- */
 
+    const tiStatusString = [];
+    tiStatusString[status.uncheck] = '待上报';
+    tiStatusString[status.checking] = '审批中';
+    tiStatusString[status.checked] = '审批通过';
+    tiStatusString[status.checkNo] = '审批退回';
+    tiStatusString[status.checkNoPre] = '审批中';
+    tiStatusString[status.checkAgain] = '审批中';
+    const tiStatusStringClass = [];
+    tiStatusStringClass[status.uncheck] = '';
+    tiStatusStringClass[status.checking] = 'text-warning';
+    tiStatusStringClass[status.checked] = 'text-success';
+    tiStatusStringClass[status.checkNo] = 'text-warning';
+    tiStatusStringClass[status.checkNoPre] = 'text-warning';
+    tiStatusStringClass[status.checkAgain] = 'text-warning';
     const backType = {
         org: 1,
         pre: 2,
     };
     return {
-        status,
-        statusString,
-        statusClass,
-        statusButton,
-        statusButtonClass,
-        auditString,
-        auditStringClass,
-        auditProgress,
-        auditProgressClass,
+        status, statusString, statusClass,
+        statusButton, statusButtonClass,
+        auditString, auditStringClass,
+        auditProgress, auditProgressClass,
         backType,
         timesLen: 100,
+        tiStatusString, tiStatusStringClass
     };
 })();
 

+ 108 - 16
app/controller/tender_controller.js

@@ -31,6 +31,84 @@ module.exports = app => {
             ctx.showTitle = true;
         }
 
+        async _getLedgerAuditInfo (tender) {
+            tender.cur_flow = {
+                title: '台账',
+                status: auditConst.ledger.tiStatusString[tender.ledger_status],
+                status_class: auditConst.ledger.tiStatusStringClass[tender.ledger_status],
+            };
+            if (tender.ledger_status === auditConst.ledger.status.uncheck) {
+                tender.cur_flow.name = tender.user_name;
+            } else {
+                const cur = tender.ledger_status === auditConst.ledger.status.checkNo
+                    ? await this.ctx.service.ledgerAudit.getLastestAuditor(tender.id, tender.ledger_times - 1, auditConst.ledger.status.checkNo)
+                    : await this.ctx.service.ledgerAudit.getLastestAuditor(tender.id, tender.ledger_times, tender.ledger_status);
+                if (cur) {
+                    tender.cur_flow.name = cur.name;
+                    if (cur.audit_order === 1) {
+                        tender.pre_flow = { name: tender.user_name, time: cur.begin_time };
+                    } else {
+                        const pre = await this.ctx.service.ledgerAudit.getAuditorByOrder(tender.id, cur.audit_order - 1, cur.times);
+                        if (pre) tender.pre_flow = { name: pre.name, time: pre.end_time };
+                    }
+                } else {
+                    tender.cur_flow.name = '';
+                }
+            }
+        }
+
+        async _getStageAuditInfo (tender, stage) {
+            tender.cur_flow = {
+                title: '第' + stage.order + '期',
+                status: auditConst.stage.tiStatusString[stage.status],
+                status_class: auditConst.stage.tiStatusStringClass[stage.status],
+            };
+            if (stage.status === auditConst.stage.status.uncheck) {
+                if (tender.user_id === stage.user_id) {
+                    tender.cur_flow.name = tender.user_name;
+                } else {
+                    const user = await this.ctx.service.projectAccount.getDataById(stage.user_id);
+                    tender.cur_flow.name = user.name;
+                }
+                if (stage.order > 1) {
+                    const preStage = await this.ctx.service.stage.getDataByCondition({ tid: tender.id, order: stage.order - 1});
+                    if (!preStage) return;
+
+                    const pre = await this.ctx.service.stageAudit.getLastestAuditor(preStage.id, preStage.times, auditConst.stage.status.checked);
+                    if (pre) tender.pre_flow = { name: pre.name, time: pre.end_time};
+                }
+            } else {
+                let cur;
+                if (stage.status === auditConst.stage.status.checkNo) {
+                    cur = await this.ctx.service.stageAudit.getLastestAuditor(stage.id, stage.times - 1, auditConst.stage.status.checkNo);
+                } else if (stage.status === auditConst.stage.status.checked) {
+                    cur = await this.ctx.service.stageAudit.getLastestAuditor(stage.id, stage.times, auditConst.stage.status.checked);
+                } else {
+                    cur = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
+                }
+                if (tender.id === 3024) console.log(stage, cur);
+                if (cur) {
+                    tender.cur_flow.name = cur.name;
+                    if (cur.order === 1) {
+                        tender.pre_flow = {};
+                        if (tender.user_id === stage.user_id) {
+                            tender.pre_flow.name = tender.user_name;
+                        } else {
+                            const user = await this.ctx.service.projectAccount.getDataById(stage.user_id);
+                            tender.pre_flow.name = user.name;
+                        }
+                        tender.pre_flow.time = cur.begin_time;
+                        if (tender.id === 3024) console.log(tender.pre_flow);
+                    } else {
+                        const pre = await this.ctx.service.stageAudit.getAuditorByOrder(stage.id, cur.order - 1, cur.times);
+                        if (pre) tender.pre_flow = { name: pre.name, time: pre.end_time };
+                    }
+                } else {
+                    tender.cur_flow.name = '';
+                }
+            }
+        }
+
         async _listDetail(view, modal = '') {
             try {
                 // 获取用户新建标段权利
@@ -74,7 +152,7 @@ module.exports = app => {
                 //         }
                 //     }
                 // }
-                tenderList.forEach(async t => {
+                for (const t of tenderList) {
                     if (t.user_id === this.ctx.session.sessionUser.accountId && (
                             t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck)) {
                         const sum = await this.ctx.service.ledger.addUp({ tender_id: t.id/* , is_leaf: true*/ });
@@ -92,23 +170,38 @@ module.exports = app => {
                         if (t.lastStage) await this.ctx.service.stage.checkStageGatherData(t.lastStage);
                         t.completeStage = await this.ctx.service.stage.getLastestCompleteStage(t.id);
                     }
+
                     if (t.lastStage) {
-                        if (t.lastStage.status === auditConst.stage.status.uncheck) {
-                            const status_name = await this.ctx.service.projectAccount.getAccountInfoById(t.lastStage.user_id);
-                            t.status_users = status_name ? status_name.name : '';
-                            // const status_name = await this.ctx.service.stageAudit.getStatusName(t.lastStage.id, t.lastStage.times - 1);
-                            // t.status_users = status_name ? status_name.name : '';
-                        } else {
-                            const status_name = await this.ctx.service.stageAudit.getAuditorByStatus(t.lastStage.id, t.lastStage.status, t.lastStage.times);
-                            t.status_users = status_name ? status_name.name : '';
-                        }
+                        await this._getStageAuditInfo(t, t.lastStage);
                     } else {
-                        if (t.ledger_status !== auditConst.ledger.status.uncheck) {
-                            const status_name = await this.ctx.service.ledgerAudit.getStatusName(t.id, t.ledger_times);
-                            t.status_users = status_name ? status_name.name : '';
-                        }
+                        await this._getLedgerAuditInfo(t);
                     }
-                });
+                }
+                // tenderList.forEach(async t => {
+                //     if (t.user_id === this.ctx.session.sessionUser.accountId && (
+                //             t.ledger_status === auditConst.ledger.status.checkNo || t.ledger_status === auditConst.ledger.status.uncheck)) {
+                //         const sum = await this.ctx.service.ledger.addUp({ tender_id: t.id/* , is_leaf: true*/ });
+                //         t.total_price = sum.total_price;
+                //         t.deal_tp = sum.deal_tp;
+                //     }
+                //     t.advance_tp = await this.ctx.service.advance.getSumAdvance(t.id);
+                //
+                //     if (t.ledger_status === auditConst.ledger.status.checked) {
+                //         t.lastStage = await this.ctx.service.stage.getLastestStage(t.id, true);
+                //         if (t.lastStage && t.lastStage.status === auditConst.stage.status.uncheck &&
+                //             t.lastStage.user_id !== this.ctx.session.sessionUser.accountId) {
+                //             t.lastStage = await this.ctx.service.stage.getLastestStage(t.id);
+                //         }
+                //         if (t.lastStage) await this.ctx.service.stage.checkStageGatherData(t.lastStage);
+                //         t.completeStage = await this.ctx.service.stage.getLastestCompleteStage(t.id);
+                //     }
+                //
+                //     if (t.lastStage) {
+                //         await this._getStageAuditInfo(t, t.lastStage);
+                //     } else {
+                //         await this._getLedgerAuditInfo(t);
+                //     }
+                // });
                 const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 const valuations = await this.ctx.service.valuation.getProjectValidValuation(this.ctx.session.sessionProject.id);
                 const renderData = {
@@ -168,7 +261,6 @@ module.exports = app => {
                 renderData.pid = this.ctx.session.sessionProject.id;
                 await this.layout(view, renderData, modal);
             } catch (err) {
-                console.log('error', err);
                 this.log(err);
                 this.ctx.redirect('/dashboard');
             }

+ 40 - 31
app/public/js/tender_list_info.js

@@ -296,7 +296,7 @@ function recursiveGetTenderNodeHtml (node, arr, pid) {
     const html = [];
     html.push('<tr pid="' + pid + '">');
     // 名称
-    html.push('<td style="width: 23%" class="in-' + node.level + '">');
+    html.push('<td style="width: 20%" class="in-' + node.level + '">');
     if (node.cid) {
         html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ', node.name);
     } else {
@@ -308,55 +308,63 @@ function recursiveGetTenderNodeHtml (node, arr, pid) {
     }
     html.push('</td>');
     // 计量模式
-    html.push('<td style="width: 7%" class="text-center">');
+    html.push('<td style="width: 6%" class="text-center">');
     if (node.measure_type) {
         html.push(node.measure_type === measureType.tz.value ? '0号台账' : '工程量清单');
     }
     html.push('</td>');
-    // 计量期数
-    html.push('<td style="width: 7%" class="text-center">');
-    if (!node.cid) {
-        html.push(node.lastStage ? '第' + node.lastStage.order + '期' : '台账');
+    // 计量进度
+    html.push('<td style="width: 6%">');
+    if (!node.cid && node.cur_flow) {
+        html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>' + ')');
     }
     html.push('</td>');
-    // 审批状态
-    html.push('<td style="width: 7%">');
-    html.push(node.lastStage ? auditConst.stage.statusString[node.lastStage.status] : auditConst.ledger.statusString[node.ledger_status]);
+    // 当前流程
+    html.push('<td style="width: 6%">');
+    if (!node.cid && node.cur_flow) {
+        html.push(node.cur_flow.name + ' ' + '<span class="' + node.cur_flow.status_class +'">' + node.cur_flow.status + '</span>');
+    }
+    html.push('</td>');
+    // 上一流程审批时间
+    html.push('<td style="width: 8%">');
+    if (!node.cid && node.pre_flow) {
+        html.push(node.pre_flow.name + ' ' + moment(node.pre_flow.time).format('YYYY-MM-DD'));
+    }
     html.push('</td>');
     // 0号台账合同
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.total_price);
     html.push('</td>');
     // 本期完成
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.gather_tp);
     html.push('</td>');
     // 截止本期合同
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.end_contract_tp);
     html.push('</td>');
     // 截止本期变更
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.end_qc_tp);
     html.push('</td>');
     // 截止本期完成
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.end_gather_tp);
     html.push('</td>');
     // 截止上期完成
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.pre_gather_tp);
     html.push('</td>');
     // 预付款
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.advance_tp);
     html.push('</td>');
     // 本期应付
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.yf_tp);
     html.push('</td>');
     // 截止本期应付
-    html.push('<td style="width: 7%" class="text-right">');
+    html.push('<td style="width: 6%" class="text-right">');
     html.push(node.end_yf_tp);
     html.push('</td>');
     html.push('</tr>');
@@ -373,19 +381,20 @@ function getTenderTreeHtml () {
         const html = [];
         html.push('<table class="table table-hover table-bordered">');
         html.push('<thead style="position: fixed;left:56px;top: 34px;">', '<tr>');
-        html.push('<th class="text-center" style="width: 23%">', '标段名称', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '计量模式', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '计量期数', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '审批状态', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '0号台帐', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '本期完成', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '截止本期合同', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '截止本期变更', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '截止本期完成', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '截止上期完成', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '预付款', '<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="预付款流程中截止本期金额"></i>', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '本期应付', '</th>');
-        html.push('<th class="text-center" style="width: 7%">', '截止本期应付', '</th>');
+        html.push('<th class="text-center" style="width: 20%">', '标段名称', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '计量模式', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '计量进度', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '当前流程', '</th>');
+        html.push('<th class="text-center" style="width: 8%">', '上一流程审批时间', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '0号台帐', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '本期完成', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '截止本期合同', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '截止本期变更', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '截止本期完成', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '截止上期完成', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '预付款', '<i class="fa fa-question-circle text-primary" data-placement="bottom" data-toggle="tooltip" data-original-title="预付款流程中截止本期金额"></i>', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '本期应付', '</th>');
+        html.push('<th class="text-center" style="width: 6%">', '截止本期应付', '</th>');
         html.push('</tr>', '</thead>');
         parentId = 0;
         for (const t of tenderTree) {

+ 22 - 0
app/service/ledger_audit.js

@@ -46,6 +46,28 @@ module.exports = app => {
             return await this.db.queryOne(sql, sqlParam);
         }
 
+        async getAuditorByOrder(tenderId, order, times = 1) {
+            const sql =
+                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
+                'FROM ?? AS la, ?? AS pa ' +
+                'WHERE la.`tender_id` = ? and la.`audit_order` = ? and la.`times` = ?' +
+                '    and la.`audit_id` = pa.`id`';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, order, times];
+            return await this.db.queryOne(sql, sqlParam);
+        }
+
+        async getLastestAuditor(tenderId, times, status) {
+            const sql =
+                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`,' +
+                '    la.`times`, la.`audit_order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
+                '    FROM ' + this.tableName + ' AS la' +
+                '    Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`audit_id` = pa.`id`' +
+                '  WHERE la.`tender_id` = ? and la.`status` = ? and la.`times` = ?' +
+                '  ORDER BY `audit_order` DESC';
+            const sqlParam = [tenderId, status, times ? times : 1];
+            return await this.db.queryOne(sql, sqlParam);
+        }
+
         /**
          * 获取标段审核人最后一位的名称
          *

+ 27 - 6
app/service/stage_audit.js

@@ -47,6 +47,31 @@ module.exports = app => {
             return await this.db.queryOne(sql, sqlParam);
         }
 
+        async getAuditorByOrder(stageId, order, times) {
+            const sql =
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`,' +
+                '    la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
+                '    FROM ' + this.tableName + ' AS la' +
+                '    Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`aid` = pa.`id`' +
+                '  WHERE la.`sid` = ? and la.`order` = ? and la.`times` = ?' +
+                '  ORDER BY `order` DESC';
+            const sqlParam = [stageId, order, times ? times: 1];
+            return await this.db.queryOne(sql, sqlParam);
+        }
+
+        async getLastestAuditor(stageId, times, status) {
+            const sql =
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`,' +
+                '    la.`times`, la.`order`, la.`status`, la.`opinion`, la.`begin_time`, la.`end_time` ' +
+                '    FROM ' + this.tableName + ' AS la' +
+                '    Left Join ' + this.ctx.service.projectAccount.tableName + ' AS pa ON la.`aid` = pa.`id`' +
+                '  WHERE la.`sid` = ? and la.`status` = ? and la.`times` = ?' +
+                '  ORDER BY `order` DESC';
+            const sqlParam = [stageId, status, times ? times: 1];
+            if (stageId === 1400) console.log(this.db.format(sql, sqlParam));
+            return await this.db.queryOne(sql, sqlParam);
+        }
+
         /**
          * 获取 审核列表信息
          *
@@ -74,12 +99,8 @@ module.exports = app => {
 
         async getAllAuditors(tenderId) {
             const sql =
-                'SELECT sa.aid, sa.tid FROM ' +
-                this.tableName +
-                ' sa' +
-                '  LEFT JOIN ' +
-                this.ctx.service.tender.tableName +
-                ' t On sa.tid = t.id' +
+                'SELECT sa.aid, sa.tid FROM ' + this.tableName + ' sa' +
+                '  LEFT JOIN ' + this.ctx.service.tender.tableName + ' t On sa.tid = t.id' +
                 '  WHERE t.id = ?' +
                 '  GROUP BY  sa.aid';
             const sqlParam = [tenderId];

+ 1 - 1
config/web.js

@@ -65,7 +65,7 @@ const JsFiles = {
                 mergeFile: 'tender_list',
             },
             info: {
-                files: ['/public/js/ztree/jquery.ztree.core.js', '/public/js/ztree/jquery.ztree.exedit.js', '/public/js/decimal.min.js'],
+                files: ['/public/js/ztree/jquery.ztree.core.js', '/public/js/ztree/jquery.ztree.exedit.js', '/public/js/decimal.min.js', '/public/js/moment/moment.min.js'],
                 mergeFiles: [
                     '/public/js/zh_calc.js',
                     '/public/js/PinYinOrder.bundle.js',