Blame view

HHECS.Web/src/views/logManage/components/contentLog.vue 8.81 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="name">
陈嘉新 authored
21
22
23
24
            <el-input
              v-model="queryConfig.content"
              placeholder="请选择内容"
            ></el-input>
陈嘉新 authored
25
26
27
28
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label="标志:" prop="">
陈嘉新 authored
29
            <el-select v-model="queryConfig.flag" placeholder="请选择标志">
陈嘉新 authored
30
              <el-option
31
                v-for="item in optionsFlag"
陈嘉新 authored
32
33
34
35
36
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
陈嘉新 authored
37
38
39
40
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
          <el-form-item label="开始时间:" prop="">
陈嘉新 authored
41
42
43
44
45
            <el-date-picker
              v-model="form.startTime"
              type="datetime"
              placeholder="选择日期时间"
            />
陈嘉新 authored
46
47
48
49
          </el-form-item>
        </el-col>
        <el-col :span="3.5">
          <el-form-item label="结束时间:" prop="">
陈嘉新 authored
50
51
52
53
54
            <el-date-picker
              v-model="form.endTime"
              type="datetime"
              placeholder="选择日期时间"
            />
陈嘉新 authored
55
56
57
58
59
60
61
62
63
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="" prop="">
            <el-button
              icon="el-icon-search"
              class="T1"
              @click="btnAction()"
              type="primary"
陈嘉新 authored
64
              size="small"
陈嘉新 authored
65
66
              >查询</el-button
            >
陈嘉新 authored
67
68
69
            <el-button class="T1" size="small" @click="details()"
              >查询情况</el-button
            >
陈嘉新 authored
70
71
72
73
74
            <el-button
              class="T1"
              size="small"
              icon="el-icon-download"
              @click="ExportList()"
陈嘉新 authored
75
              >导出</el-button
陈嘉新 authored
76
            >
陈嘉新 authored
77
78
79
80
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
陈嘉新 authored
81
    <div class="table">
陈嘉新 authored
82
83
      <el-table
        :data="tableData"
陈嘉新 authored
84
85
86
        border
        stripe
        :height="TableHeight"
陈嘉新 authored
87
        @selection-change="handleSelectionChange"
陈嘉新 authored
88
        :header-cell-style="{ color: '#000000' }"
陈嘉新 authored
89
      >
陈嘉新 authored
90
91
92
93
94
        <el-table-column
          type="selection"
          align="center"
          width="55"
        ></el-table-column>
95
        <el-table-column prop="id" label="内置ID" width="180">
陈嘉新 authored
96
        </el-table-column>
97
        <el-table-column prop="title" label="标题" width="180">
陈嘉新 authored
98
        </el-table-column>
99
100
101
102
103
        <el-table-column prop="content" label="内容"> </el-table-column>
        <el-table-column prop="level" label="标志"> </el-table-column>
        <el-table-column prop="errorCode" label="报警代码"> </el-table-column>
        <el-table-column prop="created" label="创建时间"> </el-table-column>
        <el-table-column prop="createdBy" label="创建人"> </el-table-column>
陈嘉新 authored
104
105
106
      </el-table>
      <div class="pagination-container">
        <el-pagination
陈嘉新 authored
107
108
109
110
          style="margin-top: 15px"
          align="center"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
陈嘉新 authored
111
          :current-page="queryConfig.currentPage"
陈嘉新 authored
112
          :page-sizes="[20, 50, 100]"
陈嘉新 authored
113
          :page-size="queryConfig.pageSize"
陈嘉新 authored
114
          layout="total, sizes, prev, pager, next, jumper"
陈嘉新 authored
115
          :total="total"
陈嘉新 authored
116
        />
陈嘉新 authored
117
118
      </div>
    </div>
陈嘉新 authored
119
120
121
122
123
124
125
126
127
128
129
130
131
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
    <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.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.requestIp }}</div>
        </div> -->
        <div class="box1">
          <div class="inner-left">内容:</div>
          <div class="inner-right">
            <el-input
              type="textarea"
              :autosize="{ minRows: 2, maxRows: 4 }"
              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
157
158
159
  </div>
