Commit 42056450a8c48e5af8bbc853146d147ee0419c01
1 parent
dd5150c5
权限修改
Showing
10 changed files
with
459 additions
and
195 deletions
E/system-commandline-sentinel-files/dotnet-suggest-registration-git-credential-manager-core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null
0 → 100644
1 | +Exception during registration: | |
2 | +System.ComponentModel.Win32Exception (0x80004005): 系统找不到指定的文件。 | |
3 | + 在 System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) | |
4 | + 在 System.Diagnostics.Process.Start() | |
5 | + 在 System.CommandLine.Invocation.Process.StartProcess(String command, String args, String workingDir, Action`1 stdOut, Action`1 stdErr, ValueTuple`2[] environmentVariables) | |
6 | + 在 System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_1>d.MoveNext() | |
0 | 7 | \ No newline at end of file | ... | ... |
src/api/apis/apis.js
src/api/urls/apis.js
... | ... | @@ -7,7 +7,7 @@ export default { |
7 | 7 | // 查询角色列表 |
8 | 8 | roleList: "/api_html/school/manager/roleList", |
9 | 9 | // 分页查询账号 |
10 | - deviceList: "/api_html/school/manager/userPage", | |
10 | + userPage: "/api_html/school/manager/userPage", | |
11 | 11 | // 修改账号 禁用账号、修改账号密码等 |
12 | 12 | updateUser: "/api_html/school/manager/updateUser", |
13 | 13 | // 查询学校详情 | ... | ... |
src/router/permission.js
1 | -import NProgress from "nprogress" | |
2 | -import router from "./index" | |
3 | -import store from "../store" | |
1 | +import NProgress from "nprogress"; | |
2 | +import router from "./index"; | |
3 | +import store from "../store"; | |
4 | 4 | |
5 | 5 | // 获取角色信息,根据用户权限动态加载路由 |
6 | 6 | router.beforeEach((to, from, next) => { |
7 | - NProgress.start() | |
8 | - if (store.getters.token) { | |
9 | - // if (to.path === "/login") { | |
10 | - next() | |
11 | - // } else { | |
12 | - // if (!store.getters.info.permissions) { | |
13 | - // (async function getAddRouters() { | |
14 | - // // 省略 axios 请求代码 通过 token 向后台请求用户权限等信息,这里用假数据赋值 | |
15 | - // const userInfo = { | |
16 | - // permissions: [ | |
17 | - // { | |
18 | - // role: "superAdmin", | |
19 | - // roleName: "超级管理员" | |
20 | - // } | |
21 | - // ], | |
22 | - // name: "李老师", | |
23 | - // // avatar: data.avatar ? data.avatar : "", | |
24 | - // // uid: data.id, | |
25 | - // authorityRouter: ["examinationPaper", | |
26 | - // "examinationPaperAdd", | |
27 | - // "examinationPaperEdit", | |
28 | - // "examinationPaperRecycle", "ask", | |
29 | - // "askAnalysis", | |
30 | - // "test", | |
31 | - // "testAnalysis", "portrait"], | |
32 | - | |
33 | - // } | |
34 | - // await store.commit("setInfo", { ...userInfo }) | |
35 | - // await store.commit("setRouters", userInfo.authorityRouter) | |
36 | - // let newAddRouters = store.getters.addRouters | |
37 | - // newAddRouters.forEach(res => { | |
38 | - // router.addRoute(res) | |
39 | - // }) | |
40 | - // router.addRoute({ | |
41 | - // path: "*", | |
42 | - // redirect: "/404", | |
43 | - // hidden: true, | |
44 | - // children: [] | |
45 | - // }) | |
46 | - // next({ path: to.fullPath }) | |
47 | - // }()) | |
48 | - // } else { | |
49 | - // next() | |
50 | - // } | |
51 | - // } | |
7 | + NProgress.start(); | |
8 | + if (to.path === "/login") { | |
9 | + next(); | |
52 | 10 | } else { |
53 | - if (store.getters.info && store.getters.addRouters) { | |
54 | - console.log(store.getters.addRouters) | |
55 | - store.commit("setToken", "isLogin"); | |
56 | - store.commit( | |
57 | - "setRouters", | |
58 | - store.getters.info.authorityRouter | |
59 | - ); | |
60 | - | |
61 | - let newAddRouters = store.getters.addRouters; | |
62 | - newAddRouters.forEach((res) => { | |
63 | - router.addRoute(res); | |
64 | - }); | |
65 | - router.addRoute({ | |
66 | - path: "*", | |
67 | - redirect: "/404", | |
68 | - hidden: true, | |
69 | - children: [], | |
70 | - }); | |
71 | - next({ path: to.fullPath }) | |
11 | + if (store.getters.token) { | |
12 | + next(); | |
72 | 13 | } else { |
73 | - if (store.getters.code) { | |
74 | - next() | |
14 | + if (store.getters.info && store.getters.addRouters) { | |
15 | + store.commit("setToken", "isLogin"); | |
16 | + let userInfo = store.getters.info; | |
17 | + let authorityRouterObj = userInfo.permissions.filter((item) => { | |
18 | + return item.roleName == userInfo.showRoleName; | |
19 | + }); | |
20 | + console.log([...authorityRouterObj[0]?.authorityRouter]) | |
21 | + store.commit("setRouters", [...authorityRouterObj[0]?.authorityRouter]); | |
22 | + store.commit("setInfo", { ...userInfo }); | |
23 | + store.getters.addRouters.forEach((res) => { | |
24 | + router.addRoute(res); | |
25 | + }); | |
26 | + router.addRoute({ | |
27 | + path: "*", | |
28 | + redirect: "/404", | |
29 | + hidden: true, | |
30 | + children: [], | |
31 | + }); | |
32 | + next({ path: to.fullPath }); | |
75 | 33 | } else { |
76 | - if (to.path === "/login") { | |
77 | - next() | |
34 | + if (store.getters.code) { | |
35 | + next(); | |
78 | 36 | } else { |
79 | - next({ path: "/login" }) | |
37 | + if (to.path === "/login") { | |
38 | + next(); | |
39 | + } else { | |
40 | + next({ path: "/login" }); | |
41 | + } | |
80 | 42 | } |
81 | 43 | } |
82 | 44 | } |
83 | 45 | } |
84 | -}) | |
46 | +}); | |
85 | 47 | |
86 | 48 | router.afterEach(() => { |
87 | - NProgress.done() | |
88 | -}) | |
49 | + NProgress.done(); | |
50 | +}); | |
89 | 51 | router.onError((error) => { |
90 | 52 | const pattern = /Loading chunk (\d)+ failed/g; |
91 | 53 | const isChunkLoadFailed = error.message.match(pattern); |
92 | 54 | const targetPath = router.history.pending.fullPath; |
93 | - if (isChunkLoadFailed) { router.replace(targetPath); } | |
55 | + if (isChunkLoadFailed) { | |
56 | + router.replace(targetPath); | |
57 | + } | |
94 | 58 | }); | ... | ... |
src/store/index.js
1 | -import Vue from "vue" | |
2 | -import Vuex from "vuex" | |
3 | -import Cookies from "js-cookie" | |
4 | -import layoutStore from "./modules/layout/index" | |
5 | -import { defaultRouter } from "@/router/index" | |
1 | +import Vue from "vue"; | |
2 | +import Vuex from "vuex"; | |
3 | +import Cookies from "js-cookie"; | |
4 | +import layoutStore from "./modules/layout/index"; | |
5 | +import { defaultRouter } from "@/router/index"; | |
6 | 6 | import { encryptLoginPassword } from "@/utils"; |
7 | 7 | |
8 | -import request from "@/api/index" | |
9 | -import router from "@/router/index" | |
10 | -import { addrouters } from "@/router/index" | |
11 | -Vue.use(Vuex) | |
8 | +import request from "@/api/index"; | |
9 | +import router from "@/router/index"; | |
10 | +import { addrouters } from "@/router/index"; | |
11 | +Vue.use(Vuex); | |
12 | 12 | |
13 | 13 | const store = new Vuex.Store({ |
14 | 14 | state: { |
15 | 15 | token: "", |
16 | 16 | csCode: localStorage.getItem("csCode") || "", |
17 | - info: sessionStorage.getItem("info") ? JSON.parse(sessionStorage.getItem("info")) : "", // 每次刷新都要通过token请求个人信息来筛选动态路由 | |
18 | - routers: [],//左侧菜单 | |
19 | - addRouters: sessionStorage.getItem("addRouters") ? JSON.parse(sessionStorage.getItem("addRouters")) : [],//动态路由 | |
20 | - tokenSources: new Map(),//正在请求接口(切换取消请求) | |
17 | + info: sessionStorage.getItem("info") | |
18 | + ? JSON.parse(sessionStorage.getItem("info")) | |
19 | + : "", // 每次刷新都要通过token请求个人信息来筛选动态路由 | |
20 | + routers: [], //左侧菜单 | |
21 | + addRouters: | |
22 | + sessionStorage.getItem("addRouters") && | |
23 | + sessionStorage.getItem("addRouters") != "undefined" | |
24 | + ? JSON.parse(sessionStorage.getItem("addRouters")) | |
25 | + : [], //动态路由 | |
26 | + tokenSources: new Map(), //正在请求接口(切换取消请求) | |
21 | 27 | }, |
22 | 28 | mutations: { |
23 | 29 | setToken(state, token) { |
24 | - state.token = token | |
30 | + state.token = token; | |
25 | 31 | }, |
26 | 32 | setCode(state, code) { |
27 | 33 | state.csCode = code; |
28 | - localStorage.setItem("csCode", code) | |
34 | + localStorage.setItem("csCode", code); | |
29 | 35 | }, |
30 | 36 | setInfo(state, data) { |
31 | - state.info = { | |
32 | - role: data.role, | |
33 | - permissions: data.permissions, | |
34 | - name: data.name, | |
35 | - authorityRouter: data.authorityRouter, | |
36 | - avatar: data.avatar ? data.avatar : "", | |
37 | - uid: data.uid | |
38 | - } | |
39 | - sessionStorage.setItem("info", JSON.stringify(state.info)) | |
37 | + state.info = { ...data }; | |
38 | + sessionStorage.setItem("info", JSON.stringify(state.info)); | |
40 | 39 | }, |
41 | 40 | setRouters: (state, routers) => { |
42 | - let aRouters = addrouters.filter(item => { | |
43 | - let path = item.children[0]?.path.replace("/", "") | |
44 | - return routers?.includes(path) | |
45 | - }) | |
41 | + let aRouters = addrouters.filter((item) => { | |
42 | + let path = item.children[0]?.path.replace("/", ""); | |
43 | + return routers?.includes(path); | |
44 | + }); | |
46 | 45 | |
47 | - state.addRouters = aRouters // 保存动态路由用来addRouter | |
48 | - state.routers = defaultRouter.concat(aRouters) // 所有有权限的路由表,用来生成菜单列表 | |
49 | - sessionStorage.setItem("addRouters", JSON.stringify(routers)) | |
46 | + state.addRouters = aRouters; // 保存动态路由用来addRouter | |
47 | + state.routers = defaultRouter.concat(aRouters); // 所有有权限的路由表,用来生成菜单列表 | |
48 | + sessionStorage.setItem("addRouters", JSON.stringify(routers)); | |
50 | 49 | }, |
51 | 50 | setTokenSources(state, data) { |
52 | 51 | if (data instanceof Array) { |
53 | - state.tokenSources.set(data[0], data[1]) | |
52 | + state.tokenSources.set(data[0], data[1]); | |
54 | 53 | } else { |
55 | - state.tokenSources = new Map() | |
54 | + state.tokenSources = new Map(); | |
56 | 55 | } |
57 | 56 | }, |
58 | 57 | delTokenSources(state, data) { |
59 | - state.tokenSources.delete(data) | |
58 | + state.tokenSources.delete(data); | |
60 | 59 | }, |
61 | 60 | }, |
62 | 61 | actions: { |
63 | 62 | Login({ state, commit }, params) { |
64 | - let loginForm = {} | |
63 | + let loginForm = {}; | |
65 | 64 | loginForm.username = params.username; |
66 | 65 | loginForm.password = encryptLoginPassword(params.password); |
67 | - request.login({ ...loginForm }).then(res => { | |
68 | - let response = res | |
69 | - if (response.status == 0) { | |
70 | - const userInfo = { ...response.data } | |
71 | - commit("setToken", Cookies.get("ZT_YIJIAO_TOKEN")); | |
72 | - commit("setInfo", { ...userInfo }); | |
73 | - | |
74 | - commit("setRouters", [...userInfo.authorityRouter]) | |
75 | - state.addRouters.forEach((res) => { | |
76 | - router.addRoute(res); | |
77 | - }); | |
78 | - router.addRoute({ | |
79 | - path: "*", | |
80 | - redirect: "/404", | |
81 | - hidden: true, | |
82 | - children: [] | |
83 | - }) | |
84 | - console.log() | |
85 | - if (params.url) { | |
86 | - window.location.href = params.url; | |
87 | - } else { | |
88 | - router.push({ path: "/" }) | |
66 | + request | |
67 | + .login({ ...loginForm }) | |
68 | + .then((res) => { | |
69 | + let response = res; | |
70 | + if (response.status == 0) { | |
71 | + const userInfo = { ...response.data }; | |
72 | + userInfo.showRoleName = response.data.permissions[0]?.roleName; | |
73 | + commit("setToken", "isLogin"); | |
74 | + commit("setInfo", { ...userInfo }); | |
75 | + commit("setRouters", [...userInfo.permissions[0]?.authorityRouter]); | |
76 | + state.addRouters.forEach((res) => { | |
77 | + router.addRoute(res); | |
78 | + }); | |
79 | + router.addRoute({ | |
80 | + path: "*", | |
81 | + redirect: "/404", | |
82 | + hidden: true, | |
83 | + children: [], | |
84 | + }); | |
85 | + console.log(Cookies.get("ZT_YIJIAO_TOKEN")); | |
86 | + if (params.url) { | |
87 | + window.location.href = params.url; | |
88 | + } else { | |
89 | + router.push({ path: "/" }); | |
90 | + } | |
89 | 91 | } |
90 | - } | |
91 | - }).catch(() => { | |
92 | - }) | |
92 | + }) | |
93 | + .catch(() => {}); | |
93 | 94 | }, |
94 | - permissions({ state, commit }, that) { | |
95 | - let userInfo = { | |
96 | - permissions: [ | |
97 | - { | |
98 | - role: "ROLE_XUEXIAO", | |
99 | - roleName: "学校管理员", | |
100 | - }, | |
101 | - { | |
102 | - role: "ROLE_LAOSHI", | |
103 | - roleName: "老师", | |
104 | - }, | |
105 | - ], | |
106 | - name: "李老师", | |
107 | - authorityRouter:[ | |
108 | - "setUpAccount", | |
109 | - "setUpSchool", | |
110 | - "setUpTeacher", | |
111 | - "setUpStudent", | |
112 | - "card", | |
113 | - "device", | |
114 | - "analysis", | |
115 | - "down", | |
116 | - "downClient", | |
117 | - "dataSync" | |
118 | - ], | |
119 | - } | |
120 | - commit("setToken", "xxxx") | |
95 | + permissions({ state, commit }, role) { | |
96 | + commit("setToken", "isLogin"); | |
97 | + let userInfo = state.info; | |
98 | + let authorityRouterObj = userInfo.permissions.filter((item) => { | |
99 | + return item.role == role; | |
100 | + }); | |
101 | + userInfo.showRoleName = authorityRouterObj[0]?.roleName | |
121 | 102 | commit("setInfo", userInfo); |
122 | - commit("setRouters", [...userInfo.authorityRouter]) | |
103 | + commit("setRouters", [...authorityRouterObj[0]?.authorityRouter]); | |
123 | 104 | state.addRouters.forEach((res) => { |
124 | 105 | router.addRoute(res); |
125 | 106 | }); |
... | ... | @@ -127,27 +108,26 @@ const store = new Vuex.Store({ |
127 | 108 | path: "*", |
128 | 109 | redirect: "/404", |
129 | 110 | hidden: true, |
130 | - children: [] | |
131 | - }) | |
132 | - // } | |
133 | - // }) | |
134 | - } | |
111 | + children: [], | |
112 | + }); | |
113 | + router.push({ path: "/" }); | |
114 | + }, | |
135 | 115 | }, |
136 | 116 | getters: { |
137 | - addRouters: state => state.addRouters, | |
138 | - token: state => state.token, | |
139 | - code: state => state.csCode, | |
140 | - info: state => state.info, | |
141 | - routers: state => state.routers, | |
142 | - logoShow: state => state.layoutStore.logoShow, | |
143 | - isCollapse: state => state.layoutStore.isCollapse, | |
144 | - uniquerouter: state => state.layoutStore.uniquerouter, | |
145 | - tabnavBox: state => state.layoutStore.tabnavBox, | |
146 | - rightNav: state => state.layoutStore.rightNav | |
117 | + addRouters: (state) => state.addRouters, | |
118 | + token: (state) => state.token, | |
119 | + code: (state) => state.csCode, | |
120 | + info: (state) => state.info, | |
121 | + routers: (state) => state.routers, | |
122 | + logoShow: (state) => state.layoutStore.logoShow, | |
123 | + isCollapse: (state) => state.layoutStore.isCollapse, | |
124 | + uniquerouter: (state) => state.layoutStore.uniquerouter, | |
125 | + tabnavBox: (state) => state.layoutStore.tabnavBox, | |
126 | + rightNav: (state) => state.layoutStore.rightNav, | |
147 | 127 | }, |
148 | 128 | modules: { |
149 | - layoutStore | |
150 | - } | |
151 | -}) | |
129 | + layoutStore, | |
130 | + }, | |
131 | +}); | |
152 | 132 | |
153 | -export default store | |
133 | +export default store; | ... | ... |
src/views/index/mainIndex.vue
src/views/layout/header/header.vue
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | <img :src="avatar" /> |
15 | 15 | <div class="txt"> |
16 | 16 | <p>{{ `${this.$store.getters.info.name}` }}</p> |
17 | - <p>{{ `${permissions[0].roleName}` }}</p> | |
17 | + <p>{{ `${this.$store.getters.info.showRoleName}` }}</p> | |
18 | 18 | </div> |
19 | 19 | <i class="el-icon-arrow-down"></i> |
20 | 20 | </div> |
... | ... | @@ -125,7 +125,7 @@ export default { |
125 | 125 | }, |
126 | 126 | handleCommand(command) { |
127 | 127 | //刷新权限跳转首页 |
128 | - this.$store.dispatch("permissions", this); | |
128 | + this.$store.dispatch("permissions", command); | |
129 | 129 | }, |
130 | 130 | async logOut() { |
131 | 131 | const { data,status } = await this.$request.logout(); | ... | ... |
src/views/login/index.vue
... | ... | @@ -92,8 +92,10 @@ export default { |
92 | 92 | loginForm: { |
93 | 93 | // username: "13610050254", |
94 | 94 | // password: "Pw050254#", |
95 | - username: "18946034886", | |
96 | - password: "Pw034886#", | |
95 | + // username: "18946034886", | |
96 | + // password: "Pw034886#", | |
97 | + username: "18332123505", | |
98 | + password: "Pw123505#", | |
97 | 99 | }, |
98 | 100 | loginRules: { |
99 | 101 | username: [ | ... | ... |
src/views/setUp/account.vue
1 | 1 | <template> |
2 | - <div>账号管理</div> | |
2 | + <div> | |
3 | + <back-box> | |
4 | + <template slot="title"> | |
5 | + <span>账号管理</span> | |
6 | + </template> | |
7 | + </back-box> | |
8 | + <div class="answer-header"> | |
9 | + <div class="sel-box"> | |
10 | + <el-select | |
11 | + class="sel" | |
12 | + v-model="query.id" | |
13 | + placeholder="选择账号角色" | |
14 | + @change="(page = 1),_QueryData(1)" | |
15 | + > | |
16 | + <el-option | |
17 | + v-for="item in roleList" | |
18 | + :key="item.id" | |
19 | + :label="item.roleName" | |
20 | + :value="item.id" | |
21 | + > | |
22 | + </el-option> | |
23 | + </el-select> | |
24 | + <el-select | |
25 | + class="sel" | |
26 | + v-model="query.available" | |
27 | + placeholder="选择账号状态" | |
28 | + @change="(page = 1),_QueryData(1)" | |
29 | + > | |
30 | + <el-option label="可用" :value="0"></el-option> | |
31 | + <el-option label="不可用" :value="1"></el-option> | |
32 | + </el-select> | |
33 | + <el-input | |
34 | + type="number" | |
35 | + placeholder="请输入老师账号" | |
36 | + v-model="query.loginName" | |
37 | + class="input-with-select" | |
38 | + @keyup.enter.native="(page = 1),_QueryData(2)" | |
39 | + > | |
40 | + <el-button | |
41 | + slot="append" | |
42 | + icon="el-icon-search" | |
43 | + @click="(page = 1),_QueryData(2)" | |
44 | + ></el-button> | |
45 | + </el-input> | |
46 | + <el-input | |
47 | + placeholder="请输入老师姓名" | |
48 | + v-model="query.realName" | |
49 | + class="input-with-select" | |
50 | + @keyup.enter.native="(page = 1),_QueryData(3)" | |
51 | + > | |
52 | + <el-button | |
53 | + slot="append" | |
54 | + icon="el-icon-search" | |
55 | + @click="(page = 1),_QueryData(3)" | |
56 | + ></el-button> | |
57 | + </el-input> | |
58 | + </div> | |
59 | + </div> | |
60 | + <div class="table-box"> | |
61 | + <el-table | |
62 | + :data="tableData" | |
63 | + border | |
64 | + style="width: 100%" | |
65 | + v-loading="loading" | |
66 | + > | |
67 | + <el-table-column | |
68 | + prop="loginName" | |
69 | + label="账号" | |
70 | + align="center" | |
71 | + ></el-table-column> | |
72 | + <el-table-column | |
73 | + prop="realName" | |
74 | + label="姓名" | |
75 | + align="center" | |
76 | + ></el-table-column> | |
77 | + <el-table-column prop="roleList" label="角色" align="center"> | |
78 | + <template slot-scope="scoped"> | |
79 | + <span v-for="(item, index) in scoped.row.roleList" :key="item.id">{{ | |
80 | + `${item.roleName}${ | |
81 | + index != scoped.row.roleList.length - 1 ? "、" : "" | |
82 | + }` | |
83 | + }}</span> | |
84 | + </template> | |
85 | + </el-table-column> | |
86 | + <el-table-column prop="available" label="状态" align="center" | |
87 | + ><template slot-scope="scoped">{{ | |
88 | + `${scoped.row.available == 0 ? "可用" : "不可用"}` | |
89 | + }}</template></el-table-column | |
90 | + > | |
91 | + <el-table-column | |
92 | + prop="createdTime" | |
93 | + label="创建时间" | |
94 | + align="center" | |
95 | + ></el-table-column> | |
96 | + <el-table-column label="操作" align="center" width="160"> | |
97 | + <template slot-scope="scoped"> | |
98 | + <el-tooltip content="修改账号" placement="left"> | |
99 | + <el-button | |
100 | + class="set-count" | |
101 | + type="primary" | |
102 | + circle | |
103 | + icon="el-icon-edit-outline" | |
104 | + size="mini" | |
105 | + @click="setCount(scoped.row)" | |
106 | + ></el-button> | |
107 | + </el-tooltip> | |
108 | + <el-dropdown | |
109 | + trigger="hover" | |
110 | + @command="handleDropdownClick($event, scoped.row)" | |
111 | + > | |
112 | + <el-button | |
113 | + type="info" | |
114 | + size="mini" | |
115 | + circle | |
116 | + icon="el-icon-more" | |
117 | + ></el-button> | |
118 | + <el-dropdown-menu slot="dropdown"> | |
119 | + <el-dropdown-item :command="0">重置密码</el-dropdown-item> | |
120 | + <el-dropdown-item :command="1">禁用</el-dropdown-item> | |
121 | + <el-dropdown-item :command="2">删除</el-dropdown-item> | |
122 | + </el-dropdown-menu> | |
123 | + </el-dropdown> | |
124 | + </template> | |
125 | + </el-table-column> | |
126 | + </el-table> | |
127 | + <div class="pagination-box"> | |
128 | + <el-pagination | |
129 | + small="" | |
130 | + layout="total,prev, pager, next" | |
131 | + :hide-on-single-page="true" | |
132 | + :total="total" | |
133 | + @current-change="changePage" | |
134 | + :current-page="page" | |
135 | + :page-size="size" | |
136 | + > | |
137 | + </el-pagination> | |
138 | + </div> | |
139 | + <el-empty | |
140 | + v-if="!loading && tableData.length == 0" | |
141 | + content="没有更多数据" | |
142 | + :image-size="100" | |
143 | + ></el-empty> | |
144 | + </div> | |
145 | + <el-dialog title="修改年级信息" :visible.sync="diaCount" width="400"> | |
146 | + <el-form | |
147 | + class="form-box" | |
148 | + :model="formCount" | |
149 | + :rules="ruleCount" | |
150 | + ref="formCount" | |
151 | + label-width="160px" | |
152 | + > | |
153 | + <el-form-item label="手机号码:" prop="loginName"> | |
154 | + <el-col :span="12"> | |
155 | + <el-input | |
156 | + placeholder="请输入联系电话" | |
157 | + v-model.trim="formCount.loginName" | |
158 | + maxlength="11" | |
159 | + > | |
160 | + </el-input> | |
161 | + </el-col> | |
162 | + </el-form-item> | |
163 | + <el-form-item label="姓名:" prop="realName"> | |
164 | + <el-col :span="12"> | |
165 | + <el-input | |
166 | + placeholder="请输入教师姓名" | |
167 | + v-model.trim="formCount.realName" | |
168 | + maxlength="11" | |
169 | + > | |
170 | + </el-input> | |
171 | + </el-col> | |
172 | + </el-form-item> | |
173 | + </el-form> | |
174 | + <div class="dialog-footer" slot="footer"> | |
175 | + <el-button @click="saveCount">确 定</el-button> | |
176 | + <el-button @click="diaCount = false">取 消</el-button> | |
177 | + </div> | |
178 | + </el-dialog> | |
179 | + </div> | |
3 | 180 | </template> |
4 | 181 | |
5 | 182 | <script> |
6 | 183 | export default { |
184 | + data() { | |
185 | + return { | |
186 | + loading: false, | |
187 | + diaCount: false, | |
188 | + formCount: { | |
189 | + userId: "", | |
190 | + loginName: "", | |
191 | + realName: "", | |
192 | + }, | |
193 | + ruleCount: { | |
194 | + loginName: [ | |
195 | + { required: true, message: "请输入联系电话", trigger: "blur" }, | |
196 | + ], | |
197 | + realName: [ | |
198 | + { required: true, message: "请输入教师姓名", trigger: "blur" }, | |
199 | + ], | |
200 | + }, | |
201 | + roleList: [], | |
202 | + query: { | |
203 | + roleId: "", | |
204 | + available: "", | |
205 | + loginName: "", | |
206 | + realName: "", | |
207 | + }, | |
208 | + tableData: [], | |
209 | + total: 0, | |
210 | + page: 1, | |
211 | + size: 20, | |
212 | + }; | |
213 | + }, | |
214 | + created() { | |
215 | + this._QueryData(4); | |
216 | + this._RoleList(); | |
217 | + }, | |
218 | + methods: { | |
219 | + setCount(obj) { | |
220 | + this.formCount.userId = obj.userId; | |
221 | + this.formCount.loginName = obj.loginName; | |
222 | + this.formCount.realName = obj.realName; | |
223 | + this.diaCount = true; | |
224 | + }, | |
225 | + handleDropdownClick(value, item) { | |
226 | + //更多 | |
227 | + this.updateUser(item, value); | |
228 | + }, | |
229 | + changePage(page) { | |
230 | + this.page = page; | |
231 | + this._QueryData(4); | |
232 | + }, | |
7 | 233 | |
8 | -} | |
234 | + saveCount() { | |
235 | + this.$refs.formCount.validate(async (valid) => { | |
236 | + if (valid) { | |
237 | + const { data, status, info } = await this.$request.updateUser({ | |
238 | + type: 3, | |
239 | + ...this.formCount, | |
240 | + }); | |
241 | + if (status === 0) { | |
242 | + this.$message.success(info); | |
243 | + this._QueryData(4); | |
244 | + } else { | |
245 | + this.$message.error(info); | |
246 | + } | |
247 | + } else { | |
248 | + console.log("输入有误请检查!"); | |
249 | + return false; | |
250 | + } | |
251 | + }); | |
252 | + }, | |
253 | + async updateUser(obj, type) { | |
254 | + let query = { | |
255 | + userId: obj.userId, | |
256 | + type: type, | |
257 | + }; | |
258 | + if (type == 1) { | |
259 | + query.available = obj.available == 0 ? 1 : 0; | |
260 | + } | |
261 | + const { data, status, info } = await this.$request.updateUser({ | |
262 | + ...query, | |
263 | + }); | |
264 | + if (status === 0) { | |
265 | + this.$message.success(info); | |
266 | + this._QueryData(4); | |
267 | + } else { | |
268 | + this.$message.error(info); | |
269 | + } | |
270 | + }, | |
271 | + async _RoleList() { | |
272 | + const { data, status, info } = await this.$request.roleList(); | |
273 | + if (status === 0) { | |
274 | + this.roleList = data.list || []; | |
275 | + } else { | |
276 | + this.$message.error(info); | |
277 | + } | |
278 | + }, | |
279 | + async _QueryData(type) { | |
280 | + let query = {}; | |
281 | + if (type == 1) { | |
282 | + query.roleId = this.query.roleId; | |
283 | + query.available = this.query.available; | |
284 | + this.query.loginName = ""; | |
285 | + this.query.realName = ""; | |
286 | + } else if (type == 2) { | |
287 | + this.query.roleId = ""; | |
288 | + this.query.available = ""; | |
289 | + query.loginName = this.query.loginName; | |
290 | + this.query.realName = ""; | |
291 | + } else if (type == 3) { | |
292 | + this.query.roleId = ""; | |
293 | + this.query.available = ""; | |
294 | + this.query.loginName = ""; | |
295 | + query.realName = this.query.realName; | |
296 | + } else { | |
297 | + query = { ...this.query }; | |
298 | + } | |
299 | + this.loading = true; | |
300 | + this.tableData = []; | |
301 | + const { data, status, info } = await this.$request.userPage({ | |
302 | + ...query, | |
303 | + page: this.page, | |
304 | + size: this.size, | |
305 | + }); | |
306 | + this.loading = false; | |
307 | + if (status === 0) { | |
308 | + this.tableData = data.list || []; | |
309 | + this.total = data.count; | |
310 | + } else { | |
311 | + this.$message.error(info); | |
312 | + } | |
313 | + }, | |
314 | + }, | |
315 | +}; | |
9 | 316 | </script> |
10 | 317 | |
11 | -<style> | |
12 | - | |
318 | +<style lang="scss" scoped> | |
319 | +.set-count { | |
320 | + margin-right: 12px; | |
321 | +} | |
322 | +.table-box { | |
323 | + padding: 0 20px; | |
324 | +} | |
13 | 325 | </style> |
14 | 326 | \ No newline at end of file | ... | ... |
src/views/setUp/index.vue deleted