Blame view

HHECS.Web/src/views/logManage/components/deviceLog.vue 11 KB
陈嘉新 authored
1
2
<template>
  <div class="interfacel">
陈嘉新 authored
3
4
5
6
7
8
9
10
11
    <el-form
      :model="queryConfig"
      :rules="rules"
      ref="queryConfig"
      label-width="100px"
      class="demo-queryConfig"
    >
      <el-row :gutter="10">
        <el-col :span="3">
陈嘉新 authored
12
          <el-form-item :label="$t('logManage.deviceName')" prop="name">
陈嘉新 authored
13
14
            <el-input
              v-model="queryConfig.equipmentCode"
陈嘉新 authored
15
16
17
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.deviceName')
              "
陈嘉新 authored
18
            ></el-input>
陈嘉新 authored
19
20
21
          </el-form-item>
        </el-col>
        <el-col :span="3">
陈嘉新 authored
22
          <el-form-item :label="$t('logManage.Category')" prop="name">
陈嘉新 authored
23
24
            <el-input
              v-model="queryConfig.logType"
陈嘉新 authored
25
26
27
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.Category')
              "
陈嘉新 authored
28
            ></el-input>
陈嘉新 authored
29
30
31
          </el-form-item>
        </el-col>
        <el-col :span="3">
陈嘉新 authored
32
          <el-form-item :label="$t('logManage.message')" prop="name">
陈嘉新 authored
33
34
            <el-input
              v-model="queryConfig.message"
陈嘉新 authored
35
36
37
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.message')
              "
陈嘉新 authored
38
            ></el-input>
陈嘉新 authored
39
40
41
          </el-form-item>
        </el-col>
        <el-col :span="3">
陈嘉新 authored
42
          <el-form-item :label="$t('logManage.Category')" prop="">
陈嘉新 authored
43
44
            <el-select
              v-model="queryConfig.bllResultCode"
陈嘉新 authored
45
46
47
              :placeholder="
                $t('logManage.PleaseSelect') + $t('logManage.Category')
              "
陈嘉新 authored
48
            >
陈嘉新 authored
49
              <el-option
50
                v-for="item in optionsBllResult"
陈嘉新 authored
51
52
53
54
55
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
陈嘉新 authored
56
57
58
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
陈嘉新 authored
59
          <el-form-item :label="$t('logManage.startTime')" prop="">
陈嘉新 authored
60
61
62
            <el-date-picker
              v-model="form.startTime"
              type="datetime"
陈嘉新 authored
63
64
65
              :placeholder="
                $t('logManage.PleaseSelect') + $t('logManage.startTime')
              "
陈嘉新 authored
66
            />
陈嘉新 authored
67
68
69
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
陈嘉新 authored
70
          <el-form-item :label="$t('logManage.endTime')" prop="">
陈嘉新 authored
71
72
73
            <el-date-picker
              v-model="form.endTime"
              type="datetime"
陈嘉新 authored
74
75
76
              :placeholder="
                $t('logManage.PleaseSelect') + $t('logManage.endTime')
              "
陈嘉新 authored
77
            />
陈嘉新 authored
78
79
80
81
82
83
84
85
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="" prop="">
            <el-button
              icon="el-icon-search"
              class="T1"
              @click="btnAction()"
陈嘉新 authored
86
              size="small"
陈嘉新 authored
87
              type="primary"
陈嘉新 authored
88
              >{{ $t("logManage.query") }}</el-button
陈嘉新 authored
89
            >
陈嘉新 authored
90
91
92
            <el-button class="T1" size="small" @click="details()">{{
              $t("logManage.queryDetails")
            }}</el-button>
陈嘉新 authored
93
94
95
96
97
            <el-button
              class="T1"
              size="small"
              icon="el-icon-download"
              @click="ExportList()"
陈嘉新 authored
98
              >{{ $t("logManage.export") }}</el-button
陈嘉新 authored
99
            >
陈嘉新 authored
100
101
102
103
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
陈嘉新 authored
104
    <div class="table">
陈嘉新 authored
105
106
      <el-table
        :data="tableData"
陈嘉新 authored
107
        border
陈嘉新 authored
108
        highlight-current-row
陈嘉新 authored
109
        :height="TableHeight"
陈嘉新 authored
110
        @selection-change="handleSelectionChange"
陈嘉新 authored
111
        :header-cell-style="{ color: '#000000' }"
陈嘉新 authored
112
        class="custom-table"
陈嘉新 authored
113
      >
陈嘉新 authored
114
115
116
117
118
        <el-table-column
          type="selection"
          align="center"
          width="55"
        ></el-table-column>
