mooho-base-admin-plus 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +5 -0
- package/.env.development +0 -0
- package/.env.production +0 -0
- package/.eslintignore +11 -0
- package/.eslintrc.js +47 -0
- package/.prettierrc +15 -0
- package/README.md +18 -0
- package/dist/favicon.ico +0 -0
- package/dist/mooho-base-admin-plus.min.esm.js +131746 -0
- package/dist/mooho-base-admin-plus.min.js +279 -0
- package/dist/setting.js +31 -0
- package/dist/static/images/app-barcode.png +0 -0
- package/dist/static/images/login/bg.png +0 -0
- package/dist/static/images/login/logo.png +0 -0
- package/dist/static/images/login/password-active.png +0 -0
- package/dist/static/images/login/password-default.png +0 -0
- package/dist/static/images/login/signIn-img.png +0 -0
- package/dist/static/images/login/user-active.png +0 -0
- package/dist/static/images/login/user-default.png +0 -0
- package/dist/static/images/logo-dark.png +0 -0
- package/dist/static/images/logo-small.png +0 -0
- package/dist/static/images/logo.png +0 -0
- package/dist/static/images/logo.svg +510 -0
- package/dist/static/images/no-image.png +0 -0
- package/dist/style.css +4 -0
- package/index.html +18 -0
- package/other/pda.vue +28 -0
- package/package.json +59 -0
- package/public/favicon.ico +0 -0
- package/public/setting.js +31 -0
- package/public/static/images/app-barcode.png +0 -0
- package/public/static/images/login/bg.png +0 -0
- package/public/static/images/login/logo.png +0 -0
- package/public/static/images/login/password-active.png +0 -0
- package/public/static/images/login/password-default.png +0 -0
- package/public/static/images/login/signIn-img.png +0 -0
- package/public/static/images/login/user-active.png +0 -0
- package/public/static/images/login/user-default.png +0 -0
- package/public/static/images/logo-dark.png +0 -0
- package/public/static/images/logo-small.png +0 -0
- package/public/static/images/logo.png +0 -0
- package/public/static/images/logo.svg +510 -0
- package/public/static/images/no-image.png +0 -0
- package/src/App.vue +60 -0
- package/src/api/application.js +35 -0
- package/src/api/customModel.js +187 -0
- package/src/api/customPage.js +15 -0
- package/src/api/customTable.js +24 -0
- package/src/api/dataSource.js +93 -0
- package/src/api/dataView.js +199 -0
- package/src/api/dictType.js +23 -0
- package/src/api/entityView.js +13 -0
- package/src/api/enum.js +15 -0
- package/src/api/filterColumn.js +16 -0
- package/src/api/model.js +244 -0
- package/src/api/movePlan.js +29 -0
- package/src/api/notification.js +28 -0
- package/src/api/openApiPermission.js +25 -0
- package/src/api/permission.js +51 -0
- package/src/api/planJob.js +15 -0
- package/src/api/process.js +23 -0
- package/src/api/processDef.js +36 -0
- package/src/api/processInst.js +16 -0
- package/src/api/rolePermission.js +17 -0
- package/src/api/roleProperty.js +36 -0
- package/src/api/shortcut.js +20 -0
- package/src/api/system.js +23 -0
- package/src/api/task.js +56 -0
- package/src/api/taskQueue.js +24 -0
- package/src/api/user.js +45 -0
- package/src/api/viewColumn.js +16 -0
- package/src/assets/svg/body.svg +17 -0
- package/src/assets/svg/header-theme-dark.svg +40 -0
- package/src/assets/svg/header-theme-primary.svg +40 -0
- package/src/assets/svg/header-top.svg +40 -0
- package/src/assets/svg/icon-happy.svg +1 -0
- package/src/assets/svg/icon-sad.svg +1 -0
- package/src/assets/svg/icon-social-bilibili.svg +1 -0
- package/src/assets/svg/icon-social-dingding.svg +1 -0
- package/src/assets/svg/icon-social-facebook.svg +1 -0
- package/src/assets/svg/icon-social-juejin.svg +1 -0
- package/src/assets/svg/icon-social-qq.svg +1 -0
- package/src/assets/svg/icon-social-twitter.svg +1 -0
- package/src/assets/svg/icon-social-wechat.svg +1 -0
- package/src/assets/svg/icon-social-weibo.svg +1 -0
- package/src/assets/svg/icon-social-zhihu.svg +1 -0
- package/src/assets/svg/nav-theme-dark.svg +40 -0
- package/src/assets/svg/nav-theme-light.svg +40 -0
- package/src/components/copyright/index.vue +28 -0
- package/src/components/home/notice-list.vue +62 -0
- package/src/components/home/shortcut.vue +125 -0
- package/src/components/input/dialog-select.vue +301 -0
- package/src/components/input/item-select.vue +195 -0
- package/src/components/link/index.vue +54 -0
- package/src/components/richEditor/index.vue +86 -0
- package/src/components/upload/file-upload.vue +84 -0
- package/src/components/upload/upload-attachment.vue +119 -0
- package/src/components/upload/upload-image.vue +212 -0
- package/src/components/view/column-check.vue +223 -0
- package/src/components/view/column-edit.vue +850 -0
- package/src/components/view/column-select.vue +206 -0
- package/src/components/view/condition-edit.vue +164 -0
- package/src/components/view/filter-edit.vue +633 -0
- package/src/components/view/filter-setting.vue +126 -0
- package/src/components/view/form-setting-layout.vue +375 -0
- package/src/components/view/form-setting.vue +247 -0
- package/src/components/view/group-column.vue +104 -0
- package/src/components/view/group-method.vue +104 -0
- package/src/components/view/mixin.js +72 -0
- package/src/components/view/modal-form-filter.vue +319 -0
- package/src/components/view/modal-form-sort.vue +248 -0
- package/src/components/view/modal-form.vue +453 -0
- package/src/components/view/modal-table.vue +471 -0
- package/src/components/view/table-filter.vue +702 -0
- package/src/components/view/table-setting.vue +533 -0
- package/src/components/view/view-chart.vue +423 -0
- package/src/components/view/view-form-draggable.vue +837 -0
- package/src/components/view/view-form.vue +1444 -0
- package/src/components/view/view-table.vue +2261 -0
- package/src/components/workflow/flow-chart.vue +846 -0
- package/src/directive/focus.js +10 -0
- package/src/directive/tabHide.js +9 -0
- package/src/i18n/index.js +15 -0
- package/src/i18n/locale/en-US.js +1 -0
- package/src/i18n/locale/lang.js +1 -0
- package/src/i18n/locale/zh-CN.js +1 -0
- package/src/i18n/locale.js +102 -0
- package/src/index.js +222 -0
- package/src/layouts/basic-layout/header-breadcrumb/index.vue +122 -0
- package/src/layouts/basic-layout/header-collapse/index.vue +44 -0
- package/src/layouts/basic-layout/header-fullscreen/index.vue +19 -0
- package/src/layouts/basic-layout/header-i18n/index.vue +45 -0
- package/src/layouts/basic-layout/header-log/index.vue +41 -0
- package/src/layouts/basic-layout/header-logo/index.vue +23 -0
- package/src/layouts/basic-layout/header-notice/index.vue +218 -0
- package/src/layouts/basic-layout/header-reload/index.vue +21 -0
- package/src/layouts/basic-layout/header-search/index.vue +37 -0
- package/src/layouts/basic-layout/header-setting/index.vue +219 -0
- package/src/layouts/basic-layout/header-user/index.vue +175 -0
- package/src/layouts/basic-layout/i18n.js +50 -0
- package/src/layouts/basic-layout/index.vue +280 -0
- package/src/layouts/basic-layout/menu-head/index.vue +120 -0
- package/src/layouts/basic-layout/menu-head/title.vue +48 -0
- package/src/layouts/basic-layout/menu-side/index.vue +113 -0
- package/src/layouts/basic-layout/menu-side/menu-collapse.vue +76 -0
- package/src/layouts/basic-layout/menu-side/menu-item.vue +31 -0
- package/src/layouts/basic-layout/menu-side/menu-title.vue +56 -0
- package/src/layouts/basic-layout/menu-side/submenu.vue +31 -0
- package/src/layouts/basic-layout/mixins/click-item.js +21 -0
- package/src/layouts/basic-layout/mixins/sider-menu-badge.js +13 -0
- package/src/layouts/basic-layout/mixins/translate-title.js +11 -0
- package/src/layouts/basic-layout/tabs/index.vue +192 -0
- package/src/layouts/basic-layout/water-mark/index.vue +29 -0
- package/src/libs/lodop/index.js +145 -0
- package/src/libs/random_str.js +10 -0
- package/src/libs/request/index.js +158 -0
- package/src/libs/system/index.js +234 -0
- package/src/libs/util.cookies.js +44 -0
- package/src/libs/util.db.js +13 -0
- package/src/libs/util.js +55 -0
- package/src/libs/util.log.js +88 -0
- package/src/libs/water-mark.js +44 -0
- package/src/menu/header.js +20 -0
- package/src/menu/modules/dashboard.js +23 -0
- package/src/menu/sider.js +12 -0
- package/src/mixins/app.js +9 -0
- package/src/mixins/page.js +643 -0
- package/src/pages/account/login.vue +101 -0
- package/src/pages/common/home.vue +169 -0
- package/src/pages/common/task-form.vue +350 -0
- package/src/pages/common/todo.vue +31 -0
- package/src/pages/system/apiLog.vue +79 -0
- package/src/pages/system/applicationType.vue +182 -0
- package/src/pages/system/customPage.vue +62 -0
- package/src/pages/system/customTable.vue +98 -0
- package/src/pages/system/dict.vue +36 -0
- package/src/pages/system/dictType.vue +58 -0
- package/src/pages/system/entityView.vue +38 -0
- package/src/pages/system/error/404.vue +6 -0
- package/src/pages/system/extendColumn.vue +99 -0
- package/src/pages/system/formView.vue +136 -0
- package/src/pages/system/log.vue +55 -0
- package/src/pages/system/notice.vue +26 -0
- package/src/pages/system/openApi.vue +26 -0
- package/src/pages/system/openUser.vue +66 -0
- package/src/pages/system/organization.vue +98 -0
- package/src/pages/system/organizationType.vue +26 -0
- package/src/pages/system/permission.vue +175 -0
- package/src/pages/system/planJob.vue +40 -0
- package/src/pages/system/printTemplate.vue +48 -0
- package/src/pages/system/process.vue +79 -0
- package/src/pages/system/processType.vue +26 -0
- package/src/pages/system/role.vue +395 -0
- package/src/pages/system/rolePropertyEdit.vue +480 -0
- package/src/pages/system/sequenceSetting.vue +26 -0
- package/src/pages/system/systemData.vue +52 -0
- package/src/pages/system/tableView.vue +386 -0
- package/src/pages/system/taskQueue.vue +48 -0
- package/src/pages/system/user.vue +250 -0
- package/src/pages/template/processPage.vue +243 -0
- package/src/pages/template/reportPage.vue +66 -0
- package/src/pages/template/viewPage.vue +139 -0
- package/src/plugins/auth/index.js +21 -0
- package/src/plugins/error/index.js +31 -0
- package/src/plugins/index.js +24 -0
- package/src/plugins/sweetalert2/index.js +20 -0
- package/src/router/dynamic.js +183 -0
- package/src/router/index.js +84 -0
- package/src/setting.js +202 -0
- package/src/store/index.js +9 -0
- package/src/store/modules/admin/index.js +16 -0
- package/src/store/modules/admin/modules/account.js +103 -0
- package/src/store/modules/admin/modules/cache.js +119 -0
- package/src/store/modules/admin/modules/dataView.js +112 -0
- package/src/store/modules/admin/modules/db.js +231 -0
- package/src/store/modules/admin/modules/i18n.js +87 -0
- package/src/store/modules/admin/modules/layout.js +115 -0
- package/src/store/modules/admin/modules/loader.js +44 -0
- package/src/store/modules/admin/modules/log.js +77 -0
- package/src/store/modules/admin/modules/menu.js +338 -0
- package/src/store/modules/admin/modules/page.js +466 -0
- package/src/store/modules/admin/modules/user.js +96 -0
- package/src/store/modules/admin/modules/viewPage.js +34 -0
- package/src/styles/common.less +47 -0
- package/src/styles/css/default.css +510 -0
- package/src/styles/css/login.css +1217 -0
- package/src/styles/default/index.less +6 -0
- package/src/styles/font/demo.css +539 -0
- package/src/styles/font/demo_index.html +372 -0
- package/src/styles/font/icon-demo/demo.css +539 -0
- package/src/styles/font/icon-demo/demo_index.html +423 -0
- package/src/styles/font/icon-demo/iconfont.css +61 -0
- package/src/styles/font/icon-demo/iconfont.eot +0 -0
- package/src/styles/font/icon-demo/iconfont.js +1 -0
- package/src/styles/font/icon-demo/iconfont.svg +59 -0
- package/src/styles/font/icon-demo/iconfont.ttf +0 -0
- package/src/styles/font/icon-demo/iconfont.woff +0 -0
- package/src/styles/font/icon-demo/iconfont.woff2 +0 -0
- package/src/styles/font/iconfont.css +47 -0
- package/src/styles/font/iconfont.js +1 -0
- package/src/styles/font/iconfont.json +65 -0
- package/src/styles/font/iconfont.ttf +0 -0
- package/src/styles/font/iconfont.woff +0 -0
- package/src/styles/font/iconfont.woff2 +0 -0
- package/src/styles/font/ionicons.svg +870 -0
- package/src/styles/font/ionicons.ttf +0 -0
- package/src/styles/font/ionicons.woff +0 -0
- package/src/styles/font/ionicons.woff2 +0 -0
- package/src/styles/index.less +7 -0
- package/src/styles/layout/basic-layout/layout.less +527 -0
- package/src/styles/layout/basic-layout/menu.less +274 -0
- package/src/styles/layout/index.less +2 -0
- package/src/styles/setting.less +6 -0
- package/styleguide.config.js +22 -0
- package/test/api/barcode.js +50 -0
- package/test/api/inbound.js +47 -0
- package/test/api/interfaceLog.js +15 -0
- package/test/api/interfaceQueue.js +15 -0
- package/test/api/interfaceServer.js +29 -0
- package/test/api/movePlan.js +50 -0
- package/test/api/movePlanItem.js +13 -0
- package/test/api/moveType.js +22 -0
- package/test/api/openApiPermission.js +25 -0
- package/test/api/outbound.js +40 -0
- package/test/api/permission.js +34 -0
- package/test/api/rolePermission.js +17 -0
- package/test/api/user.js +40 -0
- package/test/api/viewColumn.js +16 -0
- package/test/api/warehouse.js +13 -0
- package/test/api/warehouseMoveType.js +18 -0
- package/test/main.js +55 -0
- package/test/package.js +33 -0
- package/test/pages/home/index.vue +22 -0
- package/test/pages/task/test.vue +28 -0
- package/test/pages/test/dataViewTest.vue +28 -0
- package/test/pages/test/logReport.vue +25 -0
- package/test/pages/test/testPage.vue +38 -0
- package/test/router/routes.js +88 -0
- package/test/setting.env.js +22 -0
- package/test/styles/css/custom.css +0 -0
- package/test/styles/css/login.css +1217 -0
- package/vite.config.js +72 -0
- package/vue.config.js +20 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import { get } from 'lodash';
|
|
3
|
+
import util from '../../../../libs/util.js';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
namespaced: true,
|
|
7
|
+
state: {
|
|
8
|
+
/**
|
|
9
|
+
* @description 错误日志,单条属性:
|
|
10
|
+
* message: 必填,日志信息
|
|
11
|
+
* type: 非必填,类型,可选值为 info(默认值)| success | warning | error,其中 error 会以具体数目强调显示,其它以点轻量显示
|
|
12
|
+
* time: 必填,日志记录时间
|
|
13
|
+
* meta: 非必填,其它携带信息
|
|
14
|
+
* */
|
|
15
|
+
log: []
|
|
16
|
+
},
|
|
17
|
+
getters: {
|
|
18
|
+
/**
|
|
19
|
+
* @description 返回现存 log (all) 的条数
|
|
20
|
+
* @param {*} state vuex state
|
|
21
|
+
*/
|
|
22
|
+
length(state) {
|
|
23
|
+
return state.log.length;
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* @description 返回现存 log (error) 的条数
|
|
27
|
+
* @param {*} state vuex state
|
|
28
|
+
*/
|
|
29
|
+
lengthError(state) {
|
|
30
|
+
return state.log.filter(log => log.type === 'error').length;
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
actions: {
|
|
34
|
+
/**
|
|
35
|
+
* @description 添加一个日志
|
|
36
|
+
* @param {String} param message {String} 信息
|
|
37
|
+
* @param {String} param type {String} 类型
|
|
38
|
+
* @param {Object} param meta {Object} 附带的信息
|
|
39
|
+
*/
|
|
40
|
+
push({ rootState, commit }, { message, type = 'info', meta }) {
|
|
41
|
+
commit('push', {
|
|
42
|
+
message,
|
|
43
|
+
type,
|
|
44
|
+
time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
|
45
|
+
meta: {
|
|
46
|
+
// 当前用户信息
|
|
47
|
+
user: rootState.admin.user.info,
|
|
48
|
+
// 当前用户的 uuid
|
|
49
|
+
uuid: util.cookies.get('uuid'),
|
|
50
|
+
// 当前的 token
|
|
51
|
+
token: util.cookies.get('token'),
|
|
52
|
+
// 当前地址
|
|
53
|
+
url: get(window, 'location.href', ''),
|
|
54
|
+
// 用户设置
|
|
55
|
+
...meta
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
mutations: {
|
|
61
|
+
/**
|
|
62
|
+
* @description 添加日志
|
|
63
|
+
* @param {Object} state vuex state
|
|
64
|
+
* @param {Object} log data
|
|
65
|
+
*/
|
|
66
|
+
push(state, log) {
|
|
67
|
+
state.log.push(log);
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* @description 清空日志
|
|
71
|
+
* @param {Object} state vuex state
|
|
72
|
+
*/
|
|
73
|
+
clean(state) {
|
|
74
|
+
state.log = [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 菜单
|
|
3
|
+
* */
|
|
4
|
+
import { cloneDeep } from 'lodash';
|
|
5
|
+
import {
|
|
6
|
+
includeArray,
|
|
7
|
+
setNativeMenuSider,
|
|
8
|
+
//setNativeMenuHeader,
|
|
9
|
+
setNativePermission,
|
|
10
|
+
getHeaderName,
|
|
11
|
+
getMenuSider,
|
|
12
|
+
getSiderSubmenu,
|
|
13
|
+
getNativeMenuSider,
|
|
14
|
+
getNativeMenuHeader,
|
|
15
|
+
getNativePermission
|
|
16
|
+
} from '../../../../libs/system';
|
|
17
|
+
import router from '../../../../router';
|
|
18
|
+
import permissionApi from '../../../../api/permission';
|
|
19
|
+
|
|
20
|
+
// 根据 menu 配置的权限,过滤菜单
|
|
21
|
+
function filterMenu(menuList, access, lastList) {
|
|
22
|
+
menuList.forEach(menu => {
|
|
23
|
+
let menuAccess = menu.auth;
|
|
24
|
+
|
|
25
|
+
if (!menuAccess || includeArray(menuAccess, access)) {
|
|
26
|
+
let newMenu = {};
|
|
27
|
+
for (let i in menu) {
|
|
28
|
+
if (i !== 'children') newMenu[i] = cloneDeep(menu[i]);
|
|
29
|
+
}
|
|
30
|
+
if (menu.children && menu.children.length) newMenu.children = [];
|
|
31
|
+
|
|
32
|
+
lastList.push(newMenu);
|
|
33
|
+
menu.children && filterMenu(menu.children, access, newMenu.children);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return lastList;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 转换菜单
|
|
40
|
+
function convertMenu(source) {
|
|
41
|
+
if (!source) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 外部链接
|
|
46
|
+
var reg = /(http|https):\/\/([\w.]+\/?)\S*/;
|
|
47
|
+
return source.map(item => {
|
|
48
|
+
return {
|
|
49
|
+
path: reg.test(item.url) ? item.url : '/' + item.url.split('?')[0],
|
|
50
|
+
title: item.name,
|
|
51
|
+
subtitle: item.subName,
|
|
52
|
+
target: item.isNewWindow ? '_blank' : null,
|
|
53
|
+
header: 'home',
|
|
54
|
+
custom: item.icon,
|
|
55
|
+
children: convertMenu(item.subPermissions)
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default {
|
|
61
|
+
namespaced: true,
|
|
62
|
+
state: {
|
|
63
|
+
// 顶部菜单
|
|
64
|
+
header: [],
|
|
65
|
+
// 侧栏菜单
|
|
66
|
+
sider: [],
|
|
67
|
+
// 当前顶栏菜单的 name
|
|
68
|
+
headerName: '',
|
|
69
|
+
// 当前所在菜单的 path
|
|
70
|
+
activePath: '',
|
|
71
|
+
// 展开的子菜单 name 集合
|
|
72
|
+
openNames: [],
|
|
73
|
+
// 所有的菜单
|
|
74
|
+
menuSider: [],
|
|
75
|
+
// 侧边菜单徽标
|
|
76
|
+
siderMenuBadge: [],
|
|
77
|
+
// 顶栏菜单徽标
|
|
78
|
+
headerMenuBadge: [],
|
|
79
|
+
// 用户权限
|
|
80
|
+
userPermissions: null
|
|
81
|
+
},
|
|
82
|
+
getters: {
|
|
83
|
+
/**
|
|
84
|
+
* @description 获取侧边菜单
|
|
85
|
+
* */
|
|
86
|
+
// sider(state) {
|
|
87
|
+
// return state.sider;
|
|
88
|
+
// },
|
|
89
|
+
/**
|
|
90
|
+
* @description 根据 user 里登录用户权限,对侧边菜单进行鉴权过滤
|
|
91
|
+
* */
|
|
92
|
+
filterSider(state, getters, rootState) {
|
|
93
|
+
const userInfo = rootState.admin.user.info;
|
|
94
|
+
// @权限
|
|
95
|
+
const access = userInfo.access;
|
|
96
|
+
if (access && access.length) {
|
|
97
|
+
return filterMenu(state.sider, access, []);
|
|
98
|
+
} else {
|
|
99
|
+
return filterMenu(state.sider, [], []);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* @description 根据 user 里登录用户权限,对顶栏菜单进行鉴权过滤
|
|
104
|
+
* */
|
|
105
|
+
filterHeader(state, getters, rootState) {
|
|
106
|
+
const userInfo = rootState.admin.user.info;
|
|
107
|
+
// @权限
|
|
108
|
+
const access = userInfo.access;
|
|
109
|
+
if (access && access.length) {
|
|
110
|
+
return state.header.filter(item => {
|
|
111
|
+
let state = true;
|
|
112
|
+
if (item.auth && !includeArray(item.auth, access)) state = false;
|
|
113
|
+
if (item.children && item.children.length) {
|
|
114
|
+
item.children = item.children.filter(child => {
|
|
115
|
+
let state = true;
|
|
116
|
+
if (child.auth && !includeArray(child.auth, access)) state = false;
|
|
117
|
+
return state;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return state;
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
return state.header.filter(item => {
|
|
124
|
+
let state = true;
|
|
125
|
+
if (item.auth && item.auth.length) state = false;
|
|
126
|
+
if (item.children && item.children.length) {
|
|
127
|
+
item.children = item.children.filter(child => {
|
|
128
|
+
let state = true;
|
|
129
|
+
if (child.auth && child.auth.length) state = false;
|
|
130
|
+
return state;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
return state;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* @description 当前 header 的全部信息
|
|
139
|
+
* */
|
|
140
|
+
currentHeader(state) {
|
|
141
|
+
return state.header.find(item => item.name === state.headerName);
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* @description 在当前 header 下,是否隐藏 sider(及折叠按钮)
|
|
145
|
+
* */
|
|
146
|
+
hideSider(state, getters) {
|
|
147
|
+
let visible = false;
|
|
148
|
+
if (getters.currentHeader && 'hideSider' in getters.currentHeader) visible = getters.currentHeader.hideSider;
|
|
149
|
+
return visible;
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* @description 获取权限
|
|
153
|
+
* */
|
|
154
|
+
permission(state) {
|
|
155
|
+
return state.userPermissions;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
mutations: {
|
|
159
|
+
/**
|
|
160
|
+
* @description 设置侧边栏菜单
|
|
161
|
+
* @param {Object} state vuex state
|
|
162
|
+
* @param {Array} menu menu
|
|
163
|
+
*/
|
|
164
|
+
setSider(state, menu) {
|
|
165
|
+
state.sider = menu;
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* @description 设置顶栏菜单
|
|
169
|
+
* @param {Object} state vuex state
|
|
170
|
+
* @param {Array} menu menu
|
|
171
|
+
*/
|
|
172
|
+
setHeader(state, menu) {
|
|
173
|
+
state.header = menu;
|
|
174
|
+
},
|
|
175
|
+
/**
|
|
176
|
+
* @description 设置当前顶栏菜单 name
|
|
177
|
+
* @param {Object} state vuex state
|
|
178
|
+
* @param {Array} name headerName
|
|
179
|
+
*/
|
|
180
|
+
setHeaderName(state, name) {
|
|
181
|
+
state.headerName = name;
|
|
182
|
+
},
|
|
183
|
+
/**
|
|
184
|
+
* @description 设置当前所在菜单的 path,用于侧栏菜单高亮当前项
|
|
185
|
+
* @param {Object} state vuex state
|
|
186
|
+
* @param {Array} path fullPath
|
|
187
|
+
*/
|
|
188
|
+
setActivePath(state, path) {
|
|
189
|
+
state.activePath = path;
|
|
190
|
+
},
|
|
191
|
+
/**
|
|
192
|
+
* @description 设置当前所在菜单的全部展开父菜单的 names 集合
|
|
193
|
+
* @param {Object} state vuex state
|
|
194
|
+
* @param {Array} names openNames
|
|
195
|
+
*/
|
|
196
|
+
setOpenNames(state, names) {
|
|
197
|
+
state.openNames = names;
|
|
198
|
+
},
|
|
199
|
+
/**
|
|
200
|
+
* @description 设置所有菜单
|
|
201
|
+
* @param {Object} state vuex state
|
|
202
|
+
* @param {Array} menuSider menuSider
|
|
203
|
+
* */
|
|
204
|
+
setMenuSider(state, menuSider) {
|
|
205
|
+
state.menuSider = menuSider;
|
|
206
|
+
},
|
|
207
|
+
/**
|
|
208
|
+
* @description 设置全部的侧边菜单的徽标
|
|
209
|
+
* */
|
|
210
|
+
setAllSiderMenuBadge(state, data) {
|
|
211
|
+
state.siderMenuBadge = data;
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* @description 新增或修改某个侧边菜单的徽标
|
|
215
|
+
* */
|
|
216
|
+
setSiderMenuBadge(state, { path, badge }) {
|
|
217
|
+
const siderMenuBadge = cloneDeep(state.siderMenuBadge);
|
|
218
|
+
const menuIndex = siderMenuBadge.findIndex(item => item.path === path);
|
|
219
|
+
if (menuIndex >= 0) {
|
|
220
|
+
siderMenuBadge[menuIndex] = badge;
|
|
221
|
+
state.siderMenuBadge = siderMenuBadge;
|
|
222
|
+
} else {
|
|
223
|
+
state.siderMenuBadge.push(badge);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
/**
|
|
227
|
+
* @description 删除某个侧边菜单的徽标
|
|
228
|
+
* */
|
|
229
|
+
removeSiderMenuBadge(state, path) {
|
|
230
|
+
const menuIndex = state.siderMenuBadge.findIndex(item => item.path === path);
|
|
231
|
+
if (menuIndex >= 0) state.siderMenuBadge.splice(menuIndex, 1);
|
|
232
|
+
},
|
|
233
|
+
/**
|
|
234
|
+
* @description 设置全部的顶栏菜单的徽标
|
|
235
|
+
* */
|
|
236
|
+
setAllHeaderMenuBadge(state, data) {
|
|
237
|
+
state.headerMenuBadge = data;
|
|
238
|
+
},
|
|
239
|
+
/**
|
|
240
|
+
* @description 新增或修改某个顶栏菜单的徽标
|
|
241
|
+
* */
|
|
242
|
+
setHeaderMenuBadge(state, { path, badge }) {
|
|
243
|
+
const headerMenuBadge = cloneDeep(state.headerMenuBadge);
|
|
244
|
+
const menuIndex = headerMenuBadge.findIndex(item => item.path === path);
|
|
245
|
+
if (menuIndex >= 0) {
|
|
246
|
+
headerMenuBadge[menuIndex] = badge;
|
|
247
|
+
state.headerMenuBadge = headerMenuBadge;
|
|
248
|
+
} else {
|
|
249
|
+
state.headerMenuBadge.push(badge);
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
/**
|
|
253
|
+
* @description 删除某个顶栏菜单的徽标
|
|
254
|
+
* */
|
|
255
|
+
removeHeaderMenuBadge(state, path) {
|
|
256
|
+
const menuIndex = state.headerMenuBadge.findIndex(item => item.path === path);
|
|
257
|
+
if (menuIndex >= 0) state.headerMenuBadge.splice(menuIndex, 1);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
actions: {
|
|
261
|
+
/**
|
|
262
|
+
* @description 设置菜单(动态+静态)
|
|
263
|
+
* */
|
|
264
|
+
setMenuList({ state, commit }, to = {}) {
|
|
265
|
+
// 设置顶栏菜单
|
|
266
|
+
const menuHeaderList = getNativeMenuHeader();
|
|
267
|
+
commit('setHeader', menuHeaderList);
|
|
268
|
+
|
|
269
|
+
// 设置侧边栏菜单
|
|
270
|
+
const menuSiderList = getNativeMenuSider();
|
|
271
|
+
let path = to.matched[to.matched.length - 1].path;
|
|
272
|
+
|
|
273
|
+
let headerName = getHeaderName(path, menuSiderList);
|
|
274
|
+
if (headerName === null) {
|
|
275
|
+
path = to.path;
|
|
276
|
+
headerName = getHeaderName(path, menuSiderList);
|
|
277
|
+
}
|
|
278
|
+
// 在 404 时,是没有 headerName 的
|
|
279
|
+
if (headerName !== null) {
|
|
280
|
+
commit('setHeaderName', headerName);
|
|
281
|
+
commit('setMenuSider', menuSiderList);
|
|
282
|
+
|
|
283
|
+
const filterMenuSider = getMenuSider(menuSiderList, headerName);
|
|
284
|
+
commit('setSider', filterMenuSider);
|
|
285
|
+
commit('setActivePath', to.path);
|
|
286
|
+
|
|
287
|
+
const openNames = getSiderSubmenu(path, menuSiderList);
|
|
288
|
+
commit('setOpenNames', openNames);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (state.userPermissions == null) {
|
|
292
|
+
state.userPermissions = getNativePermission();
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
/**
|
|
296
|
+
* @description 动态获取菜单
|
|
297
|
+
* @param dispatch
|
|
298
|
+
* @param loadMenu 是否加载菜单,需传 $route 信息
|
|
299
|
+
* */
|
|
300
|
+
getMenuList({ dispatch }, loadMenu) {
|
|
301
|
+
return new Promise((resolve, reject) => {
|
|
302
|
+
permissionApi
|
|
303
|
+
.query()
|
|
304
|
+
.then(res => {
|
|
305
|
+
// 默认包含首页
|
|
306
|
+
res.menus.unshift({
|
|
307
|
+
name: '首页',
|
|
308
|
+
subName: 'Home',
|
|
309
|
+
parentID: null,
|
|
310
|
+
url: 'home',
|
|
311
|
+
templateUrl: '@/home',
|
|
312
|
+
icon: 'fa fa-home'
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
let menu = convertMenu(res.menus);
|
|
316
|
+
|
|
317
|
+
//setNativeMenuHeader(res.header);
|
|
318
|
+
setNativeMenuSider(menu);
|
|
319
|
+
if (loadMenu) {
|
|
320
|
+
const to = loadMenu === true ? router.currentRoute.value : loadMenu;
|
|
321
|
+
dispatch('setMenuList', to);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
let permissions = {};
|
|
325
|
+
res.permissions.forEach(key => {
|
|
326
|
+
permissions[key] = true;
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
setNativePermission(permissions);
|
|
330
|
+
resolve();
|
|
331
|
+
})
|
|
332
|
+
.catch(err => {
|
|
333
|
+
reject(err);
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
};
|