af-mobile-client-vue3 1.4.47 → 1.4.49
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/package.json +7 -4
- package/public/favicon.svg +4 -4
- package/scripts/verifyCommit.js +19 -19
- package/src/assets/img/component/liuli.png +0 -0
- package/src/components/common/otherCharge/ChargePrintSelectorAndRemarks.vue +137 -137
- package/src/components/common/otherCharge/CodePayment.vue +357 -357
- package/src/components/common/otherCharge/FileUploader.vue +602 -602
- package/src/components/common/otherCharge/GridFileUploader.vue +846 -846
- package/src/components/common/otherCharge/PaymentMethodSelector.vue +202 -202
- package/src/components/common/otherCharge/PaymentMethodSelectorCard.vue +45 -45
- package/src/components/common/otherCharge/ReceiptModal.vue +273 -273
- package/src/components/common/otherCharge/index.ts +43 -43
- package/src/components/data/OtherCharge/OtherChargeItemModal.vue +547 -547
- package/src/components/data/UserDetail/types.ts +1 -1
- package/src/components/data/XReportGrid/XAddReport/index.ts +1 -1
- package/src/components/data/XReportGrid/XReportDrawer/index.ts +1 -1
- package/src/components/data/XTag/index.vue +10 -10
- package/src/components/layout/TabBarLayout/index.vue +40 -40
- package/src/hooks/useCommon.ts +9 -9
- package/src/main.ts +1 -2
- package/src/plugins/AppData.ts +38 -38
- package/src/router/invoiceRoutes.ts +33 -33
- package/src/router/routes.ts +433 -427
- package/src/services/api/common.ts +109 -109
- package/src/services/api/manage.ts +8 -8
- package/src/services/api/search.ts +16 -16
- package/src/services/restTools.ts +56 -56
- package/src/utils/authority-utils.ts +84 -84
- package/src/utils/crypto.ts +39 -39
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/utils/runEvalFunction.ts +13 -13
- package/src/utils/wechat.ts +4 -4
- package/src/views/component/EvaluateRecordView/index.vue +40 -40
- package/src/views/component/MateChat/MateChatView.vue +258 -0
- package/src/views/component/MateChat/apiService.ts +104 -0
- package/src/views/component/XCellDetailView/index.vue +217 -217
- package/src/views/component/XCellListView/index.vue +107 -138
- package/src/views/component/XFormGroupView/index.vue +78 -82
- package/src/views/component/XFormView/index.vue +41 -46
- package/src/views/component/XReportFormIframeView/index.vue +47 -47
- package/src/views/component/XReportFormView/index.vue +13 -13
- package/src/views/component/XSignatureView/index.vue +50 -50
- package/src/views/component/index.vue +4 -0
- package/src/views/component/notice.vue +46 -46
- package/src/views/component/topNav.vue +36 -36
- package/src/views/invoiceShow/index.vue +61 -61
- package/src/views/user/login/index.vue +22 -22
- package/vite.config.ts +6 -0
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { del, post, postWithConfig } from '@af-mobile-client-vue3/services/restTools'
|
|
2
|
-
import { indexedDB } from '@af-mobile-client-vue3/utils/indexedDB'
|
|
3
|
-
|
|
4
|
-
const commonApi = {
|
|
5
|
-
// 获取配置
|
|
6
|
-
getConfig: 'logic/openapi/getLiuliConfiguration',
|
|
7
|
-
// 通用查询
|
|
8
|
-
query: 'logic/commonQuery',
|
|
9
|
-
// 编辑前查询
|
|
10
|
-
queryWithResource: 'logic/commonQueryWithResource',
|
|
11
|
-
// 通用新增/修改
|
|
12
|
-
addOrModify: 'logic/commonAddOrModify',
|
|
13
|
-
// 通用删除
|
|
14
|
-
delete: 'logic/commonDelete',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 根据配置名获取配置内容
|
|
19
|
-
* @param configName 配置名称
|
|
20
|
-
* @param callback 回调函数
|
|
21
|
-
*/
|
|
22
|
-
export function getConfigByName(configName: string, callback: Function): void
|
|
23
|
-
export function getConfigByName(configName: string, callback: Function, serviceName: string): void
|
|
24
|
-
/**
|
|
25
|
-
* 根据配置名获取配置内容
|
|
26
|
-
* @param configName 配置名称
|
|
27
|
-
* @param callback 回调函数
|
|
28
|
-
* @param serviceName 服务名
|
|
29
|
-
*/
|
|
30
|
-
export function getConfigByName(configName: string, callback: Function, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME): void {
|
|
31
|
-
indexedDB.getByWeb(configName, `/${serviceName}/${commonApi.getConfig}`, { configName }, callback, null)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export async function getConfigByNameAsync(configName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME): Promise<any> {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
indexedDB.getByWeb(configName, `/${serviceName}/${commonApi.getConfig}`, { configName }, resolve, null)
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 临时使用
|
|
42
|
-
* 获取琉璃配置,不走indexedDB缓存
|
|
43
|
-
* @param configName
|
|
44
|
-
* @param serviceName
|
|
45
|
-
*/
|
|
46
|
-
export function getConfigByNameWithoutIndexedDB(configName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
47
|
-
return post(`/${serviceName}/${commonApi.getConfig}`, { configName })
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 通用执行业务逻辑
|
|
52
|
-
*/
|
|
53
|
-
export function runLogic<T>(logicName: string, parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME): Promise<T> {
|
|
54
|
-
return post<T>(`/${serviceName}/logic/${logicName}`, parameter)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 通用查询
|
|
59
|
-
*/
|
|
60
|
-
export function query(parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
61
|
-
return post(`/${serviceName}/${commonApi.query}`, parameter)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* 编辑前查询
|
|
66
|
-
*/
|
|
67
|
-
export function queryWithResource(parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
68
|
-
return post(`/${serviceName}/${commonApi.queryWithResource}`, parameter)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 通用新增/修改
|
|
73
|
-
*/
|
|
74
|
-
export function addOrModify(parameter: object, tableName = 't_files', serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
75
|
-
return post(`/${serviceName}/entity/${tableName}`, parameter)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 通用新增/修改
|
|
80
|
-
*/
|
|
81
|
-
export function addOrModifyEntity(parameter: object, tableName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
82
|
-
return post(`/${serviceName}/entity/save/${tableName}`, parameter)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* 通用删除
|
|
87
|
-
*/
|
|
88
|
-
export function remove(parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
89
|
-
return post(`/${serviceName}/${commonApi.delete}`, parameter)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @description: 上传
|
|
94
|
-
*/
|
|
95
|
-
export function upload(parameter, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME, config) {
|
|
96
|
-
return postWithConfig(`/${serviceName}/resource/upload`, parameter, config)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @description: 删除
|
|
101
|
-
*/
|
|
102
|
-
export function deleteFile(data, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
103
|
-
return del(`/${serviceName}/entity/t_files`, data)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function openApiLogic(parameter, logicName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
107
|
-
return post(`/${serviceName}/logic/openapi/${logicName}`, parameter)
|
|
108
|
-
}
|
|
109
|
-
export { commonApi }
|
|
1
|
+
import { del, post, postWithConfig } from '@af-mobile-client-vue3/services/restTools'
|
|
2
|
+
import { indexedDB } from '@af-mobile-client-vue3/utils/indexedDB'
|
|
3
|
+
|
|
4
|
+
const commonApi = {
|
|
5
|
+
// 获取配置
|
|
6
|
+
getConfig: 'logic/openapi/getLiuliConfiguration',
|
|
7
|
+
// 通用查询
|
|
8
|
+
query: 'logic/commonQuery',
|
|
9
|
+
// 编辑前查询
|
|
10
|
+
queryWithResource: 'logic/commonQueryWithResource',
|
|
11
|
+
// 通用新增/修改
|
|
12
|
+
addOrModify: 'logic/commonAddOrModify',
|
|
13
|
+
// 通用删除
|
|
14
|
+
delete: 'logic/commonDelete',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 根据配置名获取配置内容
|
|
19
|
+
* @param configName 配置名称
|
|
20
|
+
* @param callback 回调函数
|
|
21
|
+
*/
|
|
22
|
+
export function getConfigByName(configName: string, callback: Function): void
|
|
23
|
+
export function getConfigByName(configName: string, callback: Function, serviceName: string): void
|
|
24
|
+
/**
|
|
25
|
+
* 根据配置名获取配置内容
|
|
26
|
+
* @param configName 配置名称
|
|
27
|
+
* @param callback 回调函数
|
|
28
|
+
* @param serviceName 服务名
|
|
29
|
+
*/
|
|
30
|
+
export function getConfigByName(configName: string, callback: Function, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME): void {
|
|
31
|
+
indexedDB.getByWeb(configName, `/${serviceName}/${commonApi.getConfig}`, { configName }, callback, null)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function getConfigByNameAsync(configName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME): Promise<any> {
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
indexedDB.getByWeb(configName, `/${serviceName}/${commonApi.getConfig}`, { configName }, resolve, null)
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 临时使用
|
|
42
|
+
* 获取琉璃配置,不走indexedDB缓存
|
|
43
|
+
* @param configName
|
|
44
|
+
* @param serviceName
|
|
45
|
+
*/
|
|
46
|
+
export function getConfigByNameWithoutIndexedDB(configName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
47
|
+
return post(`/${serviceName}/${commonApi.getConfig}`, { configName })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 通用执行业务逻辑
|
|
52
|
+
*/
|
|
53
|
+
export function runLogic<T>(logicName: string, parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME): Promise<T> {
|
|
54
|
+
return post<T>(`/${serviceName}/logic/${logicName}`, parameter)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 通用查询
|
|
59
|
+
*/
|
|
60
|
+
export function query(parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
61
|
+
return post(`/${serviceName}/${commonApi.query}`, parameter)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 编辑前查询
|
|
66
|
+
*/
|
|
67
|
+
export function queryWithResource(parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
68
|
+
return post(`/${serviceName}/${commonApi.queryWithResource}`, parameter)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 通用新增/修改
|
|
73
|
+
*/
|
|
74
|
+
export function addOrModify(parameter: object, tableName = 't_files', serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
75
|
+
return post(`/${serviceName}/entity/${tableName}`, parameter)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 通用新增/修改
|
|
80
|
+
*/
|
|
81
|
+
export function addOrModifyEntity(parameter: object, tableName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
82
|
+
return post(`/${serviceName}/entity/save/${tableName}`, parameter)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 通用删除
|
|
87
|
+
*/
|
|
88
|
+
export function remove(parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
89
|
+
return post(`/${serviceName}/${commonApi.delete}`, parameter)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @description: 上传
|
|
94
|
+
*/
|
|
95
|
+
export function upload(parameter, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME, config) {
|
|
96
|
+
return postWithConfig(`/${serviceName}/resource/upload`, parameter, config)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @description: 删除
|
|
101
|
+
*/
|
|
102
|
+
export function deleteFile(data, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
103
|
+
return del(`/${serviceName}/entity/t_files`, data)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function openApiLogic(parameter, logicName: string, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
107
|
+
return post(`/${serviceName}/logic/openapi/${logicName}`, parameter)
|
|
108
|
+
}
|
|
109
|
+
export { commonApi }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const manageApi = {
|
|
2
|
-
// 查询:获取省市区街道三级分类
|
|
3
|
-
getDivisionsOhChina: '/af-system/logic/getDivisionsOhChina',
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export {
|
|
7
|
-
manageApi,
|
|
8
|
-
}
|
|
1
|
+
const manageApi = {
|
|
2
|
+
// 查询:获取省市区街道三级分类
|
|
3
|
+
getDivisionsOhChina: '/af-system/logic/getDivisionsOhChina',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
manageApi,
|
|
8
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { post } from '@af-mobile-client-vue3/services/restTools'
|
|
2
|
-
|
|
3
|
-
export async function getUserPermissions(userid: string) {
|
|
4
|
-
interface permissions {
|
|
5
|
-
name: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const res = await post<permissions[]>(`/af-system/search`, {
|
|
9
|
-
source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($功能权限$) != -1)',
|
|
10
|
-
userid,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
return res.map((row) => {
|
|
14
|
-
return row.name
|
|
15
|
-
})
|
|
16
|
-
}
|
|
1
|
+
import { post } from '@af-mobile-client-vue3/services/restTools'
|
|
2
|
+
|
|
3
|
+
export async function getUserPermissions(userid: string) {
|
|
4
|
+
interface permissions {
|
|
5
|
+
name: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const res = await post<permissions[]>(`/af-system/search`, {
|
|
9
|
+
source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($功能权限$) != -1)',
|
|
10
|
+
userid,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
return res.map((row) => {
|
|
14
|
+
return row.name
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* GET请求
|
|
5
|
-
* @param url 请求地址
|
|
6
|
-
* @param params 路径参数
|
|
7
|
-
*/
|
|
8
|
-
export function get<T = any>(url: string, params?: any): Promise<T> {
|
|
9
|
-
return http.request<T>({
|
|
10
|
-
url,
|
|
11
|
-
method: 'GET',
|
|
12
|
-
params,
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* POST请求
|
|
18
|
-
* @param url 请求地址
|
|
19
|
-
* @param data 请求参数
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* POST请求
|
|
23
|
-
* @param url 请求地址
|
|
24
|
-
* @param data 请求参数
|
|
25
|
-
*/
|
|
26
|
-
export function post<T = any>(url: string, data: any): Promise<T> {
|
|
27
|
-
return http.request <T>({
|
|
28
|
-
url,
|
|
29
|
-
method: 'POST',
|
|
30
|
-
data,
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function postWithConfig<T = any>(url: string, data: any, config: any): Promise<T> {
|
|
35
|
-
return http.request<T>({
|
|
36
|
-
url,
|
|
37
|
-
method: 'POST',
|
|
38
|
-
data,
|
|
39
|
-
headers: { ...config },
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* DELETE请求
|
|
45
|
-
* @param url 请求地址
|
|
46
|
-
* @param data 查询参数
|
|
47
|
-
* @param config 额外的配置项(如自定义头信息等)
|
|
48
|
-
*/
|
|
49
|
-
export function del<T = any>(url: string, data?: any, config?: any): Promise<T> {
|
|
50
|
-
return http.request<T>({
|
|
51
|
-
url,
|
|
52
|
-
method: 'DELETE',
|
|
53
|
-
data,
|
|
54
|
-
...config,
|
|
55
|
-
})
|
|
56
|
-
}
|
|
1
|
+
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* GET请求
|
|
5
|
+
* @param url 请求地址
|
|
6
|
+
* @param params 路径参数
|
|
7
|
+
*/
|
|
8
|
+
export function get<T = any>(url: string, params?: any): Promise<T> {
|
|
9
|
+
return http.request<T>({
|
|
10
|
+
url,
|
|
11
|
+
method: 'GET',
|
|
12
|
+
params,
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* POST请求
|
|
18
|
+
* @param url 请求地址
|
|
19
|
+
* @param data 请求参数
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* POST请求
|
|
23
|
+
* @param url 请求地址
|
|
24
|
+
* @param data 请求参数
|
|
25
|
+
*/
|
|
26
|
+
export function post<T = any>(url: string, data: any): Promise<T> {
|
|
27
|
+
return http.request <T>({
|
|
28
|
+
url,
|
|
29
|
+
method: 'POST',
|
|
30
|
+
data,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function postWithConfig<T = any>(url: string, data: any, config: any): Promise<T> {
|
|
35
|
+
return http.request<T>({
|
|
36
|
+
url,
|
|
37
|
+
method: 'POST',
|
|
38
|
+
data,
|
|
39
|
+
headers: { ...config },
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* DELETE请求
|
|
45
|
+
* @param url 请求地址
|
|
46
|
+
* @param data 查询参数
|
|
47
|
+
* @param config 额外的配置项(如自定义头信息等)
|
|
48
|
+
*/
|
|
49
|
+
export function del<T = any>(url: string, data?: any, config?: any): Promise<T> {
|
|
50
|
+
return http.request<T>({
|
|
51
|
+
url,
|
|
52
|
+
method: 'DELETE',
|
|
53
|
+
data,
|
|
54
|
+
...config,
|
|
55
|
+
})
|
|
56
|
+
}
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 判断是否有路由的权限
|
|
3
|
-
* @param authority 路由权限配置
|
|
4
|
-
* @param permissions 用户权限集合
|
|
5
|
-
*/
|
|
6
|
-
function hasPermission(authority: any, permissions: any): boolean {
|
|
7
|
-
let required: string = '*'
|
|
8
|
-
if (typeof authority === 'string')
|
|
9
|
-
required = authority
|
|
10
|
-
else if (Array.isArray(authority))
|
|
11
|
-
required = authority.toString()
|
|
12
|
-
else if (typeof authority === 'object')
|
|
13
|
-
required = authority.permission
|
|
14
|
-
|
|
15
|
-
return required === '*' || hasAnyItem(required, permissions, (r, t) => !!(r === t || r === t.id))
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 判断是否有路由需要的角色
|
|
20
|
-
* @param authority 路由权限配置
|
|
21
|
-
* @param roles 用户角色集合
|
|
22
|
-
*/
|
|
23
|
-
function hasRole(authority, roles) {
|
|
24
|
-
let required
|
|
25
|
-
if (typeof authority === 'object')
|
|
26
|
-
required = authority.role
|
|
27
|
-
|
|
28
|
-
return authority === '*' || hasAnyItem(required, roles, (r, t) => !!(r === t || r === t.id))
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 判断目标数组是否有所需元素
|
|
33
|
-
* @param {string | string[]}required 所需元素,数组或单个元素
|
|
34
|
-
* @param {string[] | object[]} source 目标数组
|
|
35
|
-
* @param {Function} filter 匹配条件
|
|
36
|
-
* (r: String, s: String|Object) => boolean
|
|
37
|
-
*/
|
|
38
|
-
function hasAnyItem(required, source, filter): boolean {
|
|
39
|
-
if (!required)
|
|
40
|
-
return false
|
|
41
|
-
|
|
42
|
-
const checkedList = Array.isArray(required) ? required : [required]
|
|
43
|
-
return !!source.find(s => checkedList.find(r => filter(r, s)))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 路由权限校验
|
|
48
|
-
* @param route 路由
|
|
49
|
-
* @param permissions 用户权限集合
|
|
50
|
-
* @param roles 用户角色集合
|
|
51
|
-
*/
|
|
52
|
-
function hasAuthority(route, permissions, roles) {
|
|
53
|
-
// TODO 此处判断可能有问题
|
|
54
|
-
if (!route.meta.pAuthorities)
|
|
55
|
-
return true
|
|
56
|
-
|
|
57
|
-
const authorities = [...route.meta.pAuthorities, route.meta.authority]
|
|
58
|
-
for (const authority of authorities) {
|
|
59
|
-
if (!hasPermission(authority, permissions) && !hasRole(authority, roles))
|
|
60
|
-
return false
|
|
61
|
-
}
|
|
62
|
-
return true
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 根据权限配置过滤菜单数据
|
|
67
|
-
* @param menuData
|
|
68
|
-
* @param permissions
|
|
69
|
-
* @param roles
|
|
70
|
-
*/
|
|
71
|
-
function filterMenu(menuData, permissions, roles) {
|
|
72
|
-
return menuData.filter((menu) => {
|
|
73
|
-
if (menu.meta && menu.meta.invisible === undefined) {
|
|
74
|
-
if (!hasAuthority(menu, permissions, roles))
|
|
75
|
-
return false
|
|
76
|
-
}
|
|
77
|
-
if (menu.children && menu.children.length > 0)
|
|
78
|
-
menu.children = filterMenu(menu.children, permissions, roles)
|
|
79
|
-
|
|
80
|
-
return true
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export { filterMenu, hasAuthority }
|
|
1
|
+
/**
|
|
2
|
+
* 判断是否有路由的权限
|
|
3
|
+
* @param authority 路由权限配置
|
|
4
|
+
* @param permissions 用户权限集合
|
|
5
|
+
*/
|
|
6
|
+
function hasPermission(authority: any, permissions: any): boolean {
|
|
7
|
+
let required: string = '*'
|
|
8
|
+
if (typeof authority === 'string')
|
|
9
|
+
required = authority
|
|
10
|
+
else if (Array.isArray(authority))
|
|
11
|
+
required = authority.toString()
|
|
12
|
+
else if (typeof authority === 'object')
|
|
13
|
+
required = authority.permission
|
|
14
|
+
|
|
15
|
+
return required === '*' || hasAnyItem(required, permissions, (r, t) => !!(r === t || r === t.id))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 判断是否有路由需要的角色
|
|
20
|
+
* @param authority 路由权限配置
|
|
21
|
+
* @param roles 用户角色集合
|
|
22
|
+
*/
|
|
23
|
+
function hasRole(authority, roles) {
|
|
24
|
+
let required
|
|
25
|
+
if (typeof authority === 'object')
|
|
26
|
+
required = authority.role
|
|
27
|
+
|
|
28
|
+
return authority === '*' || hasAnyItem(required, roles, (r, t) => !!(r === t || r === t.id))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 判断目标数组是否有所需元素
|
|
33
|
+
* @param {string | string[]}required 所需元素,数组或单个元素
|
|
34
|
+
* @param {string[] | object[]} source 目标数组
|
|
35
|
+
* @param {Function} filter 匹配条件
|
|
36
|
+
* (r: String, s: String|Object) => boolean
|
|
37
|
+
*/
|
|
38
|
+
function hasAnyItem(required, source, filter): boolean {
|
|
39
|
+
if (!required)
|
|
40
|
+
return false
|
|
41
|
+
|
|
42
|
+
const checkedList = Array.isArray(required) ? required : [required]
|
|
43
|
+
return !!source.find(s => checkedList.find(r => filter(r, s)))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 路由权限校验
|
|
48
|
+
* @param route 路由
|
|
49
|
+
* @param permissions 用户权限集合
|
|
50
|
+
* @param roles 用户角色集合
|
|
51
|
+
*/
|
|
52
|
+
function hasAuthority(route, permissions, roles) {
|
|
53
|
+
// TODO 此处判断可能有问题
|
|
54
|
+
if (!route.meta.pAuthorities)
|
|
55
|
+
return true
|
|
56
|
+
|
|
57
|
+
const authorities = [...route.meta.pAuthorities, route.meta.authority]
|
|
58
|
+
for (const authority of authorities) {
|
|
59
|
+
if (!hasPermission(authority, permissions) && !hasRole(authority, roles))
|
|
60
|
+
return false
|
|
61
|
+
}
|
|
62
|
+
return true
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 根据权限配置过滤菜单数据
|
|
67
|
+
* @param menuData
|
|
68
|
+
* @param permissions
|
|
69
|
+
* @param roles
|
|
70
|
+
*/
|
|
71
|
+
function filterMenu(menuData, permissions, roles) {
|
|
72
|
+
return menuData.filter((menu) => {
|
|
73
|
+
if (menu.meta && menu.meta.invisible === undefined) {
|
|
74
|
+
if (!hasAuthority(menu, permissions, roles))
|
|
75
|
+
return false
|
|
76
|
+
}
|
|
77
|
+
if (menu.children && menu.children.length > 0)
|
|
78
|
+
menu.children = filterMenu(menu.children, permissions, roles)
|
|
79
|
+
|
|
80
|
+
return true
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export { filterMenu, hasAuthority }
|
package/src/utils/crypto.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import AesEncryptJS from 'crypto-js'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
/**
|
|
5
|
-
* AES加密
|
|
6
|
-
*
|
|
7
|
-
* @param word
|
|
8
|
-
* @param encryKey
|
|
9
|
-
*/
|
|
10
|
-
AESEncrypt(word: string, encryKey: string): string {
|
|
11
|
-
const key = AesEncryptJS.enc.Utf8.parse(encryKey)
|
|
12
|
-
const srcs = AesEncryptJS.enc.Utf8.parse(word)
|
|
13
|
-
const encrypted = AesEncryptJS.AES.encrypt(srcs, key, {
|
|
14
|
-
mode: AesEncryptJS.mode.ECB,
|
|
15
|
-
padding: AesEncryptJS.pad.Pkcs7,
|
|
16
|
-
})
|
|
17
|
-
return encrypted.toString()
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* AES解密
|
|
21
|
-
*
|
|
22
|
-
* @param word
|
|
23
|
-
* @param encryKey
|
|
24
|
-
*/
|
|
25
|
-
AESDecrypt(word: string, encryKey: string): any {
|
|
26
|
-
const key = AesEncryptJS.enc.Utf8.parse(encryKey)
|
|
27
|
-
const decrypt = AesEncryptJS.AES.decrypt(word, key, {
|
|
28
|
-
mode: AesEncryptJS.mode.ECB,
|
|
29
|
-
padding: AesEncryptJS.pad.Pkcs7,
|
|
30
|
-
})
|
|
31
|
-
const ret = AesEncryptJS.enc.Utf8.stringify(decrypt).toString()
|
|
32
|
-
try {
|
|
33
|
-
return JSON.parse(ret)
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return ret
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
}
|
|
1
|
+
import AesEncryptJS from 'crypto-js'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
/**
|
|
5
|
+
* AES加密
|
|
6
|
+
*
|
|
7
|
+
* @param word
|
|
8
|
+
* @param encryKey
|
|
9
|
+
*/
|
|
10
|
+
AESEncrypt(word: string, encryKey: string): string {
|
|
11
|
+
const key = AesEncryptJS.enc.Utf8.parse(encryKey)
|
|
12
|
+
const srcs = AesEncryptJS.enc.Utf8.parse(word)
|
|
13
|
+
const encrypted = AesEncryptJS.AES.encrypt(srcs, key, {
|
|
14
|
+
mode: AesEncryptJS.mode.ECB,
|
|
15
|
+
padding: AesEncryptJS.pad.Pkcs7,
|
|
16
|
+
})
|
|
17
|
+
return encrypted.toString()
|
|
18
|
+
},
|
|
19
|
+
/**
|
|
20
|
+
* AES解密
|
|
21
|
+
*
|
|
22
|
+
* @param word
|
|
23
|
+
* @param encryKey
|
|
24
|
+
*/
|
|
25
|
+
AESDecrypt(word: string, encryKey: string): any {
|
|
26
|
+
const key = AesEncryptJS.enc.Utf8.parse(encryKey)
|
|
27
|
+
const decrypt = AesEncryptJS.AES.decrypt(word, key, {
|
|
28
|
+
mode: AesEncryptJS.mode.ECB,
|
|
29
|
+
padding: AesEncryptJS.pad.Pkcs7,
|
|
30
|
+
})
|
|
31
|
+
const ret = AesEncryptJS.enc.Utf8.stringify(decrypt).toString()
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(ret)
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return ret
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
}
|