From 5ee6e6f59c969b22b4c354a2783f49bc231311ab Mon Sep 17 00:00:00 2001 From: dongchunyu <1540770111@qq.com> Date: Thu, 4 Nov 2021 08:35:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=20feat=EF=BC=9A=E6=B7=BB=E5=8A=A0@riophae/vu?= =?UTF-8?q?e-treeselect=E7=BB=84=E4=BB=B6=20feat=EF=BC=9A=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=9B=BE=E6=A0=87=E9=80=89=E6=8B=A9=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=20feat=EF=BC=9A=E4=BF=AE=E6=94=B9resources=20=E5=8F=98?= =?UTF-8?q?=E6=88=90=20resource=20feat=EF=BC=9A=E4=BC=98=E5=8C=96=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 +- src/api/admin/dept/dept.js | 4 +- .../admin/resource/{module.js => resource.js} | 39 +- src/components/IconSelect/index.vue | 68 ++ src/components/IconSelect/requireIcons.js | 11 + src/icons/svg/Steve-Jobs.svg | 1 + src/icons/svg/alipay.svg | 1 + src/icons/svg/anq.svg | 1 + src/icons/svg/app.svg | 1 + src/icons/svg/backup.svg | 1 + src/icons/svg/chain.svg | 1 + src/icons/svg/codeConsole.svg | 1 + src/icons/svg/database.svg | 1 + src/icons/svg/date.svg | 1 + src/icons/svg/deploy.svg | 1 + src/icons/svg/dept.svg | 1 + src/icons/svg/dev.svg | 1 + src/icons/svg/develop.svg | 1 + src/icons/svg/dictionary.svg | 1 + src/icons/svg/doc.svg | 1 + src/icons/svg/download.svg | 1 + src/icons/svg/error.svg | 1 + src/icons/svg/fwb.svg | 1 + src/icons/svg/github.svg | 1 + src/icons/svg/gonggao.svg | 1 + src/icons/svg/image.svg | 1 + src/icons/svg/index.svg | 1 + src/icons/svg/ipvisits.svg | 1 + src/icons/svg/java.svg | 1 + src/icons/svg/log.svg | 1 + src/icons/svg/login.svg | 1 + src/icons/svg/markdown.svg | 1 + src/icons/svg/menu.svg | 1 + src/icons/svg/mnt.svg | 1 + src/icons/svg/monitor.svg | 1 + src/icons/svg/permission.svg | 1 + src/icons/svg/phone.svg | 1 + src/icons/svg/qiniu.svg | 1 + src/icons/svg/redis.svg | 1 + src/icons/svg/role.svg | 1 + src/icons/svg/server.svg | 1 + src/icons/svg/source.svg | 1 + src/icons/svg/sqlMonitor.svg | 1 + src/icons/svg/swagger.svg | 1 + src/icons/svg/sys-tools.svg | 1 + src/icons/svg/system.svg | 1 + src/icons/svg/system1.svg | 1 + src/icons/svg/timing.svg | 1 + src/icons/svg/tools.svg | 1 + src/icons/svg/unlock.svg | 1 + src/icons/svg/user1.svg | 1 + src/icons/svg/validCode.svg | 1 + src/icons/svg/visits.svg | 1 + src/icons/svg/web.svg | 1 + src/icons/svg/weixin.svg | 1 + src/icons/svg/zujian.svg | 1 + src/main.js | 11 + src/permission.js | 61 +- src/router/_import_development.js | 2 + src/router/_import_production.js | 2 + src/router/index.js | 14 +- src/store/getters.js | 3 +- src/store/modules/permission.js | 25 +- src/views/admin/config/config-manage.vue | 8 +- src/views/admin/dept/dept-manage.vue | 357 +++++---- src/views/admin/dict/dict-type-manage.vue | 8 +- src/views/admin/job/job-manage.vue | 12 +- src/views/admin/post/post-manage.vue | 8 +- src/views/admin/resource/resource-manage.vue | 315 +++++--- src/views/admin/role/role-manage.vue | 487 +++++------ src/views/admin/user/user-manage.vue | 755 +++++++++--------- src/views/flow/form/form-manager.vue | 15 + src/views/flow/model/model-manage.vue | 8 +- src/views/flow/process/process-manage.vue | 8 +- 74 files changed, 1359 insertions(+), 917 deletions(-) rename src/api/admin/resource/{module.js => resource.js} (64%) create mode 100644 src/components/IconSelect/index.vue create mode 100644 src/components/IconSelect/requireIcons.js create mode 100644 src/icons/svg/Steve-Jobs.svg create mode 100644 src/icons/svg/alipay.svg create mode 100644 src/icons/svg/anq.svg create mode 100644 src/icons/svg/app.svg create mode 100644 src/icons/svg/backup.svg create mode 100644 src/icons/svg/chain.svg create mode 100644 src/icons/svg/codeConsole.svg create mode 100644 src/icons/svg/database.svg create mode 100644 src/icons/svg/date.svg create mode 100644 src/icons/svg/deploy.svg create mode 100644 src/icons/svg/dept.svg create mode 100644 src/icons/svg/dev.svg create mode 100644 src/icons/svg/develop.svg create mode 100644 src/icons/svg/dictionary.svg create mode 100644 src/icons/svg/doc.svg create mode 100644 src/icons/svg/download.svg create mode 100644 src/icons/svg/error.svg create mode 100644 src/icons/svg/fwb.svg create mode 100644 src/icons/svg/github.svg create mode 100644 src/icons/svg/gonggao.svg create mode 100644 src/icons/svg/image.svg create mode 100644 src/icons/svg/index.svg create mode 100644 src/icons/svg/ipvisits.svg create mode 100644 src/icons/svg/java.svg create mode 100644 src/icons/svg/log.svg create mode 100644 src/icons/svg/login.svg create mode 100644 src/icons/svg/markdown.svg create mode 100644 src/icons/svg/menu.svg create mode 100644 src/icons/svg/mnt.svg create mode 100644 src/icons/svg/monitor.svg create mode 100644 src/icons/svg/permission.svg create mode 100644 src/icons/svg/phone.svg create mode 100644 src/icons/svg/qiniu.svg create mode 100644 src/icons/svg/redis.svg create mode 100644 src/icons/svg/role.svg create mode 100644 src/icons/svg/server.svg create mode 100644 src/icons/svg/source.svg create mode 100644 src/icons/svg/sqlMonitor.svg create mode 100644 src/icons/svg/swagger.svg create mode 100644 src/icons/svg/sys-tools.svg create mode 100644 src/icons/svg/system.svg create mode 100644 src/icons/svg/system1.svg create mode 100644 src/icons/svg/timing.svg create mode 100644 src/icons/svg/tools.svg create mode 100644 src/icons/svg/unlock.svg create mode 100644 src/icons/svg/user1.svg create mode 100644 src/icons/svg/validCode.svg create mode 100644 src/icons/svg/visits.svg create mode 100644 src/icons/svg/web.svg create mode 100644 src/icons/svg/weixin.svg create mode 100644 src/icons/svg/zujian.svg create mode 100644 src/router/_import_development.js create mode 100644 src/router/_import_production.js create mode 100644 src/views/flow/form/form-manager.vue diff --git a/package.json b/package.json index 8072911..7da8af3 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,9 @@ "new": "plop" }, "dependencies": { + "@riophae/vue-treeselect": "^0.4.0", "axios": "0.18.1", + "bpmn-js": "^7.2.1", "element-ui": "2.13.0", "js-cookie": "2.2.0", "normalize.css": "7.0.0", @@ -23,9 +25,9 @@ "path-to-regexp": "2.4.0", "screenfull": "4.2.0", "vue": "2.6.10", + "vue-drag-formdesign": "^2.0.10", "vue-router": "3.1.3", "vuex": "3.1.2", - "bpmn-js": "^7.2.1", "xcrud": "0.4.1" }, "devDependencies": { diff --git a/src/api/admin/dept/dept.js b/src/api/admin/dept/dept.js index 3faa050..5cdaae9 100644 --- a/src/api/admin/dept/dept.js +++ b/src/api/admin/dept/dept.js @@ -46,9 +46,9 @@ export const deleteDeptById = (deptId) => { * @param deptId * @returns {AxiosPromise} */ -export const getDeptTreeTableList = () => { +export const getDeptTreeList = () => { return axios.request({ - url: '/system/dept/getDeptTreeTableList', + url: '/system/dept/getDeptTreeList', method: 'get' }) } diff --git a/src/api/admin/resource/module.js b/src/api/admin/resource/resource.js similarity index 64% rename from src/api/admin/resource/module.js rename to src/api/admin/resource/resource.js index 697bf65..6d12f99 100644 --- a/src/api/admin/resource/module.js +++ b/src/api/admin/resource/resource.js @@ -7,7 +7,7 @@ import axios from '_l/api.request' */ export const addResource = (module) => { return axios.request({ - url: '/system/resources/save', + url: '/system/resource/save', method: 'post', data: module }) @@ -20,7 +20,7 @@ export const addResource = (module) => { */ export const updateResource = (module) => { return axios.request({ - url: '/system/resources/update', + url: '/system/resource/update', method: 'post', data: module }) @@ -33,7 +33,7 @@ export const updateResource = (module) => { */ export const deleteResourceById = (moduleId) => { return axios.request({ - url: '/system/resources/delete', + url: '/system/resource/delete', method: 'post', params: { id: moduleId @@ -42,25 +42,22 @@ export const deleteResourceById = (moduleId) => { } /** - * 批量删除模块 - * @param moduleIds - * @returns {ClientHttp2Stream | * | AxiosPromise | ClientRequest | void} + * 获取模块tree-table数据 + * @returns {*|AxiosPromise|ClientRequest|void|ClientHttp2Stream} */ -export const deleteBatchResourceById = (moduleIds) => { +export const getResourceTreeList = () => { return axios.request({ - url: '/system/resources/deleteBatch', - method: 'post', - data: moduleIds + url: '/system/resource/getResourceTreeList' }) } /** - * 获取模块tree-table数据 - * @returns {*|AxiosPromise|ClientRequest|void|ClientHttp2Stream} + * 获取菜单列表 + * @returns {AxiosPromise} */ -export const getResourceTreeTableList = () => { +export const getMenuList = () => { return axios.request({ - url: '/system/resources/getResourceTreeTableList' + url: '/system/resource/getMenuList' }) } @@ -68,11 +65,21 @@ export const getResourceTreeTableList = () => { * 获取tree列表数据 * @returns {*|AxiosPromise|ClientRequest|void|ClientHttp2Stream} */ -export const getResourceTreeList = (roleId) => { +export const getResourceIdListByRoleId = (roleId) => { return axios.request({ - url: '/system/resources/getResourceTreeListByRoleId', + url: '/system/resource/getResourceIdListByRoleId', params: { roleId: roleId } }) } + +/** + * 根据登录人获取目录和菜单路由 + * @returns {AxiosPromise} + */ +export const getRouterList = () => { + return axios.request({ + url: '/system/resource/getRouterList' + }) +} diff --git a/src/components/IconSelect/index.vue b/src/components/IconSelect/index.vue new file mode 100644 index 0000000..b0ec9fa --- /dev/null +++ b/src/components/IconSelect/index.vue @@ -0,0 +1,68 @@ + + + + + + diff --git a/src/components/IconSelect/requireIcons.js b/src/components/IconSelect/requireIcons.js new file mode 100644 index 0000000..83a3395 --- /dev/null +++ b/src/components/IconSelect/requireIcons.js @@ -0,0 +1,11 @@ + +const req = require.context('../../icons/svg', false, /\.svg$/) +const requireAll = requireContext => requireContext.keys() + +const re = /\.\/(.*)\.svg/ + +const icons = requireAll(req).map(i => { + return i.match(re)[1] +}) + +export default icons diff --git a/src/icons/svg/Steve-Jobs.svg b/src/icons/svg/Steve-Jobs.svg new file mode 100644 index 0000000..53843e2 --- /dev/null +++ b/src/icons/svg/Steve-Jobs.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/alipay.svg b/src/icons/svg/alipay.svg new file mode 100644 index 0000000..9138981 --- /dev/null +++ b/src/icons/svg/alipay.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/anq.svg b/src/icons/svg/anq.svg new file mode 100644 index 0000000..a466608 --- /dev/null +++ b/src/icons/svg/anq.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/app.svg b/src/icons/svg/app.svg new file mode 100644 index 0000000..0796da3 --- /dev/null +++ b/src/icons/svg/app.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/backup.svg b/src/icons/svg/backup.svg new file mode 100644 index 0000000..a3272a4 --- /dev/null +++ b/src/icons/svg/backup.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/chain.svg b/src/icons/svg/chain.svg new file mode 100644 index 0000000..ed3317f --- /dev/null +++ b/src/icons/svg/chain.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/codeConsole.svg b/src/icons/svg/codeConsole.svg new file mode 100644 index 0000000..672ec6e --- /dev/null +++ b/src/icons/svg/codeConsole.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/database.svg b/src/icons/svg/database.svg new file mode 100644 index 0000000..7fbad9b --- /dev/null +++ b/src/icons/svg/database.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/date.svg b/src/icons/svg/date.svg new file mode 100644 index 0000000..0540e99 --- /dev/null +++ b/src/icons/svg/date.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/deploy.svg b/src/icons/svg/deploy.svg new file mode 100644 index 0000000..f4a1c56 --- /dev/null +++ b/src/icons/svg/deploy.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/dept.svg b/src/icons/svg/dept.svg new file mode 100644 index 0000000..894e4bf --- /dev/null +++ b/src/icons/svg/dept.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/dev.svg b/src/icons/svg/dev.svg new file mode 100644 index 0000000..ed4d23c --- /dev/null +++ b/src/icons/svg/dev.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/develop.svg b/src/icons/svg/develop.svg new file mode 100644 index 0000000..e189223 --- /dev/null +++ b/src/icons/svg/develop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/dictionary.svg b/src/icons/svg/dictionary.svg new file mode 100644 index 0000000..6e83c43 --- /dev/null +++ b/src/icons/svg/dictionary.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/doc.svg b/src/icons/svg/doc.svg new file mode 100644 index 0000000..9160de8 --- /dev/null +++ b/src/icons/svg/doc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/download.svg b/src/icons/svg/download.svg new file mode 100644 index 0000000..0243c6a --- /dev/null +++ b/src/icons/svg/download.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/error.svg b/src/icons/svg/error.svg new file mode 100644 index 0000000..fd935da --- /dev/null +++ b/src/icons/svg/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/fwb.svg b/src/icons/svg/fwb.svg new file mode 100644 index 0000000..59933fc --- /dev/null +++ b/src/icons/svg/fwb.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/github.svg b/src/icons/svg/github.svg new file mode 100644 index 0000000..8145e95 --- /dev/null +++ b/src/icons/svg/github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/gonggao.svg b/src/icons/svg/gonggao.svg new file mode 100644 index 0000000..22aed08 --- /dev/null +++ b/src/icons/svg/gonggao.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/image.svg b/src/icons/svg/image.svg new file mode 100644 index 0000000..16d572f --- /dev/null +++ b/src/icons/svg/image.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/index.svg b/src/icons/svg/index.svg new file mode 100644 index 0000000..fdb3826 --- /dev/null +++ b/src/icons/svg/index.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/ipvisits.svg b/src/icons/svg/ipvisits.svg new file mode 100644 index 0000000..4ca473d --- /dev/null +++ b/src/icons/svg/ipvisits.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/java.svg b/src/icons/svg/java.svg new file mode 100644 index 0000000..e2effbb --- /dev/null +++ b/src/icons/svg/java.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/log.svg b/src/icons/svg/log.svg new file mode 100644 index 0000000..4fefe74 --- /dev/null +++ b/src/icons/svg/log.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/login.svg b/src/icons/svg/login.svg new file mode 100644 index 0000000..cc5a854 --- /dev/null +++ b/src/icons/svg/login.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/markdown.svg b/src/icons/svg/markdown.svg new file mode 100644 index 0000000..7cd6747 --- /dev/null +++ b/src/icons/svg/markdown.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/menu.svg b/src/icons/svg/menu.svg new file mode 100644 index 0000000..e4360a0 --- /dev/null +++ b/src/icons/svg/menu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/mnt.svg b/src/icons/svg/mnt.svg new file mode 100644 index 0000000..502a7c0 --- /dev/null +++ b/src/icons/svg/mnt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/monitor.svg b/src/icons/svg/monitor.svg new file mode 100644 index 0000000..fbf0a2f --- /dev/null +++ b/src/icons/svg/monitor.svg @@ -0,0 +1 @@ + diff --git a/src/icons/svg/permission.svg b/src/icons/svg/permission.svg new file mode 100644 index 0000000..c4c7409 --- /dev/null +++ b/src/icons/svg/permission.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/phone.svg b/src/icons/svg/phone.svg new file mode 100644 index 0000000..da339f9 --- /dev/null +++ b/src/icons/svg/phone.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/qiniu.svg b/src/icons/svg/qiniu.svg new file mode 100644 index 0000000..c2f9f8b --- /dev/null +++ b/src/icons/svg/qiniu.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/redis.svg b/src/icons/svg/redis.svg new file mode 100644 index 0000000..bef111b --- /dev/null +++ b/src/icons/svg/redis.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/role.svg b/src/icons/svg/role.svg new file mode 100644 index 0000000..76cb18f --- /dev/null +++ b/src/icons/svg/role.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/server.svg b/src/icons/svg/server.svg new file mode 100644 index 0000000..db6dcdf --- /dev/null +++ b/src/icons/svg/server.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/source.svg b/src/icons/svg/source.svg new file mode 100644 index 0000000..1c3a038 --- /dev/null +++ b/src/icons/svg/source.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/sqlMonitor.svg b/src/icons/svg/sqlMonitor.svg new file mode 100644 index 0000000..950a430 --- /dev/null +++ b/src/icons/svg/sqlMonitor.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/swagger.svg b/src/icons/svg/swagger.svg new file mode 100644 index 0000000..ded7de8 --- /dev/null +++ b/src/icons/svg/swagger.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/sys-tools.svg b/src/icons/svg/sys-tools.svg new file mode 100644 index 0000000..324aa04 --- /dev/null +++ b/src/icons/svg/sys-tools.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/system.svg b/src/icons/svg/system.svg new file mode 100644 index 0000000..9333c60 --- /dev/null +++ b/src/icons/svg/system.svg @@ -0,0 +1 @@ + diff --git a/src/icons/svg/system1.svg b/src/icons/svg/system1.svg new file mode 100644 index 0000000..37b0a0a --- /dev/null +++ b/src/icons/svg/system1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/timing.svg b/src/icons/svg/timing.svg new file mode 100644 index 0000000..f8fdc6d --- /dev/null +++ b/src/icons/svg/timing.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/tools.svg b/src/icons/svg/tools.svg new file mode 100644 index 0000000..aba1a40 --- /dev/null +++ b/src/icons/svg/tools.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/unlock.svg b/src/icons/svg/unlock.svg new file mode 100644 index 0000000..1219e41 --- /dev/null +++ b/src/icons/svg/unlock.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/user1.svg b/src/icons/svg/user1.svg new file mode 100644 index 0000000..14ca51e --- /dev/null +++ b/src/icons/svg/user1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/validCode.svg b/src/icons/svg/validCode.svg new file mode 100644 index 0000000..a1feb74 --- /dev/null +++ b/src/icons/svg/validCode.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/visits.svg b/src/icons/svg/visits.svg new file mode 100644 index 0000000..8425662 --- /dev/null +++ b/src/icons/svg/visits.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/web.svg b/src/icons/svg/web.svg new file mode 100644 index 0000000..9c57415 --- /dev/null +++ b/src/icons/svg/web.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/weixin.svg b/src/icons/svg/weixin.svg new file mode 100644 index 0000000..8dbcfa5 --- /dev/null +++ b/src/icons/svg/weixin.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/zujian.svg b/src/icons/svg/zujian.svg new file mode 100644 index 0000000..2aba32f --- /dev/null +++ b/src/icons/svg/zujian.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/main.js b/src/main.js index fb05fe5..dbe3b8d 100644 --- a/src/main.js +++ b/src/main.js @@ -16,9 +16,20 @@ import router from './router' import './icons' // icon import './permission' // permission control +// 权限指令 +import permission from "@/directive/permission/index"; + import '@/libs/validate.form' import * as filters from './filters' // global filters +import VueDragFormdesign from 'vue-drag-formdesign' +import 'vue-drag-formdesign/lib/vue-drag-formdesign.css' +import VueTreeselect from '@riophae/vue-treeselect' +import '@riophae/vue-treeselect/dist/vue-treeselect.css' + +Vue.use(permission) +Vue.use(VueTreeselect) +Vue.use(VueDragFormdesign) Vue.use(Element, { size: Cookies.get('size') || 'medium' // set element-ui default size }) diff --git a/src/permission.js b/src/permission.js index e2bc0f4..acaa4fe 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,16 +1,20 @@ import router from './router' import store from './store' -import { Message } from 'element-ui' +import {Message} from 'element-ui' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style -import { getToken } from '@/libs/auth' // get token from cookie +import {getToken, removeToken} from '@/libs/auth' // get token from cookie import getPageTitle from '@/libs/get-page-title' +import Layout from '@/layout' +import ParentView from '@/views/parent-view' -NProgress.configure({ showSpinner: false }) // NProgress Configuration +const _import = require('./router/_import_' + process.env.NODE_ENV) // 获取组件的方法 + +NProgress.configure({showSpinner: false}) // NProgress Configuration const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist -router.beforeEach(async(to, from, next) => { +router.beforeEach(async (to, from, next) => { // start progress bar NProgress.start() @@ -23,7 +27,7 @@ router.beforeEach(async(to, from, next) => { if (hasToken) { if (to.path === '/login') { // if is logged in, redirect to the home page - next({ path: '/' }) + next({path: '/'}) NProgress.done() } else { // determine whether the user has obtained his permission roles through getInfo @@ -35,19 +39,22 @@ router.beforeEach(async(to, from, next) => { // get user info // note: roles must be a object array! such as: ['admin'] or ,['developer','editor'] const userInfo = await store.dispatch('user/getInfo') - + await store.dispatch('permission/loadMenu') let roles = userInfo.resources; - - - // generate accessible routes map based on roles - const accessRoutes = await store.dispatch('permission/generateRoutes', roles) - - // dynamically add accessible routes - router.addRoutes(accessRoutes) - - // hack method to ensure that addRoutes is complete - // set the replace: true, so the navigation will not leave a history record - next({ ...to, replace: true }) + if (!roles || roles.length === 0) { + removeToken() + next('/401') + } else { + // 过滤路由 + const accessRoutes = filterAsyncRouter(store.getters.sidebarRouters); + // 添加动态路由 + router.addRoutes(accessRoutes) + // 保存路由 + store.commit('permission/SET_ROUTES', accessRoutes) + // hack method to ensure that addRoutes is complete + // set the replace: true, so the navigation will not leave a history record + next({...to, replace: true}) + } } catch (error) { // remove token and go to login page to re-login await store.dispatch('user/resetToken') @@ -75,3 +82,23 @@ router.afterEach(() => { // finish progress bar NProgress.done() }) + +// 遍历后台传来的路由字符串,转换为组件对象 +function filterAsyncRouter(asyncRouterMap) { + const accessedRouters = asyncRouterMap.filter(route => { + if (route.component) { + if (route.component === 'Layout') { + route.component = Layout + } else if (route.component === 'ParentView') { + route.component = ParentView + } else { + route.component = _import(route.component) // 导入组件 + } + } + if (route.children && route.children.length) { + route.children = filterAsyncRouter(route.children) + } + return true + }) + return accessedRouters +} diff --git a/src/router/_import_development.js b/src/router/_import_development.js new file mode 100644 index 0000000..42de012 --- /dev/null +++ b/src/router/_import_development.js @@ -0,0 +1,2 @@ +// 开发环境导入组件 +module.exports = file => require('@/views/' + file + '.vue').default // vue-loader at least v13.0.0+ diff --git a/src/router/_import_production.js b/src/router/_import_production.js new file mode 100644 index 0000000..796b0da --- /dev/null +++ b/src/router/_import_production.js @@ -0,0 +1,2 @@ +// 生产环境导入组件 +module.exports = file => () => import('@/views/' + file + '.vue') diff --git a/src/router/index.js b/src/router/index.js index 7e242a8..7975249 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -121,9 +121,9 @@ export const asyncRoutes = [ meta: {title: '角色管理'} }, { - path: 'power-manage', + path: 'resource-manage', component: () => import('@/views/admin/resource/resource-manage'), - name: 'power-manage', + name: 'resource-manage', meta: {title: '资源管理'} }, { @@ -139,9 +139,9 @@ export const asyncRoutes = [ meta: {title: '岗位管理'} }, { - path: 'dictType-manage', + path: 'dict-manage', component: () => import('@/views/admin/dict/dict-type-manage'), - name: 'dictType-manage', + name: 'dict-manage', meta: {title: '字典管理'} }, { @@ -203,6 +203,12 @@ export const asyncRoutes = [ component: () => import('@/views/flow/process/process-manage'), name: 'process-manage', meta: {title: '流程管理'} + }, + { + path: 'form-manage', + component: () => import('@/views/flow/form/form-manager.vue'), + name: 'form-manage', + meta: {title: '表单管理'} } ] }, diff --git a/src/store/getters.js b/src/store/getters.js index c762593..050d54c 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -11,6 +11,7 @@ const getters = { userId: state => state.user.userId, introduction: state => state.user.introduction, roles: state => state.user.roles, - permission_routes: state => state.permission.routes + permission_routes: state => state.permission.routes, + sidebarRouters: state => state.permission.sidebarRouters } export default getters diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index ef3ec90..e76b96e 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -1,4 +1,5 @@ -import { asyncRoutes, constantRoutes } from '@/router' +import {asyncRoutes, constantRoutes} from '@/router' +import {getRouterList} from "@/api/admin/resource/resource"; /** * Use meta.role to determine if the current user has permission @@ -22,7 +23,7 @@ export function filterAsyncRoutes(routes, roles) { const res = [] routes.forEach(route => { - const tmp = { ...route } + const tmp = {...route} if (hasPermission(roles, tmp)) { if (tmp.children) { tmp.children = filterAsyncRoutes(tmp.children, roles) @@ -36,18 +37,22 @@ export function filterAsyncRoutes(routes, roles) { const state = { routes: [], - addRoutes: [] + addRoutes: [], + sidebarRouters: [] } const mutations = { SET_ROUTES: (state, routes) => { state.addRoutes = routes state.routes = constantRoutes.concat(routes) + }, + SET_SIDEBAR_ROUTERS: (state, routers) => { + state.sidebarRouters = routers } } const actions = { - generateRoutes({ commit }, roles) { + generateRoutes({commit}, roles) { return new Promise(resolve => { let accessedRoutes if (roles.includes('ROLE_ADMIN')) { @@ -58,6 +63,18 @@ const actions = { commit('SET_ROUTES', accessedRoutes) resolve(accessedRoutes) }) + }, + loadMenu({commit}) { + return new Promise((resolve, reject) => { + getRouterList().then(res => { + const {data} = res + data.push({ path: '*', redirect: '/404', hidden: true }) + commit('SET_SIDEBAR_ROUTERS', data) + resolve(data) + }).catch(error => { + reject(error) + }) + }) } } diff --git a/src/views/admin/config/config-manage.vue b/src/views/admin/config/config-manage.vue index b5e1eed..d483d54 100644 --- a/src/views/admin/config/config-manage.vue +++ b/src/views/admin/config/config-manage.vue @@ -8,8 +8,8 @@ 查询 重置 - 添加 - 删除 + 添加 + 删除 @@ -26,8 +26,8 @@ diff --git a/src/views/admin/dept/dept-manage.vue b/src/views/admin/dept/dept-manage.vue index 775bb44..05e53bc 100644 --- a/src/views/admin/dept/dept-manage.vue +++ b/src/views/admin/dept/dept-manage.vue @@ -15,13 +15,14 @@ 查询 重置 + 添加 @@ -46,28 +46,48 @@ :close-on-click-modal="false" @close="handleReset('form')"> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +