Browse Source

登录日志

gzb
wangzhonglu 1 year ago
parent
commit
edcfa09c2e
3 changed files with 183 additions and 41 deletions
  1. 7
    0
      src/api/index.js
  2. 139
    4
      src/views/log/index.vue
  3. 37
    37
      src/views/users/index.vue

+ 7
- 0
src/api/index.js View File

91
     method: "post",
91
     method: "post",
92
     data
92
     data
93
   });
93
   });
94
+// 登录日志
95
+export const list_log = (data) =>
96
+  request({
97
+    url: window._config.baseUrl + "log/list_log",
98
+    method: "post",
99
+    data
100
+  });

+ 139
- 4
src/views/log/index.vue View File

1
 <template>
1
 <template>
2
-  <div>user</div>
2
+  <div>
3
+    <div class="searchBox">
4
+      <div>
5
+        <RadioGroup v-model="logSearch.userstate" @on-change="searchList()">
6
+          <Radio :label="0">全部</Radio>
7
+          <Radio :label="1">正常</Radio>
8
+          <Radio :label="10">已删除</Radio>
9
+        </RadioGroup>
10
+        <Input
11
+          v-model="logSearch.username"
12
+          @on-enter="searchList()"
13
+          placeholder="请输入用户姓名"
14
+          style="margin: 0 16px; width: 200px"
15
+          clearable
16
+        />
17
+        <Button type="primary" @click="searchList()">搜索</Button>
18
+      </div>
19
+    </div>
20
+    <Table border :columns="logColumns" :data="logSearch.list">
21
+      <template slot-scope="{ row }" slot="loginstateSlot">
22
+        <span>{{ row.loginstate === 1 ? "成功" : "失败" }}</span>
23
+      </template>
24
+      <template slot-scope="{ row }" slot="logtimeSlot">
25
+        <span>{{ dateFormat(row.logtime) }}</span>
26
+      </template>
27
+    </Table>
28
+    <div class="foot_page" v-if="logSearch.total > 0">
29
+      <Page
30
+        :total="logSearch.total"
31
+        @on-change="changePage"
32
+        :current="logSearch.page"
33
+        show-total
34
+      ></Page>
35
+    </div>
36
+  </div>
3
 </template>
37
 </template>
4
 
38
 
5
 <script>
39
 <script>
40
+import { list_log } from "@/api";
41
+import { dateFormat } from "@/utils";
6
 export default {
42
 export default {
7
   data() {
43
   data() {
8
-    return {};
44
+    return {
45
+      dateFormat,
46
+      logSearch: {
47
+        loginname: "",
48
+        logtime: null,
49
+        endtime: null,
50
+        page: 1,
51
+        size: 10,
52
+        total: 0,
53
+        list: []
54
+      },
55
+      logColumns: [
56
+        {
57
+          title: "序号",
58
+          width: 70,
59
+          render: (h, params) => {
60
+            return h(
61
+              "span",
62
+              params.index + (this.logSearch.page - 1) * this.logSearch.size + 1
63
+            );
64
+          }
65
+        },
66
+        {
67
+          title: "用户姓名",
68
+          key: "username",
69
+          width: 100
70
+        },
71
+        {
72
+          title: "登录账号",
73
+          key: "loginname",
74
+          width: 140
75
+        },
76
+        {
77
+          title: "登录状态",
78
+          slot: "loginstateSlot",
79
+          width: 100
80
+        },
81
+        {
82
+          title: "登录地址",
83
+          key: "logaddress"
84
+        },
85
+        {
86
+          title: "登录IP",
87
+          key: "logip",
88
+          width: 140
89
+        },
90
+        {
91
+          title: "登录时间",
92
+          slot: "logtimeSlot",
93
+          width: 200
94
+        },
95
+        {
96
+          title: "备注",
97
+          key: "logtxt"
98
+        }
99
+      ],
100
+      userInfo: {}
101
+    };
9
   },
102
   },
10
-  methods: {}
103
+  created() {
104
+    this.userInfo = JSON.parse(localStorage.getItem("xhWebAdminUser"));
105
+    this.getLogList();
106
+  },
107
+  methods: {
108
+    searchList() {
109
+      this.logSearch.page = 1;
110
+      this.getLogList();
111
+    },
112
+    getLogList() {
113
+      list_log({
114
+        page: this.logSearch.page,
115
+        size: this.logSearch.size,
116
+        userstate: this.logSearch.userstate,
117
+        username: this.logSearch.username
118
+      })
119
+        .then((data) => {
120
+          if (data.code === 0) {
121
+            this.logSearch.total = data.obj.total;
122
+            this.logSearch.list = data.obj.list;
123
+          } else {
124
+            this.logSearch.total = 0;
125
+            this.logSearch.list = [];
126
+            this.$Message.error(data.msg);
127
+          }
128
+        })
129
+        .catch(() => {});
130
+    },
131
+    changePage(page) {
132
+      this.logSearch.page = page;
133
+      this.getLogList();
134
+    }
135
+  }
11
 };
136
 };
