guoshilong
2023-10-27 2311b03aee9db1bebacdd2ced13c071efda6a011
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
<template>
    <view class="container">
        <view style=" margin: 0 20rpx;">
            <Card>
                <template slot="insideHead">
                    <view class="card_box headTitle">
                        水情监测
                    </view>
                </template>
                <template slot="content">
                    <view class="card_box j-c-s-a h" style="padding: 20rpx 0;">
                        <view class="card_box h" style="background-color: #eaf2fc;padding: 0 10rpx; "
                            @click="sqVisible=true">
                            <view class="title">{{czOptionList[sqIndex].name}}</view>
                            <u-icon name="arrow-down-fill" size="12"></u-icon>
                        </view>
                        <view class="date" style="background-color: #eaf2fc;">
                            <uni-datetime-picker @change="czSqChange" :clear-icon="false" v-model="datetimerange"
                                type="datetimerange" rangeSeparator="至" />
                        </view>
                        <view class="card_box h" style="background-color: #eaf2fc;padding: 0 10rpx;"
                            @click="flagVisible=true">
                            <view class="title">{{flagOption[flagIndex].name}}</view>
                            <u-icon name="arrow-down-fill" size="12"></u-icon>
                        </view>
                    </view>
                    <SqStation :option="sqEchartOption" ref="SqStation"></SqStation>
 
                </template>
            </Card>
        </view>
        <view style="margin: 0 20rpx;">
            <Card>
                <template slot="insideHead">
                    <view class="card_box headTitle">
                        雨情监测
                    </view>
                </template>
                <template slot="content">
                    <view class="card_box j-c-s-a h" style="padding: 20rpx 0;">
                        <view class="card_box h" style="background-color: #eaf2fc;padding: 0 10rpx;"
                            @click="yqVisible=true">
                            <view class="title">{{czOptionList[yqIndex].name}}</view>
                            <u-icon name="arrow-down-fill" size="12"></u-icon>
                        </view>
                        <view class="date" style="background-color: #eaf2fc;">
                            <uni-datetime-picker @change="czYqChange" :clear-icon="false" v-model="yqDatetimerange"
                                type="datetimerange" rangeSeparator="至" />
                        </view>
                        <view class="card_box h" style="background-color: #eaf2fc;padding: 0 10rpx;"
                            @click="intvVisible=true">
                            <view class="title">{{intvOption[intvIndex].name}}</view>
                            <u-icon name="arrow-down-fill" size="12"></u-icon>
                        </view>
                    </view>
                    <YqStation :option='yqEchartOption' ref="YqStation"></YqStation>
                </template>
            </Card>
        </view>
 
        <view class="main">
        </view>
        <my-select v-if="sqVisible" :show="sqVisible" type="radio" v-model="sqValue" popupTitle="请选择"
            :dataLists="czOptionList" @cancel="sqVisible=false" @submit="sqSelectSubmit">
        </my-select>
        <my-select v-if="yqVisible" :show="yqVisible" type="radio" v-model="yqValue" popupTitle="请选择"
            :dataLists="czOptionList" @cancel="yqVisible=false" @submit="yqSelectSubmit">
        </my-select>
        <my-select v-if="flagVisible" :show="flagVisible" type="radio" v-model="flagValue" popupTitle="请选择"
            :dataLists="flagOption" @cancel="flagVisible=false" @submit="flagSelectSubmit">
        </my-select>
        <my-select v-if="intvVisible" :show="intvVisible" type="radio" v-model="intvValue" popupTitle="请选择"
            :dataLists="intvOption" @cancel="intvVisible=false" @submit="intvSelectSubmit">
        </my-select>
 
    </view>
</template>
 
