@yqg/permission 1.3.13 → 1.3.14-beta.1
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-OokdyEmj.js → apply-modal-CbdSpFHD.js} +4 -4
- package/dist/{category-selector-C-yZxEgO.js → category-selector-CeFM3lr8.js} +502 -474
- package/dist/{index-BkbJOH6j.js → index-D-ZB-Fhd.js} +3 -3
- package/dist/{index-CSnwgcu-.js → index-D_ujkA5Y.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{permission-item-CZ7LWwNL.js → permission-item-DaZXxED4.js} +4 -4
- package/dist/{yqg-permission-D0O9c9lI.js → yqg-permission-C8hIbxln.js} +2 -2
- package/dist/yqg-permission.umd.js +42 -42
- package/package.json +2 -2
- package/src/App.vue +2 -2
- package/src/components/category-selector.vue +1 -1
- package/src/hooks/useAttributesCache.ts +64 -6
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -19,7 +19,7 @@ const changeLocale = () => {
|
|
|
19
19
|
locale.value = locale.value === 'id-ID' ? 'en-US' : 'id-ID';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const permissions = ref('
|
|
22
|
+
const permissions = ref('APP_CENTER.APP.AUTHORITY');
|
|
23
23
|
|
|
24
24
|
</script>
|
|
25
25
|
|
|
@@ -33,7 +33,7 @@ const permissions = ref('TECH.SCHEDULER.JOB.VISIBLE,TECH.SCHEDULER.JOB.QUERY,TEC
|
|
|
33
33
|
<!-- 03541 -->
|
|
34
34
|
<!-- 02124 -->
|
|
35
35
|
<!-- 05184 -->
|
|
36
|
-
<yqg-permission :omitCategoryIds="[]" :permissions="permissions" workNumber="
|
|
36
|
+
<yqg-permission :omitCategoryIds="[]" :permissions="permissions" workNumber="03817" :color="color" :locale="locale"
|
|
37
37
|
@onSuccess="() => {console.log('成功')}">
|
|
38
38
|
</yqg-permission>
|
|
39
39
|
</div>
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
allowClear v-model:value="item.attributeValueIds_view"
|
|
12
12
|
treeNodeFilterProp="attributeName" v-model:searchValue="searchValue"
|
|
13
13
|
:fieldNames="{ label: 'attributeName', value: 'id' }" treeNodeLabelProp="attributeName"
|
|
14
|
-
:show-checked-strategy="SHOW_PARENT">
|
|
14
|
+
:show-checked-strategy="SHOW_PARENT" :virtual="true">
|
|
15
15
|
<template #title="{ attributeName }">
|
|
16
16
|
<span v-if="searchValue.toLowerCase() && attributeName.includes(searchValue.toLowerCase())"
|
|
17
17
|
style="color: #1677ff; font-weight: bold;">{{ attributeName
|
|
@@ -5,7 +5,7 @@ const categoryValuesMap = reactive<Record<number, []>>({});
|
|
|
5
5
|
export default function useAttributesCache(props: any) {
|
|
6
6
|
|
|
7
7
|
watch(() => props.categoryList, (newVal) => {
|
|
8
|
-
newVal.forEach(async (item:CategoryType) => {
|
|
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;
|
|
@@ -24,16 +24,74 @@ export default function useAttributesCache(props: any) {
|
|
|
24
24
|
return item.attributeName;
|
|
25
25
|
}
|
|
26
26
|
if (item.children && item.children.length) {
|
|
27
|
-
|
|
27
|
+
const result = getCategoryName(id, item.children);
|
|
28
|
+
if (result) {
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
return '';
|
|
31
|
-
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// 根据 ids 查找对应的节点及其所有后代节点,铺平并去重
|
|
37
|
+
const getAllViewAttributeNodes = (ids: number[], list: AttributeValueType[]): AttributeValueType[] => {
|
|
38
|
+
const allNodes: AttributeValueType[] = [];
|
|
39
|
+
const idSet = new Set<number>();
|
|
40
|
+
|
|
41
|
+
// 收集节点及其所有后代(内部函数)
|
|
42
|
+
const collect = (node: AttributeValueType) => {
|
|
43
|
+
if (!idSet.has(node.id)) {
|
|
44
|
+
idSet.add(node.id);
|
|
45
|
+
allNodes.push(node);
|
|
46
|
+
}
|
|
47
|
+
if (node.children && node.children.length) {
|
|
48
|
+
for (let j = 0; j < node.children.length; j++) {
|
|
49
|
+
collect(node.children[j]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// 查找节点并收集(内部函数)
|
|
55
|
+
const findAndCollect = (id: number, nodeList: AttributeValueType[]): boolean => {
|
|
56
|
+
for (let i = 0; i < nodeList.length; i++) {
|
|
57
|
+
const item = nodeList[i];
|
|
58
|
+
if (item.id === id) {
|
|
59
|
+
collect(item);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
if (item.children && item.children.length) {
|
|
63
|
+
if (findAndCollect(id, item.children)) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
for (let i = 0; i < ids.length; i++) {
|
|
72
|
+
findAndCollect(ids[i], list);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return allNodes;
|
|
76
|
+
};
|
|
32
77
|
|
|
33
78
|
const getDeleteAttributesNames = (item: CategoryType) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
79
|
+
const viewNodes = getAllViewAttributeNodes(item.attributeValueIds_view || [], categoryValuesMap[item.id] || []);
|
|
80
|
+
const viewNodeIdSet = new Set<number>();
|
|
81
|
+
for (let i = 0; i < viewNodes.length; i++) {
|
|
82
|
+
viewNodeIdSet.add(viewNodes[i].id);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 获取所有原始节点(包括后代)的映射,用于快速查找 name
|
|
86
|
+
const allNodes = getAllViewAttributeNodes(item.defaultValueIds || [], categoryValuesMap[item.id] || []);
|
|
87
|
+
const allNodeMap = new Map<number, string>();
|
|
88
|
+
for (let i = 0; i < allNodes.length; i++) {
|
|
89
|
+
allNodeMap.set(allNodes[i].id, allNodes[i].attributeName);
|
|
90
|
+
}
|
|
91
|
+
const deleteAttributesNames = item.defaultValueIds?.filter(id => !viewNodeIdSet.has(id))?.map(id => {
|
|
92
|
+
return allNodeMap.get(id) || getCategoryName(id, categoryValuesMap[item.id] || []);
|
|
93
|
+
}).filter(Boolean).join('、');
|
|
94
|
+
return deleteAttributesNames;
|
|
37
95
|
};
|
|
38
96
|
|
|
39
97
|
return {
|