Blame view

HHECS.Web/src/views/logManage/components/interfaceLog.vue 15.6 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="4">
陈嘉新 authored
12
          <el-form-item :label="$t('logManage.InterfaceName')" prop="name">
陈嘉新 authored
13
14
            <el-input
              v-model="queryConfig.interfaceName"
陈嘉新 authored
15
16
17
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.InterfaceName')
              "
陈嘉新 authored
18
            ></el-input>
陈嘉新 authored
19
20
21
          </el-form-item>
        </el-col>
        <el-col :span="4">
陈嘉新 authored
22
23
24
25
26
          <el-form-item :label="$t('logManage.sign')" prop="">
            <el-select
              v-model="queryConfig.flag"
              :placeholder="$t('logManage.PleaseSelect') + $t('logManage.sign')"
            >
陈嘉新 authored
27
              <el-option
28
                v-for="item in optionsFlag"
陈嘉新 authored
29
30
31
32
33
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
陈嘉新 authored
34
35
36
37
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="Url:" prop="">
陈嘉新 authored
38
39
40
41
            <el-input
              v-model="queryConfig.url"
              :placeholder="$t('logManage.PleaseEnter') + 'Url'"
            />
陈嘉新 authored
42
43
44
          </el-form-item>
        </el-col>
        <el-col :span="4">
陈嘉新 authored
45
          <el-form-item :label="$t('logManage.RequestMethod')" prop="">
陈嘉新 authored
46
47
            <el-input
              v-model="queryConfig.method"
陈嘉新 authored
48
49
50
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.RequestMethod')
              "
陈嘉新 authored
51
            />
陈嘉新 authored
52
53
54
          </el-form-item>
        </el-col>
        <el-col :span="4">
陈嘉新 authored
55
56
57
58
          <el-form-item
            :label="$t('logManage.timeConsuming')"
            prop="totalMilliseconds"
          >
陈嘉新 authored
59
60
            <el-input
              v-model="queryConfig.totalMilliseconds"
陈嘉新 authored
61
62
63
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.timeConsuming')
              "
陈嘉新 authored
64
            />
陈嘉新 authored
65
66
67
          </el-form-item>
        </el-col>
        <el-col :span="4">
陈嘉新 authored
68
69
70
71
72
73
74
          <el-form-item :label="$t('logManage.request')" prop="">
            <el-input
              v-model="queryConfig.request"
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.request')
              "
            />
陈嘉新 authored
75
76
77
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
陈嘉新 authored
78
          <el-form-item :label="$t('logManage.reply')" prop="">
陈嘉新 authored
79
80
            <el-input
              v-model="queryConfig.response"
陈嘉新 authored
81
              :placeholder="$t('logManage.PleaseEnter') + $t('logManage.reply')"
陈嘉新 authored
82
            />
陈嘉新 authored
83
84
85
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
陈嘉新 authored
86
          <el-form-item :label="$t('logManage.startTime')" prop="">
陈嘉新 authored
87
88
89
            <el-date-picker
              v-model="form.startTime"
              type="datetime"
陈嘉新 authored
90
91
92
              :placeholder="
                $t('logManage.PleaseSelect') + $t('logManage.startTime')
              "
陈嘉新 authored
93
            />
陈嘉新 authored
94
95
96
          </el-form-item>
        </el-col>
        <el-col :span="4">
陈嘉新 authored
97
          <el-form-item :label="$t('logManage.endTime')" prop="">
陈嘉新 authored
98
99
100
            <el-date-picker
              v-model="form.endTime"
              type="datetime"
陈嘉新 authored
101
102
103
              :placeholder="
                $t('logManage.PleaseSelect') + $t('logManage.endTime')
              "
陈嘉新 authored
104
            />
陈嘉新 authored
105
106
107
108
109
110
111
112
113
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="" prop="">
            <el-button
              icon="el-icon-search"
              class="T1"
              @click="btnAction('queryConfig')"
              type="primary"
陈嘉新 authored
114
              size="small"
陈嘉新 authored
115
              >{{ $t("logManage.query") }}</el-button
陈嘉新 authored
116
            >
陈嘉新 authored
117
118
119
            <el-button class="T1" size="small" @click="details()">{{
              $t("logManage.queryDetails")
            }}</el-button>
陈嘉新 authored
120
121
122
123
124
            <el-button
              class="T1"
              size="small"
              icon="el-icon-download"
              @click="ExportList()"
陈嘉新 authored
125
              >{{ $t("logManage.export") }}</el-button
陈嘉新 authored
126
            >
陈嘉新 authored
127
128
129
130
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
陈嘉新 authored
131
    <div class="table">
陈嘉新 authored
132
133
      <el-table
        :data="tableData"
陈嘉新 authored
134
        border
陈嘉新 authored
135
        highlight-current-row
