bl-common-vue3 3.7.20 → 3.7.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/.history/package_20230222150904.json +54 -54
- package/.history/package_20230227191203.json +54 -54
- package/.history/package_20230227193052.json +54 -54
- package/.history/package_20230308102851.json +54 -54
- package/.history/src/common/utils/util_20230210124242.js +156 -156
- package/.history/src/common/utils/util_20230228192253.js +157 -157
- package/.history/src/components/BLIcon/index_20230103102354.js +17 -17
- package/.history/src/components/BLIcon/index_20230227191108.js +18 -18
- package/.history/src/components/BLIcon/index_20230227193020.js +18 -18
- package/.history/src/components/BLIcon/index_20230227193025.js +18 -18
- package/.history/src/components/ChooseHousingResources/index_20230222193654.vue +1252 -1252
- package/.history/src/components/ChooseHousingResources/index_20230227191144.vue +1252 -1252
- package/.history/src/components/ChooseHousingResources/index_20230227193035.vue +1252 -1252
- package/.history/src/components/VillageTree/index_20230227202552.vue +298 -298
- package/.history/src/components/VillageTree/index_20230308102756.vue +305 -305
- package/.history/src/components/VillageTree/index_20230308113141.vue +305 -305
- package/.history/src/components/components_20230216190147.js +15 -15
- package/.history/src/components/components_20230227191116.js +15 -15
- package/.history/src/components/components_20230227191117.js +15 -15
- package/.history/src/components/components_20230308102833.js +16 -16
- package/.idea/components_vue3.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/lib/vue3common.common.js +21317 -34351
- package/lib/vue3common.umd.js +21317 -34351
- package/lib/vue3common.umd.min.js +41 -37
- package/package.json +1 -1
|
@@ -1,156 +1,156 @@
|
|
|
1
|
-
import { Modal, notification } from "ant-design-vue";
|
|
2
|
-
import { createVNode } from "vue";
|
|
3
|
-
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
|
|
4
|
-
|
|
5
|
-
const utils = {
|
|
6
|
-
numberReg: /^\d+(\.\d+)?$/, // 数字验证正则
|
|
7
|
-
requiredRule: [{ required: true, message: "必填项" }], // 表单验证为必填项
|
|
8
|
-
blCommonKey: "BL_COMMON_LOCAL", // 公共localstorge存储
|
|
9
|
-
BTN_PERMISSION: null, // 按钮权限集合
|
|
10
|
-
DICTIONARY: null, // 多语言字典
|
|
11
|
-
/**
|
|
12
|
-
* 表单验证为数字
|
|
13
|
-
*/
|
|
14
|
-
numberValidator: async (rules, value, message) => {
|
|
15
|
-
if (!value) {
|
|
16
|
-
if (rules.required) {
|
|
17
|
-
return Promise.reject("必填项");
|
|
18
|
-
}
|
|
19
|
-
return Promise.resolve();
|
|
20
|
-
}
|
|
21
|
-
if (!utils.numberReg.test(value)) {
|
|
22
|
-
return Promise.reject(message || "请输入数字");
|
|
23
|
-
}
|
|
24
|
-
return Promise.resolve();
|
|
25
|
-
},
|
|
26
|
-
/**
|
|
27
|
-
* 获取路由参数
|
|
28
|
-
*/
|
|
29
|
-
getQueryObj: (queryString) => {
|
|
30
|
-
let queryParams = {};
|
|
31
|
-
if (!queryString) {
|
|
32
|
-
let query = location.href.split("?");
|
|
33
|
-
if (query && query[1]) {
|
|
34
|
-
queryString = query[1];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (queryString) {
|
|
38
|
-
let queryArr = queryString.split("&");
|
|
39
|
-
for (let item of queryArr) {
|
|
40
|
-
const res = item.split("=");
|
|
41
|
-
queryParams[res[0]] = res[1];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return queryParams;
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* 是否是手机端
|
|
48
|
-
*/
|
|
49
|
-
isMobile: () => {
|
|
50
|
-
const query = utils.getQueryObj();
|
|
51
|
-
if (query.from == "mobile") {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return navigator.userAgent.match(
|
|
55
|
-
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
56
|
-
);
|
|
57
|
-
},
|
|
58
|
-
/**
|
|
59
|
-
* 存取公共存储参数
|
|
60
|
-
*/
|
|
61
|
-
setCommonLocal: (key, value) => {
|
|
62
|
-
let localData = localStorage.getItem(utils.blCommonKey);
|
|
63
|
-
if (localData) {
|
|
64
|
-
localData = JSON.parse(localData);
|
|
65
|
-
} else {
|
|
66
|
-
localData = {};
|
|
67
|
-
}
|
|
68
|
-
localData[key] = value;
|
|
69
|
-
localStorage.setItem(utils.blCommonKey, JSON.stringify(localData));
|
|
70
|
-
},
|
|
71
|
-
getCommonLocal: (key) => {
|
|
72
|
-
let localData = localStorage.getItem(utils.blCommonKey);
|
|
73
|
-
if (localData) {
|
|
74
|
-
localData = JSON.parse(localData);
|
|
75
|
-
}
|
|
76
|
-
return key && localData ? localData[key] : null;
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* 多语言转化
|
|
80
|
-
* vars 替换变量
|
|
81
|
-
*/
|
|
82
|
-
L: (key = "", vars = {}) => {
|
|
83
|
-
let dictionary = utils.DICTIONARY;
|
|
84
|
-
if (!dictionary || !Object.keys(dictionary).length) {
|
|
85
|
-
dictionary = utils.DICTIONARY = utils.getCommonLocal("DICTIONARY");
|
|
86
|
-
}
|
|
87
|
-
let result = dictionary && dictionary[key] ? dictionary[key] : key;
|
|
88
|
-
if (Object.keys(vars).length) {
|
|
89
|
-
for (let v in vars) {
|
|
90
|
-
result.replace(v, vars[v]);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
},
|
|
95
|
-
/**
|
|
96
|
-
* 存储多语言字典
|
|
97
|
-
*/
|
|
98
|
-
setDictionary: (dictionary) => {
|
|
99
|
-
utils.setCommonLocal("DICTIONARY", dictionary);
|
|
100
|
-
utils.DICTIONARY = dictionary;
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* 设置按钮权限
|
|
104
|
-
*/
|
|
105
|
-
setSystemBtnPermission: (permission) => {
|
|
106
|
-
utils.setCommonLocal("BTN_PERMISSION", permission);
|
|
107
|
-
utils.BTN_PERMISSION = permission;
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* 获取按钮权限
|
|
111
|
-
* action= [alias, actionKey, action]
|
|
112
|
-
* alias 权限路由alias
|
|
113
|
-
* actionKey 所属权限key
|
|
114
|
-
* action 权限字段
|
|
115
|
-
*/
|
|
116
|
-
getBtnPermission: (action) => {
|
|
117
|
-
if (!action || !Array.isArray(action) || action.length < 3) {
|
|
118
|
-
notification.error({
|
|
119
|
-
message: "错误",
|
|
120
|
-
description: "v-action格式错误",
|
|
121
|
-
});
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
if (!utils.BTN_PERMISSION || !Object.keys(utils.BTN_PERMISSION).length) {
|
|
125
|
-
utils.BTN_PERMISSION = utils.getCommonLocal("BTN_PERMISSION");
|
|
126
|
-
}
|
|
127
|
-
let permisson = utils.BTN_PERMISSION;
|
|
128
|
-
if (
|
|
129
|
-
permisson &&
|
|
130
|
-
permisson[action[0]] &&
|
|
131
|
-
permisson[action[0]][action[1]] &&
|
|
132
|
-
permisson[action[0]][action[1]].includes(action[2])
|
|
133
|
-
) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
},
|
|
138
|
-
/**
|
|
139
|
-
* 删除确认框
|
|
140
|
-
*/
|
|
141
|
-
delConfirm: (params = {}) => {
|
|
142
|
-
Modal.confirm({
|
|
143
|
-
title: () => params.title || "提示",
|
|
144
|
-
content: () => params.content || "确认删除本条目?",
|
|
145
|
-
centered: true,
|
|
146
|
-
okText: params.okText || "确定",
|
|
147
|
-
cancelText: params.cancelText || "取消",
|
|
148
|
-
icon: () => createVNode(ExclamationCircleOutlined),
|
|
149
|
-
onOk: () => {
|
|
150
|
-
params.onOk && params.onOk();
|
|
151
|
-
},
|
|
152
|
-
});
|
|
153
|
-
},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export default utils;
|
|
1
|
+
import { Modal, notification } from "ant-design-vue";
|
|
2
|
+
import { createVNode } from "vue";
|
|
3
|
+
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
|
|
4
|
+
|
|
5
|
+
const utils = {
|
|
6
|
+
numberReg: /^\d+(\.\d+)?$/, // 数字验证正则
|
|
7
|
+
requiredRule: [{ required: true, message: "必填项" }], // 表单验证为必填项
|
|
8
|
+
blCommonKey: "BL_COMMON_LOCAL", // 公共localstorge存储
|
|
9
|
+
BTN_PERMISSION: null, // 按钮权限集合
|
|
10
|
+
DICTIONARY: null, // 多语言字典
|
|
11
|
+
/**
|
|
12
|
+
* 表单验证为数字
|
|
13
|
+
*/
|
|
14
|
+
numberValidator: async (rules, value, message) => {
|
|
15
|
+
if (!value) {
|
|
16
|
+
if (rules.required) {
|
|
17
|
+
return Promise.reject("必填项");
|
|
18
|
+
}
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
if (!utils.numberReg.test(value)) {
|
|
22
|
+
return Promise.reject(message || "请输入数字");
|
|
23
|
+
}
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* 获取路由参数
|
|
28
|
+
*/
|
|
29
|
+
getQueryObj: (queryString) => {
|
|
30
|
+
let queryParams = {};
|
|
31
|
+
if (!queryString) {
|
|
32
|
+
let query = location.href.split("?");
|
|
33
|
+
if (query && query[1]) {
|
|
34
|
+
queryString = query[1];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (queryString) {
|
|
38
|
+
let queryArr = queryString.split("&");
|
|
39
|
+
for (let item of queryArr) {
|
|
40
|
+
const res = item.split("=");
|
|
41
|
+
queryParams[res[0]] = res[1];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return queryParams;
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* 是否是手机端
|
|
48
|
+
*/
|
|
49
|
+
isMobile: () => {
|
|
50
|
+
const query = utils.getQueryObj();
|
|
51
|
+
if (query.from == "mobile") {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return navigator.userAgent.match(
|
|
55
|
+
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* 存取公共存储参数
|
|
60
|
+
*/
|
|
61
|
+
setCommonLocal: (key, value) => {
|
|
62
|
+
let localData = localStorage.getItem(utils.blCommonKey);
|
|
63
|
+
if (localData) {
|
|
64
|
+
localData = JSON.parse(localData);
|
|
65
|
+
} else {
|
|
66
|
+
localData = {};
|
|
67
|
+
}
|
|
68
|
+
localData[key] = value;
|
|
69
|
+
localStorage.setItem(utils.blCommonKey, JSON.stringify(localData));
|
|
70
|
+
},
|
|
71
|
+
getCommonLocal: (key) => {
|
|
72
|
+
let localData = localStorage.getItem(utils.blCommonKey);
|
|
73
|
+
if (localData) {
|
|
74
|
+
localData = JSON.parse(localData);
|
|
75
|
+
}
|
|
76
|
+
return key && localData ? localData[key] : null;
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* 多语言转化
|
|
80
|
+
* vars 替换变量
|
|
81
|
+
*/
|
|
82
|
+
L: (key = "", vars = {}) => {
|
|
83
|
+
let dictionary = utils.DICTIONARY;
|
|
84
|
+
if (!dictionary || !Object.keys(dictionary).length) {
|
|
85
|
+
dictionary = utils.DICTIONARY = utils.getCommonLocal("DICTIONARY");
|
|
86
|
+
}
|
|
87
|
+
let result = dictionary && dictionary[key] ? dictionary[key] : key;
|
|
88
|
+
if (Object.keys(vars).length) {
|
|
89
|
+
for (let v in vars) {
|
|
90
|
+
result.replace(v, vars[v]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* 存储多语言字典
|
|
97
|
+
*/
|
|
98
|
+
setDictionary: (dictionary) => {
|
|
99
|
+
utils.setCommonLocal("DICTIONARY", dictionary);
|
|
100
|
+
utils.DICTIONARY = dictionary;
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* 设置按钮权限
|
|
104
|
+
*/
|
|
105
|
+
setSystemBtnPermission: (permission) => {
|
|
106
|
+
utils.setCommonLocal("BTN_PERMISSION", permission);
|
|
107
|
+
utils.BTN_PERMISSION = permission;
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* 获取按钮权限
|
|
111
|
+
* action= [alias, actionKey, action]
|
|
112
|
+
* alias 权限路由alias
|
|
113
|
+
* actionKey 所属权限key
|
|
114
|
+
* action 权限字段
|
|
115
|
+
*/
|
|
116
|
+
getBtnPermission: (action) => {
|
|
117
|
+
if (!action || !Array.isArray(action) || action.length < 3) {
|
|
118
|
+
notification.error({
|
|
119
|
+
message: "错误",
|
|
120
|
+
description: "v-action格式错误",
|
|
121
|
+
});
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (!utils.BTN_PERMISSION || !Object.keys(utils.BTN_PERMISSION).length) {
|
|
125
|
+
utils.BTN_PERMISSION = utils.getCommonLocal("BTN_PERMISSION");
|
|
126
|
+
}
|
|
127
|
+
let permisson = utils.BTN_PERMISSION;
|
|
128
|
+
if (
|
|
129
|
+
permisson &&
|
|
130
|
+
permisson[action[0]] &&
|
|
131
|
+
permisson[action[0]][action[1]] &&
|
|
132
|
+
permisson[action[0]][action[1]].includes(action[2])
|
|
133
|
+
) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* 删除确认框
|
|
140
|
+
*/
|
|
141
|
+
delConfirm: (params = {}) => {
|
|
142
|
+
Modal.confirm({
|
|
143
|
+
title: () => params.title || "提示",
|
|
144
|
+
content: () => params.content || "确认删除本条目?",
|
|
145
|
+
centered: true,
|
|
146
|
+
okText: params.okText || "确定",
|
|
147
|
+
cancelText: params.cancelText || "取消",
|
|
148
|
+
icon: () => createVNode(ExclamationCircleOutlined),
|
|
149
|
+
onOk: () => {
|
|
150
|
+
params.onOk && params.onOk();
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export default utils;
|
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
import { Modal, notification } from "ant-design-vue";
|
|
2
|
-
import { createVNode } from "vue";
|
|
3
|
-
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
|
|
4
|
-
|
|
5
|
-
const utils = {
|
|
6
|
-
numberReg: /^\d+(\.\d+)?$/, // 数字验证正则
|
|
7
|
-
requiredRule: [{ required: true, message: "必填项" }], // 表单验证为必填项
|
|
8
|
-
blCommonKey: "BL_COMMON_LOCAL", // 公共localstorge存储
|
|
9
|
-
BTN_PERMISSION: null, // 按钮权限集合
|
|
10
|
-
DICTIONARY: null, // 多语言字典
|
|
11
|
-
/**
|
|
12
|
-
* 表单验证为数字
|
|
13
|
-
*/
|
|
14
|
-
numberValidator: async (rules, value, message) => {
|
|
15
|
-
if (!value) {
|
|
16
|
-
if (rules.required) {
|
|
17
|
-
return Promise.reject("必填项");
|
|
18
|
-
}
|
|
19
|
-
return Promise.resolve();
|
|
20
|
-
}
|
|
21
|
-
if (!utils.numberReg.test(value)) {
|
|
22
|
-
return Promise.reject(message || "请输入数字");
|
|
23
|
-
}
|
|
24
|
-
return Promise.resolve();
|
|
25
|
-
},
|
|
26
|
-
/**
|
|
27
|
-
* 获取路由参数
|
|
28
|
-
*/
|
|
29
|
-
getQueryObj: (queryString) => {
|
|
30
|
-
let queryParams = {};
|
|
31
|
-
if (!queryString) {
|
|
32
|
-
let query = location.href.split("?");
|
|
33
|
-
if (query && query[1]) {
|
|
34
|
-
queryString = query[1];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (queryString) {
|
|
38
|
-
let queryArr = queryString.split("&");
|
|
39
|
-
for (let item of queryArr) {
|
|
40
|
-
const res = item.split("=");
|
|
41
|
-
queryParams[res[0]] = res[1];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return queryParams;
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* 是否是手机端
|
|
48
|
-
*/
|
|
49
|
-
isMobile: () => {
|
|
50
|
-
const query = utils.getQueryObj();
|
|
51
|
-
if (query.from == "mobile") {
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return navigator.userAgent.match(
|
|
55
|
-
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
56
|
-
);
|
|
57
|
-
},
|
|
58
|
-
/**
|
|
59
|
-
* 存取公共存储参数
|
|
60
|
-
*/
|
|
61
|
-
setCommonLocal: (key, value) => {
|
|
62
|
-
let localData = localStorage.getItem(utils.blCommonKey);
|
|
63
|
-
if (localData) {
|
|
64
|
-
localData = JSON.parse(localData);
|
|
65
|
-
} else {
|
|
66
|
-
localData = {};
|
|
67
|
-
}
|
|
68
|
-
localData[key] = value;
|
|
69
|
-
localStorage.setItem(utils.blCommonKey, JSON.stringify(localData));
|
|
70
|
-
},
|
|
71
|
-
getCommonLocal: (key) => {
|
|
72
|
-
let localData = localStorage.getItem(utils.blCommonKey);
|
|
73
|
-
if (localData) {
|
|
74
|
-
localData = JSON.parse(localData);
|
|
75
|
-
}
|
|
76
|
-
return key && localData ? localData[key] : null;
|
|
77
|
-
},
|
|
78
|
-
/**
|
|
79
|
-
* 多语言转化
|
|
80
|
-
* vars 替换变量
|
|
81
|
-
*/
|
|
82
|
-
L: (key = "", vars = {}) => {
|
|
83
|
-
let dictionary = utils.DICTIONARY;
|
|
84
|
-
if (!dictionary || !Object.keys(dictionary).length) {
|
|
85
|
-
dictionary = utils.DICTIONARY = utils.getCommonLocal("DICTIONARY");
|
|
86
|
-
}
|
|
87
|
-
let result = dictionary && dictionary[key] ? dictionary[key] : key;
|
|
88
|
-
if (Object.keys(vars).length) {
|
|
89
|
-
for (let v in vars) {
|
|
90
|
-
result.replace(v, vars[v]);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
},
|
|
95
|
-
/**
|
|
96
|
-
* 存储多语言字典
|
|
97
|
-
*/
|
|
98
|
-
setDictionary: (dictionary) => {
|
|
99
|
-
utils.setCommonLocal("DICTIONARY", dictionary);
|
|
100
|
-
utils.DICTIONARY = dictionary;
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* 设置按钮权限
|
|
104
|
-
*/
|
|
105
|
-
setSystemBtnPermission: (permission) => {
|
|
106
|
-
utils.setCommonLocal("BTN_PERMISSION", permission);
|
|
107
|
-
utils.BTN_PERMISSION = permission;
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* 获取按钮权限
|
|
111
|
-
* action= [alias, actionKey, action]
|
|
112
|
-
* alias 权限路由alias
|
|
113
|
-
* actionKey 所属权限key
|
|
114
|
-
* action 权限字段
|
|
115
|
-
*/
|
|
116
|
-
getBtnPermission: (action) => {
|
|
117
|
-
if (!action || !Array.isArray(action) || action.length < 3) {
|
|
118
|
-
notification.error({
|
|
119
|
-
message: "错误",
|
|
120
|
-
description: "v-action格式错误",
|
|
121
|
-
});
|
|
122
|
-
return true;
|
|
123
|
-
}
|
|
124
|
-
if (!utils.BTN_PERMISSION || !Object.keys(utils.BTN_PERMISSION).length) {
|
|
125
|
-
utils.BTN_PERMISSION = utils.getCommonLocal("BTN_PERMISSION");
|
|
126
|
-
}
|
|
127
|
-
let permisson = utils.BTN_PERMISSION;
|
|
128
|
-
if (
|
|
129
|
-
permisson &&
|
|
130
|
-
permisson[action[0]] &&
|
|
131
|
-
permisson[action[0]][action[1]] &&
|
|
132
|
-
permisson[action[0]][action[1]].includes(action[2])
|
|
133
|
-
) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
},
|
|
138
|
-
/**
|
|
139
|
-
* 删除确认框
|
|
140
|
-
*/
|
|
141
|
-
delConfirm: (params = {}) => {
|
|
142
|
-
Modal.confirm({
|
|
143
|
-
title: () => params.title || "提示",
|
|
144
|
-
content: () => params.content || "确认删除本条目?",
|
|
145
|
-
centered: true,
|
|
146
|
-
okType: params.okType || "danger",
|
|
147
|
-
okText: params.okText || "确定",
|
|
148
|
-
cancelText: params.cancelText || "取消",
|
|
149
|
-
icon: () => createVNode(ExclamationCircleOutlined),
|
|
150
|
-
onOk: () => {
|
|
151
|
-
params.onOk && params.onOk();
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
export default utils;
|
|
1
|
+
import { Modal, notification } from "ant-design-vue";
|
|
2
|
+
import { createVNode } from "vue";
|
|
3
|
+
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
|
|
4
|
+
|
|
5
|
+
const utils = {
|
|
6
|
+
numberReg: /^\d+(\.\d+)?$/, // 数字验证正则
|
|
7
|
+
requiredRule: [{ required: true, message: "必填项" }], // 表单验证为必填项
|
|
8
|
+
blCommonKey: "BL_COMMON_LOCAL", // 公共localstorge存储
|
|
9
|
+
BTN_PERMISSION: null, // 按钮权限集合
|
|
10
|
+
DICTIONARY: null, // 多语言字典
|
|
11
|
+
/**
|
|
12
|
+
* 表单验证为数字
|
|
13
|
+
*/
|
|
14
|
+
numberValidator: async (rules, value, message) => {
|
|
15
|
+
if (!value) {
|
|
16
|
+
if (rules.required) {
|
|
17
|
+
return Promise.reject("必填项");
|
|
18
|
+
}
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
}
|
|
21
|
+
if (!utils.numberReg.test(value)) {
|
|
22
|
+
return Promise.reject(message || "请输入数字");
|
|
23
|
+
}
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* 获取路由参数
|
|
28
|
+
*/
|
|
29
|
+
getQueryObj: (queryString) => {
|
|
30
|
+
let queryParams = {};
|
|
31
|
+
if (!queryString) {
|
|
32
|
+
let query = location.href.split("?");
|
|
33
|
+
if (query && query[1]) {
|
|
34
|
+
queryString = query[1];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (queryString) {
|
|
38
|
+
let queryArr = queryString.split("&");
|
|
39
|
+
for (let item of queryArr) {
|
|
40
|
+
const res = item.split("=");
|
|
41
|
+
queryParams[res[0]] = res[1];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return queryParams;
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* 是否是手机端
|
|
48
|
+
*/
|
|
49
|
+
isMobile: () => {
|
|
50
|
+
const query = utils.getQueryObj();
|
|
51
|
+
if (query.from == "mobile") {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return navigator.userAgent.match(
|
|
55
|
+
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* 存取公共存储参数
|
|
60
|
+
*/
|
|
61
|
+
setCommonLocal: (key, value) => {
|
|
62
|
+
let localData = localStorage.getItem(utils.blCommonKey);
|
|
63
|
+
if (localData) {
|
|
64
|
+
localData = JSON.parse(localData);
|
|
65
|
+
} else {
|
|
66
|
+
localData = {};
|
|
67
|
+
}
|
|
68
|
+
localData[key] = value;
|
|
69
|
+
localStorage.setItem(utils.blCommonKey, JSON.stringify(localData));
|
|
70
|
+
},
|
|
71
|
+
getCommonLocal: (key) => {
|
|
72
|
+
let localData = localStorage.getItem(utils.blCommonKey);
|
|
73
|
+
if (localData) {
|
|
74
|
+
localData = JSON.parse(localData);
|
|
75
|
+
}
|
|
76
|
+
return key && localData ? localData[key] : null;
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* 多语言转化
|
|
80
|
+
* vars 替换变量
|
|
81
|
+
*/
|
|
82
|
+
L: (key = "", vars = {}) => {
|
|
83
|
+
let dictionary = utils.DICTIONARY;
|
|
84
|
+
if (!dictionary || !Object.keys(dictionary).length) {
|
|
85
|
+
dictionary = utils.DICTIONARY = utils.getCommonLocal("DICTIONARY");
|
|
86
|
+
}
|
|
87
|
+
let result = dictionary && dictionary[key] ? dictionary[key] : key;
|
|
88
|
+
if (Object.keys(vars).length) {
|
|
89
|
+
for (let v in vars) {
|
|
90
|
+
result.replace(v, vars[v]);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* 存储多语言字典
|
|
97
|
+
*/
|
|
98
|
+
setDictionary: (dictionary) => {
|
|
99
|
+
utils.setCommonLocal("DICTIONARY", dictionary);
|
|
100
|
+
utils.DICTIONARY = dictionary;
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* 设置按钮权限
|
|
104
|
+
*/
|
|
105
|
+
setSystemBtnPermission: (permission) => {
|
|
106
|
+
utils.setCommonLocal("BTN_PERMISSION", permission);
|
|
107
|
+
utils.BTN_PERMISSION = permission;
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* 获取按钮权限
|
|
111
|
+
* action= [alias, actionKey, action]
|
|
112
|
+
* alias 权限路由alias
|
|
113
|
+
* actionKey 所属权限key
|
|
114
|
+
* action 权限字段
|
|
115
|
+
*/
|
|
116
|
+
getBtnPermission: (action) => {
|
|
117
|
+
if (!action || !Array.isArray(action) || action.length < 3) {
|
|
118
|
+
notification.error({
|
|
119
|
+
message: "错误",
|
|
120
|
+
description: "v-action格式错误",
|
|
121
|
+
});
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
if (!utils.BTN_PERMISSION || !Object.keys(utils.BTN_PERMISSION).length) {
|
|
125
|
+
utils.BTN_PERMISSION = utils.getCommonLocal("BTN_PERMISSION");
|
|
126
|
+
}
|
|
127
|
+
let permisson = utils.BTN_PERMISSION;
|
|
128
|
+
if (
|
|
129
|
+
permisson &&
|
|
130
|
+
permisson[action[0]] &&
|
|
131
|
+
permisson[action[0]][action[1]] &&
|
|
132
|
+
permisson[action[0]][action[1]].includes(action[2])
|
|
133
|
+
) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* 删除确认框
|
|
140
|
+
*/
|
|
141
|
+
delConfirm: (params = {}) => {
|
|
142
|
+
Modal.confirm({
|
|
143
|
+
title: () => params.title || "提示",
|
|
144
|
+
content: () => params.content || "确认删除本条目?",
|
|
145
|
+
centered: true,
|
|
146
|
+
okType: params.okType || "danger",
|
|
147
|
+
okText: params.okText || "确定",
|
|
148
|
+
cancelText: params.cancelText || "取消",
|
|
149
|
+
icon: () => createVNode(ExclamationCircleOutlined),
|
|
150
|
+
onOk: () => {
|
|
151
|
+
params.onOk && params.onOk();
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export default utils;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { createFromIconfontCN } from "@ant-design/icons-vue";
|
|
2
|
-
import { defineComponent } from "vue";
|
|
3
|
-
const BLIcon = createFromIconfontCN({
|
|
4
|
-
scriptUrl: "https://at.alicdn.com/t/c/font_3830450_qycn1dphw6e.js", // 在 iconfont.cn 上生成
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
export default defineComponent({
|
|
8
|
-
props: {
|
|
9
|
-
type: {
|
|
10
|
-
type: String,
|
|
11
|
-
default: "",
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
setup(props) {
|
|
15
|
-
return () => <BLIcon type={`bl-${props.type}`} />;
|
|
16
|
-
},
|
|
17
|
-
});
|
|
1
|
+
import { createFromIconfontCN } from "@ant-design/icons-vue";
|
|
2
|
+
import { defineComponent } from "vue";
|
|
3
|
+
const BLIcon = createFromIconfontCN({
|
|
4
|
+
scriptUrl: "https://at.alicdn.com/t/c/font_3830450_qycn1dphw6e.js", // 在 iconfont.cn 上生成
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export default defineComponent({
|
|
8
|
+
props: {
|
|
9
|
+
type: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: "",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
setup(props) {
|
|
15
|
+
return () => <BLIcon type={`bl-${props.type}`} />;
|
|
16
|
+
},
|
|
17
|
+
});
|