wangzhonglu 1 anno fa
parent
commit
edcfa09c2e
3 ha cambiato i file con 183 aggiunte e 41 eliminazioni
  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 Vedi File

@@ -91,3 +91,10 @@ export const dh_remove = (data) =>
91 91
     method: "post",
92 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 Vedi File

@@ -1,14 +1,149 @@
1 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 37
 </template>
4 38
 
5 39
 <script>
40
+import { list_log } from "@/api";
41
+import { dateFormat } from "@/utils";
6 42
 export default {
7 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 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 Vedi File

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

Loading…
Annulla
Salva