Blame view

HHECS.Web/src/views/logManage/components/systemLog.vue 9.72 KB
陈嘉新 authored
1
2
<template>
  <div class="interfacel">
陈嘉新 authored
3
4
5
6
7
8
9
10
11
12
    <el-form
      :model="queryConfig"
      :rules="rules"
      ref="queryConfig"
      label-width="100px"
      class="demo-queryConfig"
    >
      <el-row :gutter="10">
        <el-col :span="3">
          <el-form-item label="标题:" prop="name">
陈嘉新 authored
13
14
15
16
            <el-input
              v-model="queryConfig.title"
              placeholder="请选择标题"
            ></el-input>
陈嘉新 authored
17
18
19
20
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="模块:" prop="">
陈嘉新 authored
21
            <el-select v-model="queryConfig.module" placeholder="请选择模块">
陈嘉新 authored
22
              <el-option
23
                v-for="item in optionsModule"
陈嘉新 authored
24
25
26
27
28
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
陈嘉新 authored
29
30
31
32
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="内容:" prop="name">
陈嘉新 authored
33
34
35
36
            <el-input
              v-model="queryConfig.content"
              placeholder="请选择内容"
            ></el-input>
陈嘉新 authored
37
38
39
40
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="标志:" prop="">
陈嘉新 authored
41
            <el-select v-model="queryConfig.flag" placeholder="请选择标志">
陈嘉新 authored
42
              <el-option
43
                v-for="item in optionsFlag"
陈嘉新 authored
44
45
46
47
48
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
陈嘉新 authored
49
50
51
52
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
          <el-form-item label="开始时间:" prop="">
陈嘉新 authored
53
54
55
56
57
            <el-date-picker
              v-model="form.startTime"
              type="datetime"
              placeholder="选择日期时间"
            />
陈嘉新 authored
58
59
60
61
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
          <el-form-item label="结束时间:" prop="">
陈嘉新 authored
62
63
64
65
66
            <el-date-picker
              v-model="form.endTime"
              type="datetime"
              placeholder="选择日期时间"
            />
陈嘉新 authored
67
68
69
70
71
72
73
74
          </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
75
              size="small"
陈嘉新 authored
76
77
78
              type="primary"
              >查询</el-button
            >
陈嘉新 authored
79
80
81
            <el-button class="T1" size="small" @click="details()"
              >查询情况</el-button
            >
陈嘉新 authored
82
83
84
85
86
            <el-button
              class="T1"
              size="small"
              icon="el-icon-download"
              @click="ExportList()"
陈嘉新 authored
87
              >导出</el-button
陈嘉新 authored
88
            >
陈嘉新 authored
89
90
91
92
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
陈嘉新 authored
93
    <div class="table">
陈嘉新 authored
94
95
      <el-table
        :data="tableData"
陈嘉新 authored
96
        border
陈嘉新 authored
97
        highlight-current-row
陈嘉新 authored
98
        :height="TableHeight"
陈嘉新 authored
99
        @selection-change="handleSelectionChange"
陈嘉新 authored
100
        :header-cell-style="{ color: '#000000' }"
陈嘉新 authored
101
        class="custom-table"
陈嘉新 authored
102
      >
陈嘉新 authored
103
104
105
106
107
        <el-table-column
          type="selection"
          align="center"
          width="55"
        ></el-table-column>
108
        <el-table-column prop="id" label="内置id" width="180">
陈嘉新 authored
109
        </el-table-column>
110
        <el-table-column prop="title" label="标题" width="180">
陈嘉新 authored
111
        </el-table-column>
112
113
114
115
116
        <el-table-column prop="module" label="模块"> </el-table-column>
        <el-table-column prop="content" label="内容"> </el-table-column>
        <el-table-column prop="level" label="标志"> </el-table-column>
        <el-table-column prop="created" label="创建时间"> </el-table-column>
        <el-table-column prop="userCode" label="创建人"> </el-table-column>
陈嘉新 authored
117
118
119
      </el-table>
      <div class="pagination-container">
        <el-pagination
陈嘉新 authored
120
121
122
123
          style="margin-top: 15px"
          align="center"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
陈嘉新 authored
124
          :current-page="queryConfig.currentPage"
陈嘉新 authored
125
          :page-sizes="[20, 50, 100]"
陈嘉新 authored
126
          :page-size="queryConfig.pageSize"
