zhaowei
2025-04-10 a41fc1ec8d3aa557b22a690c61537c7e177fed74
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
<template>
  <div ref="workChart">
    <a-modal :title="title" :getContainer="() => this.$refs.workChart" width="80%" wrap-class-name="full-modal"
             :footer="null" :visible="visible"
             @cancel="handleCancel" cancelText="关闭">
      <div>
        <div>
          <a-row :gutter="24">
            <a-col :span="6">
              <a-form-item label="设备编号" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input placeholder="输入设备编号查询" :readOnly="readOnly" v-model="queryParams.equipmentId"></a-input>
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item label="日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-date-picker v-model="queryParams.paramDate" :disabledDate="disabledDate" format='YYYY-MM-DD'/>
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-item label="采样周期" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input-number v-model="queryParams.period"/>
              </a-form-item>
            </a-col>
          </a-row>
          <a-row :gutter="24">
            <a-col :span="6">
              <a-form-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <a-input placeholder="输入设备名称查询" :readOnly="readOnly" v-model="queryParams.equipmentName"></a-input>
              </a-form-item>
 
            </a-col>
            <a-col :span="10">
              <a-form-item label="时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
                <div class="params_time">
                  <a-time-picker :open="stratOpen" format="HH:mm" @openChange="timeHandleChange('start')"
                                 v-model="queryParams.start">
                    <a-button slot="addon" size="small" type="primary" @click="timeHandleClose('start')">
                      确定
                    </a-button>
                  </a-time-picker>
                  <a-time-picker :open="endOpen" format="HH:mm" @openChange="timeHandleChange('end')"
                                 v-model="queryParams.end">
                    <a-button slot="addon" size="small" type="primary" @click="timeHandleClose('end')">
                      确定
                    </a-button>
                  </a-time-picker>
                </div>
              </a-form-item>
            </a-col>
            <a-col :span="4">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            </a-col>
          </a-row>
 
        </div>
        <div class="checkboxgroup">
          <p>统计参数</p>
          <div class="checkboxgroup_con">
            <a-checkbox-group name="checkboxgroup" :value="option" :options="plainOptions" @change="checkboxOnChange"/>
          </div>
        </div>
 
 
        <a-spin :spinning="spinning">
          <div id="workChart" style="width:85%;height: 500px;"/>
        </a-spin>
      </div>
    </a-modal>
  </div>
</template>
 
