Bläddra i källkod

用户信息

gzb
wangzhonglu 1 år sedan
förälder
incheckning
fb5d26c6f8
5 ändrade filer med 471 tillägg och 8 borttagningar
  1. 1
    0
      public/index.html
  2. 32
    1
      src/App.vue
  3. 28
    0
      src/api/index.js
  4. 5
    3
      src/views/login/index.vue
  5. 405
    4
      src/views/users/index.vue

+ 1
- 0
public/index.html Visa fil

@@ -6,6 +6,7 @@
6 6
     <meta name="viewport" content="width=device-width,initial-scale=1.0" />
7 7
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
8 8
     <meta http-equiv="cache-control" content="no-cache">
9
+    <title>河南星火燎原软件科技有限公司</title>
9 10
     <link rel="stylesheet" href="/librarys/view-design@4.3.2/iview.css">
10 11
     <link rel="stylesheet" href="/iconfont/iconfont.css">
11 12
     <script src="/config.js"></script>

+ 32
- 1
src/App.vue Visa fil

@@ -46,7 +46,7 @@ body,
46 46
   -khtml-user-select: none;
47 47
   user-select: none;
48 48
   position: relative;
49
-  background: #f8f8fd;
49
+  background: #fff;
50 50
   box-sizing: border-box;
51 51
   font-family: "Microsoft YaHei", "微软雅黑" !important;
52 52
   // -webkit-user-select: text;
@@ -96,4 +96,35 @@ body,
96 96
 .ivu-page-item-jump-prev:after {
97 97
   content: "\2022\2022\2022" !important;
98 98
 }
99
+.modal1 {
100
+  .ivu-modal {
101
+    width: 50% !important;
102
+    .ivu-modal-content {
103
+      border-radius: 0;
104
+      .ivu-modal-header {
105
+        background: #2d8cf0;
106
+        padding: 13px 16px !important;
107
+        .ivu-modal-header-inner {
108
+          font-size: 18px !important;
109
+          color: #ffffff;
110
+        }
111
+      }
112
+      .ivu-modal-close {
113
+        top: 4px;
114
+        .ivu-icon-ios-close:before {
115
+          color: #ffffff;
116
+          font-size: 36px;
117
+          font-weight: 600;
118
+        }
119
+      }
120
+      .ivu-modal-footer {
121
+        border-top: none;
122
+      }
123
+    }
124
+  }
125
+}
126
+.ivu-table-header thead tr th,
127
+.ivu-table-cell {
128
+  text-align: center;
129
+}
99 130
 </style>

+ 28
- 0
src/api/index.js Visa fil

@@ -7,3 +7,31 @@ export const user_login = (data) =>
7 7
     method: "post",
8 8
     data
9 9
   });
10
+// 用户列表
11
+export const user_list = (data) =>
12
+  request({
13
+    url: window._config.baseUrl + "user/list",
14
+    method: "post",
15
+    data
16
+  });
17
+// 用户删除
18
+export const user_del = (data) =>
19
+  request({
20
+    url: window._config.baseUrl + "user/del",
21
+    method: "post",
22
+    data
23
+  });
24
+// 用户保存
25
+export const user_save = (data) =>
26
+  request({
27
+    url: window._config.baseUrl + "user/save",
28
+    method: "post",
29
+    data
30
+  });
31
+// 用户更新
32
+export const user_update = (data) =>
33
+  request({
34
+    url: window._config.baseUrl + "user/update",
35
+    method: "post",
36
+    data
37
+  });

+ 5
- 3
src/views/login/index.vue Visa fil

@@ -55,7 +55,8 @@ export default {
55 55
           {
56 56
             min: 4,
57 57
             max: 18,
58
-            message: "账号长度为4~18个字符"
58
+            message: "账号长度为4~18个字符",
59
+            trigger: "blur"
59 60
           }
60 61
         ],
61 62
         loginpwd: [
@@ -63,7 +64,8 @@ export default {
63 64
           {
64 65
             min: 6,
65 66
             max: 16,
66
-            message: "密码长度为6~16个字符"
67
+            message: "密码长度为6~16个字符",
68
+            trigger: "blur"
67 69
           }
68 70
         ]
69 71
       }
@@ -78,7 +80,7 @@ export default {
78 80
             loginpwd: this.loginInfo.loginpwd
79 81
           })