</template>
<script>
陈嘉新 authored
160
161
162
163
164
import {
  GetDictWithDetailsLangs,
  GetContentLog,
  GetContentLogById,
} from "@/api/logManage/index";
陈嘉新 authored
165
import downloadFile from "@/api/user";
陈嘉新 authored
166
167
168
export default {
  data() {
    return {
169
      tableData: [],
陈嘉新 authored
170
171
172
      queryConfig: {
        currentPage: 1,
        pageSize: 20,
173
174
175
        title: "",
        content: "",
        flag: "",
陈嘉新 authored
176
177
178
179
180
181
182
183
      },
      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"),
      },
184
185
186
187
188
189
      optionsFlag: [
        {
          value: "",
          label: "全部",
        },
      ],
陈嘉新 authored
190
191
192
      dialogFormVisible: false,
      multipleSelection: [],
      detailsData: [],
陈嘉新 authored
193
      export: "http://localhost:5221/api/Log/ExportContentLog",
陈嘉新 authored
194
195
    };
  },
196
197
198
199
  created() {
    this.getFlag("LogLevelFlag");
    this.getTableList();
  },
陈嘉新 authored
200
201
  computed: {
    TableHeight() {
陈嘉新 authored
202
      return `calc(100vh - 320px )`;
陈嘉新 authored
203
204
    },
  },
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
  methods: {
    btnAction() {
      this.getTableList();
    },
    getFlag(data) {
      let params = { Code: data };
      GetDictWithDetailsLangs(params).then((response) => {
        response.data.dictDetails.forEach((x) => {
          this.optionsFlag.push({ value: x.code, label: x.name });
        });
      });
    },
    getTableList() {
      const params = {
        pageNumber: this.queryConfig.currentPage,
        perPageCount: this.queryConfig.pageSize,
        queryConfig: {
          title: this.queryConfig.title,
          content: this.queryConfig.content,
          level: this.queryConfig.level,
          begin: this.form.startTime,
          end: this.form.endTime,
        },
      };
      this.listLoading = true;
      GetContentLog(params).then((response) => {
        this.total = response.data.totalCount;
        this.tableData = response.data.data;
        this.listLoading = false;
      });
    },
陈嘉新 authored
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    //导出按钮
    ExportList() {
      const params = {
        pageNumber: this.queryConfig.currentPage,
        perPageCount: this.queryConfig.pageSize,
        queryConfig: {
          title: this.queryConfig.title,
          content: this.queryConfig.content,
          level: this.queryConfig.level,
          begin: this.form.startTime,
          end: this.form.endTime,
        },
      };
      let text = "内容日志数据.xlsx";
      // 调用下载函数
      downloadFile(this.export, params, text);
    },
陈嘉新 authored
253
254
255
256
    //获取表格行数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
257
258
259
260
261
262
263
    //   详情
    details() {
      if (this.multipleSelection.length == 0) {
        this.$alert("请选择一条数据!", "标题名称", {
          confirmButtonText: "确定",
        });
      } else {
陈嘉新 authored
264
265
266
267
268
269
270
        this.detailsData = [];
        let params = {
          id: this.multipleSelection[0].id,
        };
        GetContentLogById(params).then((response) => {
          this.detailsData.push(response.data);
        });
271
272
273
274
275
276
277
278
        this.dialogFormVisible = true;
      }
    },
    //获取表格行数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //分页
陈嘉新 authored
279
280
281
282
283
284
285
286
    handleSizeChange(val) {
      this.queryConfig.pageSize = val;
      this.queryConfig.currentPage = 1;
      this.getTableList();
    },

    handleCurrentChange(val) {
      this.queryConfig.currentPage = val;
287
288
289
      this.getTableList();
    },
  },
陈嘉新 authored
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
};
</script>
<style scoped lang="scss">
.interfacel {
  width: 100%;
}
.el-row {
  margin-bottom: 5px;
}
.table {
  border: 1px solid #e5e9f2;
}
.T1 {
  border: 1px solid #b3d8ff;
}
.pagination-container {
  text-align: center; /* 使分页组件靠右 */
  margin-top: 20px; /* 添加顶部间距 */
}
</style>