Blame view

HHECS.Web/src/views/main/components/TaskCompensation.vue 13.4 KB
王硕 authored
1
2
<template>
  <div class="task-compensation">
王硕 authored
3
4
5
    <el-row :gutter="20">
      <!-- 左侧区域 -->
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
王硕 authored
6
        <div>
王硕 authored
7
8
9
10
          <el-row :gutter="20">
            <!-- 执行线程 -->
            <el-col :span="24">
              <el-card>
王硕 authored
11
                <div slot="header" class="zhx">
12
                  <span class="title-text">{{ $t("main.eALogging.executionThread") }}</span>
王硕 authored
13
                  <div>
王硕 authored
14
15
16
17
18
                    <el-button
                      type="primary"
                      size="small"
                      icon="el-icon-refresh"
                      @click="getZxxctableData"
19
                      >{{ $t("main.eALogging.schedulingProgramReset") }}</el-button
王硕 authored
20
21
22
23
24
                    >
                  </div>
                </div>
                <el-table
                  :data="zxxctableData"
25
                  :empty-text="$t('main.eALogging.noData')"
王硕 authored
26
                  border
王硕 authored
27
                  :height="leftTableHeight"
王硕 authored
28
29
30
31
32
                  style="width: 100%"
                  :cell-style="{ color: '#000' }"
                  stripe
                  highlight-current-row
                >
33
                  <el-table-column prop="code" :label="$t('main.eALogging.threadTagging')" width="220">
王硕 authored
34
                  </el-table-column>
35
                  <el-table-column prop="status" :label="$t('main.eALogging.executionStatus')">
王硕 authored
36
                  </el-table-column>
37
                  <el-table-column prop="time" :label="$t('main.eALogging.timeConsuming')">
王硕 authored
38
39
40
41
                    <template slot-scope="scope">
                      {{ scope.row.time }} ms
                    </template>
                  </el-table-column>
42
                  <el-table-column prop="remark" :label="$t('main.eALogging.notes')">
王硕 authored
43
                  </el-table-column>
王硕 authored
44
45
                  <el-table-column
                    prop="equipmentCodes"
46
                    width="2000"
47
                    :label="$t('main.eALogging.associatedDevices')"
王硕 authored
48
                  >
王硕 authored
49
50
51
52
53
54
                  </el-table-column>
                </el-table>
              </el-card>
            </el-col>

            <!-- 诊断 -->
王硕 authored
55
            <el-col :span="24" style="margin-top: 10px">
王硕 authored
56
              <el-card>
王硕 authored
57
                <div slot="header" class="zhx">
58
                  <span class="title-text">{{ $t("main.eALogging.diagnosis") }}</span>
王硕 authored
59
                  <div>
王硕 authored
60
61
62
63
64
                    <el-button
                      type="primary"
                      size="small"
                      icon="el-icon-refresh-left"
                      @click="zhengdauntableData"
65
                      >{{ $t("main.eALogging.schedulingDiagnosis") }}</el-button
王硕 authored
66
67
68
69
70
71
                    >
                    <el-button
                      type="primary"
                      size="small"
                      icon="el-icon-delete-solid"
                      @click="clearLog"
72
                      >{{ $t("main.eALogging.diagnosticLogClearing") }}</el-button
王硕 authored
73
74
75
76
                    >
                  </div>
                </div>
                <el-table
77
                  :empty-text="$t('main.eALogging.noData')"
王硕 authored
78
79
                  :data="eqBjtableData"
                  border
王硕 authored
80
                  :height="leftTableHeight"
王硕 authored
81
                  style="width: 100%"
王硕 authored
82
                  :cell-style="{ color: '#fff' }"
王硕 authored
83
84
                  :row-class-name="tableZDRowClassName"
                  fit
王硕 authored
85
86
87
88
89
                  :default-sort="{ prop: 'time', order: 'descending' }"
                >
                  <el-table-column
                    sortable
                    prop="time"
90
                    :label="$t('main.eALogging.diagnosisTime')"
王硕 authored
91
92
93
                    width="180"
                  >
                  </el-table-column>
94
                  <el-table-column prop="level" :label="$t('main.eALogging.logLevel')" width="120">
王硕 authored
95
96
97
                    <template slot-scope="scope">
                      {{ levelMap[scope.row.level] || "未知" }}
                    </template>
王硕 authored
98
                  </el-table-column>
