Blame view

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

    handleCurrentChange(val) {
      this.queryConfig.currentPage = val;
357
358
359
      this.getTableList();
    },
  },
陈嘉新 authored
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
};
</script>
<style scoped lang="scss">
.interfacel {
  width: 100%;
}
.table {
  border: 1px solid #e5e9f2;
}
.T1 {
  border: 1px solid #b3d8ff;
}
.pagination-container {
  text-align: center; /* 使分页组件靠右 */
  margin-top: 20px; /* 添加顶部间距 */
}
</style>