陈嘉新 authored
136
        :height="TableHeight"
137
        @selection-change="handleSelectionChange"
陈嘉新 authored
138
139
        @row-click="handleRowClick"
        ref="multipleTable"
陈嘉新 authored
140
        :header-cell-style="{ color: '#000000' }"
陈嘉新 authored
141
        class="custom-table"
陈嘉新 authored
142
      >
143
144
145
146
147
        <el-table-column
          type="selection"
          align="center"
          width="55"
        ></el-table-column>
陈嘉新 authored
148
149
150
151
152
        <el-table-column
          prop="id"
          :label="$t('logManage.internalID')"
          width="100"
        >
153
154
155
        </el-table-column>
        <el-table-column
          prop="interfaceName"
陈嘉新 authored
156
          :label="$t('logManage.InterfaceName')"
157
          width="180"
陈嘉新 authored
158
          show-overflow
159
160
        >
        </el-table-column>
陈嘉新 authored
161
        <el-table-column prop="url" width="180" label="URL" show-overflow>
162
        </el-table-column>
陈嘉新 authored
163
164
165
166
167
168
        <el-table-column prop="method" :label="$t('logManage.RequestMethod')">
        </el-table-column>
        <el-table-column
          prop="totalMilliseconds"
          :label="$t('logManage.timeConsuming')"
        >
陈嘉新 authored
169
        </el-table-column>
陈嘉新 authored
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
        <el-table-column prop="request" :label="$t('logManage.request')">
        </el-table-column>
        <el-table-column
          prop="response"
          :label="$t('logManage.reply')"
          width="200"
        >
        </el-table-column>
        <el-table-column prop="flag" :label="$t('logManage.sign')">
        </el-table-column>
        <el-table-column prop="requestIp" :label="$t('logManage.RequesterIP')">
        </el-table-column>
        <el-table-column prop="remark" :label="$t('logManage.notes')">
        </el-table-column>
        <el-table-column prop="created" :label="$t('logManage.startTime')">
        </el-table-column>
        <el-table-column prop="createdBy" :label="$t('logManage.founder')">
陈嘉新 authored
187
188
189
190
        </el-table-column>
      </el-table>
      <div class="pagination-container">
        <el-pagination
陈嘉新 authored
191
192
193
194
          style="margin-top: 15px"
          align="center"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
陈嘉新 authored
195
          :current-page="queryConfig.currentPage"
陈嘉新 authored
196
          :page-sizes="[20, 50, 100]"
陈嘉新 authored
197
          :page-size="queryConfig.pageSize"
陈嘉新 authored
198
          layout="total, sizes, prev, pager, next, jumper"
陈嘉新 authored
199
          :total="total"
陈嘉新 authored
200
        />
陈嘉新 authored
201
202
      </div>
    </div>
陈嘉新 authored
203
204
205
206
    <el-dialog
      :title="$t('logManage.InterfaceLogDetails')"
      :visible.sync="dialogFormVisible"
    >
陈嘉新 authored
207
      <div class="container" v-for="(item, index) in detailsData" :key="index">
208
        <div class="box">
陈嘉新 authored
209
          <div class="inner-left">{{ $t("logManage.internalID") }}:</div>
210
211
212
          <div class="inner-right">{{ item.id }}</div>
        </div>
        <div class="box">
陈嘉新 authored
213
          <div class="inner-left">{{ $t("logManage.InterfaceName") }}:</div>
214
215
216
          <div class="inner-right">{{ item.interfaceName }}</div>
        </div>
        <div class="box">
陈嘉新 authored
217
          <div class="inner-left">{{ $t("logManage.timeConsuming") }}:</div>
218
219
220
          <div class="inner-right">{{ item.totalMilliseconds }}</div>
        </div>
        <div class="box">
陈嘉新 authored
221
          <div class="inner-left">{{ $t("logManage.sign") }}:</div>
222
223
224
          <div class="inner-right">{{ item.flag }}</div>
        </div>
        <div class="box">
陈嘉新 authored
225
          <div class="inner-left">{{ $t("logManage.startTime") }}:</div>
226
227
228
          <div class="inner-right">{{ item.created }}</div>
        </div>
        <div class="box">
陈嘉新 authored
229
          <div class="inner-left">{{ $t("logManage.RequesterIP") }}:</div>
230
231
          <div class="inner-right">{{ item.requestIp }}</div>
        </div>
陈嘉新 authored
232
        <div class="TextField">
陈嘉新 authored
233
          <div class="inner-left">{{ $t("logManage.request") }}:</div>
234
235
236
          <div class="inner-right">
            <el-input
              type="textarea"
陈嘉新 authored
237
              :rows="6"
陈嘉新 authored
238
239
240
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.request')
              "
