Browse Source

决策大屏成本管理大屏

ellisran 1 week ago
parent
commit
a1ffd36e5a
1 changed files with 114 additions and 77 deletions
  1. 114 77
      app/view/datacollect/index_cost.ejs

+ 114 - 77
app/view/datacollect/index_cost.ejs

@@ -192,7 +192,7 @@
                                 <div class="tablebox">
                                     <table id="tableId">
                                         <thead>
-                                        <tr>
+                                        <tr class="text-center">
                                             <th></th>
                                             <th>投资估算</th>
                                             <th>设计概算</th>
@@ -226,7 +226,6 @@
                                         <tbody class="tender-data">
                                         </tbody>
                                     </table>
-                                    <table id="profit_tableId1"></table>
                                 </div>
                             </div>
                         </div>
@@ -343,10 +342,10 @@
             //     height:10,
             // }
         ],
-        legend: {
-            data: ['利润'],
-            top:'17%'
-        },
+        // legend: {
+        //     data: ['利润'],
+        //     top:'17%'
+        // },
         grid: {
             top:'25%',
             left: '3%',
@@ -445,69 +444,107 @@
         backgroundColor: '#343a40 ',
         tooltip: {
             trigger: 'axis',
-            axisPointer: {            // Use axis to trigger tooltip
-                type: 'shadow'        // 'shadow' as default; can also be 'line' or 'shadow'
-            }
-        },
-        grid: {
-            left: '10%',
-            right: '10%',
-            bottom: '3%',
-            containLabel: true
-        },
-        xAxis: {
-            type: 'value'
-        },
-        yAxis: {
-            type: 'category',
-            data: [],
-            axisLabel: {
-                show: true,
-                interval: 0,
-                // textStyle: {
-                //     color: "#fff",
-                //     fontSize: 14
-                // },
-                formatter: function(value) {
-                    var res = value;
-                    if(res.length > 6) {
-                        res = res.substring(0, 5) + "..";
-                    }
-                    return res;
-                }
-            }
+            axisPointer: {            // 坐标轴指示器,坐标轴触发有效
+                type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
+            },
         },
+
         dataZoom: [
             {
                 brushSelect:false,
-                start: 0,
-                end: 10,
+                // zoomLock: false,
                 type: 'slider',
                 show: true,
-                handleSize: 0,
                 realtime: true,
-                showDetail: false,
-                // filterMode: 'empty',
-                yAxisIndex: [0,1],
-                width: 10,
-                height: '80%',
-                right: '5%',
-                bottom:'2%'
+                showdetail: false,
+                showDataShadow: false,
+                // dataZoomIndex: 10,
+                start: 0,
+                end: 8,
+                handleSize: 0,
+                height: 10,
+                bottom: '10%',
             },
         ],
+        // legend: {
+        //     data: ['利润率'],
+        //     top:'17%'
+        // },
+        grid: {
+            top:'25%',
+            left: '3%',
+            right: '4%',
+            bottom: '15%',
+            containLabel: true
+        },
+        xAxis: [
+            {
+                type: 'category',
+                data: [],
+                axisLabel: {
+                    show: true,
+                    interval: 0,
+                    textStyle: {
+                        color: "#fff",
+                        fontSize: 14
+                    },
+                    formatter: function(value) {
+                        var res = value;
+                        if(res.length > 6) {
+                            res = res.substring(0, 5) + "..";
+                        }
+                        return res;
+                    }
+                }
+            }
+        ],
+        yAxis: [
+            // {
+            //     type: 'value',
+            //     name:'利润率',
+            //     position: 'left',
+            //     axisLabel : {
+            //         formatter: function (value, index) {
+            //             if (value < 0) {
+            //                 let newValue = Math.abs(value);
+            //                 if (newValue >= 10000 && newValue < 10000000) {
+            //                     newValue = newValue / 10000 + "万";
+            //                 } else if (newValue >= 10000000) {
+            //                     newValue = newValue / 10000000 + "千万";
+            //                 }
+            //                 value = '-' + newValue;
+            //             }
+            //             if (value >= 10000 && value < 10000000) {
+            //                 value = value / 10000 + "万";
+            //             } else if (value >= 10000000) {
+            //                 value = value / 10000000 + "千万";
+            //             }
+            //             return value;
+            //         }
+            //     },
+            //     splitArea : {show : true}
+            // },
+            {
+                type: 'value',
+                name:'利润率',
+                position: 'left',
+                min:0,
+                max:100,
+                axisLabel : {
+                    formatter: '{value} %'
+                },
+                splitArea : {show : true}
+            }
+        ],
         series: [
             {
-                name: '利润率(%)',
+                name: '利润率',
                 type: 'bar',
-                stack: 'total',
-                label: {
-                    show: true
-                },
                 emphasis: {
                     focus: 'series'
                 },
                 data: []
-            }
+            },
         ]
     };
     var chart3 = document.getElementsByClassName('jldbchart');
@@ -535,7 +572,6 @@
             echartsReset();
             $(".tableid_").find('th').each(function(i) {
                 $(this).css('width', $('#tableId').find('th:eq(' + i + ')').innerWidth());
-                $(this).css('width', $('#profit_tableId').find('th:eq(' + i + ')').innerWidth());
             });
         }, 500);
     })
