Browse Source

修复wap一些已知bug

laiguoran 5 năm trước cách đây
mục cha
commit
2b05f9072e

+ 55 - 5
app/controller/wap_controller.js

@@ -106,6 +106,7 @@ module.exports = app => {
                 audit.end_qc_tp = ctx.helper.add(audit.qc_tp, audit.pre_qc_tp);
                 audit.end_gather_tp = ctx.helper.add(audit.end_contract_tp, audit.end_qc_tp);
                 audit.pre_gather_tp = ctx.helper.add(audit.pre_contract_tp, audit.pre_qc_tp);
+                console.log(audit);
             }
             const renderData = {
                 auditStages,
@@ -167,13 +168,62 @@ module.exports = app => {
          */
         async tender(ctx) {
             try {
+                const tender = ctx.tender.data;
+                if (tender.user_id === this.ctx.session.sessionUser.accountId && (
+                    tender.ledger_status === auditConst.ledger.status.checkNo || tender.ledger_status === auditConst.ledger.status.uncheck)) {
+                    const sum = await this.ctx.service.ledger.addUp({tender_id: tender.id/*, is_leaf: true*/});
+                    tender.total_price = sum.total_price;
+                    tender.deal_tp = sum.deal_tp;
+                }
+                const stages = await ctx.service.stage.getValidStages(ctx.tender.id);
+                const lastStage = stages.length > 0 ? stages[0] : null; //await ctx.service.stage.getLastestStage(ctx.tender.id);
+                if (lastStage) {
+                    await this.ctx.service.stage.checkStageGatherData(lastStage);
+                    tender.gather_tp = ctx.helper.add(lastStage.contract_tp, lastStage.qc_tp);
+                    tender.end_contract_tp = ctx.helper.add(lastStage.contract_tp, lastStage.pre_contract_tp);
+                    tender.end_qc_tp = ctx.helper.add(lastStage.qc_tp, lastStage.pre_qc_tp);
+                    tender.end_gather_tp = ctx.helper.add(tender.end_contract_tp, tender.end_qc_tp);
+                    tender.pre_gather_tp = ctx.helper.add(lastStage.pre_contract_tp, lastStage.pre_qc_tp);
+                    tender.yf_tp = lastStage.yf_tp;
+                    tender.qc_ratio = ctx.helper.mul(ctx.helper.div(tender.end_qc_tp, ctx.tender.info.deal_param.contractPrice, 2), 100);
+                    tender.sum = ctx.helper.add(tender.total_price, tender.end_qc_tp);
+                    tender.pre_ratio = ctx.helper.mul(ctx.helper.div(tender.pre_gather_tp, tender.sum, 2), 100);
+                    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);
+                }
+                const monthProgress = [];
+                for (const s of stages) {
+                    if (s.s_time) {
+                        let progress = monthProgress.find(function(x) {
+                            return x.month === s.s_time;
+                        });
+                        if (!progress) {
+                            progress = { month: s.s_time };
+                            monthProgress.push(progress);
+                        }
+                        progress.tp = ctx.helper.add(ctx.helper.add(progress.tp, s.contract_tp), s.qc_tp);
+                    }
+                }
+                monthProgress.sort(function(x, y) {
+                    return Date.parse(x.month) - Date.parse(y.month);
+                });
+                let sum = 0;
+                for (const p of monthProgress) {
+                    p.ratio = ctx.helper.mul(ctx.helper.div(p.tp, tender.sum, 4), 100);
+                    sum = ctx.helper.add(sum, p.tp);
+                    p.end_tp = sum;
+                    p.end_ratio = ctx.helper.mul(ctx.helper.div(p.end_tp, tender.sum, 4), 100);
+                }
                 const renderData = {
-                    tender: ctx.tender.data,
+                    tender,
+                    stages,
                     auditConst: auditConst.stage,
+                    monthProgress,
+                    stagesEcharts: JSON.parse(JSON.stringify(stages)).reverse(),
                 };
-                renderData.stages = await ctx.service.stage.getValidStages(ctx.tender.id);
-                if (renderData.stages.length > 0) {
-                    for (const s of renderData.stages) {
+                if (stages.length > 0) {
+                    for (const s of stages) {
                         // s.curAuditor = null;
                         // 根据期状态返回展示用户
                         s.curAuditor = await ctx.service.stageAudit.getAuditorByStatus(s.id, s.status, s.times);
@@ -181,7 +231,7 @@ module.exports = app => {
                             s.curAuditor2 = await ctx.service.stageAudit.getAuditorByStatus(s.id, auditConst.stage.status.checking);
                         }
                     }
-                    renderData.stage = renderData.stages[0];
+                    renderData.stage = stages[0];
                     renderData.stage.user = await ctx.service.projectAccount.getAccountInfoById(renderData.stages[0].user_id);
                     renderData.stage.auditors = await ctx.service.stageAudit.getAuditors(renderData.stages[0].id, renderData.stages[0].times);
                     // 获取审批流程中左边列表

+ 3 - 2
app/public/js/tender_showhide.js

@@ -30,7 +30,7 @@ function removeValueToCate(cate) {
     return newCate;
 }
 
-function localHideList() {
+function localHideList(wap = false) {
     const pro_cate = getLocalCache('pro_'+ pid + '_category_list');
     const cate = JSON.stringify(removeValueToCate(category));
     if (pro_cate && cate === pro_cate) {
@@ -49,7 +49,8 @@ function localHideList() {
         removeLocalCache(uphlname);
         setLocalCache('pro_'+ pid + '_category_list', cate);
     }
-    setTopTr();
+    if (!wap)
+        setTopTr();
 }
 $(window).resize(setTopTr);
 // 设置表头固定并动态调整宽度高度

+ 2 - 1
app/public/js/wap.js

@@ -237,8 +237,9 @@ function bindTenderUrl() {
 
 $(document).ready(() => {
     // 初始化标段树结构
+    sortCategory();
     initTenderTree();
     $('.c-body').html(getTenderTreeHtml());
     bindTenderUrl();
-    localHideList();
+    localHideList(true);
 });

+ 12 - 9
app/view/wap/dashboard.ejs

@@ -10,8 +10,11 @@
     <link rel="stylesheet" href="/public/css/toast.css">
     <link rel="stylesheet" href="/public/css/font-awesome/font-awesome.min.css">
     <link rel="shortcut icon" href="/public/images/favicon.ico">
-<style>
-</style>
+    <style>
+        body {
+            padding: 0;
+        }
+    </style>
 </head>
 <body>
     <div class="container">
@@ -44,16 +47,16 @@
                         <div class="d-flex justify-content-between"><span>第<%- audit.order %>期</span><span><%- audit.s_time %></span></div>
                         <div class="my-2">
                             <table class="table table-sm table-bordered">
-                                <tr><th>本期合同计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.contract_tp,2) %></td></tr>
-                                <tr><th>本期数量变更计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.qc_tp,2) %></td></tr>
-                                <tr><th>本期完成计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.gather_tp,2) %></td></tr>
-                                <tr><th>截止上期完成计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.pre_gather_tp,2) %></td></tr>
-                                <tr><th>截止本期完成计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.end_gather_tp,2) %></td></tr>
-                                <tr><th>本期应付</th><td class="text-right"><%- ctx.helper.formatMoney(audit.yf_tp,2) %></td></tr>
+                                <tr><th>本期合同计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.contract_tp) %></td></tr>
+                                <tr><th>本期数量变更计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.qc_tp) %></td></tr>
+                                <tr><th>本期完成计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.gather_tp) %></td></tr>
+                                <tr><th>截止上期完成计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.pre_gather_tp) %></td></tr>
+                                <tr><th>截止本期完成计量</th><td class="text-right"><%- ctx.helper.formatMoney(audit.end_gather_tp) %></td></tr>
+                                <tr><th>本期应付</th><td class="text-right"><%- ctx.helper.formatMoney(audit.yf_tp) %></td></tr>
                             </table>
                         </div>
                         <div class="">