241
242
243
244
              v-model="item.request"
            />
          </div>
        </div>
陈嘉新 authored
245
        <div class="TextField">
陈嘉新 authored
246
          <div class="inner-left">{{ $t("logManage.reply") }}:</div>
247
248
249
          <div class="inner-right">
            <el-input
              type="textarea"
陈嘉新 authored
250
              :rows="6"
陈嘉新 authored
251
              :placeholder="$t('logManage.PleaseEnter') + $t('logManage.reply')"
252
253
254
255
              v-model="item.response"
            />
          </div>
        </div>
陈嘉新 authored
256
        <div class="TextField">
陈嘉新 authored
257
          <div class="inner-left">{{ $t("logManage.content") }}:</div>
258
259
260
          <div class="inner-right">
            <el-input
              type="textarea"
陈嘉新 authored
261
              :rows="6"
陈嘉新 authored
262
263
264
              :placeholder="
                $t('logManage.PleaseEnter') + $t('logManage.content')
              "
265
266
267
268
              v-model="item.content"
            />
          </div>
        </div>
陈嘉新 authored
269
        <div class="TextField">
陈嘉新 authored
270
          <div class="inner-left">{{ $t("logManage.notes") }}:</div>
271
272
273
          <div class="inner-right">
            <el-input
              type="textarea"
陈嘉新 authored
274
              :rows="6"
陈嘉新 authored
275
              :placeholder="$t('logManage.PleaseEnter') + $t('logManage.notes')"
276
277
278
279
280
281
              v-model="item.remark"
            />
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
陈嘉新 authored
282
283
284
        <el-button @click="dialogFormVisible = false">{{
          $t("logManage.cancel")
        }}</el-button>
285
286
      </div>
    </el-dialog>
陈嘉新 authored
287
288
  </div>
</template>
陈嘉新 authored
289
陈嘉新 authored
290
<script>
291
292
293
import {
  GetDictWithDetailsLangs,
  GetInterfaceLog,
陈嘉新 authored
294
  GetInterfaceLogById,
295
} from "@/api/logManage/index";
陈嘉新 authored
296
import downloadFile from "@/api/user";
陈嘉新 authored
297
陈嘉新 authored
298
299
300
export default {
  data() {
    return {
301
      tableData: [],
陈嘉新 authored
302
303
304
      queryConfig: {
        currentPage: 1,
        pageSize: 20,
305
306
307
308
309
310
311
        interfaceName: "",
        flag: "",
        url: "",
        method: "",
        totalMilliseconds: 0,
        request: "",
        response: "",
陈嘉新 authored
312
      },
陈嘉新 authored
313
314
      rules: {
        totalMilliseconds: [
陈嘉新 authored
315
316
317
318
319
          {
            required: true,
            message: this.$t("logManage.empty"),
            trigger: "blur",
          },
陈嘉新 authored
320
321
322
          { validator: this.validateNumber, trigger: "blur" },
        ],
      },
陈嘉新 authored
323
324
325
326
327
328
329
      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"),
      },
330
331
332
      optionsFlag: [
        {
          value: "",
陈嘉新 authored
333
          label: "",
334
335
336
337
        },
      ],
      dialogFormVisible: false,
      multipleSelection: [],
陈嘉新 authored
338
      detailsData: [],
陈嘉新 authored
339
      export: "http://localhost:5221/api/Log/ExportInterfaceLog",
陈嘉新 authored
340
341
    };
  },
342
  created() {
陈嘉新 authored
343
    this.optionsFlag[0].label = this.$t("taskManage.all");
344
345
346
    this.getFlag("LogLevelFlag");
    this.getTableList();
  },
陈嘉新 authored
347
348
  computed: {
    TableHeight() {
陈嘉新 authored
349
      return `calc(100vh - 390px )`;
陈嘉新 authored
350
351
    },
  },