陈嘉新 authored
119
120
121
122
123
124
125
126
127
128
129
130
131
        <el-table-column
          prop="id"
          :label="$t('logManage.internalID')"
          width="180"
        >
        </el-table-column>
        <el-table-column
          prop="equipmentCode"
          :label="$t('logManage.deviceName')"
          width="180"
        >
        </el-table-column>
        <el-table-column prop="logType" :label="$t('logManage.Category')">
陈嘉新 authored
132
        </el-table-column>
陈嘉新 authored
133
        <el-table-column prop="message" :label="$t('logManage.message')">
陈嘉新 authored
134
        </el-table-column>
陈嘉新 authored
135
136
137
138
139
        <el-table-column prop="bllResultCode" :label="$t('logManage.logLevel')">
        </el-table-column>
        <el-table-column prop="errorCode" :label="$t('logManage.alarmDode')">
        </el-table-column>
        <el-table-column prop="created" :label="$t('logManage.createdTime')">
140
        </el-table-column>
陈嘉新 authored
141
142
143
      </el-table>
      <div class="pagination-container">
        <el-pagination
陈嘉新 authored
144
145
146
147
          style="margin-top: 15px"
          align="center"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
陈嘉新 authored
148
          :current-page="queryConfig.currentPage"
陈嘉新 authored
149
          :page-sizes="[20, 50, 100]"
陈嘉新 authored
150
          :page-size="queryConfig.pageSize"
陈嘉新 authored
151
          layout="total, sizes, prev, pager, next, jumper"
陈嘉新 authored
152
          :total="total"
陈嘉新 authored
153
        />
陈嘉新 authored
154
155
      </div>
    </div>
陈嘉新 authored
156
157
158
159
    <el-dialog
      :title="$t('logManage.DeviceExecutionLogData')"
      :visible.sync="dialogFormVisible"
    >
陈嘉新 authored
160
161
      <div class="container" v-for="(item, index) in detailsData" :key="index">
        <div class="box">
陈嘉新 authored
162
          <div class="inner-left">{{ $t("logManage.internalID") }}:</div>
陈嘉新 authored
163
164
165
          <div class="inner-right">{{ item.id }}</div>
        </div>
        <div class="box">
陈嘉新 authored
166
          <div class="inner-left">{{ $t("logManage.logLevel") }}:</div>
陈嘉新 authored
167
168
169
          <div class="inner-right">{{ item.bllResultCode }}</div>
        </div>
        <div class="box">
陈嘉新 authored
170
          <div class="inner-left">{{ $t("logManage.EquipmentCode") }}:</div>
陈嘉新 authored
171
172
173
          <div class="inner-right">{{ item.equipmentCode }}</div>
        </div>
        <div class="box">
陈嘉新 authored
174
          <div class="inner-left">{{ $t("logManage.Category") }}:</div>
陈嘉新 authored
175
176
177
          <div class="inner-right">{{ item.logType }}</div>
        </div>
        <div class="box">
陈嘉新 authored
178
          <div class="inner-left">{{ $t("logManage.startTime") }}:</div>
陈嘉新 authored
179
180
181
          <div class="inner-right">{{ item.created }}</div>
        </div>
        <div class="box">
陈嘉新 authored
182
          <div class="inner-left">{{ $t("logManage.endTime") }}:</div>
陈嘉新 authored
183
184
185
          <div class="inner-right">{{ item.update }}</div>
        </div>
        <div class="box">
陈嘉新 authored
186
          <div class="inner-left">{{ $t("logManage.endTime") }}:</div>
陈嘉新 authored
187
188
          <div class="inner-right">{{ item.errorCode }}</div>
        </div>
陈嘉新 authored
189
        <div class="TextField">
陈嘉新 authored
190
          <div class="inner-left">{{ $t("logManage.message") }}:</div>
陈嘉新 authored
191
192
193
          <div class="inner-right">
            <el-input
              type="textarea"
陈嘉新 authored
194
              :rows="6"
陈嘉新 authored
195
196
197
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.message')
              "
陈嘉新 authored
198
199
200
201
202
203
              v-model="item.message"
            />
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
陈嘉新 authored
204
205
206
        <el-button @click="dialogFormVisible = false">{{
          $t("logManage.cancel")
        }}</el-button>
陈嘉新 authored
207
208
      </div>
    </el-dialog>
陈嘉新 authored
209
210
211
  </div>