@@ -796,8 +832,8 @@
                 console.log(level1List);
                 if (level1List.length > 0) {
                     for (const t of level1List) {
-                        html += '<tr>\n' +
-                            '                                                    <td><span data-toggle="tooltip" data-placement="right" data-original-title="'+ t.name +'">'+ (t.name.length > 15 ? t.name.substring(0, 15) + '...' : t.name) +'</span></td>\n' +
+                        html += '<tr class="text-center">\n' +
+                            '                                                    <td class="text-left"><span data-toggle="tooltip" data-placement="right" data-original-title="'+ t.name +'">'+ (t.name.length > 15 ? t.name.substring(0, 15) + '...' : t.name) +'</span></td>\n' +
                             '                                                    <td>'+ (ZhCalc.div(t.gu_tp, 10000)) + '</td>\n' +
                             '                                                    <td>'+ (ZhCalc.div(t.gai_tp, 10000)) +'</td>\n' +
                             '                                                    <td>'+ (ZhCalc.div(t.yu_tp, 10000)) +'</td>\n' +
@@ -818,14 +854,6 @@
             let total_in_tp = 0;
             let total_out_tp = 0;
             let total_profit = 0;
-            // let total_change_price = 0;
-            let total_checked_change_price = 0;
-            // let total_checked_change_positive_price = 0;
-            // let total_checked_change_negative_price = 0;
-            let total_after_change_price = 0;
-            let total_stage_price = 0;
-            let total_advance_price = 0;
-            // let total_material_price = 0;
             let stage_num = 0;
             let cost_ledger_num = 0;
             let cost_book_num = 0;
@@ -853,7 +881,7 @@
             //     option1_is_tender = true;
             // }
             const chart_option4_data = [];
-            let index = 1;
+
             for(const t of tenderList) {
                 const stage_tp = t.cost_analysis ? t.cost_analysis.stage_tp : null;
                 total_in_tp = ZhCalc.add(total_in_tp, stage_tp.in_tp);
@@ -867,11 +895,6 @@
                 cost_ledger_num = ZhCalc.add(cost_ledger_num, t.cost_ledger_num);
                 cost_book_num = ZhCalc.add(cost_book_num, t.cost_book_num);
                 cost_analysis_num = ZhCalc.add(cost_analysis_num, t.cost_analysis_num);
-                tender_html += `<tr>
-                    <td>${index}</td>
-                    <td>${t.name}</td>
-                    <td class="text-center">${stage_tp.profit_percent}</td>
-</tr>`;
                 // if (option1_is_tender) {
                 //     if(stage_tp.profit)
                 chart_option1_data.push({ value: stage_tp.profit, name: t.name});
@@ -882,6 +905,26 @@
                 //         chart_option1_data[index].value = ZhCalc.add(chart_option1_data[index].value, (stage_tp.profit ? stage_tp.profit : 0));
                 //     }
                 // }
+            }
+            // 根据利润率排行并只显示前5位
+            let index = 1;
+            const percent_tender_list = _.orderBy(tenderList, (t) => {
+                const stage_tp = t.cost_analysis ? t.cost_analysis.stage_tp : null;
+                return stage_tp.profit_percent ? stage_tp.profit_percent : 0;
+            }, 'desc').slice(0, 5);
+            const medalIcons = {
+                1: '<i class="fa fa-trophy" style="font-size:18px; color:#F0C040;"></i>',
+                2: '<i class="fa fa-trophy" style="font-size:18px; color:#B0B8C1;"></i>',
+                3: '<i class="fa fa-trophy" style="font-size:18px; color:#CD7F4A;"></i>',
+            };
+            for (const t of percent_tender_list) {
+                const stage_tp = t.cost_analysis ? t.cost_analysis.stage_tp : null;
+                const rankDisplay = medalIcons[index] ?? index;
+                tender_html += `<tr class="bg-dark">
+                    <td class="text-center py-2">${rankDisplay}</td>
+                    <td class="py-2">${t.name}</td>
+                    <td class="text-center py-2">${stage_tp.profit_percent}</td>
+                </tr>`;
                 index++;
             }
             // console.log(tenderList);
@@ -897,8 +940,6 @@
 
             // 滚动数据
             $('.tender-data').eq(0).html(tender_html);
-            // if (originDataCollect === 1 || originDataCollect === 2) {
-            tableScroll('profit_tableId', '100%', 30, 7);
 
             // }
             $('[data-toggle="tooltip"]').tooltip();
@@ -919,16 +960,12 @@
             const option3 = myChart3_1.getOption();
             option3.dataZoom[0].start = 0;
             option3.dataZoom[0].end = computedPosition(tenderList.length);
-            option3.yAxis[0].data = chart_option_name;
+            option3.xAxis[0].data = chart_option_name;
             option3.series[0].data = chart_option3_data;
             if (tenderList.length >= 8) {
                 option3.dataZoom[0].show = true;
-                // option3.dataZoom[0].bottom = '10%';
-                // option3.grid.bottom = '15%';
             } else {
                 option3.dataZoom[0].show = false;
-                // option3.dataZoom[0].bottom = '0%';
-                // option3.grid.bottom = '3%';
             }
             myChart3_1.setOption(option3);