-                            <a href="/wap/tender/<%- audit.tid %>" class="btn btn-block btn-success">审批</a>
+                            <a href="/wap/tender/<%- audit.tid %>#shenpi" class="btn btn-block btn-success">审批</a>
                         </div>
                     </div>
                 </div>

+ 3 - 0
app/view/wap/list.ejs

@@ -12,6 +12,9 @@
     <link rel="shortcut icon" href="/public/images/favicon.ico">
     <style>
         html{height:100%;}
+        body {
+            padding: 0;
+        }
     </style>
 </head>
 <body>

+ 80 - 63
app/view/wap/tender.ejs

@@ -11,6 +11,11 @@
     <link rel="stylesheet" href="/public/css/font-awesome/font-awesome.min.css">
     <script src=/public/js/echarts/echarts.min.js></script>
     <link rel="shortcut icon" href="/public/images/favicon.ico">
+    <style>
+        body {
+            padding: 0;
+        }
+    </style>
 </head>
 <body>
 <div class="container">
@@ -319,7 +324,11 @@
             {
                 type : 'category',
                 splitLine : {show : true},
-                data : ['第一期','第二期','第三期','第四期','第五期','第六期','第七期']
+                data : [
+                    <% for (const s of stagesEcharts) {%>
+                    '第<%- s.order %>期',
+                    <% } %>
+                ]
             }
         ],
         yAxis : [
@@ -330,7 +339,8 @@
                 axisLabel : {
                     formatter: '{value} 元'
                 },
-                splitArea : {show : true}
+                splitArea : {show : true},
+                splitLine : {show : true},
             },
             {
                 type : 'value',
@@ -339,7 +349,8 @@
                     formatter: '{value} %'
                 },
                 position: 'right',
