Explorar o código

标段概况更新

laiguoran %!s(int64=3) %!d(string=hai) anos
pai
achega
6a6e1e6311

+ 32 - 8
app/controller/tender_controller.js

@@ -408,22 +408,38 @@ module.exports = app => {
                     tender.cur_ratio = ctx.helper.mul(ctx.helper.div(tender.gather_tp, tender.sum, 2), 100);
                     tender.other_tp = ctx.helper.sub(ctx.helper.sub(tender.sum, tender.pre_gather_tp), tender.gather_tp);
                     tender.other_ratio = Math.max(0, 100 - tender.pre_ratio - tender.cur_ratio);
+                    tender.end_yf_tp = ctx.helper.add(lastStage.yf_tp, lastStage.pre_yf_tp);
+                    tender.end_sf_tp = ctx.helper.add(lastStage.sf_tp, lastStage.pre_sf_tp);
+                    const change_tp = await ctx.service.change.getChangeTp(tender.id);
+                    tender.undone_tp = ctx.helper.sub(ctx.helper.sub(ctx.helper.add(tender.total_price, change_tp), tender.end_contract_tp), tender.end_qc_tp);
                     if (lastStage.status === auditConst.stage.status.uncheck) {
                         const status_name = await this.ctx.service.projectAccount.getAccountInfoById(lastStage.user_id);
                         lastStage.status_users = status_name ? status_name.name : '';
                         lastStage.auditors = [];
                     } else {
-                        const status_name = await this.ctx.service.stageAudit.getAuditorByStatus(lastStage.id, lastStage.status, lastStage.times);
-                        lastStage.status_users = status_name ? status_name.name : '';
+                        lastStage.status = lastStage.status === auditConst.stage.status.checkNoPre ? auditConst.stage.status.checking : lastStage.status;
+                        let cur;
+                        if (lastStage.status === auditConst.stage.status.checked) {
+                            cur = await this.ctx.service.stageAudit.getLastestAuditor(lastStage.id, lastStage.times, auditConst.stage.status.checked);
+                        } else if (lastStage.status === auditConst.stage.status.checking) {
+                            cur = await this.ctx.service.stageAudit.getCurAuditor(lastStage.id, lastStage.times);
+                        } else {
+                            cur = await this.ctx.service.stageAudit.getAuditorByStatus(lastStage.id, lastStage.status, lastStage.times);
+                        }
+                        // const status_name = await this.ctx.service.stageAudit.getAuditorByStatus(lastStage.id, lastStage.status, lastStage.times);
+                        lastStage.status_users = cur ? cur.name : '';
                         const times = lastStage.status === auditConst.stage.status.checkNo ? lastStage.times - 1 : lastStage.times;
-                        lastStage.auditors = await ctx.service.stageAudit.getAuditors(lastStage.id, times);
+                        lastStage.auditors = await ctx.service.stageAudit.getFinalAuditGroup(lastStage.id, times);
                     }
                 } else {
                     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 : '';
                         const times = tender.status === auditConst.ledger.status.checkNo ? tender.times - 1 : tender.times;
-                        tender.auditors = await ctx.service.ledgerAudit.getAuditors(tender.id, times);
+                        tender.auditors = await ctx.service.ledgerAudit.getFinalAuditGroup(tender.id, times);
+                    } else {
+                        const status_name = await this.ctx.service.projectAccount.getAccountInfoById(tender.user_id);
+                        tender.status_users = status_name ? status_name.name : '';
                     }
                 }
                 const monthProgress = [];
