@yqg/permission 1.3.0-alpha.0 → 1.3.0-alpha.2
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/dist/{apply-modal-CpmDDWWV.js → apply-modal-DGX6gpHK.js} +7 -7
- package/dist/{category-selector-BQ0-kg3o.js → category-selector-C4wE2v-D.js} +97 -97
- package/dist/{index-D_0ZQip-.js → index-C28x1Vhk.js} +3 -3
- package/dist/{index-wLkVeDMW.js → index-EF-patVm.js} +10 -12
- package/dist/index.js +2 -2
- package/dist/{permission-item-Df_aagL1.js → permission-item-DcI9HD6q.js} +236 -236
- package/dist/{yqg-permission-BjVCs5lN.js → yqg-permission-DITcGx8T.js} +5 -7
- package/dist/yqg-permission.umd.js +3 -3
- package/package.json +1 -1
- package/src/App.vue +7 -7
- package/src/components/apply-modal.vue +2 -2
- package/src/components/category-selector.vue +1 -1
- package/src/components/permission-item.vue +1 -1
- package/src/components/yqg-permission.vue +2 -3
- package/src/hooks/useAttributesCache.ts +4 -4
- package/src/hooks/useCategory.ts +0 -1
- package/src/hooks/useFormat.ts +24 -18
- package/src/main.ts +2 -2
- package/src/yqg-permission/index.ts +0 -1
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -9,13 +9,13 @@ const color = ref<string>('#1677ff');
|
|
|
9
9
|
const locale = ref<LocaleType>('zh-CN');
|
|
10
10
|
|
|
11
11
|
const permissions = reactive([
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
12
|
+
'CRANE.PERMISSION.QUERY',
|
|
13
|
+
'CRANE.PERMISSION.CREATE',
|
|
14
|
+
'CRANE.PERMISSION.UPDATE',
|
|
15
|
+
'CRANE.PERMISSION.DELETE',
|
|
16
|
+
'CRANE.PERMISSION.DETAIL_QUERY',
|
|
17
|
+
'CRANE.PERMISSION.ROLE_ASSIGN',
|
|
18
|
+
'CRANE.PERMISSION.EXPORT',
|
|
19
19
|
]);
|
|
20
20
|
// const permissions = reactive(['CRANE.BUSINESS.QUERY', 'RANE.BUSINESS.CREATE', 'CRANE.BUSINESS.UPDATE', 'CRANE.BUSINESS.DELETE']);
|
|
21
21
|
const changeColor = () => {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
{{t('noPermissionTips')}}
|
|
10
10
|
</span>
|
|
11
11
|
|
|
12
|
-
<Tree checkable :
|
|
12
|
+
<Tree checkable :default-expand-all="true" :tree-data="permissionList" :height="200"
|
|
13
13
|
:checkedKeys="formState.features" class="crane-permission-tree" @check="onCheck">
|
|
14
14
|
<template #title="item: PermissionType">
|
|
15
15
|
<div v-if="item.children && item.children.length">
|
|
@@ -232,7 +232,7 @@ const onCheck = (checkedIds:any, info:any) => {
|
|
|
232
232
|
|
|
233
233
|
// 收集需要展示的数据属性
|
|
234
234
|
categoryList.value = useCategory(permissionList.value, formState.features);
|
|
235
|
-
|
|
235
|
+
console.log(categoryList.value, formState.features);
|
|
236
236
|
// 预览审批流程
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -55,7 +55,7 @@ const showForm = computed(() => {
|
|
|
55
55
|
});
|
|
56
56
|
const formRef = ref();
|
|
57
57
|
const searchValue = ref('');
|
|
58
|
-
const { categoryValuesMap } = useAttributesCache(props
|
|
58
|
+
const { categoryValuesMap } = useAttributesCache(props);
|
|
59
59
|
|
|
60
60
|
// 返回promise
|
|
61
61
|
const validate = () => {
|
|
@@ -167,9 +167,8 @@ import useFormat from '../hooks/useFormat';
|
|
|
167
167
|
workNumber,
|
|
168
168
|
features: permissions.toString(),
|
|
169
169
|
};
|
|
170
|
-
|
|
171
|
-
loading.value = true;
|
|
172
170
|
|
|
171
|
+
loading.value = true;
|
|
173
172
|
const res = await Http.getPermissions(params);
|
|
174
173
|
permissionList.value = useFormat(res.body || []);
|
|
175
174
|
curStatus.value = useStatus(permissionList.value, curApproving);
|
|
@@ -177,8 +176,8 @@ import useFormat from '../hooks/useFormat';
|
|
|
177
176
|
};
|
|
178
177
|
|
|
179
178
|
const showModal = () => {
|
|
180
|
-
getPermissions();
|
|
181
179
|
open.value = !open.value;
|
|
180
|
+
getPermissions();
|
|
182
181
|
};
|
|
183
182
|
|
|
184
183
|
const { currentTop, dragElement } = useDraggable(props, showModal);
|
|
@@ -2,10 +2,10 @@ import { watch, reactive } from 'vue';
|
|
|
2
2
|
import Http from '../axios/index';
|
|
3
3
|
|
|
4
4
|
const categoryValuesMap = reactive<Record<number, []>>({});
|
|
5
|
-
export default function useAttributesCache(
|
|
5
|
+
export default function useAttributesCache(props: any) {
|
|
6
6
|
|
|
7
|
-
watch(() => categoryList, (newVal) => {
|
|
8
|
-
newVal.forEach(async (item) => {
|
|
7
|
+
watch(() => props.categoryList, (newVal) => {
|
|
8
|
+
newVal.forEach(async (item:CategoryType) => {
|
|
9
9
|
if (!categoryValuesMap[item.id]) {
|
|
10
10
|
const res = await Http.getCategoryValues(item.id);
|
|
11
11
|
const { flatAttributeValue, treeAttributeValue, showWay } = res.body;
|
|
@@ -13,7 +13,7 @@ export default function useAttributesCache(categoryList: CategoryType[]) {
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
}, { immediate: true });
|
|
16
|
+
}, { immediate: true, deep: true });
|
|
17
17
|
|
|
18
18
|
return {
|
|
19
19
|
categoryValuesMap
|
package/src/hooks/useCategory.ts
CHANGED
|
@@ -5,7 +5,6 @@ export default function useCategory(tree: PermissionType[], checkedIds: string[]
|
|
|
5
5
|
const categoryList: CategoryType[] = [];
|
|
6
6
|
deepTree(tree, (item) => {
|
|
7
7
|
if (!item.children && checkedIds.includes(item.feature)) {
|
|
8
|
-
|
|
9
8
|
item.categoryVOS.forEach((category: any) => {
|
|
10
9
|
category.attributeValueIds_view = category?.attributeValueIds || [];
|
|
11
10
|
categoryList.push(category);
|
package/src/hooks/useFormat.ts
CHANGED
|
@@ -9,18 +9,15 @@ const StatusType = {
|
|
|
9
9
|
TEMP_OWNER: 'TEMP_OWNER'
|
|
10
10
|
}
|
|
11
11
|
export default function useFormat(tree: PermissionListType) {
|
|
12
|
-
function sortTree(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// 递归对每个节点的子节点进行排序
|
|
20
|
-
tree.forEach(node => {
|
|
12
|
+
function sortTree(
|
|
13
|
+
tree: PermissionListType,
|
|
14
|
+
sortMap: Map<string | null, number>,
|
|
15
|
+
levelSortMap: Map<string | null, number>
|
|
16
|
+
) {
|
|
17
|
+
return tree.map((node) => {
|
|
21
18
|
node.key = node.feature;
|
|
22
|
-
|
|
23
|
-
if (!node.children) {
|
|
19
|
+
|
|
20
|
+
if (!node.children || node.children.length === 0) {
|
|
24
21
|
node.categoryVOS = (node.categoryVOS || []).filter((item: any) => item.configWay !== Category.AUTO);
|
|
25
22
|
|
|
26
23
|
if ([StatusType.NO].includes(node.businessApplyType)) {
|
|
@@ -30,21 +27,30 @@ export default function useFormat(tree: PermissionListType) {
|
|
|
30
27
|
if ([StatusType.OWNER, StatusType.PENDING].includes(node.businessApplyType) && !node.categoryVOS.length) {
|
|
31
28
|
node.disabled = true;
|
|
32
29
|
}
|
|
30
|
+
} else {
|
|
31
|
+
// 递归对子节点进行排序
|
|
32
|
+
node.children = sortTree(node.children, sortMap, levelSortMap);
|
|
33
|
+
|
|
34
|
+
// 检查所有子节点是否 `disabled === true`
|
|
35
|
+
if (node.children.every((child) => child.disabled)) {
|
|
36
|
+
node.disabled = true;
|
|
37
|
+
}
|
|
33
38
|
}
|
|
34
|
-
if (node.children && node.children.length > 0) {
|
|
35
|
-
sortTree(node.children, sortMap, levelSortMap);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
return node;
|
|
41
|
+
}).sort((a, b) => {
|
|
42
|
+
return (sortMap.get(a.businessApplyType) ?? 0) - (sortMap.get(b.businessApplyType) ?? 0)
|
|
43
|
+
|| (levelSortMap.get(a.securityLevel) ?? 0) - (levelSortMap.get(b.securityLevel) ?? 0);
|
|
44
|
+
});
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
// 需要排序,规则:businessApplyType 为 null 在前面, PENDING. OWNER 在中间, NO 在后面
|
|
43
48
|
// 然后再根据 L1, L2, L3 排序
|
|
44
49
|
const sort = [null, StatusType.TEMP_OWNER, StatusType.PENDING, StatusType.OWNER, StatusType.NO];
|
|
45
|
-
const levelSort = [null,
|
|
50
|
+
const levelSort = [null, "L1", "L2", "L3"];
|
|
46
51
|
const sortMap = new Map(sort.map((value, index) => [value, index]));
|
|
47
52
|
const levelSortMap = new Map(levelSort.map((value, index) => [value, index]));
|
|
48
53
|
|
|
49
54
|
return sortTree(tree, sortMap, levelSortMap);
|
|
50
|
-
}
|
|
55
|
+
}
|
|
56
|
+
|
package/src/main.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createApp } from 'vue';
|
|
2
2
|
import App from './App.vue';
|
|
3
3
|
import './style.css';
|
|
4
|
-
import yqgPermission from './yqg-permission';
|
|
5
|
-
|
|
4
|
+
// import yqgPermission from './yqg-permission';
|
|
5
|
+
import yqgPermission from '../dist';
|
|
6
6
|
yqgPermission.init();
|
|
7
7
|
|
|
8
8
|
const app = createApp(App);
|