-                splitArea : {show : true}
+                splitArea : {show : false},
+                splitLine : {show : false},
             }
         ],
         series : [
@@ -348,35 +359,55 @@
                 type:'bar',
                 tooltip : {trigger: 'item',formatter: "{b}  <br/>{a}:{c}元"},
                 stack: '合同',
-                data:[320, 332, 301, 334, 390, 330, 320]
+                data:[
+                    <% for (const s of stagesEcharts) {%>
+                    <%- s.contract_tp %>,
+                    <% } %>
+                ]
             },
             {
                 name:'本期数量变更计量',
                 type:'bar',
                 tooltip : {trigger: 'item',formatter: "{b}  <br/>{a}:{c}元"},
-                stack: '合同',
-                data:[320, -20, 301, 334, 390, 330, 320]
+                stack: '变更',
+                data:[
+                    <% for (const s of stagesEcharts) {%>
+                    <%- s.qc_tp %>,
+                    <% } %>
+                ]
             },
             {
                 name:'截止上期累计完成',
                 type:'bar',
                 tooltip : {trigger: 'item',formatter: "{b}  <br/>{a}:{c}元"},
                 stack: '完成',
-                data:[120, 132, 101, 134, 90, 230, 210]
+                data:[
+                    <% for (const s of stagesEcharts) {%>
+                    <%- ctx.helper.add(s.pre_contract_tp, s.pre_qc_tp) %>,
+                    <% } %>
+                ]
             },
             {
                 name:'本期完成计量',
                 type:'bar',
                 tooltip : {trigger: 'item',formatter: "{b}  <br/>{a}:{c}元"},
                 stack: '完成',
-                data:[220, 182, 191, 234, 290, 330, 310]
+                data:[
+                    <% for (const s of stagesEcharts) {%>
+                    <%- ctx.helper.add(s.contract_tp, s.qc_tp) %>,
+                    <% } %>
+                ]
             },
             {
                 name:'完成度',
                 type:'line',
                 tooltip : {trigger: 'axis',formatter: "{b}占总标段<br/>{a}:{c} %"},
                 yAxisIndex: 1,
-                data:[10, 15, 20, 13, 11, 9, 5]
+                data:[
+                    <% for (const s of stagesEcharts) {%>
+                    <%- ctx.helper.mul(ctx.helper.div(ctx.helper.add(s.contract_tp, s.qc_tp), tender.sum, 2), 100) %>,
+                    <% } %>
+                ]
             },
         ]
     };
