wujingjing
2024-09-29 b9f5b855a3b8890d7dbbab6985bf4f78315cfe49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>官网概述</title>
        <script src="/customer_list/ch/ai_html/views/demo/js/tailwind.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/vue.global.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/datav.umd.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/index.full.js"></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/iframe-resizer/child-5.1.5.js" async></script>
        <script src="/customer_list/ch/ai_html/views/demo/js/echarts.min.js"></script>
        <link href="/customer_list/ch/ai_html/views/demo/css/variablesDemo.css" rel="stylesheet" type="text/css" />
        <link href="/customer_list/ch/static/fonts/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
        <script src="/customer_list/ch/ai_html/views/demo/js/customInstruction.js"></script>
        <link href="/customer_list/ch/ai_html/views/demo/css/ele-index.css" rel="stylesheet" type="text/css" />
        <style>
            .el-dialog__header {
                margin-right: 0;
                padding: 8px 10px;
                background: #528abe;
            }
 
            .el-dialog__title {
                color: #fff;
                font-size: 14px;
            }
 
            .el-dialog__close {
                color: #fff !important;
            }
        </style>
    </head>
 
    <body>
        <div class="w-full h-full bg-[#f2f4f8]" id="workOrder">
            <div class="screen-top-center">
                <div class="top-center-data">
                    <div class="data-item" v-for="(item, index) in state.dataList">
                        <p class="data-item-title">{{item.title}}</p>
                        <p class="data-item-desc cursor-pointer" @click="handleDataItemClick(item)">
                            {{item.value}}<span class="text-[13px]"> {{' '+item.unit}}</span>
                        </p>
                    </div>
                </div>
                <div class="top-center-chart">
                    <div class="chart-item">
                        <div class="screen-top-header flex flex-wrap justify-center items-center">
                            <div class="header-left flex-c">
                                <i class="myiconfont icon-ico_shuju text-[#1c86ff]"></i>
                            </div>
                            <div class="header-right flex-l">
                                <span class="header-title">巡检养护情况</span>
                                <Decoration3 class="dv-dec-3" />
                            </div>
                        </div>
 
                        <div id="inspectionChart" class="w-full h-[280px]" v-resize="chartContainerResize"></div>
                    </div>
                    <div class="chart-item">
                        <div class="screen-top-header flex-l">
                            <div class="header-left flex-c">
                                <i class="myiconfont icon-shangchuan text-[#1c86ff]"></i>
                            </div>
                            <div class="header-right flex-l">
                                <span class="header-title">月度受理量排行</span>
                                <Decoration3 class="dv-dec-3" />
                            </div>
                        </div>
                        <div class="pond-section" v-resize="chartContainerResize">
                            <div id="salesRankChart" class="w-full h-[280px]"></div>
                        </div>
                    </div>
                </div>
            </div>
            <el-dialog
                v-model="state.isShowChartVisible"
                :title="state.inspectionInfo.title"
                width="50%"
                class="px-[unset] py-[unset]"
                :before-close="handleCloseChartVisible"
            >
                <div id="inspectionTrends" class="w-full h-[500px]"></div>
            </el-dialog>
        </div>
    </body>
    <script>
        const { createApp, onMounted, ref, reactive, nextTick } = Vue;
        const { Decoration3 } = DataV;
        const demoOverViewChart = ref(null);
        const inspectionChart = ref(null);
        const salesRankRef = ref(null);
        const inspectionTrendsChart = ref(null);
        const App = createApp({
            setup() {
                let state = reactive({
                    dataList: [
                        {
                            title: '管线总长',
                            value: 755,
                            config: {
                                number: [755],
                                toFixed: 0,
                                content: '{nt}',
                                textAlign: 'left',
                                style: {
                                    fontSize: 24,
                                },
                            },
                            unit: '米',
                        },
                        {
                            title: '压力表数',
                            value: 3288,
                            config: {
                                number: [3288],
                                toFixed: 0,
                                content: '{nt}',
                                textAlign: 'left',
                                style: {
                                    fontSize: 24,
                                },
                            },
                            unit: '个',
                        },
                        {
                            title: '流量计数',
                            value: 14222,
                            config: {
                                number: [14222],
                                toFixed: 0,
                                content: '{nt}',
                                textAlign: 'left',
                                style: {
                                    fontSize: 24,
                                },
                            },
                            unit: '个',
                        },
                        {
                            title: '户表数',
                            value: 41022,
                            config: {
                                number: [41022],
                                toFixed: 0,
                                content: '{nt}',
                                textAlign: 'left',
                                style: {
                                    fontSize: 24,
                                },
                            },
                            unit: '个',
                        },
                        {
                            title: '水质仪数',
                            value: 176888,
                            config: {
                                number: [176888],
                                toFixed: 0,
                                content: '{nt}',
                                textAlign: 'left',
                                style: {
                                    fontSize: 24,
                                },
                            },
                            unit: '个',
                        },
                        {
                            title: '阀门数',
                            value: 820,
                            config: {
                                number: [820],
                                toFixed: 0,
                                content: '{nt}',
                                textAlign: 'left',
                                style: {
                                    fontSize: 24,
                                },
                            },
                            unit: '个',
                        },
                    ],
                    isShowChartVisible: false,
                    inspectionInfo: {
                        id: null,
                        title: null,
                        value: null,
                    },
                });
                const getOverViewList = () => {
                    const iconList = [
                        'biaodan',
                        'putong',
                        'zhongduancanshuchaxun',
                        'shidu',
                        'fuwenbenkuang',
                        'fuwenben',
                        'jiliandongxuanzeqi',
                        'jinridaiban',
                        'gongju',
                    ];
                    state.dataList.forEach((annual, index) => {
                        annual.Icon = iconList[index];
                        annual.BgColor = randomHexColor();
                    });
                };
                //随机生成颜色
                const randomHexColor = () => {
                    return `#${Math.floor(Math.random() * 16777215)
                        .toString(16)
                        .padEnd(6, '0')}`;
                };
                onMounted(() => {
                    initInspectionChart();
                    drawSalesRanking();
                });
                //初始化巡检图表
                const initInspectionChart = () => {
                    var chartDom = document.getElementById('inspectionChart');
                    var myInspectChart = echarts.init(chartDom);
                    inspectionChart.value = myInspectChart;
                    var option = {
                        legend: {},
                        tooltip: {},
                        grid: {
                            left: '2%', // 调整左边距
                            right: '5%', // 调整右边距
                            bottom: '6%',
                            containLabel: true, // 确保标签和轴标题被包含在容器内
                        },
                        dataset: {
                            source: [
                                ['product', '循环完成率', '维保完成率'],
                                ['1月', 43.3, 85.8],
                                ['2月', 83.1, 73.4],
                                ['3月', 86.4, 65.2],
                                ['4月', 72.4, 53.9],
                                ['5月', 77.0, 39.1],
                                ['6月', 68.2, 56.2],
                                ['7月', 72.1, 64.5],
                                ['8月', 76.5, 70.8],
                                ['9月', 74.1, 72.4],
                                ['10月', 75.3, 71.7],
                                ['11月', 70.9, 74.2],
                                ['12月', 66.8, 75.2],
                            ],
                        },
                        xAxis: { type: 'category', name: '月份', nameGap: 10 },
                        yAxis: {
                            name: '单位: %',
                        },
                        series: [{ type: 'bar' }, { type: 'bar' }],
                    };
                    option && myInspectChart.setOption(option);
                };
                //初始化弹窗echart
                const initInspectionTrendsEchart = () => {
                    var chartDom = document.getElementById('inspectionTrends');
                    var businessTrendsChart = echarts.init(chartDom);
                    inspectionTrendsChart.value = businessTrendsChart;
                    const option = {
                        tooltip: {
                            trigger: 'axis',
                        },
                        grid: {
                            left: '3%', // 调整左边距
                            right: '5%', // 调整右边距
                            bottom: '3%', // 调整底部边距
                            top: '5%', // 调整顶部边距
                            containLabel: true, // 确保标签和轴标题被包含在容器内
                        },
                        xAxis: {
                            name: '时间',
                            type: 'category',
                            minInterval: 3600 * 4 * 1000, //12
                            data: ['00:00', '05:00', '10:00', '15:00', '20:00', '23:45'],
                        },
                        yAxis: {
                            type: 'value',
                            axisLabel: {
                                formatter: '{value}',
                            },
                        },
                        dataZoom: {
                            type: 'inside',
                        },
                        series: [
                            {
                                name: '销售额',
                                type: 'line',
                                data: [620, 1032, 701, 1234, 890, 1430, 1320, 1230, 1320, 1430, 1320], // 示例数据,模拟起伏更大
                                smooth: true, // 折线平滑
                                lineStyle: {
                                    width: 2,
                                    color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                                        { offset: 0, color: '#62c1fe' },
                                        { offset: 0.5, color: '#ad90f7' },
                                        { offset: 1, color: '#e875f2' },
                                    ]),
                                },
                                symbolSize: (value, params) => {
                                    // 获取数据系列的长度
                                    const seriesLength = option.series[0].data.length;
                                    // 中间节点放大
                                    if (params.dataIndex === Math.floor(seriesLength / 2)) {
                                        return 8; // 中间节点的大小
                                    }
                                    return 8; // 其他节点的大小
                                },
                            },
                        ],
                    };
                    option && businessTrendsChart.setOption(option);
                };
                // 绘制横向柱状图排行榜
                const drawSalesRanking = () => {
                    var chartDom = document.getElementById('salesRankChart');
                    var salesRankingElement = echarts.init(chartDom);
                    salesRankRef.value = salesRankingElement;
                    const option = {
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'shadow',
                            },
                        },
                        grid: {
                            left: '2%', // 调整左边距
                            right: '5%', // 调整右边距
                            top: '2%', // 调整下边距
                            bottom: '15%',
                            containLabel: true, // 确保标签和轴标题被包含在容器内
                        },
                        xAxis: {
                            type: 'value',
                            boundaryGap: [0, 0.01],
                            axisLine: {
                                show: false, // 不显示横坐标轴线
                            },
                            axisTick: {
                                show: false, // 不显示刻度线
                            },
                            splitLine: {
                                show: false, // 不显示x轴网格线
                            },
                        },
                        yAxis: {
                            type: 'category',
                            data: ['闵行区', '浦东区', '徐汇区'], // 示例数据
                            axisLine: {
                                show: false, // 不显示横坐标轴线
                            },
                            axisTick: {
                                show: false, // 不显示刻度线
                            },
                            splitLine: {
                                show: false, // 不显示y轴网格线
                            },
                            axisLabel: {
                                rich: {
                                    iconStyle: {
                                        fontSize: 20, // 设置图标的字体大小为20
                                    },
                                    nameStyle: {
                                        // 定义名字的样式
                                        fontSize: 12, // 设置名字的字体大小为12,或者您希望的任何大小
                                    },
                                },
                                formatter: function (value, index) {
                                    // 根据index或value来决定显示哪个排名的图标
                                    const rankIcons = {
                                        2: '{iconStyle|🥇}',
                                        1: '{iconStyle|🥈}',
                                        0: '{iconStyle|🥉}',
                                    };
                                    return `${rankIcons[index]} {nameStyle|${value}}`;
                                },
                            },
                        },
                        series: [
                            {
                                name: '受理量',
                                type: 'bar',
                                data: [9, 10, 21], // 示例数据
                                barWidth: '30%', // 调整柱子宽度
                                itemStyle: {
                                    borderRadius: [0, 5, 5, 0], // 只有右侧圆角
                                    color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
                                        // 设置渐变色,方向也要调整为横向
                                        { offset: 0, color: '#bdd1f6' },
                                        { offset: 1, color: '#4282ff' },
                                    ]),
                                },
                                label: {
                                    show: true, // 显示标签
                                    position: 'right', // 标签位置在顶部
                                    formatter: '{c}万', // 自定义显示的内容,{c}是指当前数据点的值
                                },
                            },
                        ],
                    };
                    salesRankingElement.setOption(option);
                };
                //点击数据项弹窗
                const handleDataItemClick = (item) => {
                    state.inspectionInfo = item;
                    nextTick(() => {
                        initInspectionTrendsEchart();
                    });
 
                    state.isShowChartVisible = true;
                };
                const chartContainerResize = ({ width, height }) => {
                    inspectionChart.value.resize();
                    salesRankRef.value.resize();
                };
                //关闭弹窗
                const handleCloseChartVisible = () => {
                    state.isShowChartVisible = false;
                };
                return { state, handleDataItemClick, handleCloseChartVisible, chartContainerResize };
            },
        });
 
        App.component('Decoration3', Decoration3);
        elementResizeDirective(App);
        App.use(ElementPlus);
        App.mount('#workOrder');
    </script>
</html>