Commit 51f45a4978f516e78537637b29bdc342ecfbbd7f
1 parent
b5114789
1.添加账号管理交互
Showing
14 changed files
with
372 additions
and
76 deletions
package-lock.json
... | ... | @@ -6320,7 +6320,8 @@ |
6320 | 6320 | "ansi-regex": { |
6321 | 6321 | "version": "2.1.1", |
6322 | 6322 | "bundled": true, |
6323 | - "dev": true | |
6323 | + "dev": true, | |
6324 | + "optional": true | |
6324 | 6325 | }, |
6325 | 6326 | "aproba": { |
6326 | 6327 | "version": "1.2.0", |
... | ... | @@ -6341,12 +6342,14 @@ |
6341 | 6342 | "balanced-match": { |
6342 | 6343 | "version": "1.0.0", |
6343 | 6344 | "bundled": true, |
6344 | - "dev": true | |
6345 | + "dev": true, | |
6346 | + "optional": true | |
6345 | 6347 | }, |
6346 | 6348 | "brace-expansion": { |
6347 | 6349 | "version": "1.1.11", |
6348 | 6350 | "bundled": true, |
6349 | 6351 | "dev": true, |
6352 | + "optional": true, | |
6350 | 6353 | "requires": { |
6351 | 6354 | "balanced-match": "^1.0.0", |
6352 | 6355 | "concat-map": "0.0.1" |
... | ... | @@ -6361,17 +6364,20 @@ |
6361 | 6364 | "code-point-at": { |
6362 | 6365 | "version": "1.1.0", |
6363 | 6366 | "bundled": true, |
6364 | - "dev": true | |
6367 | + "dev": true, | |
6368 | + "optional": true | |
6365 | 6369 | }, |
6366 | 6370 | "concat-map": { |
6367 | 6371 | "version": "0.0.1", |
6368 | 6372 | "bundled": true, |
6369 | - "dev": true | |
6373 | + "dev": true, | |
6374 | + "optional": true | |
6370 | 6375 | }, |
6371 | 6376 | "console-control-strings": { |
6372 | 6377 | "version": "1.1.0", |
6373 | 6378 | "bundled": true, |
6374 | - "dev": true | |
6379 | + "dev": true, | |
6380 | + "optional": true | |
6375 | 6381 | }, |
6376 | 6382 | "core-util-is": { |
6377 | 6383 | "version": "1.0.2", |
... | ... | @@ -6488,7 +6494,8 @@ |
6488 | 6494 | "inherits": { |
6489 | 6495 | "version": "2.0.4", |
6490 | 6496 | "bundled": true, |
6491 | - "dev": true | |
6497 | + "dev": true, | |
6498 | + "optional": true | |
6492 | 6499 | }, |
6493 | 6500 | "ini": { |
6494 | 6501 | "version": "1.3.5", |
... | ... | @@ -6500,6 +6507,7 @@ |
6500 | 6507 | "version": "1.0.0", |
6501 | 6508 | "bundled": true, |
6502 | 6509 | "dev": true, |
6510 | + "optional": true, | |
6503 | 6511 | "requires": { |
6504 | 6512 | "number-is-nan": "^1.0.0" |
6505 | 6513 | } |
... | ... | @@ -6514,6 +6522,7 @@ |
6514 | 6522 | "version": "3.0.4", |
6515 | 6523 | "bundled": true, |
6516 | 6524 | "dev": true, |
6525 | + "optional": true, | |
6517 | 6526 | "requires": { |
6518 | 6527 | "brace-expansion": "^1.1.7" |
6519 | 6528 | } |
... | ... | @@ -6521,12 +6530,14 @@ |
6521 | 6530 | "minimist": { |
6522 | 6531 | "version": "0.0.8", |
6523 | 6532 | "bundled": true, |
6524 | - "dev": true | |
6533 | + "dev": true, | |
6534 | + "optional": true | |
6525 | 6535 | }, |
6526 | 6536 | "minipass": { |
6527 | 6537 | "version": "2.9.0", |
6528 | 6538 | "bundled": true, |
6529 | 6539 | "dev": true, |
6540 | + "optional": true, | |
6530 | 6541 | "requires": { |
6531 | 6542 | "safe-buffer": "^5.1.2", |
6532 | 6543 | "yallist": "^3.0.0" |
... | ... | @@ -6545,6 +6556,7 @@ |
6545 | 6556 | "version": "0.5.1", |
6546 | 6557 | "bundled": true, |
6547 | 6558 | "dev": true, |
6559 | + "optional": true, | |
6548 | 6560 | "requires": { |
6549 | 6561 | "minimist": "0.0.8" |
6550 | 6562 | } |
... | ... | @@ -6634,7 +6646,8 @@ |
6634 | 6646 | "number-is-nan": { |
6635 | 6647 | "version": "1.0.1", |
6636 | 6648 | "bundled": true, |
6637 | - "dev": true | |
6649 | + "dev": true, | |
6650 | + "optional": true | |
6638 | 6651 | }, |
6639 | 6652 | "object-assign": { |
6640 | 6653 | "version": "4.1.1", |
... | ... | @@ -6646,6 +6659,7 @@ |
6646 | 6659 | "version": "1.4.0", |
6647 | 6660 | "bundled": true, |
6648 | 6661 | "dev": true, |
6662 | + "optional": true, | |
6649 | 6663 | "requires": { |
6650 | 6664 | "wrappy": "1" |
6651 | 6665 | } |
... | ... | @@ -6731,7 +6745,8 @@ |
6731 | 6745 | "safe-buffer": { |
6732 | 6746 | "version": "5.1.2", |
6733 | 6747 | "bundled": true, |
6734 | - "dev": true | |
6748 | + "dev": true, | |
6749 | + "optional": true | |
6735 | 6750 | }, |
6736 | 6751 | "safer-buffer": { |
6737 | 6752 | "version": "2.1.2", |
... | ... | @@ -6767,6 +6782,7 @@ |
6767 | 6782 | "version": "1.0.2", |
6768 | 6783 | "bundled": true, |
6769 | 6784 | "dev": true, |
6785 | + "optional": true, | |
6770 | 6786 | "requires": { |
6771 | 6787 | "code-point-at": "^1.0.0", |
6772 | 6788 | "is-fullwidth-code-point": "^1.0.0", |
... | ... | @@ -6786,6 +6802,7 @@ |
6786 | 6802 | "version": "3.0.1", |
6787 | 6803 | "bundled": true, |
6788 | 6804 | "dev": true, |
6805 | + "optional": true, | |
6789 | 6806 | "requires": { |
6790 | 6807 | "ansi-regex": "^2.0.0" |
6791 | 6808 | } |
... | ... | @@ -6829,12 +6846,14 @@ |
6829 | 6846 | "wrappy": { |
6830 | 6847 | "version": "1.0.2", |
6831 | 6848 | "bundled": true, |
6832 | - "dev": true | |
6849 | + "dev": true, | |
6850 | + "optional": true | |
6833 | 6851 | }, |
6834 | 6852 | "yallist": { |
6835 | 6853 | "version": "3.1.1", |
6836 | 6854 | "bundled": true, |
6837 | - "dev": true | |
6855 | + "dev": true, | |
6856 | + "optional": true | |
6838 | 6857 | } |
6839 | 6858 | } |
6840 | 6859 | }, |
... | ... | @@ -12175,10 +12194,9 @@ |
12175 | 12194 | "dev": true |
12176 | 12195 | }, |
12177 | 12196 | "qs": { |
12178 | - "version": "6.5.2", | |
12179 | - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", | |
12180 | - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", | |
12181 | - "dev": true | |
12197 | + "version": "6.9.1", | |
12198 | + "resolved": "https://registry.npmjs.org/qs/-/qs-6.9.1.tgz", | |
12199 | + "integrity": "sha512-Cxm7/SS/y/Z3MHWSxXb8lIFqgqBowP5JMlTUFyJN88y0SGQhVmZnqFK/PeuMX9LzUyWsqqhNxIyg0jlzq946yA==" | |
12182 | 12200 | }, |
12183 | 12201 | "query-string": { |
12184 | 12202 | "version": "5.1.1", |
... | ... | @@ -12607,6 +12625,14 @@ |
12607 | 12625 | "tough-cookie": "~2.5.0", |
12608 | 12626 | "tunnel-agent": "^0.6.0", |
12609 | 12627 | "uuid": "^3.3.2" |
12628 | + }, | |
12629 | + "dependencies": { | |
12630 | + "qs": { | |
12631 | + "version": "6.5.2", | |
12632 | + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", | |
12633 | + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", | |
12634 | + "dev": true | |
12635 | + } | |
12610 | 12636 | } |
12611 | 12637 | }, |
12612 | 12638 | "request-promise-core": { |
... | ... | @@ -12829,7 +12855,8 @@ |
12829 | 12855 | "version": "4.0.8", |
12830 | 12856 | "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz", |
12831 | 12857 | "integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=", |
12832 | - "dev": true | |
12858 | + "dev": true, | |
12859 | + "optional": true | |
12833 | 12860 | }, |
12834 | 12861 | "rx-lite-aggregates": { |
12835 | 12862 | "version": "4.0.8", | ... | ... |
package.json
src/api/role.js
0 → 100644
src/api/subject.js
0 → 100644
src/api/teacher.js
0 → 100644
1 | +import request from '@/utils/request' | |
2 | + | |
3 | +export function add(data) { | |
4 | + return request({ | |
5 | + url: '/teacher/add', | |
6 | + method: 'post', | |
7 | + data | |
8 | + }) | |
9 | +} | |
10 | +export function deluser(id) { | |
11 | + return request({ | |
12 | + url: '/teacher/del', | |
13 | + method: 'post', | |
14 | + data: { id } | |
15 | + }) | |
16 | +} | ... | ... |
src/api/user.js
... | ... | @@ -18,7 +18,40 @@ export function getInfo(token) { |
18 | 18 | |
19 | 19 | export function logout() { |
20 | 20 | return request({ |
21 | - url: '/vue-admin-template/user/logout', | |
21 | + url: '/logout', | |
22 | 22 | method: 'post' |
23 | 23 | }) |
24 | 24 | } |
25 | + | |
26 | +export function getUserList(schoolId) { | |
27 | + return request({ | |
28 | + url: '/user/schoolusers', | |
29 | + method: 'post', | |
30 | + data: { schoolId } | |
31 | + }) | |
32 | +} | |
33 | + | |
34 | +export function enableUser(id, enable) { | |
35 | + return request({ | |
36 | + url: '/user/enableuser', | |
37 | + method: 'post', | |
38 | + data: { id, enable } | |
39 | + }) | |
40 | +} | |
41 | + | |
42 | +export function searchUser(data) { | |
43 | + return request({ | |
44 | + url: '/user/search', | |
45 | + method: 'post', | |
46 | + data | |
47 | + }) | |
48 | +} | |
49 | + | |
50 | +export function resetpass(data) { | |
51 | + return request({ | |
52 | + url: '/user/resetpass', | |
53 | + method: 'post', | |
54 | + data | |
55 | + }) | |
56 | +} | |
57 | + | ... | ... |
src/layout/index.vue
src/permission.js
src/store/modules/user.js
... | ... | @@ -3,7 +3,11 @@ import { |
3 | 3 | getToken, |
4 | 4 | setToken, |
5 | 5 | removeToken, |
6 | - setLogoLayout | |
6 | + removeUser, | |
7 | + setLogoLayout, | |
8 | + saveuser, | |
9 | + setuserinfo, | |
10 | + removeuserinfo | |
7 | 11 | } from '@/utils/auth' |
8 | 12 | import { resetRouter } from '@/router' |
9 | 13 | |
... | ... | @@ -12,7 +16,8 @@ const getDefaultState = () => { |
12 | 16 | token: getToken(), |
13 | 17 | name: '', |
14 | 18 | avatar: '', |
15 | - logoLayout: '' | |
19 | + logoLayout: '', | |
20 | + userInfo: {} | |
16 | 21 | } |
17 | 22 | } |
18 | 23 | |
... | ... | @@ -33,6 +38,9 @@ const mutations = { |
33 | 38 | }, |
34 | 39 | SET_LOGOLAYOUT: (state, logoLayout) => { |
35 | 40 | state.logoLayout = logoLayout |
41 | + }, | |
42 | + SET_USERINFO: (state, userInfo) => { | |
43 | + state.userInfo = userInfo | |
36 | 44 | } |
37 | 45 | } |
38 | 46 | |
... | ... | @@ -44,9 +52,12 @@ const actions = { |
44 | 52 | login({ username: username.trim(), password: password }) |
45 | 53 | .then(response => { |
46 | 54 | const { data } = response |
47 | - commit('SET_TOKEN', data.token) | |
55 | + console.log(data) | |
56 | + commit('SET_TOKEN', data.username) | |
48 | 57 | commit('SET_LOGOLAYOUT', data.logoLayout) |
49 | - setToken(data.token) | |
58 | + commit('SET_USERINFO', JSON.stringify(data)) | |
59 | + setuserinfo(JSON.stringify(data)) | |
60 | + setToken(data.username) | |
50 | 61 | setLogoLayout(data.logoLayout) |
51 | 62 | resolve(response) |
52 | 63 | }) |
... | ... | @@ -79,12 +90,22 @@ const actions = { |
79 | 90 | }) |
80 | 91 | }, |
81 | 92 | |
93 | + saveuser({ commit }, userInfo) { | |
94 | + console.log(userInfo) | |
95 | + const { username, password } = userInfo | |
96 | + const param = { username: username.trim(), password: password } | |
97 | + console.log(param) | |
98 | + saveuser(JSON.stringify(param)) | |
99 | + }, | |
100 | + | |
82 | 101 | // user logout |
83 | 102 | logout({ commit, state }) { |
84 | 103 | return new Promise((resolve, reject) => { |
85 | 104 | logout(state.token) |
86 | 105 | .then(() => { |
87 | 106 | removeToken() // must remove token first |
107 | + removeUser() | |
108 | + removeuserinfo() | |
88 | 109 | resetRouter() |
89 | 110 | commit('RESET_STATE') |
90 | 111 | resolve() | ... | ... |
src/styles/sidebar.scss
src/utils/auth.js
... | ... | @@ -22,3 +22,25 @@ export function getLogoLayout() { |
22 | 22 | export function setLogoLayout(token) { |
23 | 23 | return Cookies.set(LogoLayout, token) |
24 | 24 | } |
25 | + | |
26 | +export function saveuser(userinfo) { | |
27 | + return Cookies.set('logininfo', userinfo) | |
28 | +} | |
29 | + | |
30 | +export function getuser() { | |
31 | + return Cookies.get('logininfo') | |
32 | +} | |
33 | + | |
34 | +export function removeUser() { | |
35 | + return Cookies.remove('logininfo') | |
36 | +} | |
37 | + | |
38 | +export function setuserinfo(userinfo) { | |
39 | + return Cookies.set('userinfo', userinfo) | |
40 | +} | |
41 | +export function getuserinfo() { | |
42 | + return Cookies.set('userinfo') | |
43 | +} | |
44 | +export function removeuserinfo() { | |
45 | + return Cookies.remove('userinfo') | |
46 | +} | ... | ... |
src/utils/request.js
... | ... | @@ -2,6 +2,7 @@ import axios from 'axios' |
2 | 2 | import { MessageBox, Message } from 'element-ui' |
3 | 3 | import store from '@/store' |
4 | 4 | import { getToken } from '@/utils/auth' |
5 | +import qs from 'qs' | |
5 | 6 | |
6 | 7 | // create an axios instance |
7 | 8 | const service = axios.create({ |
... | ... | @@ -14,7 +15,8 @@ const service = axios.create({ |
14 | 15 | service.interceptors.request.use( |
15 | 16 | config => { |
16 | 17 | // do something before request is sent |
17 | - | |
18 | + console.log(config) | |
19 | + config.data = qs.stringify(config.data) | |
18 | 20 | if (store.getters.token) { |
19 | 21 | // let each request carry token |
20 | 22 | // ['X-Token'] is a custom headers key |
... | ... | @@ -46,7 +48,7 @@ service.interceptors.response.use( |
46 | 48 | const res = response.data |
47 | 49 | |
48 | 50 | // if the custom code is not 20000, it is judged as an error. |
49 | - if (res.code !== 20000) { | |
51 | + if (res.code !== 0) { | |
50 | 52 | Message({ |
51 | 53 | message: res.message || 'Error', |
52 | 54 | type: 'error', | ... | ... |
src/views/account/index.vue
... | ... | @@ -4,31 +4,30 @@ |
4 | 4 | |
5 | 5 | <div class="app-container"> |
6 | 6 | <div class="btm-group"> |
7 | - <el-button type="primary" @click="accountdialog=true">新增账号</el-button> | |
7 | + <el-button type="primary" @click="add">新增账号</el-button> | |
8 | 8 | <el-button type="primary" @click="importdialog=true">批量导入</el-button> |
9 | 9 | <el-button type="primary">批量导出</el-button> |
10 | 10 | <el-button type="danger">批量删除</el-button> |
11 | 11 | </div> |
12 | 12 | <div class="select-group"> |
13 | 13 | <el-form ref="form" :inline="true" :model="form" label-width="60px"> |
14 | - <el-form-item label="角色:"> | |
14 | + <el-form-item label="角色:" prop="role"> | |
15 | 15 | <el-select v-model="form.role" style="width:100px" size="small" placeholder="请选择角色"> |
16 | 16 | <el-option label="全部" value="" /> |
17 | - <el-option label="教师" value="teacher" /> | |
18 | - <el-option label="班主任" value="bzr" /> | |
17 | + <el-option v-for="(item,index) in roleList" :key="index" :label="item.name" :value="item.id" /> | |
19 | 18 | </el-select> |
20 | 19 | </el-form-item> |
21 | - <el-form-item label="账号:"> | |
20 | + <el-form-item label="账号:" prop="account"> | |
22 | 21 | <el-input v-model="form.account" size="small" placeholder="请输入账号" /> |
23 | 22 | </el-form-item> |
24 | - <el-form-item label="姓名:"> | |
23 | + <el-form-item label="姓名:" prop="name"> | |
25 | 24 | <el-input v-model="form.name" size="small" placeholder="请输入姓名" /> |
26 | 25 | </el-form-item> |
27 | - <el-form-item label="状态:"> | |
26 | + <el-form-item label="状态:" prop="state"> | |
28 | 27 | <el-select v-model="form.state" style="width:100px;" size="small" placeholder="请选择状态"> |
29 | 28 | <el-option label="全部" value="" /> |
30 | - <el-option label="正常" value="normal" /> | |
31 | - <el-option label="禁用" value="disable" /> | |
29 | + <el-option label="正常" value="1" /> | |
30 | + <el-option label="禁用" value="0" /> | |
32 | 31 | </el-select> |
33 | 32 | </el-form-item> |
34 | 33 | <el-form-item> |
... | ... | @@ -51,11 +50,18 @@ |
51 | 50 | width="55" |
52 | 51 | /> |
53 | 52 | <el-table-column |
54 | - prop="role" | |
55 | - label="角色" | |
53 | + label="序号" | |
54 | + > | |
55 | + <template slot-scope="scope"> | |
56 | + {{ scope.$index+1 }} | |
57 | + </template> | |
58 | + </el-table-column> | |
59 | + <el-table-column | |
60 | + prop="id" | |
61 | + label="ID" | |
56 | 62 | /> |
57 | 63 | <el-table-column |
58 | - prop="account" | |
64 | + prop="username" | |
59 | 65 | label="账号" |
60 | 66 | /> |
61 | 67 | <el-table-column |
... | ... | @@ -67,19 +73,23 @@ |
67 | 73 | label="性别" |
68 | 74 | /> |
69 | 75 | <el-table-column |
70 | - prop="code" | |
71 | - label="授权码" | |
76 | + prop="roleName" | |
77 | + label="角色" | |
72 | 78 | /> |
73 | 79 | <el-table-column |
74 | - prop="state" | |
80 | + prop="enable" | |
75 | 81 | label="状态" |
76 | - /> | |
82 | + > | |
83 | + <template slot-scope="scope"> | |
84 | + {{ scope.row.enable==1?'正常':'禁用' }} | |
85 | + </template> | |
86 | + </el-table-column> | |
77 | 87 | <el-table-column label="操作" width="250"> |
78 | 88 | <template slot-scope="scope"> |
79 | - <el-button type="success" size="small" icon="el-ump-bofang" circle @click="enable(scope)" /> | |
80 | - <el-button type="primary" size="small" icon="el-ump-yuechi" circle @click="enable(scope)" /> | |
81 | - <el-button type="primary" size="small" icon="el-icon-edit-outline" circle @click="enable(scope)" /> | |
82 | - <el-button type="danger" size="small" icon="el-icon-delete" circle @click="enable(scope)" /> | |
89 | + <el-button :type="scope.row.enable==1?'success':'warning'" size="small" :icon="scope.row.enable==1?'el-ump-bofang':'el-ump-zanting'" circle @click="enable(scope.row)" /> | |
90 | + <el-button type="primary" size="small" icon="el-ump-yuechi" circle @click="reset(scope.row)" /> | |
91 | + <el-button type="primary" size="small" icon="el-icon-edit-outline" circle @click="edit(scope.row)" /> | |
92 | + <el-button type="danger" size="small" icon="el-icon-delete" circle @click="deluser(scope.row)" /> | |
83 | 93 | </template> |
84 | 94 | </el-table-column> |
85 | 95 | </el-table> |
... | ... | @@ -89,55 +99,52 @@ |
89 | 99 | <el-dialog |
90 | 100 | title="账号信息" |
91 | 101 | :visible.sync="accountdialog" |
92 | - width="30%" | |
93 | 102 | > |
94 | 103 | <el-form ref="account" :model="account" label-width="100px" style="margin-top:30px;"> |
95 | - <el-form-item label="用户角色"> | |
104 | + <el-form-item label="用户角色" prop="role"> | |
96 | 105 | <el-select v-model="account.role" style="width:300px;" placeholder="请选择"> |
97 | 106 | <el-option |
98 | - v-for="item in roles" | |
107 | + v-for="item in roleList" | |
99 | 108 | :key="item.id" |
100 | - :label="item.label" | |
109 | + :label="item.name" | |
101 | 110 | :value="item.id" |
102 | 111 | > |
103 | - <span style="float: left">{{ item.label }}</span> | |
112 | + <span style="float: left">{{ item.name }}</span> | |
104 | 113 | <span style="float: right; color: #8492a6; font-size: 13px">{{ item.dec }}</span> |
105 | 114 | </el-option> |
106 | 115 | </el-select> |
107 | 116 | </el-form-item> |
108 | - <el-form-item label="账号"> | |
109 | - <el-input v-model="account.account" style="width:300px;" placeholder="请输入账号" /> | |
117 | + <el-form-item label="账号" prop="username"> | |
118 | + <el-input v-model="account.username" style="width:300px;" placeholder="请输入账号" /> | |
110 | 119 | <p class="password">初始密码统一为123456</p> |
111 | 120 | </el-form-item> |
112 | - <el-form-item label="姓名"> | |
121 | + <el-form-item label="姓名" prop="name"> | |
113 | 122 | <el-input v-model="account.name" style="width:300px;" placeholder="请输入真实姓名" /> |
114 | 123 | </el-form-item> |
115 | - <el-form-item label="性别"> | |
124 | + <el-form-item label="性别" prop="sex"> | |
116 | 125 | <el-select v-model="account.sex" style="width:300px;" placeholder="请选择性别"> |
117 | 126 | <el-option value="0" label="男" /> |
118 | 127 | <el-option value="1" label="女" /> |
119 | 128 | </el-select> |
120 | 129 | </el-form-item> |
121 | - <el-form-item label="科目"> | |
122 | - <el-select v-model="account.object" style="width:300px;" placeholder="请选择"> | |
123 | - <el-option value="0" label="语文" /> | |
124 | - <el-option value="1" label="数学" /> | |
130 | + <el-form-item label="科目" prop="subjectId"> | |
131 | + <el-select v-model="account.subjectId" style="width:300px;" placeholder="请选择"> | |
132 | + <el-option v-for="(item,index) in subjectList" :key="index" :value="item.id" :label="item.cname" /> | |
125 | 133 | </el-select> |
126 | 134 | </el-form-item> |
127 | - <el-form-item label="备注"> | |
135 | + <el-form-item label="备注" prop="remark"> | |
128 | 136 | <el-input v-model="account.remark" style="width:300px;" /> |
129 | 137 | </el-form-item> |
130 | 138 | </el-form> |
131 | 139 | <span slot="footer" class="dialog-footer"> |
132 | - <el-button @click="accountdialog = false">取 消</el-button> | |
133 | - <el-button type="primary" @click="accountdialog = false">保 存</el-button> | |
140 | + <el-button @click="close">取 消</el-button> | |
141 | + <el-button type="primary" @click="save">保 存</el-button> | |
134 | 142 | </span> |
135 | 143 | </el-dialog> |
136 | 144 | <!--批量导入--> |
137 | 145 | <el-dialog |
138 | 146 | title="批量导入用户" |
139 | 147 | :visible.sync="importdialog" |
140 | - width="30%" | |
141 | 148 | > |
142 | 149 | <p>第一步:下载模板并编辑完成用户的信息 <el-link type="primary"><i class="el-ump-xiazai" />下载导入模板</el-link></p> |
143 | 150 | <p>第二步:上传编辑完成的模板文件,完成导入</p> |
... | ... | @@ -161,8 +168,12 @@ |
161 | 168 | </template> |
162 | 169 | |
163 | 170 | <script> |
164 | -import { getList } from '@/api/table' | |
165 | 171 | import Dec from '@/components/Dec' |
172 | +import { getUserList, searchUser, resetpass, enableUser } from '@/api/user' | |
173 | +import { getRoleList } from '@/api/role' | |
174 | +import { getSubjectList } from '@/api/subject' | |
175 | +import { add, deluser } from '@/api/teacher' | |
176 | +import { getuserinfo } from '@/utils/auth' | |
166 | 177 | |
167 | 178 | export default { |
168 | 179 | components: { |
... | ... | @@ -171,6 +182,7 @@ export default { |
171 | 182 | data() { |
172 | 183 | return { |
173 | 184 | list: null, |
185 | + dept: '', | |
174 | 186 | listLoading: false, |
175 | 187 | accountdialog: false, |
176 | 188 | importdialog: false, |
... | ... | @@ -179,33 +191,153 @@ export default { |
179 | 191 | { id: 0, label: '任课老师', dec: '无班级管理权限' }, |
180 | 192 | { id: 1, label: '班主任', dec: '有班级管理权限' } |
181 | 193 | ], |
194 | + roleList: [], | |
195 | + subjectList: [], | |
182 | 196 | form: { |
183 | 197 | role: '', |
184 | 198 | account: '', |
185 | 199 | name: '', |
186 | 200 | state: '' |
187 | 201 | }, |
188 | - tableData: [ | |
189 | - { role: '教师', account: 'zhangsan', name: '赵旭岚', sex: '女', code: '2322', state: '正常' } | |
190 | - ], | |
202 | + tableData: [], | |
203 | + | |
191 | 204 | multipleSelection: [], |
192 | - account: { role: '', account: '' } | |
205 | + account: { | |
206 | + role: '', | |
207 | + username: '', | |
208 | + name: '', | |
209 | + sex: '', | |
210 | + subjectId: '', | |
211 | + marker: '' | |
212 | + } | |
193 | 213 | |
194 | 214 | } |
195 | 215 | }, |
196 | 216 | created() { |
197 | - // this.fetchData() | |
217 | + const userInfo = | |
218 | + JSON.stringify(this.$store.state.user.userInfo === '{}') | |
219 | + ? JSON.parse(getuserinfo()) | |
220 | + : JSON.parse(this.$store.state.user.userInfo) | |
221 | + this.dept = userInfo.dept | |
222 | + this.fetchData(userInfo.dept) | |
223 | + this.getRoleList() | |
224 | + this.getSubjectList() | |
198 | 225 | }, |
199 | 226 | methods: { |
200 | - fetchData() { | |
227 | + fetchData(id) { | |
201 | 228 | this.listLoading = true |
202 | - getList().then(response => { | |
203 | - this.list = response.data.items | |
204 | - this.listLoading = false | |
229 | + getUserList(id).then(res => { | |
230 | + console.log(res) | |
231 | + this.tableData = res.data.data | |
205 | 232 | }) |
206 | 233 | }, |
207 | - search() {}, | |
208 | - clear() {}, | |
234 | + add() { | |
235 | + this.accountdialog = true | |
236 | + }, | |
237 | + save() { | |
238 | + const param = { | |
239 | + ...this.account, | |
240 | + password: '123456', | |
241 | + schoolId: this.dept | |
242 | + } | |
243 | + | |
244 | + add(param).then(res => { | |
245 | + if (res.code === 0) { | |
246 | + this.fetchData(this.dept) | |
247 | + this.accountdialog = false | |
248 | + } | |
249 | + }) | |
250 | + }, | |
251 | + close() { | |
252 | + this.$refs.account.resetFields() | |
253 | + this.accountdialog = false | |
254 | + }, | |
255 | + deluser(row) { | |
256 | + this.$confirm(`确认删除用户?`, '提示', { | |
257 | + confirmButtonText: '确定', | |
258 | + cancelButtonText: '取消', | |
259 | + type: 'danger' | |
260 | + }).then(() => { | |
261 | + deluser(row.id).then(res => { | |
262 | + this.$message.success('删除成功') | |
263 | + this.fetchData(this.dept) | |
264 | + }) | |
265 | + }) | |
266 | + }, | |
267 | + search() { | |
268 | + const param = { | |
269 | + roleid: this.form.role, | |
270 | + username: this.form.account, | |
271 | + name: this.form.name, | |
272 | + enable: this.form.state | |
273 | + } | |
274 | + searchUser(param).then(res => { | |
275 | + this.tableData = res.data.data | |
276 | + }) | |
277 | + }, | |
278 | + getRoleList() { | |
279 | + getRoleList({ dept: this.dept }).then(res => { | |
280 | + console.log(res) | |
281 | + this.roleList = res.data | |
282 | + }) | |
283 | + }, | |
284 | + getSubjectList() { | |
285 | + getSubjectList().then(res => { | |
286 | + console.log(res) | |
287 | + this.subjectList = res.data | |
288 | + }) | |
289 | + }, | |
290 | + clear() { | |
291 | + this.$refs.form.resetFields() | |
292 | + }, | |
293 | + reset(row) { | |
294 | + this.$confirm(`<h3>密码重置后:</h3> | |
295 | + <p>·初始密码为:123456</p> | |
296 | + <p>·重置后首次登录,用户需主动修改密码</p> | |
297 | +`, '确认重置密码?', { | |
298 | + confirmButtonText: '确定', | |
299 | + dangerouslyUseHTMLString: true, | |
300 | + cancelButtonText: '取消' | |
301 | + }).then(() => { | |
302 | + const param = { | |
303 | + id: row.id, | |
304 | + password: '123456' | |
305 | + } | |
306 | + resetpass(param).then(res => { | |
307 | + console.log(res) | |
308 | + if (res.code === 0) { | |
309 | + this.$message({ | |
310 | + type: 'success', | |
311 | + message: '重置成功!' | |
312 | + }) | |
313 | + } | |
314 | + }) | |
315 | + }).catch(() => { | |
316 | + this.$message({ | |
317 | + type: 'info', | |
318 | + message: '已取消重置' | |
319 | + }) | |
320 | + }) | |
321 | + }, | |
322 | + enable(row) { | |
323 | + enableUser(row.id, 1 ^ row.enable).then(res => { | |
324 | + console.log(res) | |
325 | + this.fetchData(this.dept) | |
326 | + }) | |
327 | + }, | |
328 | + edit(row) { | |
329 | + this.accountdialog = true | |
330 | + // this.$refs.account.resetFields() | |
331 | + // this.$refs['account'].resetFields() | |
332 | + this.account = { | |
333 | + role: row.roleName, | |
334 | + username: row.username, | |
335 | + name: row.username, | |
336 | + sex: row.sex, | |
337 | + subject: row.subject, | |
338 | + marker: row.marker | |
339 | + } | |
340 | + }, | |
209 | 341 | handleSelectionChange(val) { |
210 | 342 | this.multipleSelection = val |
211 | 343 | }, | ... | ... |
src/views/login/index.vue
... | ... | @@ -75,6 +75,7 @@ |
75 | 75 | |
76 | 76 | <script> |
77 | 77 | import { validUsername } from '@/utils/validate' |
78 | +import { getuser } from '@/utils/auth' | |
78 | 79 | |
79 | 80 | export default { |
80 | 81 | name: 'Login', |
... | ... | @@ -96,7 +97,7 @@ export default { |
96 | 97 | return { |
97 | 98 | loginForm: { |
98 | 99 | username: 'admin', |
99 | - password: '111111' | |
100 | + password: '123456' | |
100 | 101 | }, |
101 | 102 | loginRules: { |
102 | 103 | username: [ |
... | ... | @@ -121,6 +122,22 @@ export default { |
121 | 122 | immediate: true |
122 | 123 | } |
123 | 124 | }, |
125 | + created() { | |
126 | + console.log(getuser()) | |
127 | + const userinfo = getuser() | |
128 | + if (typeof (userinfo) !== 'undefined') { | |
129 | + this.loginForm = JSON.parse(userinfo) | |
130 | + this.$store | |
131 | + .dispatch('user/login', this.loginForm) | |
132 | + .then(res => { | |
133 | + this.$router.push({ path: this.redirect || '/' }) | |
134 | + this.loading = false | |
135 | + }) | |
136 | + .catch(() => { | |
137 | + this.loading = false | |
138 | + }) | |
139 | + } | |
140 | + }, | |
124 | 141 | methods: { |
125 | 142 | showPwd() { |
126 | 143 | if (this.passwordType === 'password') { |
... | ... | @@ -139,7 +156,10 @@ export default { |
139 | 156 | this.$store |
140 | 157 | .dispatch('user/login', this.loginForm) |
141 | 158 | .then(res => { |
142 | - console.log(res) | |
159 | + console.log(this.loginForm) | |
160 | + if (this.auto) { | |
161 | + this.$store.dispatch('user/saveuser', this.loginForm) | |
162 | + } | |
143 | 163 | this.$router.push({ path: this.redirect || '/' }) |
144 | 164 | this.loading = false |
145 | 165 | }) | ... | ... |