<script>
  import moment from 'moment'
  import * as echarts from 'echarts'
  import {
    getAction,
    postAction
  } from '@/api/manage'
  import {
    duplicateCheck
  } from '@/api/api'
 
  export default {
    name: 'WorkChartModel',
    components: {},
    props: {
      collectTime: {
        type: Object
      },
      equipment: {
        type: Object
      }
    },
    watch: {
      // 监控父组件点击左右箭头切换的时间值将其赋给点击工作曲线后的时间选择器的值
      collectTime: {
        handler(newVal) {
          this.currentToggledTime = newVal
        }
      }
    },
    data() {
      return {
        spinning: false,
        labelCol: {
          xs: {
            span: 24
          },
          sm: {
            span: 6
          }
        },
        wrapperCol: {
          xs: {
            span: 24
          },
          sm: {
            span: 18
          }
        },
        readOnly: true,
        title: '',
        plainOptions: [],
        option: [],
        workChart: '',
        node: {},
        stratOpen: false,
        endOpen: false,
        visible: false,
        show: false,
        queryParams: {},
        panduanResult: [],
        url: {
          initPlainOptions: '/mdc/mdcDriveTypeParamConfig/findWorkCurveParamList',
          workChart: '/mdc/mdcEquipmentRunningSection/workChart'
        },
        currentToggledTime: '',
        isClicklogListRow: false
      }
    },
    created() {
      this.$bus.$on('tableRowRecord', this.getLogListRowRecord)
    },
    mounted() {
 
    },
    methods: {
      disabledDate(current) {
        //Can not slect days before today and today
        return current && current > moment().endOf('day')
      },
      initPlainOptions(param) {
        let that = this
        let equipment = param.equipmentId
        getAction(this.url.initPlainOptions, { equipmentId: equipment }).then((res) => {
          if (res.success) {
            let temp = []
            // debugger
            for (var item of res.result) {
              temp.push({ label: item.chineseName, value: item.id, englishName: item.englishName })
            }
            that.plainOptions = temp
            if (temp.length > 0) {
              that.option = [temp[0].value]
            }
            let param = {
              driveType: that.node.driveType,
              equipmentId: that.node.equipmentId,
              date: that.queryParams.paramDateStr,
              start: that.queryParams.startStr,
              end: that.queryParams.endStr,
              interval: that.queryParams.period,
              codeTypeId: that.option.join(',')
            }
            that.initChart(param)
          }
        })
      },
      searchQuery() {
        this.queryParams.paramDateStr = this.queryParams.paramDate.format('yyyy-MM-DD')
        this.queryParams.startStr = this.queryParams.start.format('HH:mm')
        this.queryParams.endStr = this.queryParams.end.format('HH:mm')
        let param = {
          driveType: this.node.driveType, equipmentId: this.node.equipmentId,
          date: this.queryParams.paramDateStr, start: this.queryParams.startStr,
          end: this.queryParams.endStr, interval: this.queryParams.period,
          codeTypeId: this.option.join(',')
        }
        this.initChart(param)
        this.spinning = true
      },
      timeHandleChange(val) {
        if (val == 'start') {
          this.stratOpen = true
        } else {
          this.endOpen = true
        }
      },
      timeHandleClose(val) {
        if (val == 'start') {
          this.stratOpen = false
          this.endOpen = true
        } else {
          this.endOpen = false
        }
      },
      add(node) {
        let _this = this
        this.visible = true
        this.node = node
        this.spinning = true
        let paramDate
        let start
        let end
        // 当没有切换过时间currentToggledTime的值为空值,如果由于点击左右箭头切换过时间,则currentToggledTime为切换后的时间
        if (!this.currentToggledTime) {
          paramDate = moment()
        } else {
          paramDate = this.currentToggledTime
        }
        // 判断是否点击设备日志表格行的数据,若点击表格数据则显示表格数据中的时间,若点击工作曲线图片则显示0点至当前时间数据
        if (this.isClicklogListRow) {
          start = node.start
          end = node.end
        } else {
          start = moment('0:0', 'HH:mm')
          end = moment(moment().format('HH:mm'), 'HH:mm')
        }
        this.queryParams = {
          equipmentId: node.equipmentId,
          equipmentName: node.equipmentName,
          period: 100,
          paramDate: paramDate,
          paramDateStr: paramDate.format('yyyy-MM-DD'),
          start: start,
          startStr: start.format('HH:mm'),
          end: end,
          endStr: end.format('HH:mm')
        }
        this.$nextTick(() => {
          _this.initPlainOptions(node)
        })
      },
      handleCancel() {
        this.visible = false
        this.stratOpen = false
        this.endOpen = false
      },
      checkboxOnChange(e) {
        if (e.length <= 3) {
          this.option = e
        } else {
          // this.$message.warn('最多只能选择3个')
          this.$notification.warning({
            message: '消息',
            description: '最多只能选择三个'
          })
          return false
        }
      },
      close() {
        this.visible = false
        this.show = false
      },
      getYAxisOffset(index) {
        return index * 50 + 10
      },
      initChart(param) {
        if (!this.workChart) {
          this.workChart = echarts.init(document.getElementById('workChart'))
        }
        let option = {
          tooltip: {
            trigger: 'axis',
            position: function(pt) {
              return [pt[0], '10%']
            }
          },
          legend: {
            data: []
          },
          title: {
            left: 'center',
            text: ''
          },
          toolbox: {
            feature: {
              dataZoom: {
                yAxisIndex: 'none'
              },
              restore: {},
              saveAsImage: {}
            }
          },
          grid: {
            left: '8%',
            top: '10%',
            right: '2%',
            bottom: '14%',
            containLabel: true
          },
          xAxis: {
            type: 'time',
            boundaryGap: false
          },
          yAxis: [
            {
              yAxisIndex: 0,
              type: 'value',
              offset: 0,
              position: 'left',
              boundaryGap: [0, '15%'],
              axisLine: {
                show: true,
                lineStyle:{
                  color:'#5470C6'
                }
              }
            },
            {
              yAxisIndex: 1,
              type: 'value',
              offset: 60,
              position: 'left',
              boundaryGap: [0, '15%'],
              axisLine: {
                show: true,
                lineStyle:{
                  color:'#91CC75'
                }
              }
            },
            {
              yAxisIndex: 2,
              type: 'value',
              offset: 120,
              position: 'left',
              boundaryGap: [0, '15%'],
              axisLine: {
                show: true,
                lineStyle:{
                  color:'#FAC858'
                }
              }
            }
          ],
          dataZoom: [
            {
              type: 'inside',
              start: 0,
              end: 20
            },
            {
              start: 0,
              end: 20
            }
          ],
          series: [
            {
              showSymbol: true,
              symbolSize: 20,
              label: 'show',
              name: '',
              type: 'line',
              data: [],
              smooth: true,
              symbol: 'none'
            }
          ]
        }
        let _this = this
        let temp = []
        for (let i = 0; i < this.plainOptions.length; i++) {
          let item = this.plainOptions[i]
          if (this.option.indexOf(item.value) > -1) {
            temp.push(item)
          }
        }
        console.log('temp',temp)
        getAction(this.url.workChart, param).then((res) => {
          if (JSON.stringify(res.result) == '[]' || res.result == null) {
            // this.$message.warning('无数据!')
            this.$notification.warning({
              message: '消息',
              description: '无数据!'
            })
            this.spinning = false
            _this.workChart.setOption(option, true)
          } else {
            this.spinning = false
            // debugger
            let result = []
            let itemLine = []
            //y轴数组
            var Yarr = []
            var lengenddata = []
            for (let i = 0; i < temp.length; i++) {
              let item = temp[i]
              itemLine = []
              for (let m = 0; m < res.result.length; m++) {
                let d = []
                d.push(res.result[m].collectTime)
                // debugger
                d.push(res.result[m][item.englishName])
                itemLine.push(d)
              }
              var lll = {
                name: item.label
              }
              lengenddata.push(lll)
              var Yline = {
                name: item.label,
                type: 'value',
                yAxisIndex: i,
                boundaryGap: [0, '100%']
              }
              Yarr.push(Yline)
              var line = {
                name: item.label,
                type: 'line',
                // areaStyle:{},
                smooth: true,
                symbol: 'circle',
                symbolSize: 10,
                yAxisIndex: i,
                data: itemLine
              }
              result.push(line)
 
            }
            console.log('result===========',result)
            console.log('legend=============',lengenddata)
            // option.yAxis = Yarr;
            option.series = result
            option.legend = lengenddata
            // console.log(option);
            _this.workChart.setOption(option, true)
            window.addEventListener('resize', function() {
              _this.workChart.resize()
            })
          }
 
        })
      },
      /**
       * 获取点击设备日志表格行后从兄弟组件传来的时间对象
       * @param timeObj 当前行的开始时间与结束时间组成的对象
       */
      getLogListRowRecord(timeObj) {
        // 判断是否点击设备日志表格行的数据,此时为点击表格数据为true
        this.isClicklogListRow = true
        // 合并父组件传来的当前设备信息对象与兄弟组件传来的当前行的时间对象
        const newQueryParams = Object.assign(this.equipment, timeObj)
        this.add(newQueryParams)
        this.title = '工作曲线'
      }
    }
  }