王硕 authored
99
100
                  <el-table-column
                    prop="content"
101
                    :label="$t('main.eALogging.logContent')"
王硕 authored
102
103
                    min-width="1200"
                  >
王硕 authored
104
105
106
107
108
                    <template slot-scope="scope">
                      <div style="white-space: nowrap">
                        {{ scope.row.content }}
                      </div>
                    </template>
王硕 authored
109
110
111
112
113
                  </el-table-column>
                </el-table>
              </el-card>
            </el-col>
          </el-row>
王硕 authored
114
        </div>
王硕 authored
115
116
117
118
119
120
      </el-col>

      <!-- 右侧区域 -->
      <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
        <el-card>
          <div slot="header" class="clearfix">
121
            <span class="title-text">{{ $t("main.eALogging.dispatchingLog") }}</span>
王硕 authored
122
          </div>
王硕 authored
123
          <el-table
王硕 authored
124
            :data="
王硕 authored
125
              dDtableData
王硕 authored
126
王硕 authored
127
              /*.slice(
王硕 authored
128
129
                (currentPage - 1) * pageSize,
                currentPage * pageSize
王硕 authored
130
131
                )
              */
王硕 authored
132
            "
133
            :empty-text="$t('main.eALogging.noData')"
王硕 authored
134
            :height="rightTableHeight"
王硕 authored
135
            style="width: 100%"
王硕 authored
136
            :cell-style="{ color: '#fff' }"
王硕 authored
137
138
            :row-class-name="tableRowClassName"
            :default-sort="{ prop: 'time', order: 'descending' }"
王硕 authored
139
            fit
王硕 authored
140
          >
王硕 authored
141
142
143
144
            <el-table-column
              flexd
              sortable
              prop="time"
145
              :label="$t('main.eALogging.time')"
王硕 authored
146
147
              width="180"
            >
王硕 authored
148
            </el-table-column>
王硕 authored
149
150
            <el-table-column
              prop="type"
151
              :label="$t('main.eALogging.classification')"
王硕 authored
152
153
154
155
              width="180"
              sortable
              :sort-method="sortByType"
            >
王硕 authored
156
            </el-table-column>
157
            <el-table-column prop="bllResultCode" :label="$t('main.eALogging.processingResults')">
王硕 authored
158
159
160
              <template slot-scope="scope">
                {{ bllResultCodeMap[scope.row.bllResultCode] || "未知" }}
              </template>
王硕 authored
161
            </el-table-column>
162
            <el-table-column prop="equipmentCode" :label="$t('main.eALogging.device')">
王硕 authored
163
            </el-table-column>
164
            <el-table-column prop="description" :label="$t('main.eALogging.describe')" width="1200">
王硕 authored
165
166
167
168
169
              <template slot-scope="scope">
                <div style="white-space: nowrap">
                  {{ scope.row.description }}
                </div>
              </template>
王硕 authored
170
            </el-table-column>
171
            <el-table-column prop="errorCode" :label="$t('main.eALogging.errorCode')">
王硕 authored
172
173
            </el-table-column>
          </el-table>
王硕 authored
174
          <!-- <el-pagination
王硕 authored
175
            style="margin-top: 15px"
