yangyin
2024-04-04 b10a31396df8eb87510d35c19e7e9fb34e681e69
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
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
import * as echarts from '../../components/ec-canvas/echarts';
import constant from '../../utils/constant.js';
var util = require('../../utils/util.js');
var Constant = require('../../utils/constant.js');
import Request  from "../../utils/api"
 
//获取引用实例
var app = getApp();
var RefreshTime = 120;
var barec = null; //动态配置图表数据的变量
Page({
  /**
   * 页面的初始数据
   */
  data: {
    tabBar: [{
        index: 0,
        iconPath: "icon-shebeijiance-dianji",
        selectedIconPath: "icon-shebeijiance-dianji blue",
        text: "监测"
      },
      {
        index: 1,
        iconPath: "icon-gongzuo",
        selectedIconPath: "icon-gongzuo blue",
        text: "工作时间"
      },
      {
        index: 2,
        iconPath: "icon-guzhang",
        selectedIconPath: "icon-guzhang blue",
        text: "警报"
      }
    ],
 
 
 
    machineList: [], //泵组详情名称
 
    startAlarmDate: util.formatDay(util.GetBeforeDate(7)),
    endAlarmDate: util.formatDay(new Date()),
    today: util.formatDay(new Date()),
    stationID: 0,
    currentTabIndex: 0,
    lastRefreshTime: RefreshTime, //秒
    loadingHidden: false,
    loadingInfo: "加载中,请稍等...",
    intervalRefreshTime: null,
    allProductPoints: [],
    allPointId: [],
    alarmListInfo: [],
 
    isInitialAlarmData: false, //是否初始化警报记录
    hasAlarmData: false,
    hasPointData: true,
 
    IsDefault: true,
    kpiParas: { //顶部状态
      status: '未知',
      runNumber: null,
      alarmNumber: "未知"
    },
 
    scrollHeight: wx.getSystemInfoSync().windowHeight,
    isShowFloatMenu: false, //是否显示
    animationFloatMenu: '', //显示动画
 
    //echart 所有变量定义
    ec: {
      onInit: function (canvas, width, height, dpr) {
        //初始化echarts元素,绑定到全局变量,方便更改数据
        barec = echarts.init(canvas, null, {
          width: width,
          height: height,
          devicePixelRatio: dpr
        });
        canvas.setChart(barec);
        return barec;
      },
    },
    //当前时间
    yestday: util.formatDay(util.GetNextDate(new Date(), 0)),
    historyDate: util.formatDay(util.GetNextDate(new Date(), 0)),
    isNextDayAble: false, //是否可以点击下一天
    PageIndex: 1, //初始化页数
    PageSize: 20, //初始化条数
    message: '未发生报警',
    bottomStatus: false,
    isExpandList: false, //列表展开状态 默认true不展开
    isShowFloatMenu: false, //是否显示
    animationFloatMenu: '', //显示动画
    scrollHeight: wx.getSystemInfoSync().windowHeight,
    scrollTop: 0,
  },
  //监测列表伸缩
  tapExpandList() {
    var allProductPoints = this.data.allProductPoints
    if (this.data.isExpandList) {
      for (let i = 0; i < allProductPoints.length; i++) {
        allProductPoints[i].IsExpand = false
      }
      this.setData({
        isExpandList: false,
        allProductPoints: allProductPoints
      })
    } else if (this.data.isExpandList == false) {
      for (let i = 0; i < allProductPoints.length; i++) {
        allProductPoints[i].IsExpand = true
      }
      this.setData({
        isExpandList: true,
        allProductPoints: allProductPoints
      })
    }
  },
  //上一天点击事件
  yesterDay: function () {
    this.setData({
      historyDate: util.formatDay(util.GetNextDate(this.data.historyDate, -1)),
      isNextDayAble: true,
    });
    this.getWorkTime()
  },
  //下一天点击事件
  tomorrow: function () {
    var day = util.formatDay(util.GetNextDate(this.data.historyDate, 1));
    // console.log(day);
    // console.log(this.data.yestday);
 
    var isNextDayAble = true;
    if (day == this.data.yestday) {
      isNextDayAble = false;
    }
    this.setData({
      historyDate: day,
      isNextDayAble: isNextDayAble
    });
    this.getWorkTime()
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: "泵站监控" + options.name
    })
    var getNewDateArry = util.getNewDateArry.getNewDateArry();
    var that = this;
    var stationID = options.id;
    //console.log('打印stationID', stationID);
    if (stationID == null) {
      stationID = 5;
    }
    //console.log(stationID);
    // wx.showToast({
    //   title: '获取中....',
    //   icon: "loading",
    //   duration: 3000
    // }) 
    this.setData({
      stationID: stationID,
      getNewDateArry: getNewDateArry.ymdhm
    });
    var userInfo = app.globalData.userInfo;
    if (userInfo == null) {
      return;
    }
 
    Request({
      url: Constant.BASE_SERVER_URL + "SZJT/Station/Monitor/List/Mobile/GetByStationID@V1.0",
      method: 'GET',
      data: {
        StationID: stationID,
   
      },
      header: {
        'content-type': 'application/json'
      },
      fail: function (err) {
        that.setData({
          loadingHidden: true
        });
      }, //请求失败
      success: function (res) {
        that.setData({
          loadingHidden: true
        });
 
        var result = res.data;
          // console.log('获取的泵站信息', result);
 
        if (result.Code != 0) {
          wx.showModal({
            title: '',
            content: result.Message,
          });
          return;
        }
        //  console.log(result);
        var dict = result.Data;
        // var dict = result.Data.PointList;
        //  console.log('dict',dict);
        var allProductPoints = dict;
        if (allProductPoints==null) {
          wx.showModal({
            title: '当前监控暂无数据',
          });
          return;
        }
        //  console.log('allProductPoints', allProductPoints);
 
 
        var machineList = []
        for (var i = 1; i < allProductPoints.length; i++) {
          var node = allProductPoints[i];
       
          machineList.push({
            ID: node.ID,
            TitleName: node.Name,
            MachineName: node.Name,
            WorkTime: 0
          });
        
        }
        var allPointIds = [];
 
        for (var k = 0; k < allProductPoints.length; k++) {
          var product = allProductPoints[k];
          product.IsExpand = false;
          product.isExpandAll = false;
 
          var dis_num = 0;
          for (var n = 0; n < product.MonitorList.length; n++) {
            var record = product.MonitorList[n];
            record.SignalValue = ""
            record.RecordTime= ""
            record.isDisp = false;
            if (product.MonitorList.length<=2) {
              record.isDisp = true;
              dis_num++;
              allPointIds.push(record.SignalID);
            }
          }
          if (dis_num < 2) { //没有就显示前两个
            for (var n = 0; n < product.MonitorList.length; n++) {
              var record = product.MonitorList[n];
              if (dis_num <= 2) {
                record.isDisp = true;
                dis_num++;
                allPointIds.push(record.SignalID);
              }
            }
          }
        }
        // console.log(allPointIds,253)
 
        //定时刷新
        var intervalRefreshTime = setInterval(function () {
          var getNewDateArry = util.getNewDateArry.getNewDateArry()
          var miao = that.data.lastRefreshTime;
          miao = miao - 1;
          if (miao <= 0) {
            that.setData({
              lastRefreshTime: RefreshTime,
              getNewDateArry: getNewDateArry.ymdhm
            });
            that.refreshRecordValue();
          } else {
            that.setData({
              lastRefreshTime: miao
            });
          }
        }, 1000);
 
        // console.log('289行',allProductPoints)
        //更新数据
        that.setData({
          allPointId: allPointIds,
          hasPointData: true,
          allProductPoints: allProductPoints,
          intervalRefreshTime: intervalRefreshTime,
          machineList: machineList
        });
        //console.log('machineList', that.data.machineList);
 
        that.refreshRecordValue(); //刷新一下
      }
    });
  },
  onReady: function () {
    // this.getPoint(); //更新图表配置
  },
  //获取泵站运行时间
  getWorkTime: function () {
    var that = this;
    var machineList = this.data.machineList;
    var userInfo = app.globalData.userInfo;
    Request({
      url: Constant.BASE_SERVER_URL + 'SZJT/Run/Analy/Mobile/GetSpanListByStationIDOfDay@V1.0',
      method: 'GET',
      data: {
        StationID :that.data.stationID,
        Day: that.data.historyDate
      },
      header: {
        'content-type': 'application/json'
      },
      success(res) {
        // console.log(res,306)
        var result = res.data
        if (result.Code != 0) {
          return;
        }
        // 
        var run_time_array = result.Data; 
        if(run_time_array==null){
          util.popup.showModal('', '泵站没有运行时间');
          return
        }
        //  console.log('291行   ', that.data.historyDate + '的开停机:', run_time_array); 
         run_time_array.forEach(item => { 
          item.runTimeSum=0
           item.ChunkList.forEach(chunkItem=>{
            //  console.log(chunkItem,321)
             if (chunkItem.RunStatus == 1) {
               item.runTimeSum += chunkItem.Duration;              
             }
           })
           
         })
        //  console.log(run_time_array,328)
        for (var i = 0; i < machineList.length; i++) {         
          run_time_array.forEach(item => {
            if(machineList[i].TitleName == item.Name){
              machineList[i].WorkTime = (item.runTimeSum/ 60 / 60).toFixed(1)
            }
          });
        }
        that.setData({
          machineList: machineList
        })
        that.calcChartWorkTime(run_time_array)
      },
      fail(err) {}
    })
  },
  //构建图表
  calcChartWorkTime: function (records) {
    // console.log(records,"已获取导数据")
    var that = this
    var seriesData = []; //定义图表内容的数组
    var yAxisData = []; //定义y轴内容的数组
 
    var machineList = that.data.machineList;
 
    for (let i = 0; i < machineList.length; i++) { // 循环遍历获取开关机状态
      var machineListNode = []
      records.forEach(item => {
        if(item.Name == machineList[i].MachineName){
          machineListNode.push(item.ChunkList)
        }
      });
        // console.log('machineListNode', machineListNode)
      yAxisData.push(machineList[i].MachineName)
      machineList[i].list = machineListNode
      for (let j = 0; j < machineListNode[0].length; j++) {
        var nodeItem = machineListNode[0][j];
        nodeItem.StartTime = nodeItem.StartTime.replace(/-/gi, '/')
        nodeItem.EndTime = nodeItem.EndTime.replace(/-/gi, '/')
        if (nodeItem.RunStatus == 1) {
          seriesData.push({
            name: "开机",
            value: [
              i,
              new Date(new Date(nodeItem.StartTime)) - 0,
              new Date(new Date(nodeItem.EndTime)) - 0,
              "开启",
              "关闭",
              (nodeItem.Duration/60/60).toFixed(1)
            ],
            itemStyle: {
              normal: {
                color: '#7b9ce1'
              }
            }
          })
        } else if (nodeItem.RunStatus == 0) {
          seriesData.push({
            name: "关机",
            value: [
              i,
              +new Date(new Date(nodeItem.StartTime)) - 0,
              +new Date(new Date(nodeItem.EndTime)) - 0,
              "关闭",
              "开启",
              (nodeItem.Duration/60/60).toFixed(1)
            ],
            itemStyle: {
              normal: {
                color: '#ddd'
              }
            }
          })
        }
      }
    }
 
      // console.log(seriesData,"seriesData")
    var minTime = '';
    var maxTime = '';
    if (seriesData.length == 0) { //判断处理x轴的最小时间和最大时间
      minTime = that.data.historyDate
      maxTime = that.data.historyDate + " 23:59:59"
    } else {
      minTime = seriesData[0].value[1]
      maxTime = seriesData[seriesData.length - 1].value[2]
    }
    // var time1 = util.formatDay(util.GetNextDate(seriesData[0].value[1], 0)) + ' 00:00:00'
    // var time2 = util.formatDay(util.GetNextDate(seriesData[0].value[1], 1)) + ' 00:00:00'
 
 
    barec.setOption({
      disableTouch: true,
      tooltip: {
        formatter: function (params) {
          // console.log(new Date(params.value[1]).getHours());
          // console.log(params.value[3]);
          //  console.log('111',params)
          return params.name + ': ' + params.value[5] + "小时" + '\n' +
            params.value[4] + ': ' + (new Date(params.value[1]).getHours()) + ":" + (new Date(params.value[1]).getMinutes()) + '\n' +
            params.value[3] + ': ' + (new Date(params.value[2]).getHours()) + ":" + (new Date(params.value[2]).getMinutes());
        }
      },
      title: {
        text: '泵开关机状态表',
        x: 'center',
        y: '7px',
        textStyle: {
          color: '#16b5cb',
          fontSize: 16
        },
        textAlign: 'left'
      },
      grid: {
        left: '17%',
        bottom: '60',
        top: '40',
        right: '4%'
      },
      xAxis: {
        position: 'right',
        type: 'time',
        splitLine: {
          show: false
        },
        // min: +new Date(time1),
        min: minTime,
        max: maxTime,
        // max: +new Date(time2),
        scale: false,
        axisLabel: {
          formatter: function (val) {
            // console.log(val);
            var date = new Date(val);
            var texts = [date.getHours(), date.getMinutes()];
            return texts.join(':');
          }
        }
      },
      yAxis: {
        splitLine: {
          show: false
        },
        axisLabel: {
          interval: 0,
          rotate: 20
        },
        scale: false,
        offset: 2,
        inverse: true,
        data: yAxisData
      },
      series: [{
        type: 'custom',
        renderItem: function (params, api) {
          var categoryIndex = api.value(0);
          var start = api.coord([api.value(1), categoryIndex]);
          var end = api.coord([api.value(2), categoryIndex]);
          var height = (api.size([0, 1])[1] * 0.6) < 40 ? api.size([0, 1])[1] * 0.6 : 40;
          var barLength = end[0] - start[0];
          // var runtime = '开机:' + api.value(5) + '小时';
          var runtime = '';
          var flightNumberWidth = echarts.format.getTextRect(runtime).width;
          var text = api.value(3) == '开启' ? runtime : '';
          text = (barLength > flightNumberWidth) ? text : '';
          var rectShape = echarts.graphic.clipRectByRect({
            x: start[0],
            y: start[1] - height / 2,
            width: end[0] - start[0],
            height: height
          }, {
            x: params.coordSys.x,
            y: params.coordSys.y,
            width: params.coordSys.width,
            height: params.coordSys.height
          });
          return {
            type: 'rect',
            shape: rectShape,
            style: api.style({
              text: text,
              textFill: '#fff'
            })
          };
        },
        itemStyle: {
          opacity: 1
        },
        encode: {
          x: [1, 2],
          y: 0
        },
        data: seriesData
      }]
    })
 
    // console.log(barec,"获取图标配置")
  },
 
  //自定义图表方法
  renderItemFunc: function (params, api) {
    var categoryIndex = api.value(0);
    var start = api.coord([api.value(1), categoryIndex]);
    var end = api.coord([api.value(2), categoryIndex]);
    var height = (api.size([0, 1])[1] * 0.6) < 40 ? api.size([0, 1])[1] * 0.6 : 40;
    var barLength = end[0] - start[0];
    var runtime = '开机:' + api.value(5) + '小时';
    var flightNumberWidth = echarts.format.getTextRect(runtime).width;
    var text = api.value(3) == '开启' ? runtime : '';
    text = (barLength > flightNumberWidth) ? text : '';
    var rectShape = echarts.graphic.clipRectByRect({
      x: start[0],
      y: start[1] - height / 2,
      width: end[0] - start[0],
      height: height
    }, {
      x: params.coordSys.x,
      y: params.coordSys.y,
      width: params.coordSys.width,
      height: params.coordSys.height
    });
    return {
      type: 'rect',
      shape: rectShape,
      style: api.style({
        text: text,
        textFill: '#fff'
      })
    };
  },
  //底部tab切换栏
  tapTab: function (e) {
    var selIndex = e.currentTarget.dataset.index;
    var that = this;
    this.setData({
      currentTabIndex: selIndex
    });
    if (selIndex == 1) { //当选中的下标为1的时候修改图表配置
      setTimeout(function () {
        that.getWorkTime()
      }, 500)
    }
    if (selIndex == 2 && !this.data.isInitialAlarmData) {
 
      this.setData({
        loadingHidden: false,
        isInitialAlarmData: true
      })
      that.getAlarmData(); //调用警报
    }
 
  },
 
  tapProductItem: function (e) {
    // console.log(e.currentTarget.dataset.id)
 
    // wx.navigateTo({
    //  url: '../product/index?id=' + e.currentTarget.dataset.id,
    //})
  },
  refreshRecordValue: function (e) {
    var that = this;
    var allPointId = this.data.allPointId;
    var userInfo = app.globalData.userInfo;
    
    if (allPointId == null || allPointId.length == 0)
      return;
    that.setData({
      loadingHidden: false,
      loadingInfo: "刷新中,请稍等..."
    });
 
    // console.log(allPointId.join(','))
    Request({
      url: Constant.BASE_SERVER_URL + "Monitor/Record/Std/GetLastRecordList@V2.0",
      method: 'GET',
      data: {
        SignalIds : allPointId.join(',')
      },
      header: {
        'content-type': 'application/json'
      },
      fail: function (err) {
        that.setData({
          loadingHidden: true
        });
        wx.showModal({
          title: '',
          content: '通讯失败',
        })
      }, //请求失败
      complete: function () {}, //请求完成后执行的函数
      success: function (res) {
          //  console.log('打印刷新后的数据',res,613);
        that.setData({
          loadingHidden: true
        });
 
        var result = res.data;
        if (result.Code != 0) {
          wx.showModal({
            title: '',
            content: result.Message,
          });
          return;
        }
 
        // 
        var newRecordList = result.Data;
        let runNumber = 0
        // console.log(newRecordList,"新数据");
        if (newRecordList == null)
          return;
 
        var allProductPoints = that.data.allProductPoints;
        for (var p = 0; p < allProductPoints.length; p++) {
          allProductPoints[p].isShowRunStatus = false
          var allRecordList = allProductPoints[p].MonitorList;
          if(allProductPoints[p].RunStatus != "停机"&&allProductPoints[p].RunStatus){
            ++runNumber
          }
          if(allProductPoints[p].RunStatus){
            allProductPoints[p].isShowRunStatus = true
          }
          for (var i = 0; i < allRecordList.length; i++) {
            var r_ds = allRecordList[i];
            for (var j = 0; j < newRecordList.length; j++) {
              // 处理获取的值的小数位的保留
              newRecordList[j].DataValue = util.valueFormat(newRecordList[j].DataValue)
              // 判断测点id是否相同,相同则赋值
              if (r_ds.SignalID == newRecordList[j].SignalID) {
                r_ds.SignalValue =  newRecordList[j].DataValue;
                r_ds.RecordTime = newRecordList[j].DataTime;
                       break;
              }
            }
          }
        }
 
 
        //更新数据
        that.setData({
          allProductPoints: allProductPoints,
          "kpiParas.runNumber":runNumber,
          "kpiParas.status":'正常',
          "kpiParas.alarmNumber":'无',
        });
      }
 
    });
 
  },
  tapeMonitorPoint: function (e) {
    // console.log(e.currentTarget.dataset,653)
    var pointid = e.currentTarget.dataset.pointid;
    // let cronType = e.currentTarget.dataset.crontype; //计划类型暂时不看
    let pointName = e.currentTarget.dataset.pointname;
    let pointUnit = e.currentTarget.dataset.pointunit;
    let formatType= e.currentTarget.dataset.formattype
    let stationName=e.currentTarget.dataset.statitonname
    wx.navigateTo({
      url: '../singlePoint/index?id=' + pointid + '&name=' + pointName + "&unit=" + pointUnit+'&formatType='+formatType+'&stationName='+stationName,
    });
  },
  //刷新警报数据
  tapRefreshAlarm: function () {
    this.setData({ //初始化设置
      bottomStatus: false,
      PageIndex: 1,
      alarmListInfo: []
    })
    this.getAlarmData();
  },
  //警报
  getAlarmData: function () {
    var that = this;
    var alarmListInfo = that.data.alarmListInfo
    wx.showLoading({
      title: '加载中...',
    })
    const endNext=util.formatDay(util.GetNextDate(that.data.endAlarmDate, 1))
    Request({
      url: Constant.BASE_SERVER_URL + "Monitor/Value/Alarm/Record/Std/GetPageListByBelongTypeAndBelongID@V1.0",
      method: 'GET',
      data: {
        BelongType:'logic-site',
        BelongID :that.data.stationID,
        StartTime: that.data.startAlarmDate,
        EndTime: endNext,
        PageIndex: that.data.PageIndex,
        PageSize: that.data.PageSize
      },
      header: {
        'content-type': 'application/json'
      },
      fail: function (err) {
        wx.showModal({
          title: '',
          content: '通讯失败',
        })
      }, //请求失败
      complete: function () {
        that.setData({
          loadingHidden: true
        });
      }, //请求完成后执行的函数
      success: function (res) {
        //  console.log('打印警报信息', res.data)
        wx.hideLoading();
        if (res.data.Code != 0) {
          wx.showModal({
            // title: '获取数据失败',
            title:res.data.Message
          });
          that.setData({
            hasAlarmData: false
          });
          return;
        }
        let result = res.data.Data
        if(result.List==null)
        {
          wx.showToast({
            title: '当前无报警数据',
          });
          that.setData({
            hasAlarmData: false
          });
          return;
        }
        if (result.List.length == 0) {
          wx.showToast({
            title: '当前无报警数据',
          });
          that.setData({
            hasAlarmData: false
          });
          return;
        }
        if (result.Total == 0) {
          that.setData({
            hasAlarmData: false,
            message: '暂无报警数据'
          });
          return;
        }
        if (result == null) {
          that.setData({
            bottomStatus: true,
            message: '暂无报警数据'
          });
          return;
        }
        // console.log(that.data.PageIndex, that.data.PageSize)
        // console.log(that.data.PageIndex * that.data.PageSize)
 
        if (that.data.PageIndex * that.data.PageSize > res.data.Data.Total) {
          let list = res.data.Data.List
          that.setData({
            bottomStatus: true,
            hasAlarmData: false,
            alarmListInfo: alarmListInfo.concat(list)
          })
          return;
        }
        var pageIndex = that.data.PageIndex
        var ListInfo = res.data.Data.List
        // console.log(pageIndex,733)
        //更新数据
        that.setData({
          hasAlarmData: true,
          alarmListInfo: alarmListInfo.concat(ListInfo),
          PageIndex: ++pageIndex 
        });
        // console.log(that.data.alarmListInfo);
      }
    });
  },
  //回到scroll组件顶部
  goTop() {
    this.setData({
      scrollTop: 0
    })
  },
  //scroll组件高度监听
  scrollListView(e) {
    let scrollTop = e.detail.scrollTop
    // 如果超过半屏
    if (scrollTop > this.data.scrollHeight / 2) {
      this.setData({
        isShowFloatMenu: true,
        animationFloatMenu: 'fadeIn'
      })
    } else {
      this.setData({
        isShowFloatMenu: false,
        animationFloatMenu: 'fadeOut'
      })
      // setTimeout(() => {this.setData({visual: false})}, 1000)
    }
  },
  //警报 -- 开始时间选择器
  bindStartAlarmDateChange: function (e) {
    this.setData({
      startAlarmDate: e.detail.value
    })
  },
  //警报 -- 结束时间选择器
  bindEndAlarmDateChange: function (e) {
    this.setData({
      endAlarmDate: e.detail.value
    })
  },
  //展开与收缩
  tapProductName: function (e) {
    var list = this.data.allProductPoints;
    // console.log(list,848)
    var pid = e.currentTarget.dataset.productid;
    // console.log(pid,801)
    for (var i = 0; i < list.length; i++) {
      if (list[i].ID == pid) {
        list[i].IsExpand = !list[i].IsExpand
      }
    }
    this.setData({
      allProductPoints: list
    });
    // console.log(list,364)
  },
  //列表展示更多
  tapMoreMonitor(e) {
    var that = this;
    var allProductPoints = that.data.allProductPoints;
    //var id = e.currentTarget.dataset.id;
    var index = e.currentTarget.dataset.index;
    var product = allProductPoints[index];
    product.isExpandAll = true;
    // console.log(RecordList)
    //allProductPoints[index].RecordList = JSON.parse(JSON.stringify(RecordList).replace(/false/g, "true"));
    //allProductPoints[index].StateMore = "是否展示更多";
 
    var pointids = this.data.allPointId;
    // console.log(pointids,product,825)
    for (var n = 0; n < product.MonitorList.length; n++) {
      var record = product.MonitorList[n];
      if (!record.isDisp) {
        record.isDisp = true;
        pointids.push(record.PointID);
      }
    }
    //console.log(allProductPoints)
    //更新数据
    that.setData({
      allProductPoints: allProductPoints,
      allPointId: pointids
    });
 
    that.refreshRecordValue();
  },
  //警报列表 -- 到底部时加载数据
  lowRefresh: function () {
    var that = this
    if (that.data.bottomStatus == true) {
      return;
    }
    that.getAlarmData()
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
 
  },
 
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    if (this.data.intervalRefreshTime != null)
      clearInterval(this.data.intervalRefreshTime);
  },
 
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
 
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
 
  },
  /** 时间选择器状态 **/
  tapChangeWorkTime(e) {
    var isNextDayAble = true;
    if (e.detail.value == this.data.yestday) {
      isNextDayAble = false;
    }
    this.setData({
      historyDate: e.detail.value,
      isNextDayAble: isNextDayAble
    })
    this.getWorkTime();
  },
  /**返回顶部 */
  goTop() {
    this.setData({
      scrollTop: 0
    })
  },
  scrollListView(e) {
    var that = this;
    let scrollTop = e.detail.scrollTop
    // 如果超过半屏
    if (scrollTop > that.data.scrollHeight / 3.5) {
      that.setData({
        isShowFloatMenu: true,
        animationFloatMenu: 'fadeIn'
      })
    } else {
      that.setData({
        isShowFloatMenu: false,
        animationFloatMenu: 'fadeOut'
      })
      // setTimeout(() => {that.setData({visual: false})}, 1000)
    }
  },
  /**
   * 
   * 屏幕旋转事件
   */
  onResize(res) {
    res.size.windowWidth // 新的显示区域宽度
    res.size.windowHeight // 新的显示区域高度
  },
 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return Constant.Share;
  },
})