<script>
    import YqStation from "@/subPackage/realtimeMonitor/components/yq.vue"
    import SqStation from "@/subPackage/realtimeMonitor/components/sq.vue"
    import echart from "@/components/echart/echart.vue"
    import uniDataSelect from "./uni-components/uni-data-select/components/uni-data-select/uni-data-select.vue"
    import uniDatetimePicker from "./uni-components/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue"
    import Card from "@/components/my-components/card.vue"
    import mySelect from "@/components/my-components/my-select.vue"
    import {
        TimeMinute,
        getEightHourTime,
    } from "@/utils/date"
    import {
        reservoirList,
        getReservoirBasicInfo,
        getRsbNorspiData
    } from "@/api/dataCenter/reservoir/reservoir.js"
    import {
        getStation,
        getSqList as sqList,
        getYqList as yqList
 
    } from "@/api/dataCenter/rainWaterCondition/rainWaterCondition"
    export default {
        props: {
            reservoirId: {
                type: String,
                default: ""
            }
        },
        components: {
            YqStation,
            SqStation,
            uniDataSelect,
            uniDatetimePicker,
            Card,
            mySelect,
            echart
        },
        data() {
            return {
                datetimerange: getEightHourTime(),
                yqDatetimerange: getEightHourTime(),
                params: {
                    pageNo: 1,
                    pageSize: 500,
                    flag: "1",
                    intv: "1"
                },
                //水情测站显示
                sqVisible: false,
                sqValue: "",
                sqIndex: 0,
                //雨情测站显示
                yqIndex: 0,
                yqValue: "",
                yqVisible: false,
                //时段类型相关数据
                flagOption: [{
                        name: "实时",
                        value: "1",
                        index: 0,
                    },
                    {
                        name: "整点",
                        value: "2",
                        index: 1,
                    },
                    {
                        name: "八时",
                        value: "3",
                        index: 2,
                    },
                ],
                flagIndex: 0,
                flagValue: "1",
                flagVisible: false,
                //小时类型
                intvOption: [{
                        name: "1小时",
                        value: "1",
                        index: 0
                    },
                    {
                        name: "3小时",
                        value: "3",
                        index: 1
                    },
                    {
                        name: "6小时",
                        value: "6",
                        index: 2
                    },
                    {
                        name: "12小时",
                        value: "12",
                        index: 3
                    }
                ],
                intvVisible: false,
                intvIndex: 0,
                intvValue: "1",
                //获取测站数据
                czOptionList: [{
                    name: "老站",
                    index: 0
                }],
                sqEchartOption: {},
                yqEchartOption: {},
            }
        },
        created() {
            this.params.res_cd = this.reservoirId
            this.initGetStation()
        },
        options: {
            styleIsolation: 'shared'
        },
        methods: {
            //初始化监测站数据
            async initGetStation() {
                uni.showLoading({
                    title: "加载中,请稍等",
                    mask: true
                })
                const obj = {
                    res_cd: this.reservoirId
                }
                const {
                    resultList
                } = await getStation(obj)
                const arr = []
                let typeIndex = 0
                resultList.forEach((val, index) => {
                    const obj = {
                        name: `${val.sys_resource == 'wlw' ? `新站` : `老站`}`,
                        value: val.guid,
                        index: index,
                        sys_resource: val.sys_resource
                    }
                    arr.push(obj)
                })
                if (arr.length > 0) {
                    this.czOptionList = this.getTypeStation(arr)
                    this.sqValue = this.czOptionList[0].value
                    this.yqValue = this.czOptionList[0].value
                    this.params.st_cd = this.czOptionList[0].value
                    this.init()
                }
                uni.hideLoading()
            },
            //处理有多个新站或者老站的数据
            getTypeStation(data) {
                if (data.length <= 0) return []
                //获取老站数据
                const lkList = data.filter(v => v.sys_resource == 'lk')
                //获取新站数据
                const xkList = data.filter(v => v.sys_resource == 'wlw')
                this.dealStation(lkList)
                this.dealStation(xkList)
                return [...lkList, ...xkList].sort((a, b) => a.index - b.index)
            },
            dealStation(list) {
                if (list.length <= 1) return
                list.forEach((v, index) => v.name = v.name + (index + 1))
            },
            //水情测点切换
            sqSelectSubmit(e) {
                this.sqIndex = e.index
                this.sqVisible = false
                this.sqValue = e.value
                const params = {
                    st_cd: e.value
                }
                this.params = {
                    ...this.params,
                    ...params
                }
                this.getSqList()
            },
            //雨情测点切换
            yqSelectSubmit(e) {
                this.yqIndex = e.index
                this.yqVisible = false
                this.yqValue = e.value
                const params = {
                    st_cd: e.value
                }
                this.params = {
                    ...this.params,
                    ...params
                }
                this.getYqList()
            },
            //时段类型切换
            flagSelectSubmit(e) {
                this.flagIndex = e.index
                this.flagVisible = false
                this.flagValue = e.value
                const params = {
                    flag: e.value
                }
                this.params = {
                    ...this.params,
                    ...params
                }
                this.getSqList()
            },
            //雨情小时类型切换
            intvSelectSubmit(e) {
                this.intvIndex = e.index
                this.intvVisible = false
                this.intvValue = e.value
                const params = {
                    intv: e.value
                }
                this.params = {
                    ...this.params,
                    ...params
                }
                this.getYqList()
            },
            //初始化
            init() {
                this.getSqList()
                this.getYqList()
            },
            //水情列表
            async getSqList() {
                const resData = {
                    res_cd: this.reservoirId
                }
                const tbData = await getReservoirBasicInfo(resData)
                const ydgc = await getRsbNorspiData(resData).catch(err => this.loading = false)
                const [start_dt, end_dt] = this.datetimerange
                const obj = {
                    ...this.params,
                    start_dt,
                    end_dt
                }
                const {
                    data
                } = await sqList(obj)
                data.forEach(val => {
                    val.tm = new Date(val.tm).getTime()
                    val.time = TimeMinute(new Date(val.tm).getTime())
                })
 
                const xAxis = data.sort((a, b) => a.tm - b.tm).map(val => val.time)
                const swData = data.sort((a, b) => a.tm - b.tm).map(val => val.rz)
                const res = await reservoirList(1, 1, {
                    res_cd: this.reservoirId
                })
                this.sqOptionDeal(tbData.data[0], data, ydgc)
                uni.hideLoading()
            },
            sqOptionDeal(xxswData, data, ydgc) {
                if (data.length <= 0) return
                //使用深拷贝处理表格的时间倒叙变正序
                const deepArr = JSON.parse(JSON.stringify(data))
                const xAxis = deepArr.sort((a, b) => a.tm - b.tm).map(val => val.time)
                //汛限水位
                const xxswValue = xxswData.mid_flood_flse_stag
                //水位
                const series2 = deepArr.sort((a, b) => a.tm - b.tm).map(val => val.rz)
                //获取最大水位
                const maxWater = Math.max(...series2)
                //获取死水位
                const dead_stag = xxswData.tb_dead_stag || 0
                //获取正常水位
                const norm_pool_stag = xxswData.tb_norm_pool_stag || 0
                //获取设计水位
                const des_fl_stag = xxswData.tb_des_fl_stag || 0
                //获取校核水位
                const chec_fl_stag = xxswData.tb_chec_fl_stag || 0
                //获取坝顶高程
                const dam_top_elevation = xxswData.tb_dam_top_elevation || 0
                //获取堰顶高程
                const weir_top_elev = ydgc.resultList[0].tb_weir_top_elevation || 0
                const numberData = [maxWater, xxswValue, dead_stag, norm_pool_stag, des_fl_stag, chec_fl_stag,
                    dam_top_elevation, weir_top_elev
                ]
                //最大值
                const max = Math.max(...numberData)
                //最小值
                const min = Math.min(...numberData)
                this.sqEchartOption = {
                    color: ["#FF8B07", "#1180ff", "#f800e8", "#08dca9", "green", "black", "brown", "red"],
                    xAxis: [{
                        data: xAxis
                    }],
                    title: {
                        text: "水位过程线",
                        textStyle: {
                            fontSize: 14,
                            fontWeight: "normal"
                        }
                    },
                    yAxis: [{
                        type: 'value',
                        name: "水位(m)",
                        nameTextStyle: {
                            fontSize: 8,
                            vertivalAlign: "middle",
                            padding: [0, 56, 0, 0]
                        },
                        min: (min - 0.5).toFixed(2),
                        max: (val) => {
                            return (max + 0.5).toFixed(2);
                        }
                    }, ],
                    series: [{
                            name: '水位(m)',
                            type: 'line',
                            data: series2,
                            lineStyle: {
                                normal: {
                                    type: "solid"
                                }
                            },
                            smooth: true,
                            showSymbol: false
                        },
                        {
                            type: "line",
                            name: "汛限水位",
                            markLine: {
                                symbol: 'none',
                                data: [{
                                    lineStyle: {
                                        color: "#1180ff",
                                        type: "dashed"
                                    },
                                    label: {
                                        position: "middle",
                                        fontWeight: 'bold',
                                        formatter(params) {
                                            return `汛限水位 ${params.value}m`
                                        }
                                    },
                                    yAxis: xxswValue
                                }, ]
                            }
                        },
                        {
                            type: "line",
                            name: "死水位",
                            markLine: {
                                symbol: 'none',
                                data: [{
                                    lineStyle: {
                                        type: "dashed"
                                    },
                                    label: {
                                        position: "insideStartTop",
                                        distance: 5,
                                        fontWeight: 'bold',
                                        formatter(params) {
                                            return `死水位 ${params.value}m`
                                        }
                                    },
                                    yAxis: dead_stag
                                }, ]
                            }
                        },
                        {
                            type: "line",
                            name: "正常水位",
                            markLine: {
                                symbol: 'none',
                                data: [{
                                    lineStyle: {
                                        type: "dashed"
                                    },
                                    label: {
                                        position: "insideStartBottom",
                                        fontWeight: 'bold',
                                        formatter(params) {
                                            return `正常水位 ${params.value}m`
                                        }
                                    },
                                    yAxis: norm_pool_stag
                                }, ]
                            }
                        },
                        {
                            type: "line",
                            name: "设计水位",
                            markLine: {
                                symbol: 'none',
                                data: [{
                                    lineStyle: {
                                        type: "dashed"
                                    },
                                    label: {
                                        position: "insideMiddleTop",
                                        fontWeight: 'bold',
                                        formatter(params) {
                                            return `设计水位 ${params.value}m`
                                        }
                                    },
                                    yAxis: des_fl_stag
                                }, ]
                            }
                        },
                        {
                            type: "line",
                            name: "校核水位",
                            markLine: {
                                symbol: 'none',
                                data: [{
                                    lineStyle: {
                                        type: "dashed"
                                    },
                                    label: {
                                        position: "insideEndTop",
                                        fontWeight: 'bold',
                                        formatter(params) {
                                            return `校核水位 ${params.value}m`
                                        }
                                    },
                                    yAxis: chec_fl_stag
                                }, ]
                            }
                        },
                        {
                            type: "line",
                            name: "坝顶高程",
                            markLine: {
                                symbol: 'none',
                                data: [{
                                    lineStyle: {
                                        type: "dashed"
                                    },
                                    label: {
                                        position: "insideEndBottom",
                                        fontWeight: 'bold',
                                        formatter(params) {
                                            return `坝顶高程 ${params.value}m`
                                        }
                                    },
                                    yAxis: dam_top_elevation
                                }, ]
                            }
                        },
                        {
                            type: "line",
                            name: "堰顶高程",
                            markLine: {
                                symbol: 'none',
                                data: [{
                                    lineStyle: {
                                        type: "dashed"
                                    },
                                    label: {
                                        position: "insideStartBottom",
                                        fontWeight: 'bold',
                                        formatter(params) {
                                            return `堰顶高程 ${params.value}m`
                                        }
                                    },
                                    yAxis: weir_top_elev
                                }, ]
                            }
                        },
                    ]
                }
            },
            //雨情列表
            async getYqList() {
                const [start_tm, end_tm] = this.yqDatetimerange
                const {
                    st_cd,
                    res_cd,
                    intv
                } = this.params
                const params = {
                    start_tm,
                    end_tm,
                    st_cd,
                    res_cd,
                    intv
                }
                const {
                    data
                } = await yqList(params)
                data.data.forEach(val => {
                    val.tm = new Date(val.tm).getTime()
                    val.time = TimeMinute(new Date(val.tm).getTime())
                })
                const xAxis = data.data.sort((a, b) => a.tm - b.tm).map(val => val.time)
                const series1 = data.data.map(val => val.accp)
                const series2 = data.data.map(val => val.drp)
                this.yqEchartOption = {
                    xAxis: [{
                        data: xAxis
                    }],
                    series: [{
                        name: '时段雨量(mm)',
                        type: 'bar',
                        barWidth: "10",
                        yAxisIndex: 0,
                        itemStyle: {
                            color: "#1890FF"
                        },
                        tooltip: {
                            valueFormatter: function(value) {
                                return value + 'mm'
                            }
                        },
                        data: series2,
                    }]
                }
            },
            changeType(item) {
                if (this.params.flag == item.value) return
                this.params.flag = item.value
                this.getSqList()
            },
            changeRain(item) {
                if (this.params.intv == item.value) return
                this.params.intv = item.value
                this.getYqList()
            },
            changeStcd(item) {
                if (this.params.st_cd == item.value) return
                this.params.st_cd = item.value
                this.init()
            },
            czSqChange(e) {
                const [start_dt, end_dt] = e
                const params = {
                    start_dt,
                    end_dt
                }
                this.params = {
                    ...this.params,
                    ...params
                }
                this.getSqList()
            },
            czYqChange(e) {
                this.getYqList()
            }
        }
    }
</script>
 
<style scoped lang="scss">
    ::v-deep .uni-date-x--border {
        border: none !important;
    }
 
    /deep/ .uni-date-editor--x {
        border: none !important;
    }
 
    /deep/ .datetime-picker--uni-date-x {
        background-color: #eaf2fc !important;
    }
 
    /deep/ .uni-date-x {
        background-color: #eaf2fc !important;
    }
 
    /deep/ .uni-date-x .icon-calendar {
        display: none;
    }
 
    .container {
 
        // background-color: #f2f2f2;
        .headTitle {
            font-size: 32rpx;
            font-weight: 600;
        }
 
        .flex {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
 
        .j-c-s-a {
            justify-content: space-around;
        }
 
        .h {
            min-height: 70rpx;
        }
 
        .card_box {
            display: flex;
            align-items: center;
 
            .date {
                width: 400rpx;
            }
 
            .title {
                font-size: 32rpx;
            }
        }
 
    }
</style>