王硕 authored
176
177
178
179
180
181
182
183
            align="center"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[1, 5, 10, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="dDtableData.length"
王硕 authored
184
          /> -->
王硕 authored
185
186
187
        </el-card>
      </el-col>
    </el-row>
王硕 authored
188
189
190
191
  </div>
</template>

<script>
王硕 authored
192
import {
王硕 authored
193
194
195
196
  GetExecuteDetail,
  GetExecuteLogs,
  GetExecutorDiagnosisInfo,
  ResetExecute,
王硕 authored
197
} from "@/api/main";
王硕 authored
198
199
export default {
  name: "TaskCompensation",
王硕 authored
200
王硕 authored
201
  data() {
王硕 authored
202
    return {
王硕 authored
203
204
205
206
      zxxctableData: [],
      eqBjtableData: [],
      dDtableData: [],
      timer: null,
王硕 authored
207
208
209
      currentPage: 1,
      total: 100,
      pageSize: 10,
王硕 authored
210
      bllResultCodeMap: {
weijuan55650@qq.com authored
211
212
213
214
215
216
        0: this.$t("main.msg.interactive"),
        1: this.$t("main.msg.error"),
        2: this.$t("main.msg.callThePolice"),
        200: this.$t("main.msg.success"),
        201: this.$t("main.msg.abnormal"),
        202: this.$t("main.msg.fail"),
王硕 authored
217
218
      },
      levelMap: {
weijuan55650@qq.com authored
219
220
221
222
223
224
225
226
        0: this.$t("main.msg.interactive"),
        1: this.$t("main.msg.error"),
        2: this.$t("main.msg.callThePolice"),
        200: this.$t("main.msg.success"),
        201: this.$t("main.msg.abnormal"),
        202: this.$t("main.msg.fail"),
        401: this.$t("main.msg.unauthorized"),
        403: this.$t("main.msg.prohibitAccess"),
王硕 authored
227
      },
王硕 authored
228
229
230
    };
  },
  methods: {
王硕 authored
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
    sortByType(a, b) {
      // 定义分类优先级
      const typePriority = {
        失败: 1,
        异常: 1,
        报警: 2,
        成功: 3,
      };

      // 获取分类的优先级,如果没有定义则默认为4(排在最后)
      const priorityA = typePriority[a.type] || 4;
      const priorityB = typePriority[b.type] || 4;

      // 先按分类优先级排序
      if (priorityA !== priorityB) {
        return priorityA - priorityB;
      }

      // 如果优先级相同,则按时间降序排序
      return new Date(b.time) - new Date(a.time);
    },
王硕 authored
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
    tableRowClassName({ row, rowIndex }) {
      if (row.bllResultCode === 0) {
        return "white-row";
      } else if (row.bllResultCode === 1) {
        return "red-row";
      } else if (row.bllResultCode === 2) {
        return "yellow-row";
      } else if (row.bllResultCode === 200) {
        return "green-row";
      } else if (row.bllResultCode === 201) {
        return "red-row";
      } else if (row.bllResultCode === 202) {
        return "red-row";
      }
      return "";
    },
王硕 authored
268
269
270
271
272
273
274
275
276
277
278
279
280
    tableZDRowClassName({ row, rowIndex }) {
      if (row.level === 0) {
        return "white-row";
      } else if (row.level === 1) {
        return "red-row";
      } else if (row.level === 2) {
        return "yellow-row";
      } else if (row.level === 200) {
        return "green-row";
      } else if (row.level === 201) {
        return "red-row";
      } else if (row.level === 202) {
        return "red-row";
王硕 authored
281
282
283
284
      } else if (row.level === 401) {
        return "white-row";
      } else if (row.level === 403) {
        return "red-row";
王硕 authored
285
286
287
      }
      return "";
    },
王硕 authored
288
    getZxxctableData() {
王硕 authored
289
      ResetExecute().then((res) => {
weijuan55650@qq.com authored
290
        console.log(this.$t("main.msg.reset"), res);
王硕 authored
291
292
        if (res.code == "Success") {
          this.$message({
weijuan55650@qq.com authored
293
            message: this.$t("main.msg.schedulerReset"),
王硕 authored
294
295
296
297
298
299
300
301
            type: "success",
          });
          this.zxxctableData = [];
          this.eqBjtableData = [];
          this.dDtableData = [];
          this.currentPage = 1;
          this.pageSize = 10;
        }
王硕 authored
302
303
304
305
      });
    },

    GetExecuteDetail() {
王硕 authored
306
      GetExecuteDetail().then((res) => {
weijuan55650@qq.com authored
307
        console.log(this.$t("main.msg.executionThread"), res); // 确保这里能打印出数据
王硕 authored
308
309
310
311
        if (res.code == "Success") {
          this.zxxctableData = res.data;
        }
      });
王硕 authored
312
313
314
    },
    GetExecutorDiagnosisInfo() {
      GetExecutorDiagnosisInfo().then((res) => {
weijuan55650@qq.com authored
315
        console.log(this.$t("main.msg.diagnosis"), res);
王硕 authored
316
317
318
319
320
321
322
323
324
325
        if (res.code == "Success") {
          this.eqBjtableData = res.data;
        }
      });
    },
    clearLog() {
      this.eqBjtableData = [];
    },
    zhengdauntableData() {
      this.$message({
weijuan55650@qq.com authored
326
        message: this.$t("main.msg.scheDiagnosis"),
王硕 authored
327
328
329
330
331
332
        type: "success",
      });
      this.GetExecutorDiagnosisInfo();
    },
    GetExecuteLogs() {
      GetExecuteLogs().then((res) => {
weijuan55650@qq.com authored
333
        console.log(this.$t("main.msg.dispatLog"), res);
王硕 authored
334
        if (res.code == "Success") {
王硕 authored
335
336
          // 截取最新的 100 条数据
          this.dDtableData = res.data.slice(-100);
王硕 authored
337
338
        }
      });
王硕 authored
339
    },
王硕 authored
340
王硕 authored
341
342
343
344
    handleSizeChange(val) {
      this.currentPage = 1;
      this.pageSize = val;
    },
王硕 authored
345
王硕 authored
346
347
348
    handleCurrentChange(val) {
      this.currentPage = val;
    },
王硕 authored
349
    start() {
王硕 authored
350
351
      this.GetExecuteDetail();
      this.GetExecuteLogs();
王硕 authored
352
353
354
355
356
357
358
359
      this.timer = setInterval(() => {
        this.GetExecuteDetail();
        this.GetExecuteLogs();
      }, 3000);
    },
    stop() {
      clearInterval(this.timer);
      this.timer = null;
王硕 authored
360
361
      this.currentPage = 1;
      this.pageSize = 10;
王硕 authored
362
    },
王硕 authored
363
  },
王硕 authored
364
  created() {
王硕 authored
365
366
367
    // this.GetExecuteDetail();
    // this.GetExecuteLogs();
    // this.start();
王硕 authored
368
  },
王硕 authored
369
  mounted() {},
王硕 authored
370
  beforeDestroy() {
王硕 authored
371
    clearInterval(this.timer);
王硕 authored
372
  },
王硕 authored
373
374
375
376
377
378
379
380
  computed: {
    leftTableHeight() {
      return `calc((100vh - 410px) / 2)`;
    },
    rightTableHeight() {
      return `calc(100vh - 325px )`;
    },
  },
王硕 authored
381
382
383
384
385
};
</script>

<style lang="scss" scoped>
.task-compensation {
王硕 authored
386
  box-sizing: border-box !important;
387
}
王硕 authored
388
王硕 authored
389
390
.title-text {
  color: rgb(64, 133, 212);
王硕 authored
391
}
王硕 authored
392
.el-card {
王硕 authored
393
  height: 100%;
王硕 authored
394
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
王硕 authored
395
396
397
398
399
400
401
  .el-table {
    // flex: 1;

    ::v-deep .el-table__body-wrapper {
      overflow-y: auto !important;
    }
  }
王硕 authored
402
}
王硕 authored
403
王硕 authored
404
.zhx,
王硕 authored
405
.clearfix {
王硕 authored
406
  height: 30px;
王硕 authored
407
408
409
  display: flex;
  justify-content: space-between;
  align-items: center;
王硕 authored
410
411
}
王硕 authored
412
.title-text {
王硕 authored
413
  margin-top: 10px;
王硕 authored
414
}
王硕 authored
415
</style>
王硕 authored
416
王硕 authored
417
<style lang="scss" scoped>
王硕 authored
418
419
420
421
// 禁用表格行悬停效果
::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: inherit !important;
}
王硕 authored
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
// 自定义滚动条样式
::v-deep .el-table__body-wrapper {
  overflow: hidden;
}

::v-deep .el-table__body-wrapper:hover {
  overflow: auto;
}

::v-deep .el-table__body-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
  background-color: #777f87;
  border-radius: 4px;
}

::v-deep .el-table__body-wrapper::-webkit-scrollbar-track {
  background-color: #f5f5f5;
}
</style>

<style lang="scss" scoped>
王硕 authored
447
448
449
450
::v-deep.el-table thead {
  color: #101010;
  font-weight: 600;
}
王硕 authored
451
452
453
</style>
<style>
.el-table .white-row {
王硕 authored
454
  background: rgb(164, 167, 171) !important;
王硕 authored
455
}
王硕 authored
456
王硕 authored
457
.el-table .red-row {
王硕 authored
458
  background: rgb(245, 108, 108) !important;
王硕 authored
459
}
王硕 authored
460
461

.el-table .yellow-row {
王硕 authored
462
  background: rgb(233, 173, 82) !important;
王硕 authored
463
}
王硕 authored
464
465

.el-table .green-row {
王硕 authored
466
  background: rgb(103, 194, 58) !important;
王硕 authored
467
468
}
</style>