riku
2023-12-21 c24a5a2a99515b365ebc343b04538bb862790de1
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
<!-- 点击 ”查看详细” 的对话框 -->
<!-- 上一条下一条由子组件传递给父组件,父组件监听信号 -->
 
<script>
import exceptionOption from '@/utils/chartFunction/exceptionOption.js'
import index from '@/utils/exception_common_function/index.js'
import DustLineChart from '@/views/exception/components/DustLineChart.vue'
import historyApi from '@/api/historyApi.js'
 
export default {
  props: {
    // 表格的一行数据
    row: {
      type: Object,
      default: {}
    },
    // 对话框是否显示
    dialogTableVisible: {
      type: Boolean,
      default: false
    }
  },
  components: {
    DustLineChart
  },
  emits: ['update:dialogTableVisible'],
  computed: {
    dialogTableVisible: {
      get() {
        return this.dialogTableVisible
      },
      set(value) {
        this.$emit('update:dialogTableVisible', value)
      }
    }
  },
  watch: {
    row: {
      handler(newValue) {
        this.display()
      },
      deep: true
    }
  },
  data() {
    return {
      // 异常表格的数据
      historyData: [],
      //  折线图配置项
      lineChartOption: {},
      loading: {
        // 上一条按钮
        preButton: false,
        // 下一条按钮
        afterButton: false,
        // 折线图
        lineChart: false
      },
 
 
      // 标记位
      flag: {
        // 数据加载时 上下条按钮不能再点击
        banTouch: 0,
      },
 
      isPreCantouch:false,
      isNextCantouch:false
 
    }
  },
 
  mounted() {},
  methods: {
    display() {
      // 表格数据
      this.getExceptionTableDataByCurrenrRow(this.row)
 
      // 折线图数据
      this.setLineChart(this.row)
    },
 
    /**
     * 得到异常表格的数据
     * @param: 点位名称,异常开始时间,异常结束时间
     * @returns:
     */
    async getExceptionTableDataByCurrenrRow({ name, beginTime, endTime, exceptionType }) {
      if (!name || !beginTime || !endTime) {
        return
      }
      // 数据缺失异常时,构造表格数据
      if (this.exceptionType == '0') {
        this.setOfflineTbleData(this.row)
        return
      }
 
      // 根据异常的点位名称、开始、结束时间,查询该时段的颗粒物浓度数据
      const response = await historyApi.queryHistoryData({
        siteName: name,
        beginTime: beginTime,
        endTime: endTime
      })
      //  异常表格得到数据
      this.historyData = response.data.data
    },
 
    /* ***********************************************************************************  折线图 */
    /**
     * 设置折线图
     * @param:
     * @returns:
     */
    async setLineChart({ beginTime, endTime }) {
      // 计算异常区间的前后45分钟
      const beforeAndAfterTime = index.before45AndAfter45(beginTime, endTime)
      // 请求整段时间段的颗粒物浓度数据
     
 
      // 对请求回的数据进行划分
      const chartParams = await this.organizeLineChartsOptionParams(beforeAndAfterTime, this.row)
      this.lineChartOption = exceptionOption.setExceptionChartOption(chartParams)
 
    },
 
 
 
    /**
     * 构建折线图的配置项的参数
     * @param: 异常区间前后数据时间点, 表格当前行数据
     * @returns:
     */
    async organizeLineChartsOptionParams(
      time_point,
      { name, beginTime, endTime, exception, exceptionType }
    ) {
      // 折线图加载中效果
      this.loading.lineChart = true
 
      // 请求整段颗粒物浓度的数据
      const response = await historyApi.queryHistoryData({
        siteName: name,
        beginTime: time_point[0],
        endTime: time_point[3]
      })
 
      // 异常区间数据加上前后45分钟数据
      const allTimeData = response.data.data
 
      // x轴日期时间
      let xData = []
      // y轴 超标油烟浓度
      let yData = []
      let timeAndValue = {}
 
      // 从添加了首位区间的开始和结束时间进行遍历 保证时间以15分钟为间隔
      timeAndValue = index.keepContinuousByEachFiftyMinutes(
        time_point[0],
        time_point[3],
        allTimeData
      )
      xData = timeAndValue['xAxis']
      yData = timeAndValue['yAxis']
 
      // 提取异常起始时间点在整个区间内的数据索引
      let beginIndex = xData.findIndex((item) => item === beginTime)
      let endIndex = xData.findIndex((item) => item === endTime)
 
      this.flag.banTouch = 0
      this.loading.lineChart = false
 
      // 返回折线图的配置项的参数
      return {
        xData,
        yData,
        exceptionBeginTime: beginTime,
        exceptionEndTime: endTime,
        beginIndex,
        endIndex,
        exceptionName: exception,
        areaObj: '',
        lineColor: '',
        exceptionType
      }
    },
 
    /**
     * description:数据缺失异常时,设置的表格数据
     */
    setOfflineTbleData({ name, mnCode, dutyCompany, beginTime, endTime }) {
      // 无数据时的时间数组 时间相差15分钟
      const abnormalTimeTenMinute = index.descFiftyTime(beginTime, endTime)
 
      //  对表格数据进行重构
      this.historyData = []
      for (let i = 0; i < abnormalTimeTenMinute.length; i++) {
        this.historyData.push({
          name: name,
          mnCode: mnCode,
          dutyCompany: dutyCompany,
          lst: abnormalTimeTenMinute[i],
          yData: ''
        })
      }
    }
  }
}
</script>
 
