From 9bb2391a14c3365e7907003e6ad5a510004d92d8 Mon Sep 17 00:00:00 2001 From: yzw <2431960323@qq.com> Date: Tue, 19 Jul 2022 21:35:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=88=9D=E6=AD=A5=E7=9A=84?= =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/job.js | 3 +- src/api/priotity.js | 11 +- src/api/user.js | 8 ++ src/assets/images/default.png | Bin 0 -> 6390 bytes src/icons/svg/我的.svg | 2 + src/layout/components/Navbar.vue | 15 +- src/permission.js | 120 +++++++++++----- src/router/index.js | 16 ++- src/store/modules/user.js | 81 ++++++----- src/utils/auth.js | 30 ++-- src/views/job/show.vue | 155 +++++++++++++++------ src/views/login/index.vue | 113 ++++++++------- src/views/priority/components/add.vue | 44 ++++-- src/views/priority/components/modify.vue | 34 +++-- src/views/priority/components/password.vue | 121 ++++++++++++++++ src/views/priority/components/select.vue | 23 +-- src/views/priority/priority.vue | 12 +- src/views/user/user.vue | 118 ++++++++++++++++ 18 files changed, 673 insertions(+), 233 deletions(-) create mode 100644 src/assets/images/default.png create mode 100644 src/icons/svg/我的.svg create mode 100644 src/views/priority/components/password.vue create mode 100644 src/views/user/user.vue diff --git a/src/api/job.js b/src/api/job.js index 555aa96..fff9118 100644 --- a/src/api/job.js +++ b/src/api/job.js @@ -46,4 +46,5 @@ export function modifyJobDetail(data) { method: 'post', data }) -} \ No newline at end of file +} + diff --git a/src/api/priotity.js b/src/api/priotity.js index 57724d5..75cdfeb 100644 --- a/src/api/priotity.js +++ b/src/api/priotity.js @@ -30,4 +30,13 @@ export function deleteUser(data) { method: 'post', data }) -} \ No newline at end of file +} + +export function verifyJobPriority(params) { + return request({ + url: '/priority/verify', + method: 'get', + params + }) + } + diff --git a/src/api/user.js b/src/api/user.js index de69f70..d4f9032 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -22,3 +22,11 @@ export function logout() { method: 'post' }) } + +export function changePassword(data) { + return request({ + url: '/user/change-password', + method: 'post', + data + }) +} \ No newline at end of file diff --git a/src/assets/images/default.png b/src/assets/images/default.png new file mode 100644 index 0000000000000000000000000000000000000000..639f85566bd1eefe3860607471de5622c1ac9ba3 GIT binary patch literal 6390 zcmVAt)9sC@q4hNPsZO%v$#k66BF&_RO3)XJYyOmCWqD*P85=J^QS^_F9C` zA?J^;8j=%~e1Q&!VmJd|6w)D3KAs7KAm}GRE*L=ofS`?mC>VQ1@iBlM4E+#9?+J91 zMf`3o7Ff4(>GL1@`^nsg{8k`c&YO6}aXA5N0x2d4Xe>iU0X!rVvP7^AjMW6ZL5gKD z!m?FP-OfzN@`_$(0M*si*2ZmZ6Nq$*fTl7q8vcC_6`+}b7l`DA5rg|Iuc@ht`=m=s z^b!M@$%Q4&Hb}1~&@_Ms`>jz|h+rF_vn`9CZCYI02tfVTDG^z10ORbclVcjcQHgG1 z;1s|0NeYooVETQ`ia)+;;k>{5txk7jr2!P$WkpcBO;szI+45VTbP$m^GtY+5z2POb zZ}_dx;bfHo6c$%rs-!<*!UcZok{M(Pf$nN@>R zL#(%l7dO1>w=TXKz_{YF;c@1B0Zj8#48n_6o7XdoSeUGCEK)=Ytr!x;X&`jZp0gRnk`K6ep&oEHv-l+1H0#90u`W1^B z*19*YF*L@mI!9E>6}X-WXSp@7K;9s>z7knfyV0#NyCdTUP*_r4r9@9KFd*HrM6iRP z&nV-M%}#xj8~V9LsJL<*Sg#k6Ynb`?vqIb=6aQ_sp8MO`bGa`!~FSCx3ufTbpsfCapmz6 zlLmmsr#glz)-ve(O^vlLxT%|86izC?LgREVGe)L5hKMeWX}o;R(s`e_shg{Q_Ag&l zHnhDR3yCO{(g1=zO8Q^4XV?wlt{!O{z}Sl`kB_&jLxgjZ?W@3wfXLNvENS>#x_b0R3NNfYT}7Wu(Lb`f zEgqYc?w%m6JwQ>>^uBS#UnEZ91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OLX5FMzWX`*cC4^FgX)rAC5p;N$}0cl7=TTDJLTqTs|BG&cDMB1SL51v-LMb2&$t;YAR=*9Jg|@ZoE=$G>-pi6uW4Qi zi%ScM=|O zRv~fz1v5sbJC>@>qCLZ|b^Ff#8B?a@9=kXAylGs1PpD!oh<+GxYRz&oWss~efc?zm zkiF_^Abv->H-|(q?-<%S-L1R&p-^c*?Pt}Q=1k}gRjdW*u1I5T4YH)_Sr!>UCo?%T zDN+XITanJiOx0JgN6ORPQ0>o6p!3rCni7%4#MXTgr*`W1ZDH?5}>Ngv$i~52&T>^1eLqX#fBK07*qoM6N<$ Ef?3fS+5i9m literal 0 HcmV?d00001 diff --git a/src/icons/svg/我的.svg b/src/icons/svg/我的.svg new file mode 100644 index 0000000..6841f91 --- /dev/null +++ b/src/icons/svg/我的.svg @@ -0,0 +1,2 @@ + \ No newline at end of file diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 0ca5cf6..a57ab54 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -7,23 +7,17 @@
- +
- Home + 首页 - - Github - - - Docs - - Log Out + 退出登录
@@ -43,8 +37,7 @@ export default { }, computed: { ...mapGetters([ - 'sidebar', - 'avatar' + 'sidebar' ]) }, methods: { diff --git a/src/permission.js b/src/permission.js index fa1ea19..8b69730 100644 --- a/src/permission.js +++ b/src/permission.js @@ -3,14 +3,14 @@ import store from './store' import { Message } from 'element-ui' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style -import { getToken } from '@/utils/auth' // get token from cookie +// import { getToken } from '@/utils/auth' // get token from cookie import getPageTitle from '@/utils/get-page-title' NProgress.configure({ showSpinner: false }) // NProgress Configuration const whiteList = ['/login'] // no redirect whitelist -router.beforeEach(async(to, from, next) => { +router.beforeEach(async (to, from, next) => { // start progress bar NProgress.start() @@ -18,44 +18,98 @@ router.beforeEach(async(to, from, next) => { document.title = getPageTitle(to.meta.title) // determine whether the user has logged in - const hasToken = getToken() - - if (hasToken) { - if (to.path === '/login') { - // if is logged in, redirect to the home page - next({ path: '/' }) - NProgress.done() + if (to.path != '/login' && !store.state.user.id_card) { + // 没有登录,跳转到登录页面 + next({ path: '/login' }); + NProgress.done(); + } else { + let getPriorityName = function (path) { + let pos = path.indexOf('/', 1); + pos = pos == -1 ? path.length : pos; + return path.substring(1, pos); + } + let allow = false; + if (store.state.user.is_admin) { + allow = true; } else { - const hasGetUserInfo = store.getters.name - if (hasGetUserInfo) { - next() - } else { - try { - // get user info - await store.dispatch('user/getInfo') - - next() - } catch (error) { - // remove token and go to login page to re-login - await store.dispatch('user/resetToken') - Message.error(error || 'Has Error') - next(`/login?redirect=${to.path}`) - NProgress.done() - } + switch (getPriorityName(to.path)) { + case 'priority': + break; + case 'job': + // 判断岗位读权限 + allow = true; + break; + case 'person': + // 判断人员读权限 + allow = true; + break; + case 'event': + // 判断人员读权限 + allow = true; + break; + default: + allow = true; } } - } else { - /* has no token*/ - if (whiteList.indexOf(to.path) !== -1) { - // in the free login whitelist, go directly - next() + + if (allow) { + next(); } else { - // other pages that do not have permission to access are redirected to the login page. - next(`/login?redirect=${to.path}`) - NProgress.done() + Message({ + message: '权限不足', + type: 'error', + duration: 2000 + }) + next(false); + NProgress.done(); } } + + + // next() + // NProgress.done() + + // next(`/login?redirect=${to.path}`) + // NProgress.done() + + // const hasToken = getToken() + // if (hasToken) { + // if (to.path === '/login') { + // // if is logged in, redirect to the home page + // next({ path: '/' }) + // NProgress.done() + // } else { + // const hasGetUserInfo = store.getters.name + // if (hasGetUserInfo) { + // next() + // } else { + // try { + // // get user info + // await store.dispatch('user/getInfo') + + // next() + // } catch (error) { + // // remove token and go to login page to re-login + // await store.dispatch('user/resetToken') + // Message.error(error || 'Has Error') + // next(`/login?redirect=${to.path}`) + // NProgress.done() + // } + // } + // } + // } else { + // /* has no token*/ + + // if (whiteList.indexOf(to.path) !== -1) { + // // in the free login whitelist, go directly + // next() + // } else { + // // other pages that do not have permission to access are redirected to the login page. + // next(`/login?redirect=${to.path}`) + // NProgress.done() + // } + // } }) router.afterEach(() => { diff --git a/src/router/index.js b/src/router/index.js index 0895e0e..7b89e5e 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -158,7 +158,7 @@ export const constantRoutes = [ name: 'priority', component: () => import('@/views/priority/priority'), meta: { - title: '权限管理', + title: '管理员专用', icon: '权限' } }] @@ -217,6 +217,20 @@ export const constantRoutes = [ }] }, + { + path: '/user', + component: Layout, + children: [{ + path: 'user', + name: 'user', + component: () => import('@/views/user/user'), + meta: { + title: '我的', + icon: '我的' + } + }] + }, + // 404 page must be placed at the end !!! { path: '*', redirect: '/404', hidden: true } ] diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 2f6423f..8c2eaeb 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,12 +1,11 @@ import { login, logout, getInfo } from '@/api/user' -import { getToken, setToken, removeToken } from '@/utils/auth' +import { setSessionItem, getSessionItem, clearSession } from '@/utils/auth' import { resetRouter } from '@/router' const getDefaultState = () => { return { - token: getToken(), - name: '', - avatar: '' + id_card: '', + is_admin: 0 } } @@ -16,14 +15,11 @@ const mutations = { RESET_STATE: (state) => { Object.assign(state, getDefaultState()) }, - SET_TOKEN: (state, token) => { - state.token = token + SET_ID_CARD: (state, id_card) => { + state.id_card = id_card; }, - SET_NAME: (state, name) => { - state.name = name - }, - SET_AVATAR: (state, avatar) => { - state.avatar = avatar + SET_IS_ADMIN: (state, is_admin) => { + state.is_admin = is_admin; } } @@ -32,10 +28,13 @@ const actions = { login({ commit }, userInfo) { const { username, password } = userInfo return new Promise((resolve, reject) => { - login({ username: username.trim(), password: password }).then(response => { + login({ id_card: username.trim(), password: password }).then(response => { const { data } = response - commit('SET_TOKEN', data.token) - setToken(data.token) + commit('SET_ID_CARD', data.id_card) + commit('SET_IS_ADMIN', data.is_admin) + // 存储到本地 + setSessionItem('id_card', data.id_card); + setSessionItem('is_admin', data.is_admin); resolve() }).catch(error => { reject(error) @@ -44,37 +43,43 @@ const actions = { }, // get user info - getInfo({ commit, state }) { - return new Promise((resolve, reject) => { - getInfo(state.token).then(response => { - const { data } = response + // getInfo({ commit, state }) { + // return new Promise((resolve, reject) => { + // getInfo(state.token).then(response => { + // const { data } = response - if (!data) { - return reject('Verification failed, please Login again.') - } + // if (!data) { + // return reject('Verification failed, please Login again.') + // } - const { name, avatar } = data + // const { name, avatar } = data - commit('SET_NAME', name) - commit('SET_AVATAR', avatar) - resolve(data) - }).catch(error => { - reject(error) - }) - }) - }, + // commit('SET_NAME', name) + // commit('SET_AVATAR', avatar) + // resolve(data) + // }).catch(error => { + // reject(error) + // }) + // }) + // }, // user logout logout({ commit, state }) { return new Promise((resolve, reject) => { - logout(state.token).then(() => { - removeToken() // must remove token first - resetRouter() - commit('RESET_STATE') - resolve() - }).catch(error => { - reject(error) - }) + // 没有token不必再发请求 + clearSession(); + resetRouter(); + commit('RESET_STATE'); + resolve(); + + // logout(state.token).then(() => { + // removeToken() // must remove token first + // resetRouter() + // commit('RESET_STATE') + // resolve() + // }).catch(error => { + // reject(error) + // }) }) }, diff --git a/src/utils/auth.js b/src/utils/auth.js index 059af18..2e4ac31 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,15 +1,27 @@ -import Cookies from 'js-cookie' +// import Cookies from 'js-cookie' -const TokenKey = 'vue_admin_template_token' +// const TokenKey = 'vue_admin_template_token' -export function getToken() { - return Cookies.get(TokenKey) +// export function getToken() { +// return Cookies.get(TokenKey) +// } + +// export function setToken(token) { +// return Cookies.set(TokenKey, token) +// } + +// export function removeToken() { +// return Cookies.remove(TokenKey) +// } + +export function setSessionItem(key, value) { + sessionStorage[key] = value; } -export function setToken(token) { - return Cookies.set(TokenKey, token) +export function getSessionItem(key) { + return sessionStorage[key]; } -export function removeToken() { - return Cookies.remove(TokenKey) -} +export function clearSession() { + sessionStorage.clear(); +} \ No newline at end of file diff --git a/src/views/job/show.vue b/src/views/job/show.vue index 949e9d9..63ad3a9 100644 --- a/src/views/job/show.vue +++ b/src/views/job/show.vue @@ -113,6 +113,7 @@ import DepDescription from "./components/DepDescription.vue"; import NoData from "./components/NoData.vue"; import * as jobApi from "@/api/job"; +import { verifyJobPriority } from "@/api/priotity"; import { MessageBox, Message } from "element-ui"; @@ -162,52 +163,51 @@ export default { curNewNode: null, intervalId: null, comTitleEdit: null, + writePriority: null, }; }, created() {}, mounted() { // 请求组织架构 - jobApi - .getFramework() - .then( - (res) => { - let originalMindData = res.data; - // 添加 id 和 expanded - // let i = 1; - originalMindData["expanded"] = true; - let addId = function (data) { - // if (!data.hasOwnProperty("id")) { - // data["id"] = i; - // i += 1; - // } - if (!data.hasOwnProperty("expanded")) { - data["expanded"] = false; - } - if (data.hasOwnProperty("children")) { - for (let j = 0; j < data["children"].length; j++) { - addId(data["children"][j]); - } - } - }; - addId(originalMindData); - - // 修改方向 - for (let j = 0; j < originalMindData["children"].length; j++) { - if (j % 2 == 0) { - originalMindData["children"][j]["direction"] = "right"; - } else { - originalMindData["children"][j]["direction"] = "left"; + jobApi.getFramework().then( + (res) => { + let originalMindData = res.data; + // 添加 id 和 expanded + // let i = 1; + originalMindData["expanded"] = true; + let addId = function (data) { + // if (!data.hasOwnProperty("id")) { + // data["id"] = i; + // i += 1; + // } + if (!data.hasOwnProperty("expanded")) { + data["expanded"] = false; + } + if (data.hasOwnProperty("children")) { + for (let j = 0; j < data["children"].length; j++) { + addId(data["children"][j]); } } - this.mindData = originalMindData; + }; + addId(originalMindData); - // 展示思维导图 - this.showChart(); - }, - (err) => { - console.log("err: ", err); + // 修改方向 + for (let j = 0; j < originalMindData["children"].length; j++) { + if (j % 2 == 0) { + originalMindData["children"][j]["direction"] = "right"; + } else { + originalMindData["children"][j]["direction"] = "left"; + } } - ); + this.mindData = originalMindData; + + // 展示思维导图 + this.showChart(); + }, + (err) => { + console.log("err: ", err); + } + ); // this.intervalId = setInterval(() => { // if (this.jm) { @@ -525,13 +525,65 @@ export default { set_theme(theme_name) { this.jm.set_theme(theme_name); }, - clickModify() { - this.$message({ - message: "修改数据", - type: "warning", - }); - this.allowSave = true; - this.jm.enable_edit(); + verifyWritePriority() { + if (this.writePriority === null) { + return new Promise((resolve, reject) => { + verifyJobPriority({ + id_card: this.$store.state.user.id_card, + priority_type: "job_write", + }).then( + (res) => { + this.writePriority = res.data.result; + resolve(); + }, + (err) => { + this.writePriority = 0; + console.log("err:", err); + reject(); + } + ); + }); + } else { + return new Promise((resolve, reject) => { + resolve(); + }) + } + }, + async clickModify() { + await this.verifyWritePriority(); + if (this.writePriority) { + this.allowSave = true; + this.jm.enable_edit(); + } else { + // 没有权限 + this.$message({ + message: "没有修改权限", + type: "error", + duration: 2000, + }); + } + // 判断是否有修改权限 + // verifyJobPriority({ + // id_card: this.$store.state.user.id_card, + // priority_type: "job_write", + // }).then( + // (res) => { + // if (!res.data.result) { + // // 没有权限 + // this.$message({ + // message: "没有修改权限", + // type: "warning", + // duration: 2000, + // }); + // } else { + // this.allowSave = true; + // this.jm.enable_edit(); + // } + // }, + // (err) => { + // console.log("err:", err); + // } + // ); }, cleanTreeData() { // 深复制对象 @@ -636,7 +688,20 @@ export default { } return "合法名称"; }, - clickSaveDoc() { + async clickSaveDoc() { + // 判断权限 + await this.verifyWritePriority(); + + if (!this.writePriority) { + // 没有权限 + this.$message({ + message: "没有修改权限", + type: "error", + duration: 2000, + }); + return; + } + // 增加节点,判断是否可添加 if (this.curNewNode) { if (this.comName == "DepDescription") { diff --git a/src/views/login/index.vue b/src/views/login/index.vue index f29509c..7842aac 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -1,7 +1,13 @@ diff --git a/src/views/priority/components/select.vue b/src/views/priority/components/select.vue index 361ff4c..014d9f7 100644 --- a/src/views/priority/components/select.vue +++ b/src/views/priority/components/select.vue @@ -1,22 +1,5 @@ @@ -17,18 +20,20 @@ import PriorityFind from "./components/select.vue"; import PriorityModify from "./components/modify.vue"; import PriorityAdd from "./components/add.vue"; +import PriorityPassword from "./components/password.vue" export default { data() { return { comName: "PriorityFind", - comData: null, + comData: null }; }, components: { PriorityFind, PriorityModify, PriorityAdd, + PriorityPassword }, methods: { handleClick(tab, event) { @@ -47,5 +52,4 @@ export default { padding-left: 5%; padding-right: 5%; } - \ No newline at end of file diff --git a/src/views/user/user.vue b/src/views/user/user.vue new file mode 100644 index 0000000..9d09653 --- /dev/null +++ b/src/views/user/user.vue @@ -0,0 +1,118 @@ + + + + +