12
 </script>
137
 </script>
13
 
138
 
14
-<style scoped lang="less"></style>
139
+<style scoped lang="less">
140
+.searchBox {
141
+  display: flex;
142
+  justify-content: space-between;
143
+  padding: 16px 0;
144
+}
145
+.foot_page {
146
+  padding: 16px 0;
147
+  text-align: right;
148
+}
149
+</style>

+ 37
- 37
src/views/users/index.vue View File

152
         userstate: 0,
152
         userstate: 0,
153
         username: "",
153
         username: "",
154
         total: 0,
154
         total: 0,
155
-        list: [],
155
+        list: []
156
       },
156
       },
157
       userColumns: [
157
       userColumns: [
158
         {
158
         {
165
                 (this.userSearch.page - 1) * this.userSearch.size +
165
                 (this.userSearch.page - 1) * this.userSearch.size +
166
                 1
166
                 1
167
             );
167
             );
168
-          },
168
+          }
169
         },
169
         },
170
         {
170
         {
171
           title: "用户姓名",
171
           title: "用户姓名",
172
-          key: "username",
172
+          key: "username"
173
         },
173
         },
174
         {
174
         {
175
           title: "登录账号",
175
           title: "登录账号",
176
-          key: "loginname",
176
+          key: "loginname"
177
         },
177
         },
178
         {
178
         {
179
           title: "手机号",
179
           title: "手机号",
180
-          key: "userphone",
180
+          key: "userphone"
181
         },
181
         },
182
         {
182
         {
183
           title: "状态",
183
           title: "状态",
184
           slot: "userstateSlot",
184
           slot: "userstateSlot",
185
-          width: 90,
185
+          width: 90
186
         },
186
         },
187
         {
187
         {
188
           title: "创建人",
188
           title: "创建人",
189
           key: "createname",
189
           key: "createname",
190
-          width: 120,
190
+          width: 120
191
         },
191
         },
192
         {
192
         {
193
           title: "创建时间",
193
           title: "创建时间",
194
           slot: "createtimeSlot",
194
           slot: "createtimeSlot",
195
-          width: 200,
195
+          width: 200
196
         },
196
         },
197
         {
197
         {
198
           title: "操作",
198
           title: "操作",
199
           slot: "actionSlot",
199
           slot: "actionSlot",
200
-          width: 150,
201
-        },
200
+          width: 150
201
+        }
202
       ],
202
       ],
203
       userAddForm: {
203
       userAddForm: {
204
         show: false,
204
         show: false,
205
         username: "",
205
         username: "",
206
         loginname: "",
206
         loginname: "",
207
         loginpwd: "",
207
         loginpwd: "",
208
-        userphone: null,
208
+        userphone: null
209
       },
209
       },
210
       addFormRules: {
210
       addFormRules: {
211
         username: [
211
         username: [
212
           {
212
           {
213
             required: true,
213
             required: true,
214
             message: "用户姓名不能为空",
214
             message: "用户姓名不能为空",
215
-            trigger: "blur",
216
-          },
215
+            trigger: "blur"
216
+          }
217
         ],
217
         ],
218
         loginname: [
218
         loginname: [
219
           {
219
           {
220
             required: true,
220
             required: true,
221
             message: "登录账号不能为空",
221
             message: "登录账号不能为空",
222
-            trigger: "blur",
222
+            trigger: "blur"
223
           },
223
           },
224
           {
224
           {
225
             min: 4,
225
             min: 4,
226
             max: 18,
226
             max: 18,
227
             message: "登录账号长度为4~18个字符",
227
             message: "登录账号长度为4~18个字符",
228
-            trigger: "blur",
229
-          },
228
+            trigger: "blur"
229
+          }
230
         ],
230
         ],
231
         loginpwd: [
231
         loginpwd: [
232
           {
232
           {
233
             required: true,
233
             required: true,
234
             message: "登录密码不能为空",
234
             message: "登录密码不能为空",
235
-            trigger: "blur",
235
+            trigger: "blur"
236
           },
236
           },
237
           {
237
           {
238
             min: 6,
238
             min: 6,
239
             max: 16,
239
             max: 16,
240
             message: "登录密码长度为6~16个字符",
240
             message: "登录密码长度为6~16个字符",
241
-            trigger: "blur",
242
-          },
241
+            trigger: "blur"
242
+          }
243
         ],
243
         ],
244
-        userphone: [{ validator: phoneCheck, trigger: "blur" }],
244
+        userphone: [{ validator: phoneCheck, trigger: "blur" }]
245
       },
245
       },
