@lambo-design/shared 1.0.0-beta.2 → 1.0.0-beta.21
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/config/config.js +12 -0
- package/config/themes/index.js +5 -1
- package/config/themes/theme-orange.js +40 -0
- package/config/themes/theme-red.js +40 -0
- package/directives/index.js +23 -0
- package/directives/module/draggable.js +56 -0
- package/directives/module/permission.js +49 -0
- package/index.js +2 -1
- package/package.json +22 -20
- package/utils/ajax/interceptors.js +97 -90
- package/utils/assist.js +24 -19
- package/utils/menu/before-close.js +17 -0
- package/utils/menu/index.js +135 -0
- package/utils/platform.js +70 -6
- package/utils/theme.js +1 -1
- package/utils/vxetable/index.js +25 -0
package/config/config.js
CHANGED
|
@@ -6,6 +6,18 @@ let config = {
|
|
|
6
6
|
ssoLoginUrl: "/wdk?action=access.login&method=logout",
|
|
7
7
|
homeName: 'home',
|
|
8
8
|
homePageUrl: '/home',
|
|
9
|
+
homeRouter: {
|
|
10
|
+
"name": 'home',
|
|
11
|
+
"params": {},
|
|
12
|
+
"query": {},
|
|
13
|
+
"meta": {
|
|
14
|
+
"hideInMenu": true,
|
|
15
|
+
"title": "首页",
|
|
16
|
+
"icon": "md-home",
|
|
17
|
+
"appId": "home"
|
|
18
|
+
},
|
|
19
|
+
"uri": '/home'
|
|
20
|
+
},
|
|
9
21
|
upmsServerContext: '/upms-server',
|
|
10
22
|
ossServerContext: '/upms-server',
|
|
11
23
|
didaHost: "/dida-runtime-micro",
|
package/config/themes/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import themeDefault from "./theme-default";
|
|
2
2
|
import themeGold from "./theme-gold";
|
|
3
3
|
import themeLime from "./theme-lime";
|
|
4
|
+
import themeOrange from "./theme-orange";
|
|
5
|
+
import themeRed from "./theme-red";
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
export default [
|
|
7
9
|
themeDefault,
|
|
8
10
|
themeGold,
|
|
9
|
-
themeLime
|
|
11
|
+
themeLime,
|
|
12
|
+
themeOrange,
|
|
13
|
+
themeRed
|
|
10
14
|
]
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
key: "orange",
|
|
3
|
+
title: "魅力橙",
|
|
4
|
+
primaryColor: "#ee5414",
|
|
5
|
+
//自定义主题相关颜色覆盖
|
|
6
|
+
vars:
|
|
7
|
+
`
|
|
8
|
+
--primary-color: #ee5414;
|
|
9
|
+
--primary-color-tint-20: #f17643;
|
|
10
|
+
--primary-color-tint-90: #fdeee8;
|
|
11
|
+
--primary-color-tint-80: #fcddd0;
|
|
12
|
+
--primary-color-tint-5: #ef5d20;
|
|
13
|
+
--primary-color-tint-95-fade-50: rgba(254, 246, 243, 0.5);
|
|
14
|
+
--primary-color-fade-20: rgba(238, 84, 20, 0.2);
|
|
15
|
+
--primary-color-shade-5: #e25013;
|
|
16
|
+
--normal-color: rgba(254, 246, 243, 0);
|
|
17
|
+
--link-color: #ee5414;
|
|
18
|
+
--link-hover-color: #f17643;
|
|
19
|
+
--link-active-color: #e25013;
|
|
20
|
+
--selected-color: rgba(238, 84, 20, 0.9);
|
|
21
|
+
--selected-color-shade-10: rgba(210, 74, 18, 0.91);
|
|
22
|
+
--date-picker-cell-hover-bg: rgba(238, 84, 20, 0.3);
|
|
23
|
+
--btn-group-border: #e25013;
|
|
24
|
+
--btn-primary-bg: #ee5414;
|
|
25
|
+
--btn-primary-bg-tint-20: #f17643;
|
|
26
|
+
--btn-primary-bg-tint-5: #ef5d20;
|
|
27
|
+
--input-hover-border-color: #ee5414;
|
|
28
|
+
--input-hover-border-color-tint-20: #f17643;
|
|
29
|
+
--input-hover-border-color-fade-20: rgba(238, 84, 20, 0.2);
|
|
30
|
+
--input-focus-border-color: color:#ee5414;
|
|
31
|
+
--slider-color: #f17643;
|
|
32
|
+
`,
|
|
33
|
+
style:
|
|
34
|
+
`
|
|
35
|
+
html {
|
|
36
|
+
padding:0;
|
|
37
|
+
margin:0;
|
|
38
|
+
}
|
|
39
|
+
`
|
|
40
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
key: "read",
|
|
3
|
+
title: "发财红",
|
|
4
|
+
primaryColor: "#ff3457",
|
|
5
|
+
//自定义主题相关颜色覆盖
|
|
6
|
+
vars:
|
|
7
|
+
`
|
|
8
|
+
--primary-color: #ff3457;
|
|
9
|
+
--primary-color-tint-20: #ff5d79;
|
|
10
|
+
--primary-color-tint-90: #ffebee;
|
|
11
|
+
--primary-color-tint-80: #ffd6dd;
|
|
12
|
+
--primary-color-tint-5: #ff3e5f;
|
|
13
|
+
--primary-color-tint-95-fade-50: rgba(255, 245, 247, 0.5);
|
|
14
|
+
--primary-color-fade-20: rgba(255, 52, 87, 0.2);
|
|
15
|
+
--primary-color-shade-5: #f23153;
|
|
16
|
+
--normal-color: rgba(255, 245, 247, 0);
|
|
17
|
+
--link-color: #ff3457;
|
|
18
|
+
--link-hover-color: #ff5d79;
|
|
19
|
+
--link-active-color: #f23153;
|
|
20
|
+
--selected-color: rgba(255, 52, 87, 0.9);
|
|
21
|
+
--selected-color-shade-10: rgba(225, 46, 77, 0.9);
|
|
22
|
+
--date-picker-cell-hover-bg: rgba(255, 52, 87, 0.3);
|
|
23
|
+
--btn-group-border: #f23153;
|
|
24
|
+
--btn-primary-bg: #ff3457;
|
|
25
|
+
--btn-primary-bg-tint-20: #ff5d79;
|
|
26
|
+
--btn-primary-bg-tint-5: #ff3e5f;
|
|
27
|
+
--input-hover-border-color: #ff3457;
|
|
28
|
+
--input-hover-border-color-tint-20: #ff5d79;
|
|
29
|
+
--input-hover-border-color-fade-20: rgba(255, 52, 87, 0.2);
|
|
30
|
+
--input-focus-border-color: color:#ff3457;
|
|
31
|
+
--slider-color: #ff5d79;
|
|
32
|
+
`,
|
|
33
|
+
style:
|
|
34
|
+
`
|
|
35
|
+
html {
|
|
36
|
+
padding:0;
|
|
37
|
+
margin:0;
|
|
38
|
+
}
|
|
39
|
+
`
|
|
40
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const importDirective = Vue => {
|
|
2
|
+
const requireDirective = require.context(
|
|
3
|
+
// 其组件目录的相对路径
|
|
4
|
+
'./module',
|
|
5
|
+
// 是否查询其子目录
|
|
6
|
+
false,
|
|
7
|
+
// 匹配基础组件文件名的正则表达式
|
|
8
|
+
/[a-zA-Z]\w+\.(vue|js)$/
|
|
9
|
+
)
|
|
10
|
+
requireDirective.keys().forEach(fileName => {
|
|
11
|
+
// 获取组件配置
|
|
12
|
+
const directiveConfig = requireDirective(fileName)
|
|
13
|
+
|
|
14
|
+
// 获取组件的 PascalCase 命名
|
|
15
|
+
const directiveName = fileName
|
|
16
|
+
.split('/')
|
|
17
|
+
.pop()
|
|
18
|
+
.replace(/\.\w+$/, '')
|
|
19
|
+
Vue.directive(directiveName.toLowerCase(), directiveConfig.default || directiveConfig);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default importDirective
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {on} from '../../utils/dom'
|
|
2
|
+
/**
|
|
3
|
+
* 拖拽指令 v-draggable="options"
|
|
4
|
+
* options = {
|
|
5
|
+
* trigger: /这里传入作为拖拽触发器的CSS选择器/,
|
|
6
|
+
* body: /这里传入需要移动容器的CSS选择器/,
|
|
7
|
+
* recover: /拖动结束之后是否恢复到原来的位置/
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
export default {
|
|
11
|
+
inserted: (el, binding, vnode) => {
|
|
12
|
+
let triggerDom = document.querySelector(binding.value.trigger)
|
|
13
|
+
triggerDom.style.cursor = 'move'
|
|
14
|
+
let bodyDom = document.querySelector(binding.value.body)
|
|
15
|
+
let pageX = 0
|
|
16
|
+
let pageY = 0
|
|
17
|
+
let transformX = 0
|
|
18
|
+
let transformY = 0
|
|
19
|
+
let canMove = false
|
|
20
|
+
const handleMousedown = e => {
|
|
21
|
+
let transform = /\(.*\)/.exec(bodyDom.style.transform)
|
|
22
|
+
if (transform) {
|
|
23
|
+
transform = transform[0].slice(1, transform[0].length - 1)
|
|
24
|
+
let splitxy = transform.split('px, ')
|
|
25
|
+
transformX = parseFloat(splitxy[0])
|
|
26
|
+
transformY = parseFloat(splitxy[1].split('px')[0])
|
|
27
|
+
}
|
|
28
|
+
pageX = e.pageX
|
|
29
|
+
pageY = e.pageY
|
|
30
|
+
canMove = true
|
|
31
|
+
}
|
|
32
|
+
const handleMousemove = e => {
|
|
33
|
+
let xOffset = e.pageX - pageX + transformX
|
|
34
|
+
let yOffset = e.pageY - pageY + transformY
|
|
35
|
+
/*if (e.pageX <= 0) {
|
|
36
|
+
xOffset = pageX
|
|
37
|
+
}*/
|
|
38
|
+
if (e.pageY <= 0) {
|
|
39
|
+
yOffset = transformY - pageY
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (canMove) bodyDom.style.transform = `translate(${xOffset}px, ${yOffset}px)`
|
|
43
|
+
}
|
|
44
|
+
const handleMouseup = e => {
|
|
45
|
+
canMove = false
|
|
46
|
+
}
|
|
47
|
+
on(triggerDom, 'mousedown', handleMousedown)
|
|
48
|
+
on(document, 'mousemove', handleMousemove)
|
|
49
|
+
on(document, 'mouseup', handleMouseup)
|
|
50
|
+
},
|
|
51
|
+
update: (el, binding, vnode) => {
|
|
52
|
+
if (!binding.value.recover) return
|
|
53
|
+
let bodyDom = document.querySelector(binding.value.body)
|
|
54
|
+
bodyDom.style.transform = ''
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import config from "../../config/config";
|
|
2
|
+
|
|
3
|
+
const checkPermission = function (el, binding) {
|
|
4
|
+
el.style.display = "none"
|
|
5
|
+
const value = binding.value
|
|
6
|
+
const permissionInStore = sessionStorage.getItem(config.routerBase + "-permission");
|
|
7
|
+
if (permissionInStore) {
|
|
8
|
+
const permissionObj = JSON.parse(permissionInStore);
|
|
9
|
+
//判断是否以'/'为开头结尾
|
|
10
|
+
if (/(^\/.*\/$)/.test(value)) {
|
|
11
|
+
//去掉开头结尾的'/'
|
|
12
|
+
let regexStr = value.replace(/(^\/)|(\/$)/g,"");
|
|
13
|
+
|
|
14
|
+
regExCheck(el, permissionObj, regexStr)
|
|
15
|
+
} else {
|
|
16
|
+
normalCheck(el, permissionObj, value)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const regExCheck = function (el, permissionObj, value) {
|
|
22
|
+
let regex = new RegExp(value,"i");
|
|
23
|
+
for (const item of permissionObj) {
|
|
24
|
+
if (item.permissionValue) {
|
|
25
|
+
if(regex.test(item.permissionValue)){
|
|
26
|
+
console.log(item.permissionValue)
|
|
27
|
+
el.style.display = '';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const normalCheck = function (el, permissionObj, value) {
|
|
34
|
+
let permission = {};
|
|
35
|
+
for (const item of permissionObj) {
|
|
36
|
+
if (item.permissionValue) {
|
|
37
|
+
permission[item.permissionValue] = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const have = permission[value]
|
|
41
|
+
if (have || value === "all") {
|
|
42
|
+
el.style.display = '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default {
|
|
47
|
+
bind: checkPermission,
|
|
48
|
+
update: checkPermission
|
|
49
|
+
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@lambo-design/shared",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"axios": "^0.24.0",
|
|
14
|
-
"axios-cache-plugin": "^0.1.0",
|
|
15
|
-
"qs": "^6.11.0",
|
|
16
|
-
"xlsx": "
|
|
17
|
-
"classnames": "^2.3.1",
|
|
18
|
-
"xlsx-style": "^0.8.13"
|
|
19
|
-
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@lambo-design/shared",
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"author": "lambo",
|
|
7
|
+
"license": "ISC",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public",
|
|
10
|
+
"registry": "https://registry.npmjs.org/"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "^0.24.0",
|
|
14
|
+
"axios-cache-plugin": "^0.1.0",
|
|
15
|
+
"qs": "^6.11.0",
|
|
16
|
+
"xlsx": "http://10.110.34.38/package/cdn/xlsx-0.19.1.tgz",
|
|
17
|
+
"classnames": "^2.3.1",
|
|
18
|
+
"xlsx-style": "^0.8.13",
|
|
19
|
+
"moment": "2.29.4"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {}
|
|
22
|
+
}
|
|
@@ -1,90 +1,97 @@
|
|
|
1
|
-
import qs from 'qs'
|
|
2
|
-
import cacheRules from "./cacheconf";
|
|
3
|
-
import {getToken,getUrlParams} from '../platform'
|
|
4
|
-
import Bus from '../bus';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let timer1, timer2;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
1
|
+
import qs from 'qs'
|
|
2
|
+
import cacheRules from "./cacheconf";
|
|
3
|
+
import {getToken,getUrlParams} from '../platform'
|
|
4
|
+
import Bus from '../bus';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
let timer1, timer2;
|
|
8
|
+
let hasDialog = false;
|
|
9
|
+
|
|
10
|
+
function requestInterceptors(config) {
|
|
11
|
+
const params = getUrlParams();
|
|
12
|
+
|
|
13
|
+
let token = getToken();
|
|
14
|
+
if (token) {
|
|
15
|
+
config.headers.token = token;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//sso_token认证
|
|
19
|
+
if (params.hasOwnProperty('sso_token')||sessionStorage.getItem('sso_token')) {
|
|
20
|
+
config.params = Object.assign({
|
|
21
|
+
sso_token: params.sso_token||sessionStorage.getItem('sso_token') ,
|
|
22
|
+
sso_id: params.sso_id
|
|
23
|
+
}, config.params)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//oauth认证
|
|
27
|
+
if (params.hasOwnProperty('token')) {
|
|
28
|
+
if (config.url.indexOf('?') === -1) {
|
|
29
|
+
config.url = config.url + "?token=" + params.token + "&ssoid=" + params.ssoid;
|
|
30
|
+
} else {
|
|
31
|
+
config.url = config.url + "&token=" + params.token + "&ssoid=" + params.ssoid;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (config.method === 'post') {
|
|
36
|
+
// payload为自定义不使用qs.stringify序列化的标记,默认config.payload == undefined;
|
|
37
|
+
// 为true时用于匹配@requestBody定义参数的接口
|
|
38
|
+
// 使用方式:post(config.AAAServerContext + '/AAA/BBB/CCC', { ...paramRequestBody }, { payload: true })
|
|
39
|
+
if (!config.payload) {
|
|
40
|
+
config.data = qs.stringify(config.data)
|
|
41
|
+
}
|
|
42
|
+
} else if (config.method === 'get') {
|
|
43
|
+
for (let rule of cacheRules) {
|
|
44
|
+
if (rule.test(config.url)) {
|
|
45
|
+
return config;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (config.url.indexOf('?') === -1) {
|
|
49
|
+
config.url = config.url + "?t=" + new Date().getTime();
|
|
50
|
+
} else {
|
|
51
|
+
config.url = config.url + "&t=" + new Date().getTime();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return config;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function requestError(error) {
|
|
58
|
+
console.error("服务器内部异常,请稍候再试",error);
|
|
59
|
+
return Promise.reject(error);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function responseInterceptors(response) {
|
|
63
|
+
const data = response.data;
|
|
64
|
+
if (data instanceof Object) {
|
|
65
|
+
const code = data["code"];
|
|
66
|
+
if (code === 10106) {
|
|
67
|
+
if (!hasDialog) {
|
|
68
|
+
clearTimeout(timer1);
|
|
69
|
+
timer1 = setTimeout(function () {
|
|
70
|
+
hasDialog = true;
|
|
71
|
+
if (confirm("会话已失效,是否重新登录")) {
|
|
72
|
+
hasDialog = false;
|
|
73
|
+
Bus.$emit("needLogin");
|
|
74
|
+
} else {
|
|
75
|
+
hasDialog = false;
|
|
76
|
+
}
|
|
77
|
+
}, 500)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function responseError(error) {
|
|
85
|
+
clearTimeout(timer2);
|
|
86
|
+
timer2 = setTimeout(function () {
|
|
87
|
+
console.error("服务器内部异常,请稍候再试");
|
|
88
|
+
}, 500)
|
|
89
|
+
return Promise.reject(error);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export default {
|
|
93
|
+
requestInterceptors,
|
|
94
|
+
responseInterceptors,
|
|
95
|
+
requestError,
|
|
96
|
+
responseError
|
|
97
|
+
}
|
package/utils/assist.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// deepCopy
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
export function deepCopy(data) {
|
|
4
5
|
let i;
|
|
5
6
|
const t = typeOf(data);
|
|
@@ -43,29 +44,33 @@ export function typeOf(obj) {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export function operateBtn(vm, h, currentRow, operationName, operation, type, permission) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
47
|
+
return h('Button', {
|
|
48
|
+
props: {
|
|
49
|
+
type: type,
|
|
50
|
+
size: "small",
|
|
51
|
+
ghost: true,
|
|
52
|
+
},
|
|
53
|
+
directives: [(permission === '' || permission === null) ? '' : {
|
|
54
|
+
name: "permission",
|
|
55
|
+
value: permission
|
|
56
|
+
}],
|
|
57
|
+
style: {
|
|
58
|
+
margin: '0 2px'
|
|
59
|
+
},
|
|
60
|
+
on: {
|
|
61
|
+
'click': () => {
|
|
62
|
+
operation(vm, currentRow);
|
|
63
|
+
}
|
|
62
64
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
+
}, operationName);
|
|
66
|
+
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
export function operateHref(vm, h, currentRow, operationName, operation) {
|
|
68
|
-
|
|
70
|
+
return h('a', {
|
|
71
|
+
style: {
|
|
72
|
+
margin: '0 4px'
|
|
73
|
+
},
|
|
69
74
|
on: {
|
|
70
75
|
'click': () => {
|
|
71
76
|
operation(vm, currentRow);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Modal } from '@lambo-design/core'
|
|
2
|
+
|
|
3
|
+
const beforeClose = {
|
|
4
|
+
before_close_normal: (resolve) => {
|
|
5
|
+
Modal.confirm({
|
|
6
|
+
title: '确定要关闭这一页吗?',
|
|
7
|
+
onOk: () => {
|
|
8
|
+
resolve(true)
|
|
9
|
+
},
|
|
10
|
+
onCancel: () => {
|
|
11
|
+
resolve(false)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default beforeClose
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否存在路由
|
|
3
|
+
* @param $router
|
|
4
|
+
* @param name
|
|
5
|
+
* @returns {*|boolean}
|
|
6
|
+
*/
|
|
7
|
+
export const hasRoute = ($router, name) => {
|
|
8
|
+
let routes = $router.getRoutes();
|
|
9
|
+
let res = routes.filter(item => item.name === name)
|
|
10
|
+
return res && res.length > 0
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 判断是否存在路由并且页面存在
|
|
14
|
+
* @param $router
|
|
15
|
+
* @param path
|
|
16
|
+
* @returns {*|boolean}
|
|
17
|
+
*/
|
|
18
|
+
export const hasRoutePath = ($router, path) => {
|
|
19
|
+
let routes = $router.getRoutes();
|
|
20
|
+
let res = routes.filter(item => item.path === path)
|
|
21
|
+
return res && res.length > 0
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 动态生成菜单
|
|
25
|
+
* @param permissionList
|
|
26
|
+
* @returns []
|
|
27
|
+
*/
|
|
28
|
+
export const generatorMenuList = (permissionList,appId) => {
|
|
29
|
+
let menuData = [],
|
|
30
|
+
pageNode = {
|
|
31
|
+
path: "/page",
|
|
32
|
+
name: "page",
|
|
33
|
+
meta: {
|
|
34
|
+
hideInMenu: true,
|
|
35
|
+
notCache: true
|
|
36
|
+
},
|
|
37
|
+
component: "Main",
|
|
38
|
+
children: []
|
|
39
|
+
};
|
|
40
|
+
listToMenuTree(permissionList, menuData, pageNode, "0", [], true,appId);
|
|
41
|
+
|
|
42
|
+
/*if (pageNode.children.length > 0) {
|
|
43
|
+
menuData.push(pageNode);
|
|
44
|
+
}*/
|
|
45
|
+
return menuData;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 数组转树形结构
|
|
52
|
+
*/
|
|
53
|
+
const listToMenuTree = (list, menuTree, pageNode, parentId, crumbs, root, appId) => {
|
|
54
|
+
if (list == null) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
list.forEach(item => {
|
|
58
|
+
if (item.appId == appId) {
|
|
59
|
+
// 判断是否为父级菜单
|
|
60
|
+
if (item.pid === parentId) {
|
|
61
|
+
if (item.type === 1 || item.type === 2) {
|
|
62
|
+
let node = {
|
|
63
|
+
meta: {
|
|
64
|
+
appId: item.appId,
|
|
65
|
+
title: item.label,
|
|
66
|
+
icon: item.icon,
|
|
67
|
+
crumbs: [...crumbs],
|
|
68
|
+
activeName: item.name
|
|
69
|
+
},
|
|
70
|
+
type: item.type,
|
|
71
|
+
pid: item.pid,
|
|
72
|
+
component: item.name,
|
|
73
|
+
name: item.name,
|
|
74
|
+
uri: item.uri,
|
|
75
|
+
children: []
|
|
76
|
+
};
|
|
77
|
+
node.meta.crumbs.push({
|
|
78
|
+
icon: item.icon,
|
|
79
|
+
name: item.name,
|
|
80
|
+
title: item.label,
|
|
81
|
+
type: item.type
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (item.type === 1) {
|
|
85
|
+
if (root) {
|
|
86
|
+
node.component = "Main";
|
|
87
|
+
} else {
|
|
88
|
+
node.component = "parentView";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// 迭代 list, 找到当前菜单相符合的所有子菜单
|
|
92
|
+
listToMenuTree(
|
|
93
|
+
list,
|
|
94
|
+
node.children,
|
|
95
|
+
pageNode,
|
|
96
|
+
item.permissionId,
|
|
97
|
+
node.meta.crumbs,
|
|
98
|
+
false,
|
|
99
|
+
appId
|
|
100
|
+
);
|
|
101
|
+
// 删掉不存在 children 值的属性
|
|
102
|
+
if (node.children.length <= 0) {
|
|
103
|
+
delete node.children;
|
|
104
|
+
}
|
|
105
|
+
// 加入到树中
|
|
106
|
+
menuTree.push(node);
|
|
107
|
+
}
|
|
108
|
+
if (item.type === 4) {
|
|
109
|
+
let child = {
|
|
110
|
+
meta: {
|
|
111
|
+
title: item.label,
|
|
112
|
+
hideInMenu: true,
|
|
113
|
+
notCache: true,
|
|
114
|
+
crumbs: [...crumbs],
|
|
115
|
+
type: item.type
|
|
116
|
+
},
|
|
117
|
+
type: item.type,
|
|
118
|
+
pid: item.pid,
|
|
119
|
+
component: item.name,
|
|
120
|
+
name: item.name,
|
|
121
|
+
uri: item.uri
|
|
122
|
+
};
|
|
123
|
+
child.meta.crumbs.push({
|
|
124
|
+
icon: item.icon,
|
|
125
|
+
name: item.name,
|
|
126
|
+
title: item.label,
|
|
127
|
+
type: item.type
|
|
128
|
+
});
|
|
129
|
+
pageNode.children.push(child);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
export default generatorMenuList;
|
package/utils/platform.js
CHANGED
|
@@ -152,14 +152,20 @@ export const showTitle = (item, vm) => {
|
|
|
152
152
|
/**
|
|
153
153
|
* @description 本地存储和获取标签导航列表
|
|
154
154
|
*/
|
|
155
|
-
export const setTagNavListInLocalstorage = list => {
|
|
156
|
-
|
|
155
|
+
export const setTagNavListInLocalstorage = (list , key) => {
|
|
156
|
+
if (!key) {
|
|
157
|
+
key = 'LD-tagNavList';
|
|
158
|
+
}
|
|
159
|
+
localStorage[key] = JSON.stringify(list)
|
|
157
160
|
}
|
|
158
161
|
/**
|
|
159
162
|
* @returns {Array} 其中的每个元素只包含路由原信息中的name, path, meta三项
|
|
160
163
|
*/
|
|
161
|
-
export const getTagNavListFromLocalstorage = () => {
|
|
162
|
-
|
|
164
|
+
export const getTagNavListFromLocalstorage = (key) => {
|
|
165
|
+
if (!key) {
|
|
166
|
+
key = 'LD-tagNavList';
|
|
167
|
+
}
|
|
168
|
+
const list = localStorage[key]
|
|
163
169
|
return list ? JSON.parse(list) : []
|
|
164
170
|
}
|
|
165
171
|
|
|
@@ -265,7 +271,7 @@ export const getArrayFromFile = (file) => {
|
|
|
265
271
|
reader.readAsText(file) // 以文本格式读取
|
|
266
272
|
let arr = []
|
|
267
273
|
reader.onload = function (evt) {
|
|
268
|
-
let data = evt.target.
|
|
274
|
+
let data = evt.target.card // 读到的数据
|
|
269
275
|
let pasteData = data.trim()
|
|
270
276
|
arr = pasteData.split((/[\n\u0085\u2028\u2029]|\r\n?/g)).map(row => {
|
|
271
277
|
return row.split('\t')
|
|
@@ -357,7 +363,7 @@ export const routeEqual = (route1, route2) => {
|
|
|
357
363
|
const params2 = route2.params || {}
|
|
358
364
|
const query1 = route1.query || {}
|
|
359
365
|
const query2 = route2.query || {}
|
|
360
|
-
return (route1.name === route2.name)
|
|
366
|
+
return (route1.name === route2.name) && objEqual(params1, params2) && objEqual(query1, query2)
|
|
361
367
|
}
|
|
362
368
|
|
|
363
369
|
/**
|
|
@@ -517,3 +523,61 @@ export function oneOf (value, validList) {
|
|
|
517
523
|
}
|
|
518
524
|
return false
|
|
519
525
|
}
|
|
526
|
+
|
|
527
|
+
export const recursionKeyFindItem = (arr, filterKey, filterValue, recursionKey) => {
|
|
528
|
+
for (const item of arr) {
|
|
529
|
+
if (item[filterKey] && item[filterKey] == filterValue) {
|
|
530
|
+
return item;
|
|
531
|
+
}
|
|
532
|
+
let result = null;
|
|
533
|
+
if (item[recursionKey]) {
|
|
534
|
+
result = recursionKeyFindItem(item[recursionKey], filterKey, filterValue, recursionKey);
|
|
535
|
+
if (result) {
|
|
536
|
+
return result;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return null;
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
export const filterMenuName = (menuList, name) => {
|
|
544
|
+
return recursionKeyFindItem(menuList, 'name', name, 'children')
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
export const filterMenuUri = (menuList, name) => {
|
|
548
|
+
return recursionKeyFindItem(menuList, 'uri', name, 'children')
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
export const tagExists = (taglist, name) => {
|
|
552
|
+
return taglist && taglist.filter(item => item.name === name).length > 0;
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
export const getPreviousTagIndex = (tagList, name) => {
|
|
556
|
+
let count = 0;
|
|
557
|
+
if (tagList && name) {
|
|
558
|
+
for (let i = 0 ;i < tagList.length; i++) {
|
|
559
|
+
let item = tagList[i];
|
|
560
|
+
if (item.name == name) {
|
|
561
|
+
count = i - 1;
|
|
562
|
+
if (count < 0) {
|
|
563
|
+
count = 0;
|
|
564
|
+
}
|
|
565
|
+
return count;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
return count;
|
|
570
|
+
};
|
|
571
|
+
|
|
572
|
+
export const getDelTagIndex = (tagList, name) => {
|
|
573
|
+
let count = 1;
|
|
574
|
+
if (tagList && name) {
|
|
575
|
+
for (let i = 1 ;i < tagList.length; i++) {
|
|
576
|
+
let item = tagList[i];
|
|
577
|
+
if (item.name !== name) {
|
|
578
|
+
return count;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return count;
|
|
583
|
+
}
|
package/utils/theme.js
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const setParentRefs = (parentVm, targetVm, refKey) => {
|
|
2
|
+
let hasFind = false;
|
|
3
|
+
if (parentVm.$refs) {
|
|
4
|
+
//遍历父组件的refs里注册的组件
|
|
5
|
+
Object.entries(parentVm.$refs).forEach(([parentKey, parentValue]) => {
|
|
6
|
+
//找到targetVm组件
|
|
7
|
+
if (parentValue === targetVm) {
|
|
8
|
+
hasFind = true;
|
|
9
|
+
//遍历targetVm组件上注册的refKey组件
|
|
10
|
+
Object.entries(targetVm.$refs[refKey]).forEach(([key, value])=>{
|
|
11
|
+
//找到refKey组件methods里面的function
|
|
12
|
+
if(key.charAt(0) !== '$'
|
|
13
|
+
&& key.charAt(0) !== '_'
|
|
14
|
+
&& typeof value == 'function'){
|
|
15
|
+
//将function添加到targetVm组件
|
|
16
|
+
parentVm.$refs[parentKey][key] = value
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
if (!hasFind && parentVm.$parent) {
|
|
23
|
+
setParentRefs(parentVm.$parent, targetVm, refKey)
|
|
24
|
+
}
|
|
25
|
+
}
|