<template>
  <el-dialog
    class="exception-dialog"
    v-model="dialogTableVisible"
    draggable
    align-center
    height="700px"
    width="700px"
  >
 
 
    <!-- 头 -->
    <template #header>
      <div class="diag-head">
        <div class="diag-head-text">
          <div><span class="diag-head-text1">站点名称:</span>{{ row.name }}</div>
          <div><span class="diag-head-text1">设备编号:</span>{{ row.mnCode }}</div>
          <div><span class="diag-head-text1">运维商:</span>{{ row.dutyCompany }}</div>
          <div>
            <span class="diag-head-text1">异常时间段:</span>{{ row.beginTime }} ~
            {{ row.endTime }}
          </div>
        </div>
      </div>
      
 
      <!-- <div class="chart-jump-button">
        <el-button
          type="danger"
          :loading="loading.preButton"
          :disabled="isPreCantouch || flag.banTouch"
          @click="getNextRowData"
          >上条异常</el-button
        >
        <el-button
          type="danger"
          :loading="loading.afterButton"
          :disabled="isNextCantouch || flag.banTouch"
          @click="getPreviousRowData"
          >下条异常</el-button
        >
      </div> -->
 
 
    </template>
 
 
    <!-- 图形 -->
    <DustLineChart :option="lineChartOption" v-loading="loading.lineChart"></DustLineChart>
 
    <!-- 表格 -->
    <div>
      <el-table :data="historyData" size="default" height="200" border>
        <el-table-column
          type="index"
          label="序号"
          width="60px"
          align="center"
          fixed
        ></el-table-column>
 
        <el-table-column prop="lst" label="采集时间" align="center" show-overflow-tooltip />
        <el-table-column prop="yData" label="TSP(mg/m³)" align="center" show-overflow-tooltip />
        <el-table-column prop="flag" label="数据标识" align="center" show-overflow-tooltip />
      </el-table>
    </div>
 
    <template #footer>
      <div class="dialog-footer">
        <el-tag type="success" class="mx-1" effect="dark" round
          ><span class="table-line-lable" v-show="row.exceptionType == '0'">缺失数据: </span>
          <span
            v-show="
              row.exceptionType == '1' ||
              row.exceptionType == '2' ||
              row.exceptionType == '3' ||
              row.exceptionType == '4' ||
              row.exceptionType == '5' ||
              row.exceptionType == '6' ||
              row.exceptionType == '7' ||
              row.exceptionType == '8'
            "
            >异常数据:</span
          >
          <span class="table-line-num">{{ historyData.length }}条</span>
          <span v-show="row.exceptionType == '0'"> (逻辑计算)</span>
        </el-tag>
        <el-text v-show="row.exceptionType == '8'" type="warning" class="dialog-footer-text"
          >数据标识A为数据长期缺失,系统自动补全</el-text
        >
      </div>
    </template>
 
 
  </el-dialog>
</template>
 
<style scoped>
/* 查看详情对话框模块的样式 */
 
.diag-head {
  /* 对话框头部区域 */
  min-height: 200px;
}
.diag-head-text1 {
  /* 对话框头部的属性字段加粗 */
  font-weight: bold;
}
 
.diag-head-text > div {
  /*  对话框异常时间段 */
  margin-top: 15px;
}
.diag-head-text {
  margin: 10px;
  padding: 10px;
  background: linear-gradient(90deg, #00c9ff 0%, #92fe9d 100%);
  border: 2px solid #7bc0fc;
}
.chart-jump-button {
  display: flex;
  justify-content: right;
}
 
.mx-1 {
  /* position: absolute;
  left: 10px;
  bottom: 10px; */
  justify-content: flex-start;
}
.dialog-footer {
  display: flex;
}
.dialog-footer-text {
  justify-content: flex-end;
  margin-left: auto;
  font-size: 14px;
  /* color: #333333; */
}
/* 查看详情对话框模块结束 */
</style>