80 82
             .then((res) => {
81
-              if (res.code == 0) {
83
+              if (res.code === 0) {
82 84
                 localStorage.setItem("xhWebAdminUser", JSON.stringify(res.obj));
83 85
                 this.$router.replace({ path: "/users" });
84 86
               } else {

+ 405
- 4
src/views/users/index.vue Visa fil

@@ -1,14 +1,415 @@
1 1
 <template>
2
-  <div>user</div>
2
+  <div>
3
+    <div class="searchBox">
4
+      <div>
5
+        <RadioGroup v-model="userSearch.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="userSearch.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
+        <Button type="primary" @click="toAdd()">添加</Button>
21
+      </div>
22
+    </div>
23
+    <Table border :columns="userColumns" :data="userSearch.list">
24
+      <template slot-scope="{ row }" slot="userstateSlot">
25
+        <span>{{ row.userstate === 1 ? "正常" : "已删除" }}</span>
26
+      </template>
27
+      <template slot-scope="{ row }" slot="createtimeSlot">
28
+        <span>{{ dateFormat(row.createtime) }}</span>
29
+      </template>
30
+      <template slot-scope="{ row }" slot="actionSlot">
31
+        <div v-if="row.userstate === 1">
32
+          <span
33
+            style="color: #2d8cf0; cursor: pointer"
34
+            @click="toModifyUser(row)"
35
+            >修改</span
36
+          >
37
+          <span style="margin: 0 10px; color: #2d8cf0">|</span>
38
+          <span
39
+            style="color: #ff001e; cursor: pointer"
40
+            @click="toDelUser(row.userid)"
41
+            >删除</span
42
+          >
43
+        </div>
44
+      </template>
45
+    </Table>
46
+    <div class="foot_page" v-if="userSearch.total > 0">
47
+      <Page
48
+        :total="userSearch.total"
49
+        @on-change="changePage"
50
+        :current="userSearch.page"
51
+        show-total
52
+      ></Page>
53
+    </div>
54
+    <Modal
55
+      v-model="userAddForm.show"
56
+      class="modal1"
57
+      :mask-closable="false"
58
+      title="添加用户信息"
59
+    >
60
+      <Form
61
+        :label-width="90"
62
+        label-position="right"
63
+        ref="userAddForm"
64
+        :rules="addFormRules"
65
+        :model="userAddForm"
66
+      >
67
+        <FormItem label="用户姓名" prop="username">
68
+          <Input v-model="userAddForm.username" placeholder="请输入用户姓名" />
69
+        </FormItem>
70
+        <FormItem label="登录账号" prop="loginname">
71
+          <Input v-model="userAddForm.loginname" placeholder="请输入登录账号" />
72
+        </FormItem>
73
+        <FormItem label="登录密码" prop="loginpwd">
74
+          <Input v-model="userAddForm.loginpwd" placeholder="请输入登录密码" />
75
+        </FormItem>
76
+        <FormItem label="手机号" prop="userphone">
77
+          <Input v-model="userAddForm.userphone" placeholder="请输入手机号" />
78
+        </FormItem>
79
+      </Form>
80
+      <div slot="footer" style="text-align: right">
81
+        <Button @click="userAddForm.show = false">取消</Button>
82
+        <Button @click="toSaveAdd()" type="primary">保存</Button>
83
+      </div>
84
+    </Modal>
85
+    <Modal
86
+      v-model="userModifyForm.show"
87
+      class="modal1"
88
+      :mask-closable="false"
89
+      title="修改用户信息"
90
+    >
91
+      <Form
92
+        :label-width="90"
93
+        label-position="right"
94
+        ref="userModifyForm"
95
+        :rules="modifyFormRules"
96
+        :model="userModifyForm"
97
+      >
98
+        <FormItem label="用户姓名" prop="username">
99
+          <Input
100
+            v-model="userModifyForm.username"
101
+            placeholder="请输入用户姓名"
102
+          />
103
+        </FormItem>
104
+        <FormItem label="登录账号" prop="loginname">
105
+          <Input
106
+            v-model="userModifyForm.loginname"
107
+            placeholder="请输入登录账号"
108
+          />
109
+        </FormItem>
110
+        <FormItem label="登录密码" prop="loginpwd">
111
+          <Input
112
+            v-model="userModifyForm.loginpwd"
113
+            placeholder="请输入登录密码"
114
+          />
115
+        </FormItem>
116
+        <FormItem label="手机号" prop="userphone">
117
+          <Input
118
+            v-model="userModifyForm.userphone"
119
+            placeholder="请输入手机号"
120
+          />
121
+        </FormItem>
122
+      </Form>
123
+      <div slot="footer" style="text-align: right">
124
+        <Button @click="userModifyForm.show = false">取消</Button>
125
+        <Button @click="toSaveModifyUser()" type="primary">保存</Button>
126
+      </div>
127
+    </Modal>
128
+  </div>
3 129
 </template>
4 130
 
5 131
 <script>
132
+import { user_list, user_del, user_save, user_update } from "@/api";
133
+import { dateFormat } from "@/utils";
6 134
 export default {
7 135
   data() {
8
-    return {};
136
+    // 手机号验证
137
+    const phoneCheck = async (rule, value, callback) => {
138
+      var filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
139
+      if (!value) {
140
+        return;
141
+      }
142
+      let blnTest = filter.test(value);
143
+      if (!blnTest) {
144
+        return callback(new Error("手机号码格式不正确"));
145
+      }
146
+    };
147
+    return {
148
+      dateFormat,
149
+      userSearch: {
150
+        page: 1,
151
+        size: 10,
152
+        userstate: 0,
153
+        username: "",
154
+        total: 0,
155
+        list: [],
156
+      },
157
+      userColumns: [
158
+        {
159
+          title: "序号",
160
+          width: 70,
161
+          render: (h, params) => {
162
+            return h(
163
+              "span",
164
+              params.index +
165
+                (this.userSearch.page - 1) * this.userSearch.size +
166
+                1
167
+            );
168
+          },
169
+        },
170
+        {
171
+          title: "用户姓名",
172
+          key: "username",
173
+        },
174
+        {
175
+          title: "登录账号",
176
+          key: "loginname",
177
+        },
178
+        {
179
+          title: "手机号",
180
+          key: "userphone",
181
+        },
182
+        {
183
+          title: "状态",
184
+          slot: "userstateSlot",
185
+          width: 90,
186
+        },
187
+        {
188
+          title: "创建人",
189
+          key: "createname",
190
+          width: 120,
191
+        },
192
+        {
193
+          title: "创建时间",
194
+          slot: "createtimeSlot",
195
+          width: 200,
196
+        },
197
+        {
198
+          title: "操作",
199
+          slot: "actionSlot",
200
+          width: 150,
201
+        },
202
+      ],
203
+      userAddForm: {
204
+        show: false,
205
+        username: "",
206
+        loginname: "",
207
+        loginpwd: "",
208
+        userphone: null,
209
+      },
210
+      addFormRules: {
211
+        username: [
212
+          {
213
+            required: true,
214
+            message: "用户姓名不能为空",
215
+            trigger: "blur",
216
+          },
217
+        ],
218
+        loginname: [
219
+          {
220
+            required: true,
221
+            message: "登录账号不能为空",
222
+            trigger: "blur",
223
+          },
224
+          {
225
+            min: 4,
226
+            max: 18,
227
+            message: "登录账号长度为4~18个字符",
228
+            trigger: "blur",
229
+          },
230
+        ],
231
+        loginpwd: [
232
+          {
233
+            required: true,
234
+            message: "登录密码不能为空",
235
+            trigger: "blur",
236
+          },
237
+          {
238
+            min: 6,
239
+            max: 16,
240
+            message: "登录密码长度为6~16个字符",
241
+            trigger: "blur",
242
+          },
243
+        ],
244
+        userphone: [{ validator: phoneCheck, trigger: "blur" }],
245
+      },
246
+      userModifyForm: {
247
+        show: false,
248
+        userid: null,
249
+        username: "",
250
+        loginname: "",
251
+        loginpwd: "",
252
+        userphone: null,
253
+      },
254
+      modifyFormRules: {
255
+        username: [
256
+          {
257
+            required: true,
258
+            message: "用户姓名不能为空",
259
+            trigger: "blur",
260
+          },
261
+        ],
262
+        loginname: [
263
+          {
264
+            required: true,
265
+            message: "登录账号不能为空",
266
+            trigger: "blur",
267
+          },
268
+          {
269
+            min: 4,
270
+            max: 18,
271
+            message: "登录账号长度为4~18个字符",
272
+          },
273
+        ],
274
+        loginpwd: [
275
+          // {
276
+          //   required: true,
277
+          //   message: "登录密码不能为空",
278
+          //   trigger: "blur",
279
+          // },
280
+          {
281
+            min: 6,
282
+            max: 16,
283
+            message: "登录密码长度为6~16个字符",
284
+            trigger: "blur",
285
+          },
286
+        ],
287
+        userphone: [{ validator: phoneCheck, trigger: "blur" }],
288
+      },
289
+      userInfo: {},
290
+    };
291
+  },
292
+  created() {
293
+    this.userInfo = JSON.parse(localStorage.getItem("xhWebAdminUser"));
294
+    this.getUsersList();
295
+  },
296
+  methods: {
297
+    searchList() {
298
+      this.userSearch.page = 1;
299
+      this.getUsersList();
300
+    },
301
+    getUsersList() {
302
+      user_list({
303
+        page: this.userSearch.page,
304
+        size: this.userSearch.size,
305
+        userstate: this.userSearch.userstate,
306
+        username: this.userSearch.username,
307
+      })
308
+        .then((data) => {
309
+          if (data.code === 0) {
310
+            this.userSearch.total = data.obj.total;
311
+            this.userSearch.list = data.obj.list;
312
+          } else {
313
+            this.userSearch.total = 0;
314
+            this.userSearch.list = [];
315
+            this.$Message.error(data.msg);
316
+          }
317
+        })
318
+        .catch(() => {});
319
+    },
320
+    toDelUser(userid) {
321
+      this.$Modal.confirm({
322
+        title: "提示",
323
+        content: "您确定删除选中数据吗?",
324
+        onOk: () => {
325
+          user_del({ userid }).then((res) => {
326
+            if (res.code == 0) {
327
+              this.$Message.success(res.msg);
328
+              this.searchList();
329
+            }
330
+          });
331
+        },
332
+        onCancel: () => {},
333
+      });
334
+    },
335
+    toAdd() {
336
+      this.userAddForm = {
337
+        show: true,
338
+        username: "",
339
+        loginname: "",
340
+        loginpwd: "",
341
+        userphone: null,
342
+      };
343
+    },
344
+    toSaveAdd() {
345
+      this.$refs.userAddForm.validate((valid) => {
346
+        if (valid) {
347
+          user_save({
348
+            username: this.userAddForm.username,
349
+            loginname: this.userAddForm.loginname,
350
+            loginpwd: this.userAddForm.loginpwd,
351
+            createid: this.userInfo.userid,
352
+            userphone: this.userAddForm.userphone,
353
+          }).then((data) => {
354
+            if (data.code === 0) {
355
+              this.userAddForm.show = false;
356
+              this.$Message.success(data.msg);
357
+              this.searchList();
358
+            } else {
359
+              this.$Message.error(data.msg);
360
+            }
361
+          });
362
+        }
363
+      });
364
+    },
365
+    toModifyUser(user) {
366
+      this.userModifyForm = {
367
+        show: true,
368
+        userid: user.userid,
369
+        username: user.username,
370
+        loginname: user.loginname,
371
+        loginpwd: user.loginpwd,
372
+        userphone: user.userphone,
373
+      };
374
+    },
375
+    toSaveModifyUser() {
376
+      this.$refs.userModifyForm.validate((valid) => {
377
+        if (valid) {
378
+          user_update({
379
+            username: this.userModifyForm.username,
380
+            loginname: this.userModifyForm.loginname,
381
+            loginpwd: this.userModifyForm.loginpwd,
382
+            createid: this.userInfo.userid,
383
+            userphone: this.userModifyForm.userphone,
384
+            userid: this.userModifyForm.userid
385
+          }).then((data) => {
386
+            if (data.code === 0) {
387
+              this.userModifyForm.show = false;
388
+              this.$Message.success(data.msg);
389
+              this.searchList();
390
+            } else {
391
+              this.$Message.error(data.msg);
392
+            }
393
+          });
394
+        }
395
+      });
396
+    },
397
+    changePage(page) {
398
+      this.userSearch.page = page;
399
+      this.getUsersList();
400
+    },
9 401
   },
10
-  methods: {}
11 402
 };
12 403
 </script>
13 404
 
14
-<style scoped lang="less"></style>
405
+<style scoped lang="less">
406
+.searchBox {
407
+  display: flex;
408
+  justify-content: space-between;
409
+  padding: 16px 0;
410
+}
411
+.foot_page {
412
+  padding: 16px 0;
413
+  text-align: right;
414
+}
415
+</style>

Laddar…
Avbryt
Spara