246
       userModifyForm: {
246
       userModifyForm: {
247
         show: false,
247
         show: false,
249
         username: "",
249
         username: "",
250
         loginname: "",
250
         loginname: "",
251
         loginpwd: "",
251
         loginpwd: "",
252
-        userphone: null,
252
+        userphone: null
253
       },
253
       },
254
       modifyFormRules: {
254
       modifyFormRules: {
255
         username: [
255
         username: [
256
           {
256
           {
257
             required: true,
257
             required: true,
258
             message: "用户姓名不能为空",
258
             message: "用户姓名不能为空",
259
-            trigger: "blur",
260
-          },
259
+            trigger: "blur"
260
+          }
261
         ],
261
         ],
262
         loginname: [
262
         loginname: [
263
           {
263
           {
264
             required: true,
264
             required: true,
265
             message: "登录账号不能为空",
265
             message: "登录账号不能为空",
266
-            trigger: "blur",
266
+            trigger: "blur"
267
           },
267
           },
268
           {
268
           {
269
             min: 4,
269
             min: 4,
270
             max: 18,
270
             max: 18,
271
-            message: "登录账号长度为4~18个字符",
272
-          },
271
+            message: "登录账号长度为4~18个字符"
272
+          }
273
         ],
273
         ],
274
         loginpwd: [
274
         loginpwd: [
275
           // {
275
           // {
281
             min: 6,
281
             min: 6,
282
             max: 16,
282
             max: 16,
283
             message: "登录密码长度为6~16个字符",
283
             message: "登录密码长度为6~16个字符",
284
-            trigger: "blur",
285
-          },
284
+            trigger: "blur"
285
+          }
286
         ],
286
         ],
287
-        userphone: [{ validator: phoneCheck, trigger: "blur" }],
287
+        userphone: [{ validator: phoneCheck, trigger: "blur" }]
288
       },
288
       },
289
-      userInfo: {},
289
+      userInfo: {}
290
     };
290
     };
291
   },
291
   },
292
   created() {
292
   created() {
303
         page: this.userSearch.page,
303
         page: this.userSearch.page,
304
         size: this.userSearch.size,
304
         size: this.userSearch.size,
305
         userstate: this.userSearch.userstate,
305
         userstate: this.userSearch.userstate,
306
-        username: this.userSearch.username,
306
+        username: this.userSearch.username
307
       })
307
       })
308
         .then((data) => {
308
         .then((data) => {
309
           if (data.code === 0) {
309
           if (data.code === 0) {
329
             }
329
             }
330
           });
330
           });
331
         },
331
         },
332
-        onCancel: () => {},
332
+        onCancel: () => {}
333
       });
333
       });
334
     },
334
     },
335
     toAdd() {
335
     toAdd() {
338
         username: "",
338
         username: "",
339
         loginname: "",
339
         loginname: "",
340
         loginpwd: "",
340
         loginpwd: "",
341
-        userphone: null,
341
+        userphone: null
342
       };
342
       };
343
     },
343
     },
344
     toSaveAdd() {
344
     toSaveAdd() {
349
             loginname: this.userAddForm.loginname,
349
             loginname: this.userAddForm.loginname,
350
             loginpwd: this.userAddForm.loginpwd,
350
             loginpwd: this.userAddForm.loginpwd,
351
             createid: this.userInfo.userid,
351
             createid: this.userInfo.userid,
352
-            userphone: this.userAddForm.userphone,
352
+            userphone: this.userAddForm.userphone
353
           }).then((data) => {
353
           }).then((data) => {
354
             if (data.code === 0) {
354
             if (data.code === 0) {
355
               this.userAddForm.show = false;
355
               this.userAddForm.show = false;
369
         username: user.username,
369
         username: user.username,
370
         loginname: user.loginname,
370
         loginname: user.loginname,
371
         loginpwd: user.loginpwd,
371
         loginpwd: user.loginpwd,
372
-        userphone: user.userphone,
372
+        userphone: user.userphone
373
       };
373
       };
374
     },
374
     },
375
     toSaveModifyUser() {
375
     toSaveModifyUser() {
397
     changePage(page) {
397
     changePage(page) {
398
       this.userSearch.page = page;
398
       this.userSearch.page = page;
399
       this.getUsersList();
399
       this.getUsersList();
400
-    },
401
-  },
400
+    }
401
+  }
402
 };
402
 };
403
 </script>
403
 </script>
404
 
404
 

Loading…
Cancel
Save