@@ -454,9 +470,9 @@ module.exports = app => {
                 const categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
 
                 // 变更图表数据
-                const change_done_total = await ctx.service.change.getCountByStatus(tender.id, auditConst.filter.status.checked);
-                const change_doing_total = await ctx.service.change.getCountByStatus(tender.id, auditConst.filter.status.checking);
-                const change_uncheck_total = await ctx.service.change.getCountByStatus(tender.id, auditConst.filter.status.uncheck);
+                const change_done_total = await ctx.service.change.getCountByStatus2(tender.id, auditConst.filter.status.checked);
+                const change_doing_total = await ctx.service.change.getCountByStatus2(tender.id, auditConst.filter.status.checking);
+                const change_uncheck_total = await ctx.service.change.getCountByStatus2(tender.id, auditConst.filter.status.uncheck);
                 const change_status_total = [
                     { num: change_uncheck_total, name: '待上报' },
                     { num: change_doing_total, name: '审批中' },
@@ -477,10 +493,17 @@ module.exports = app => {
                     materialData = materials[0];
                     materialData.curAuditor = await ctx.service.materialAudit.getAuditorByStatus(materialData.id, materialData.status, materialData.times);
                     const times = materialData.status === auditConst.material.status.checkNo ? materialData.times - 1 : materialData.times;
-                    materialData.auditors = materialData.status === auditConst.material.status.uncheck ? [] : await ctx.service.materialAudit.getAuditors(materialData.id, times);
+                    materialData.auditors = materialData.status === auditConst.material.status.uncheck ? [] : await ctx.service.materialAudit.getFinalAuditGroup(materialData.id, times);
                 }
                 // 修订完成数目
                 const reviseNum = await ctx.service.ledgerRevise.count({ tid: tender.id, status: auditConst.revise.status.checked });
+                // 计量完成概况
+                // tender.total_price
+                const stage_total = [
+                    { num: tender.end_contract_tp ? tender.end_contract_tp : 0, name: '合同完成' },
+                    { num: tender.end_qc_tp ? tender.end_qc_tp : 0, name: '变更完成' },
+                    { num: tender.undone_tp ? tender.undone_tp : 0, name: '未完成' },
+                ];
                 const renderData = {
                     tenders,
                     categoryData,
@@ -498,6 +521,7 @@ module.exports = app => {
                     change_quality_total,
                     materialData,
                     reviseNum,
+                    stage_total,
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.tender.tenderInfo),
                 };
                 if (ctx.session.sessionUser.is_admin) {

+ 8 - 4
app/public/css/main.css

@@ -1298,16 +1298,16 @@ overflow-y: auto;
   position: relative;
 }
 .circle{
-  width: 46px; 
-  height: 46px;
+  width: 42px; 
+  height: 42px;
   border-radius: 50%;
   background: none; 
   border: 3px solid #D7B014;
 }
 .circle-num{
   position: absolute;
-  top: 4px;
-  left: 16px;
+  top: 2px;
+  left: 15px;
   font-size: 24px;
   font-weight: 500;
 }
@@ -1316,4 +1316,8 @@ overflow-y: auto;
   margin-left: 20px;
   margin-top: 10px;
   font-size: 16px;
+}
+.dropdown-wd{
+  width: 80px;
+  text-align: center;
 }

+ 38 - 0
app/service/change.js

@@ -381,6 +381,44 @@ module.exports = app => {
         }
 
         /**
+         * 获取变更令个数
+         * @param {int} tenderId - 标段id
+         * @param {int} status - 状态
+         * @return {void}
+         */
+        async getCountByStatus2(tenderId, status) {
+            if (status === audit.filter.status.uncheck) {
+                const sql =
+                    'SELECT count(*) AS count FROM ?? WHERE ' +
+                    'tid = ? AND (status = ? OR status = ? OR status = ?)';
+                const sqlParam = [
+                    this.tableName,
+                    tenderId,
+                    audit.flow.status.uncheck,
+                    audit.flow.status.back,
+                    audit.flow.status.revise,
+                ];
+                const result = await this.db.queryOne(sql, sqlParam);
+                console.log(result);
+                return result ? result.count : 0;
+            }
+            return await this.db.count(this.tableName, { tid: tenderId, status });
+        }
+
+        /**
+         * 获取已批复变更令的总金额
+         * @param {int} tenderId - 标段id
+         * @param {int} quality - 变更性质
+         * @return {void}
+         */
+        async getChangeTp(tenderId) {
+            const sql = 'SELECT SUM(`total_price`) AS tp FROM ?? WHERE tid = ? AND status = ?';
+            const sqlParam = [this.tableName, tenderId, audit.flow.status.checked];
+            const result = await this.db.queryOne(sql, sqlParam);
+            return result ? result.tp : 0;
+        }
+
+        /**
          * 上报或重新上报或保存修改功能
          * @param {int} postData - 表单提交的数据
          * @param {int} tenderId - 标段id

+ 17 - 0
app/service/ledger_audit.js

@@ -110,6 +110,23 @@ module.exports = app => {
             return result;
         }
 
+        async getFinalAuditGroup(tenderId, times = 1) {
+            const sql =
+                'SELECT la.`audit_id`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`, la.`times`, la.`tender_id`, Max(la.`audit_order`) as max_order ' +
+                'FROM ?? AS la, ?? AS pa ' +
+                'WHERE la.`tender_id` = ? and la.`times` = ? and la.`audit_id` = pa.`id` GROUP BY la.`audit_id` ORDER BY la.`audit_order`';
+            const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, tenderId, times];
+            const result = await this.db.query(sql, sqlParam);
+            for (const r of result) {
+                const auditor = await this.getDataByCondition({tender_id: tenderId, times: r.times, audit_order: r.max_order});
+                r.status = auditor.status;
+                r.opinion = auditor.opinion;
+                r.begin_time = auditor.begin_time;
+                r.end_time = auditor.end_time;
+            }
+            return result;
+        }
+
         /**
          * 获取标段当前审核人
          *

+ 17 - 0
app/service/material_audit.js

@@ -66,6 +66,23 @@ module.exports = app => {
             return result;
         }
 
+        async getFinalAuditGroup(materialId, times = 1) {
+            const sql =
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`, la.`times`, la.`mid`, Max(la.`order`) as max_order ' +
+                'FROM ?? AS la, ?? AS pa ' +
+                'WHERE la.`mid` = ? 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, materialId, times];
+            const result = await this.db.query(sql, sqlParam);
+            for (const r of result) {
+                const auditor = await this.getDataByCondition({mid: materialId, times: r.times, order: r.max_order});
+                r.status = auditor.status;
+                r.opinion = auditor.opinion;
+                r.begin_time = auditor.begin_time;
+                r.end_time = auditor.end_time;
+            }
+            return result;
+        }
+
         /**
          * 获取 当前审核人
          *

+ 2 - 1
app/service/stage_audit.js

@@ -1317,13 +1317,14 @@ module.exports = app => {
 
         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 ' +
+                'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, pa.`mobile`, pa.`telephone`, pa.`sign_path`, la.`times`, la.`sid`, 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.status = auditor.status;
                 r.opinion = auditor.opinion;
                 r.begin_time = auditor.begin_time;
                 r.end_time = auditor.end_time;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 216 - 25
app/view/tender/detail.ejs