陈嘉新 authored
127
          layout="total, sizes, prev, pager, next, jumper"
陈嘉新 authored
128
          :total="total"
陈嘉新 authored
129
        />
陈嘉新 authored
130
131
      </div>
    </div>
陈嘉新 authored
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
    <el-dialog title="系统日志详情" :visible.sync="dialogFormVisible">
      <div class="container" v-for="(item, index) in detailsData" :key="index">
        <div class="box">
          <div class="inner-left">内部id:</div>
          <div class="inner-right">{{ item.id }}</div>
        </div>
        <div class="box">
          <div class="inner-left">标题:</div>
          <div class="inner-right">{{ item.title }}</div>
        </div>
        <div class="box">
          <div class="inner-left">模块:</div>
          <div class="inner-right">{{ item.module }}</div>
        </div>
        <div class="box">
          <div class="inner-left">标志:</div>
          <div class="inner-right">{{ item.level }}</div>
        </div>
        <div class="box">
          <div class="inner-left">开始时间:</div>
          <div class="inner-right">{{ item.created }}</div>
        </div>
        <div class="box">
          <div class="inner-left">创建人:</div>
          <div class="inner-right">{{ item.userCode }}</div>
        </div>
陈嘉新 authored
158
        <div class="TextField">
陈嘉新 authored
159
160
161
162
          <div class="inner-left">内容:</div>
          <div class="inner-right">
            <el-input
              type="textarea"
陈嘉新 authored
163
              :rows="6"
陈嘉新 authored
164
165
166
167
168
169
170
171
172
173
              placeholder="请输入内容"
              v-model="item.content"
            />
          </div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
      </div>
    </el-dialog>
陈嘉新 authored
174
175
176
  </div>
</template>
<script>
陈嘉新 authored
177
178
179
180
181
import {
  GetDictWithDetailsLangs,
  GetSysLog,
  GetSysLogById,
} from "@/api/logManage/index";
陈嘉新 authored
182
import downloadFile from "@/api/user";
陈嘉新 authored
183
184
185
export default {
  data() {
    return {
186
      tableData: [],
陈嘉新 authored
187
188
189
      queryConfig: {
        currentPage: 1,
        pageSize: 20,
190
191
192
193
        title: "",
        module: "",
        content: "",
        level: "",
陈嘉新 authored
194
195
196
197
198
199
200
201
      },
      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"),
      },
202
203
204
205
206
207
208
209
210
211
212
213
      optionsModule: [
        {
          value: "",
          label: "全部",
        },
      ],
      optionsFlag: [
        {
          value: "",
          label: "全部",
        },
      ],
陈嘉新 authored
214
215
216
      dialogFormVisible: false,
      multipleSelection: [],
      detailsData: [],
陈嘉新 authored
217
      export: "http://localhost:5221/api/Log/ExportSysLog",
陈嘉新 authored
218
219
    };
  },
220
221
222
223
224
  created() {
    this.getFlag("LogLevelFlag");
    this.getFlag("LogModuleFlag");
    this.getTableList();
  },
陈嘉新 authored
225
226
  computed: {
    TableHeight() {
陈嘉新 authored
227
      return `calc(100vh - 390px )`;
陈嘉新 authored
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
  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
266
267
268
269
    //获取表格行数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
270
271
272
273
274
275
276
    //   详情
    details() {
      if (this.multipleSelection.length == 0) {
        this.$alert("请选择一条数据!", "标题名称", {
          confirmButtonText: "确定",
        });
      } else {
陈嘉新 authored
277
278
279
280
281
282
283
        this.detailsData = [];
        let params = {
          id: this.multipleSelection[0].id,
        };
        GetSysLogById(params).then((response) => {
          this.detailsData.push(response.data);
        });
284
285
286
        this.dialogFormVisible = true;
      }
    },
陈嘉新 authored
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
    //导出按钮
    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,
        },
      };
      let text = "系统日志数据.xlsx";
      // 调用下载函数
      downloadFile(this.export, params, text);
    },
305
306
307
308
309
    //获取表格行数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //分页
陈嘉新 authored
310
311
312
313
314
315
316
317
    handleSizeChange(val) {
      this.queryConfig.pageSize = val;
      this.queryConfig.currentPage = 1;
      this.getTableList();
    },

    handleCurrentChange(val) {
      this.queryConfig.currentPage = val;
318
319
320
      this.getTableList();
    },
  },
陈嘉新 authored
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
};
</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>