352
  methods: {
陈嘉新 authored
353
354
355
    handleRowClick(row) {
      this.$refs.multipleTable.toggleRowSelection(row);
    },
陈嘉新 authored
356
357
358
359
360
361
362
363
364
365
366
367
368
    //查询按钮
    btnAction(queryConfig) {
      this.$refs[queryConfig].validate((valid) => {
        if (valid) {
          this.getTableList();
        } else {
          return false;
        }
      });
    },
    //类型校验
    validateNumber(rule, value, callback) {
      if (value !== "" && isNaN(value)) {
陈嘉新 authored
369
        return callback(new Error(this.$t("logManage.number")));
陈嘉新 authored
370
371
      }
      callback(); // 验证通过
372
373
374
375
376
377
378
379
380
    },
    getFlag(data) {
      let params = { Code: data };
      GetDictWithDetailsLangs(params).then((response) => {
        response.data.dictDetails.forEach((x) => {
          this.optionsFlag.push({ value: x.code, label: x.name });
        });
      });
    },
陈嘉新 authored
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
    getTableList() {
      const params = {
        pageNumber: this.queryConfig.currentPage,
        perPageCount: this.queryConfig.pageSize,
        queryConfig: {
          interfaceName: this.queryConfig.interfaceName,
          url: this.queryConfig.url,
          request: this.queryConfig.request,
          response: this.queryConfig.response,
          method: this.queryConfig.method,
          flag: this.queryConfig.flag,
          content: "",
          totalMilliseconds: this.queryConfig.totalMilliseconds,
          remark: "",
          begin: this.form.startTime,
          end: this.form.endTime,
        },
      };
      this.listLoading = true;
      GetInterfaceLog(params).then((response) => {
        this.total = response.data.totalCount;
        this.tableData = response.data.data;
        this.listLoading = false;
      });
    },
    //   详情
    details() {
      if (this.multipleSelection.length == 0) {
陈嘉新 authored
410
411
412
413
414
415
416
        this.$alert(
          this.$t("logManage.PleaseSelectApieceOfData"),
          this.$t("logManage.InterfaceLogDetails"),
          {
            confirmButtonText: this.$t("logManage.sure"),
          }
        );
417
      } else {
陈嘉新 authored
418
419
420
421
422
423
424
        this.detailsData = [];
        let params = {
          id: this.multipleSelection[0].id,
        };
        GetInterfaceLogById(params).then((response) => {
          this.detailsData.push(response.data);
        });
425
426
427
        this.dialogFormVisible = true;
      }
    },
陈嘉新 authored
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
    //导出按钮
    ExportList() {
      const params = {
        pageNumber: this.queryConfig.currentPage,
        perPageCount: this.queryConfig.pageSize,
        queryConfig: {
          interfaceName: this.queryConfig.interfaceName,
          url: this.queryConfig.url,
          request: this.queryConfig.request,
          response: this.queryConfig.response,
          method: this.queryConfig.method,
          flag: this.queryConfig.flag,
          content: "",
          totalMilliseconds: this.queryConfig.totalMilliseconds,
          remark: "",
          begin: this.form.startTime,
          end: this.form.endTime,
        },
      };
陈嘉新 authored
447
      let text = this.$t("logManage.InterfaceLogData") + ".xlsx";
陈嘉新 authored
448
449
450
      // 调用下载函数
      downloadFile(this.export, params, text);
    },
451
452
453
454
455
    //获取表格行数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //分页
陈嘉新 authored
456
457
458
459
460
461
462
463
    handleSizeChange(val) {
      this.queryConfig.pageSize = val;
      this.queryConfig.currentPage = 1;
      this.getTableList();
    },

    handleCurrentChange(val) {
      this.queryConfig.currentPage = val;
464
465
466
      this.getTableList();
    },
  },
陈嘉新 authored
467
468
};
</script>
陈嘉新 authored
469
470

<style>
陈嘉新 authored
471
472
473
474
475
476
477
478
479
480
.interfacel {
  width: 100%;
}
.table {
  border: 1px solid #e5e9f2;
}
.pagination-container {
  text-align: center; /* 使分页组件靠右 */
  margin-top: 20px; /* 添加顶部间距 */
}
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
.container {
  width: 100%; /* 大 div 宽度 */
  display: flex; /* 使用 Flexbox 布局 */
  flex-wrap: wrap; /* 允许换行 */
  padding: 10px; /* 内边距 */
  box-sizing: border-box; /* 包含内边距在内 */
}
.box {
  width: 50%; /* 小 div 宽度为 50% */
  height: 50px; /* 小 div 高度 */
  margin: 5px 0; /* 上下外边距 */
  display: flex; /* 嵌套使用 Flexbox */
}
.box1 {
  width: 50%; /* 小 div 宽度为 50% */
  height: 100px; /* 小 div 高度 */
  margin: 5px 0; /* 上下外边距 */
  display: flex; /* 嵌套使用 Flexbox */
}
.inner-left {
  width: 40%; /* 内部左侧 div 宽度为 50% */
  height: 100%; /* 高度为 100% */
  display: flex; /* 使用 Flexbox */
  justify-content: flex-end; /* 内容靠右 */
  align-items: center; /* 垂直居中 */
  padding-right: 5px; /* 右侧内边距 */
}
.inner-right {
  width: 50%; /* 内部右侧 div 宽度为 50% */
  height: 100%; /* 高度为 100% */
  display: flex; /* 使用 Flexbox */
  justify-content: flex-start; /* 内容靠左 */
  align-items: center; /* 垂直居中 */
  padding-left: 5px; /* 左侧内边距 */
}
陈嘉新 authored
516
517
518
519

.demo-ruleForm {
  margin-top: 20px;
}
陈嘉新 authored
520
</style>