@@ -394,7 +425,24 @@
         },
         tooltip : {
             trigger: 'axis',
-            formatter: "{b} <br/>{a}:{c} %<br/>{a1}:{c1} %"
+            formatter: function (params, ticket, callback) {
+                let sHint = '';
+                for (const param of params) {
+                    if (sHint !== '') {
+                        sHint += '<br>';
+                    }
+                    if (sHint === '' && param.name !== '') {
+                        sHint = param.name + '<br>';
+                    }
+                    sHint += '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background-color:' + param.color +'"></span>';
+                    if (param.data) {
+                        sHint += param.seriesName + ': ' + param.data + ' %';
+                    } else {
+                        sHint += param.seriesName + ': -';
+                    }
+                }
+                return sHint;
+            },
         },
         legend: {
             data:['截止本月完成','本月完成']
@@ -415,7 +463,9 @@
                 type : 'category',
                 boundaryGap : true,
                 data : [
-                    '2月','3月','4月','5月','6月','7月','8月','9月','10月'
+                    <% for (const mp of monthProgress) { %>
+                    '<%- mp.month %>',
+                    <% } %>
                 ]
             }
         ],
@@ -442,7 +492,11 @@
                         }
                     }
                 },
-                data:[10, 10, 30, 40, 50, 60, 80, 85, 100]
+                data:[
+                    <% for (const mp of monthProgress) { %>
+                    <%- mp.end_ratio %>,
+                    <% } %>
+                ]
             },
             {
                 name:'本月完成',
@@ -457,7 +511,11 @@
                         }
                     }
                 },
-                data:[10, 0, 20, 10, 10, 10, 10, 5, 15]
+                data:[
+                    <% for (const mp of monthProgress) { %>
+                    <%- mp.ratio %>,
+                    <% } %>
+                ]
             }
         ]
     };
@@ -468,56 +526,15 @@
 <!--sjs-->
 <script>
     $(document).ready(function () {
-        const data = [
-            {
-                单位:'稍等',
-                精度:3,
-            },{
-                单位:'km',
-                精度:3,
-            },{
-                单位:'m',
-                精度:3,
-            },{
-                单位:'m2',
-                精度:3,
-            },{
-                单位:'m3',
-                精度:3,
-            },{
-                单位:'kg',
-                精度:3,
-            },{
-                单位:'个',
-                精度:3,
-            },{
-                单位:'台',
-                精度:3,
-            },{
-                单位:'套',
-                精度:3,
-            },{
-                单位:'棵',
-                精度:3,
-            },{
-                单位:'组',
-                精度:3,
-            },{
-                单位:'总额',
-                精度:3,
-            },{
-                单位:'系统',
-                精度:3,
-            },{
-                单位:'其他未列单位',
-                精度:3,
-            }
-        ];
-        const spread = new GC.Spread.Sheets.Workbook($('#option-spread1')[0], {
-            sheetCount: 1
-        });
-        spread.getActiveSheet().setDataSource(data);
-        spread.options.tabStripVisible = false;
+        if (window.location.hash && window.location.hash === '#shenpi') {
+            $('#gaikuang').removeClass('active');
+            $('#jlqi').removeClass('active');
+            $('.nav-item a[href="#gaikuang"]').removeClass('active');
+            $('.nav-item a[href="#jlqi"]').removeClass('active');
+
+            $('#shenpi').addClass('active');
+            $('.nav-item a[href="#shenpi"]').addClass('active');
+        }
     })
 
     // texterea换行