</template>
<script>
212
213
214
import {
  GetDictWithDetailsLangs,
  GetEquipmentExecutedLog,
陈嘉新 authored
215
  GetEquipmentExecutedLogById,
216
} from "@/api/logManage/index";
陈嘉新 authored
217
import downloadFile from "@/api/user";
陈嘉新 authored
218
219
220
export default {
  data() {
    return {
221
      tableData: [],
陈嘉新 authored
222
223
224
      queryConfig: {
        currentPage: 1,
        pageSize: 20,
225
226
227
228
        equipmentCode: "",
        logType: "",
        message: "",
        bllResultCode: "",
陈嘉新 authored
229
230
231
232
233
234
235
236
      },
      total: 0,
      form: {
        startTime: this.$moment()
          .subtract(3, "days")
          .format("YYYY-MM-DD 00:00:00"),
        endTime: this.$moment().add(1, "days").format("YYYY-MM-DD 23:59:59"),
      },
237
238
239
      optionsBllResult: [
        {
          value: "",
陈嘉新 authored
240
          label: "",
241
242
        },
      ],
陈嘉新 authored
243
244
245
      dialogFormVisible: false,
      multipleSelection: [],
      detailsData: [],
陈嘉新 authored
246
      export: "http://localhost:5221/api/Log/ExportEquipmentExecutedLog",
陈嘉新 authored
247
248
    };
  },
249
  created() {
陈嘉新 authored
250
    this.optionsBllResult[0].label = this.$t("taskManage.all");
251
252
253
    this.getFlag("LogLevelFlag");
    this.getTableList();
  },
陈嘉新 authored
254
255
  computed: {
    TableHeight() {
陈嘉新 authored
256
      return `calc(100vh - 390px )`;
陈嘉新 authored
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
  methods: {
    btnAction() {
      this.getTableList();
    },
    getFlag(data) {
      let params = { Code: data };
      GetDictWithDetailsLangs(params).then((response) => {
        response.data.dictDetails.forEach((x) => {
          this.optionsBllResult.push({ value: x.code, label: x.name });
        });
      });
    },
    getTableList() {
      const params = {
        pageNumber: this.queryConfig.currentPage,
        perPageCount: this.queryConfig.pageSize,
        queryConfig: {
          equipmentCode: this.queryConfig.equipmentCode,
          logType: this.queryConfig.logType,
          message: this.queryConfig.message,
          bllResultCode: this.queryConfig.bllResultCode,
          begin: this.form.startTime,
          end: this.form.endTime,
        },
      };
      this.listLoading = true;
      GetEquipmentExecutedLog(params).then((response) => {
        this.total = response.data.totalCount;
        this.tableData = response.data.data;
        this.listLoading = false;
      });
    },
    //   详情
    details() {
      if (this.multipleSelection.length == 0) {
陈嘉新 authored
294
295
296
297
298
299
300
        this.$alert(
          this.$t("logManage.PleaseSelectApieceOfData"),
          this.$t("logManage.DeviceExecutionLogDetails"),
          {
            confirmButtonText: this.$t("logManage.sure"),
          }
        );
301
      } else {
陈嘉新 authored
302
303
304
305
306
307
308
        this.detailsData = [];
        let params = {
          id: this.multipleSelection[0].id,
        };
        GetEquipmentExecutedLogById(params).then((response) => {
          this.detailsData.push(response.data);
        });
309
310
311
        this.dialogFormVisible = true;
      }
    },
陈嘉新 authored
312
313
314
315
316
317
318
319
320
321
322
323
324
325
    //导出按钮
    ExportList() {
      const params = {
        pageNumber: this.queryConfig.currentPage,
        perPageCount: this.queryConfig.pageSize,
        queryConfig: {
          equipmentCode: this.queryConfig.equipmentCode,
          logType: this.queryConfig.logType,
          message: this.queryConfig.message,
          bllResultCode: this.queryConfig.bllResultCode,
          begin: this.form.startTime,
          end: this.form.endTime,
        },
      };
陈嘉新 authored
326
      let text = this.$t("logManage.DeviceExecutionLogData") + ".xlsx";
陈嘉新 authored
327
328
329
      // 调用下载函数
      downloadFile(this.export, params, text);
    },
330
331
332
333
334
    //获取表格行数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //分页
陈嘉新 authored
335
336
337
338
339
340
341
342
    handleSizeChange(val) {
      this.queryConfig.pageSize = val;
      this.queryConfig.currentPage = 1;
      this.getTableList();
    },

    handleCurrentChange(val) {
      this.queryConfig.currentPage = val;
343
344
345
      this.getTableList();
    },
  },
陈嘉新 authored
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
};
</script>
<style scoped lang="scss">
.interfacel {
  width: 100%;
}
.el-row {
  margin-bottom: 5px;
}
.interfacel-content {
  display: flex;
  border-radius: 4px;
  min-height: 46px;
  margin-bottom: 10px;
  align-items: center;
}
.table {
  border: 1px solid #e5e9f2;
}
.T1 {
  border: 1px solid #b3d8ff;
}
.pagination-container {
  text-align: center; /* 使分页组件靠右 */
  margin-top: 20px; /* 添加顶部间距 */
}
</style>