</script>
 
<style scoped lang="less">
  .full-modal {
    .ant-modal {
      max-width: 100%;
      top: 0;
      padding-bottom: 0;
      margin: 0;
    }
    .ant-modal-content {
      display: flex;
      flex-direction: column;
      height: calc(100vh);
    }
    .ant-modal-body {
      flex: 1;
    }
  }
 
  /deep/ .ant-modal {
    /*background-color: #000;*/
    /*color: #fff;*/
  }
 
  /deep/ .ant-modal-header {
    /*background-color: #000;*/
  }
 
  /deep/ .ant-modal-title {
    /*color: #fff;*/
  }
 
  /deep/ .ant-modal-close {
    color: #1191b0;
    font-size: 24px;
  }
 
  /deep/ .ant-modal-content {
    /*background: -moz-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.27) 100%);*/
    /*background: -webkit-gradient(linear, left left, right right, color-stop(0%, rgba(0, 0, 0, 0.66)), color-stop(100%, rgba(0, 0, 0, 0.4)));*/
    /*background: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background: -o-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background: -ms-linear-gradient(left, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background: linear-gradient(to right, rgba(0, 0, 0, 0.66) 0%, rgba(0, 0, 0, 0.4) 100%);*/
    /*background-color: #000;*/
    /*color: #fff;*/
    position: relative;
  }
 
  /deep/ .ant-modal-header {
    /*border-bottom: none!important;*/
  }
 
  /deep/ .ant-checkbox-wrapper {
    /*color: #fff;*/
  }
 
  /deep/ .ant-form-item-label label {
    /*color: #fff;*/
  }
 
  /deep/ .ant-btn {
    /*position: absolute;*/
 
  }
 
  .checkboxgroup {
    position: absolute;
    right: 5%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
  }
 
  /deep/ .ant-checkbox-group {
    display: flex;
    flex-direction: column;
  }
 
  /deep/ .ant-checkbox-group .ant-checkbox-wrapper {
    padding: 10px;
  }
 
  .con_btn {
    display: flex;
    align-items: center;
  }
 
  .workChart_params {
    display: flex;
    /*align-items: center;*/
    flex-direction: column;
    float: left;
  }
 
  .workChart_params .params_one {
    display: flex;
    justify-content: space-between;
  }
 
  .workChart_params .params_two {
    display: flex;
    justify-content: space-between;
  }
 
  /deep/ .workChart_params .ant-form-item {
    display: flex;
  }
 
  /deep/ .workChart_params .ant-form-item .ant-form-item-control-wrapper {
    margin: 0 10px;
  }
 
  .ant-btn {
    padding: 0 10px;
    margin-left: 3px;
  }
 
  .ant-form-item-control {
    line-height: 0px;
  }
 
  /** 主表单行间距 */
  .ant-form .ant-form-item {
    margin-bottom: 10px;
  }
 
  /** Tab页面行间距 */
  .ant-tabs-content .ant-form-item {
    margin-bottom: 0px;
  }
</style>