@jari-ace/element-plus-component 0.1.10 → 0.2.0
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/README.md +18 -18
- package/dist/components/form/JaForm.vue.d.ts +0 -3
- package/dist/components/form/JaForm.vue.d.ts.map +1 -1
- package/dist/components/form/JaForm.vue.js +68 -22
- package/dist/components/form/JaForm.vue.js.map +1 -1
- package/dist/components/formItem/JaFormItem.vue.d.ts +0 -4
- package/dist/components/formItem/JaFormItem.vue.d.ts.map +1 -1
- package/dist/components/formItem/JaFormItem.vue.js +8 -26
- package/dist/components/formItem/JaFormItem.vue.js.map +1 -1
- package/dist/components/userPicker/src/UserPicker.vue.d.ts +17 -0
- package/dist/components/userPicker/src/UserPicker.vue.d.ts.map +1 -1
- package/dist/components/userPicker/src/UserPicker.vue.js +15 -0
- package/dist/components/userPicker/src/UserPicker.vue.js.map +1 -1
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts +17 -0
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts.map +1 -1
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.js +15 -0
- package/dist/components/userSelectDialog/src/userSelectDialog.vue.js.map +1 -1
- package/dist/hooks/useBackendValidations.js +0 -1
- package/dist/hooks/useBackendValidations.js.map +1 -1
- package/dist/hooks/useClassificationLevels.d.ts +21 -0
- package/dist/hooks/useClassificationLevels.d.ts.map +1 -0
- package/dist/hooks/useClassificationLevels.js +55 -0
- package/dist/hooks/useClassificationLevels.js.map +1 -0
- package/dist/hooks/useUserRefQuery.d.ts +6 -0
- package/dist/hooks/useUserRefQuery.d.ts.map +1 -1
- package/dist/hooks/useUserRefQuery.js +4 -0
- package/dist/hooks/useUserRefQuery.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/lib/index.css +1 -1
- package/lib/index.js +1527 -1531
- package/lib/index.umd.cjs +2 -2
- package/package.json +61 -61
- package/packages/components/autoComplete/JaAutoComplete.vue +47 -47
- package/packages/components/autoComplete/index.ts +5 -5
- package/packages/components/avatar/JaAvatar.vue +126 -126
- package/packages/components/avatar/avatarToken.ts +11 -11
- package/packages/components/avatar/defaultImg.ts +14 -14
- package/packages/components/avatar/index.ts +7 -7
- package/packages/components/button/JaButton.vue +51 -51
- package/packages/components/button/index.ts +4 -4
- package/packages/components/channelPicker/index.ts +7 -7
- package/packages/components/channelPicker/src/ChannelPicker.vue +43 -43
- package/packages/components/channelPicker/src/JaChannelPicker.vue +42 -42
- package/packages/components/checkbox/JaCheckbox.vue +73 -73
- package/packages/components/checkbox/index.ts +4 -4
- package/packages/components/checkboxGroup/JaCheckboxGroup.vue +45 -45
- package/packages/components/checkboxGroup/index.ts +4 -4
- package/packages/components/customGroupTree/index.ts +10 -10
- package/packages/components/customGroupTree/src/customGroupTree.vue +91 -91
- package/packages/components/datePicker/JaDatePicker.vue +52 -52
- package/packages/components/datePicker/index.ts +4 -4
- package/packages/components/departmentPicker/index.ts +4 -4
- package/packages/components/departmentPicker/src/DepartmentPicker.vue +107 -107
- package/packages/components/departmentPicker/src/consts.ts +2 -2
- package/packages/components/departmentTree/index.ts +10 -10
- package/packages/components/departmentTree/src/departmentTree.vue +135 -135
- package/packages/components/dropdownButton/JaDropdownButton.vue +59 -59
- package/packages/components/dropdownButton/index.ts +4 -4
- package/packages/components/enumList/EnumListInput.vue +107 -107
- package/packages/components/enumList/JaEnumList.vue +39 -39
- package/packages/components/enumList/index.ts +7 -7
- package/packages/components/enumPicker/index.ts +5 -5
- package/packages/components/enumPicker/src/EnumPicker.vue +103 -103
- package/packages/components/form/JaForm.vue +186 -146
- package/packages/components/form/index.ts +5 -5
- package/packages/components/form/types.ts +4 -4
- package/packages/components/formItem/JaFormItem.vue +68 -87
- package/packages/components/formItem/index.ts +4 -4
- package/packages/components/index.ts +34 -34
- package/packages/components/input/JaInput.vue +143 -143
- package/packages/components/input/index.ts +4 -4
- package/packages/components/inputI18n/I18nBundleEditor.vue +76 -76
- package/packages/components/inputI18n/InputI18n.vue +146 -146
- package/packages/components/inputI18n/JaInputI18n.vue +50 -50
- package/packages/components/inputI18n/index.ts +8 -8
- package/packages/components/inputNumber/JaInputNumber.vue +98 -98
- package/packages/components/inputNumber/index.ts +4 -4
- package/packages/components/mapItemList/JaMapItemList.vue +35 -35
- package/packages/components/mapItemList/MapItemListInput.vue +191 -191
- package/packages/components/mapItemList/index.ts +7 -7
- package/packages/components/numberList/JaNumberList.vue +36 -36
- package/packages/components/numberList/NumberListInput.vue +111 -111
- package/packages/components/numberList/index.ts +7 -7
- package/packages/components/properyPicker/JaPropertyPicker.vue +38 -38
- package/packages/components/properyPicker/PropertyPicker.vue +314 -314
- package/packages/components/properyPicker/index.ts +7 -7
- package/packages/components/radioGroup/JaRadioGroup.vue +50 -50
- package/packages/components/radioGroup/index.ts +4 -4
- package/packages/components/rolePicker/RoleEditor.vue +129 -129
- package/packages/components/rolePicker/RolePicker.vue +44 -44
- package/packages/components/rolePicker/RolePickerRaw.vue +56 -56
- package/packages/components/rolePicker/baseRolePicker.vue +87 -87
- package/packages/components/rolePicker/index.ts +10 -10
- package/packages/components/scrollbar/Scrollbar.vue +89 -89
- package/packages/components/scrollbar/index.ts +5 -5
- package/packages/components/scrollbar/utils.ts +17 -17
- package/packages/components/select/JaSelect.vue +48 -48
- package/packages/components/select/index.ts +4 -4
- package/packages/components/stringList/JaStringList.vue +36 -36
- package/packages/components/stringList/StringListInput.vue +96 -96
- package/packages/components/stringList/index.ts +7 -7
- package/packages/components/switch/JaSwitch.vue +50 -50
- package/packages/components/switch/index.ts +4 -4
- package/packages/components/timePicker/JaTimePicker.vue +52 -52
- package/packages/components/timePicker/index.ts +5 -5
- package/packages/components/tip/index.ts +4 -4
- package/packages/components/tip/src/AceTip.vue +43 -43
- package/packages/components/upload/index.ts +6 -6
- package/packages/components/upload/src/Upload.vue +25 -25
- package/packages/components/upload/src/type.ts +3 -3
- package/packages/components/userGroupPicker/index.ts +4 -4
- package/packages/components/userGroupPicker/src/UserGroupPicker.vue +94 -94
- package/packages/components/userGroupTree/index.ts +10 -10
- package/packages/components/userGroupTree/src/userGroupTree.vue +149 -149
- package/packages/components/userPicker/index.ts +10 -10
- package/packages/components/userPicker/src/CustomGroupManager.vue +189 -189
- package/packages/components/userPicker/src/JaUserList.vue +283 -283
- package/packages/components/userPicker/src/JaUserPicker.vue +37 -37
- package/packages/components/userPicker/src/UserPicker.vue +376 -368
- package/packages/components/userSelectDialog/index.ts +6 -6
- package/packages/components/userSelectDialog/src/userSelectDialog.vue +462 -455
- package/packages/components/userTag/UserInfoTag.vue +397 -397
- package/packages/components/userTag/index.ts +6 -6
- package/packages/components/userTag/sharedAxios.ts +8 -8
- package/packages/directives/auth/index.ts +41 -41
- package/packages/directives/autofocus/index.ts +29 -29
- package/packages/directives/index.ts +10 -10
- package/packages/directives/shortcut/index.ts +192 -192
- package/packages/hooks/useAppInstances.ts +34 -34
- package/packages/hooks/useBackendValidations.ts +81 -81
- package/packages/hooks/useBridage.ts +157 -157
- package/packages/hooks/useClassificationLevels.ts +62 -0
- package/packages/hooks/useDateTimeShortCuts.ts +65 -65
- package/packages/hooks/useRealms.ts +28 -28
- package/packages/hooks/useTreeData.ts +45 -45
- package/packages/hooks/useUserRefQuery.ts +232 -224
- package/packages/index.ts +21 -22
- package/packages/list.json +7 -7
- package/packages/types/custom.d.ts +13 -13
- package/packages/types/window.d.ts +16 -16
- package/packages/utils/install.ts +43 -43
- package/packages/utils/objectUtils.ts +31 -31
- package/theme-style/fonts/iconfont.json +5196 -5196
- package/theme-style/index.scss +10 -10
- package/theme-style/styles/element-plus-var.scss +1419 -1419
- package/theme-style/styles/iconfont.css +2979 -2979
- package/theme-style/styles/theme-var.scss +72 -72
- package/theme-style/styles/transition.scss +122 -122
- package/dist/utils/formUtils.d.ts +0 -7
- package/dist/utils/formUtils.d.ts.map +0 -1
- package/dist/utils/formUtils.js +0 -54
- package/dist/utils/formUtils.js.map +0 -1
- package/packages/utils/formUtils.ts +0 -57
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 用户域列表
|
|
3
|
-
*/
|
|
4
|
-
import {ref} from 'vue';
|
|
5
|
-
import {type AceAxiosRequestConfig, useRealmApi} from '@jari-ace/app-bolts';
|
|
6
|
-
import type {Realm} from '@jari-ace/app-bolts';
|
|
7
|
-
|
|
8
|
-
const realms = ref<Realm[]>([]);
|
|
9
|
-
|
|
10
|
-
export function useRealms() {
|
|
11
|
-
const realmApi = useRealmApi();
|
|
12
|
-
const getAllRealms = async () => {
|
|
13
|
-
if(realms.value.length!==0)return;
|
|
14
|
-
const config = {} as AceAxiosRequestConfig
|
|
15
|
-
realms.value = await realmApi.getAll(config);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const getDefaultRealm = async () => {
|
|
19
|
-
await getAllRealms()
|
|
20
|
-
return realms.value.find(r => r.name === 'ace-platform')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
realms,
|
|
25
|
-
getAllRealms,
|
|
26
|
-
getDefaultRealm
|
|
27
|
-
};
|
|
28
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 用户域列表
|
|
3
|
+
*/
|
|
4
|
+
import {ref} from 'vue';
|
|
5
|
+
import {type AceAxiosRequestConfig, useRealmApi} from '@jari-ace/app-bolts';
|
|
6
|
+
import type {Realm} from '@jari-ace/app-bolts';
|
|
7
|
+
|
|
8
|
+
const realms = ref<Realm[]>([]);
|
|
9
|
+
|
|
10
|
+
export function useRealms() {
|
|
11
|
+
const realmApi = useRealmApi();
|
|
12
|
+
const getAllRealms = async () => {
|
|
13
|
+
if(realms.value.length!==0)return;
|
|
14
|
+
const config = {} as AceAxiosRequestConfig
|
|
15
|
+
realms.value = await realmApi.getAll(config);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getDefaultRealm = async () => {
|
|
19
|
+
await getAllRealms()
|
|
20
|
+
return realms.value.find(r => r.name === 'ace-platform')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
realms,
|
|
25
|
+
getAllRealms,
|
|
26
|
+
getDefaultRealm
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import type {ProjectedSortPathTreeNode, EntityBase} from "@jari-ace/app-bolts";
|
|
2
|
-
|
|
3
|
-
export interface NodeType extends ProjectedSortPathTreeNode, EntityBase {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface TreeNodeType extends NodeType {
|
|
7
|
-
label?: string;
|
|
8
|
-
children: TreeNodeType[];
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function createNode<T>(n: T, labelKey: keyof T | undefined) {
|
|
13
|
-
return {
|
|
14
|
-
...n,
|
|
15
|
-
label: typeof labelKey === "string" && typeof n[labelKey] === "string"
|
|
16
|
-
? (n[labelKey] as string)
|
|
17
|
-
: "",
|
|
18
|
-
children: []
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 将平面数据处理成树状数据,使用O(n)算法复杂度,前提条件是data按照sortPath排序
|
|
24
|
-
* @param data - 平面数据
|
|
25
|
-
* @param labelKey - label字段名
|
|
26
|
-
*/
|
|
27
|
-
export function useTreeData<T extends NodeType>(
|
|
28
|
-
data: T[],
|
|
29
|
-
labelKey?: keyof T
|
|
30
|
-
): (TreeNodeType & T)[] {
|
|
31
|
-
const dict: Record<number, T & TreeNodeType> = {};
|
|
32
|
-
const result: (TreeNodeType & T)[] = [];
|
|
33
|
-
//O(n)算法建树,前提条件是data按照sortPath排序
|
|
34
|
-
for (let i = 0; i < data.length; i++) {
|
|
35
|
-
const n = data[i];
|
|
36
|
-
const extendNode = createNode(n, labelKey)
|
|
37
|
-
dict[n.id] = extendNode;
|
|
38
|
-
if (n.parentId) {
|
|
39
|
-
dict[n.parentId].children.push(extendNode);
|
|
40
|
-
} else {
|
|
41
|
-
result.push(extendNode)
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
}
|
|
1
|
+
import type {ProjectedSortPathTreeNode, EntityBase} from "@jari-ace/app-bolts";
|
|
2
|
+
|
|
3
|
+
export interface NodeType extends ProjectedSortPathTreeNode, EntityBase {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface TreeNodeType extends NodeType {
|
|
7
|
+
label?: string;
|
|
8
|
+
children: TreeNodeType[];
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function createNode<T>(n: T, labelKey: keyof T | undefined) {
|
|
13
|
+
return {
|
|
14
|
+
...n,
|
|
15
|
+
label: typeof labelKey === "string" && typeof n[labelKey] === "string"
|
|
16
|
+
? (n[labelKey] as string)
|
|
17
|
+
: "",
|
|
18
|
+
children: []
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 将平面数据处理成树状数据,使用O(n)算法复杂度,前提条件是data按照sortPath排序
|
|
24
|
+
* @param data - 平面数据
|
|
25
|
+
* @param labelKey - label字段名
|
|
26
|
+
*/
|
|
27
|
+
export function useTreeData<T extends NodeType>(
|
|
28
|
+
data: T[],
|
|
29
|
+
labelKey?: keyof T
|
|
30
|
+
): (TreeNodeType & T)[] {
|
|
31
|
+
const dict: Record<number, T & TreeNodeType> = {};
|
|
32
|
+
const result: (TreeNodeType & T)[] = [];
|
|
33
|
+
//O(n)算法建树,前提条件是data按照sortPath排序
|
|
34
|
+
for (let i = 0; i < data.length; i++) {
|
|
35
|
+
const n = data[i];
|
|
36
|
+
const extendNode = createNode(n, labelKey)
|
|
37
|
+
dict[n.id] = extendNode;
|
|
38
|
+
if (n.parentId) {
|
|
39
|
+
dict[n.parentId].children.push(extendNode);
|
|
40
|
+
} else {
|
|
41
|
+
result.push(extendNode)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
@@ -1,224 +1,232 @@
|
|
|
1
|
-
import {ref, watch} from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
type BooleanResultExpression,
|
|
4
|
-
createAxiosWithoutCache,
|
|
5
|
-
type IAceAxios,
|
|
6
|
-
QUser,
|
|
7
|
-
type SortDescriptor,
|
|
8
|
-
useLoading,
|
|
9
|
-
type UserReference,
|
|
10
|
-
useUserApi,
|
|
11
|
-
useUserQueryBuilder
|
|
12
|
-
} from "@jari-ace/app-bolts";
|
|
13
|
-
import type {TreeNodeType} from "./useTreeData";
|
|
14
|
-
import {ALL_DEPARTMENT, NO_DEPARTMENT} from "../components/departmentPicker/src/consts";
|
|
15
|
-
import debounce from "lodash-es/debounce";
|
|
16
|
-
import { useRealms } from "./useRealms";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 用户查询hook,当查询参数变化时,会自动查询,订阅结果即可
|
|
20
|
-
* @param queryPrerequisites 执行查询的前提条件,只有此方法返回true时,查询才会执行
|
|
21
|
-
* @param customFilter 自定义查询过滤条件,可以通过这个回调方法,通过程序方式添加自定义的过滤条件
|
|
22
|
-
* @param onQueryResultReturned 查询成功时的回调方法,接收Page<UserReference>类型参数
|
|
23
|
-
* @param scroll 是否滚动模式,滚动模式下,翻页后新页数据会追加到queryState.users集合中,而不是直接赋予queryState.users
|
|
24
|
-
* @param axios 自定义axios实例
|
|
25
|
-
* @param notPaged 不分页
|
|
26
|
-
*/
|
|
27
|
-
export function useUserRefQuery(
|
|
28
|
-
queryPrerequisites?: () => boolean,
|
|
29
|
-
customFilter?: (qUser: InstanceType<typeof QUser>) => BooleanResultExpression,
|
|
30
|
-
onQueryResultReturned?: (result?: UserReference[], paramsChanged?: boolean) => void,
|
|
31
|
-
scroll?: boolean,
|
|
32
|
-
axios?: IAceAxios,
|
|
33
|
-
notPaged?: boolean) {
|
|
34
|
-
const queryParams = ref<{
|
|
35
|
-
/**
|
|
36
|
-
* 用户域Id查询参数
|
|
37
|
-
*/
|
|
38
|
-
realmId?: string,
|
|
39
|
-
/**
|
|
40
|
-
* 部门查询参数
|
|
41
|
-
*/
|
|
42
|
-
currentDept?: TreeNodeType,
|
|
43
|
-
/**
|
|
44
|
-
* 用户姓名、用户名或用户拼音过滤参数
|
|
45
|
-
*/
|
|
46
|
-
name?: string,
|
|
47
|
-
/**
|
|
48
|
-
* 排序描述符
|
|
49
|
-
*/
|
|
50
|
-
currentSort?: SortDescriptor,
|
|
51
|
-
/**
|
|
52
|
-
* 用户组查询参数
|
|
53
|
-
*/
|
|
54
|
-
currentGroup?: TreeNodeType,
|
|
55
|
-
/**
|
|
56
|
-
* 自定义组查询参数
|
|
57
|
-
*/
|
|
58
|
-
currentCustomGroup?: TreeNodeType
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
builder.and(qUser.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
*
|
|
213
|
-
*/
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
*
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
*
|
|
221
|
-
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1
|
+
import {ref, watch} from 'vue';
|
|
2
|
+
import {
|
|
3
|
+
type BooleanResultExpression,
|
|
4
|
+
createAxiosWithoutCache,
|
|
5
|
+
type IAceAxios,
|
|
6
|
+
QUser,
|
|
7
|
+
type SortDescriptor,
|
|
8
|
+
useLoading,
|
|
9
|
+
type UserReference,
|
|
10
|
+
useUserApi,
|
|
11
|
+
useUserQueryBuilder
|
|
12
|
+
} from "@jari-ace/app-bolts";
|
|
13
|
+
import type {TreeNodeType} from "./useTreeData";
|
|
14
|
+
import {ALL_DEPARTMENT, NO_DEPARTMENT} from "../components/departmentPicker/src/consts";
|
|
15
|
+
import debounce from "lodash-es/debounce";
|
|
16
|
+
import { useRealms } from "./useRealms";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 用户查询hook,当查询参数变化时,会自动查询,订阅结果即可
|
|
20
|
+
* @param queryPrerequisites 执行查询的前提条件,只有此方法返回true时,查询才会执行
|
|
21
|
+
* @param customFilter 自定义查询过滤条件,可以通过这个回调方法,通过程序方式添加自定义的过滤条件
|
|
22
|
+
* @param onQueryResultReturned 查询成功时的回调方法,接收Page<UserReference>类型参数
|
|
23
|
+
* @param scroll 是否滚动模式,滚动模式下,翻页后新页数据会追加到queryState.users集合中,而不是直接赋予queryState.users
|
|
24
|
+
* @param axios 自定义axios实例
|
|
25
|
+
* @param notPaged 不分页
|
|
26
|
+
*/
|
|
27
|
+
export function useUserRefQuery(
|
|
28
|
+
queryPrerequisites?: () => boolean,
|
|
29
|
+
customFilter?: (qUser: InstanceType<typeof QUser>) => BooleanResultExpression,
|
|
30
|
+
onQueryResultReturned?: (result?: UserReference[], paramsChanged?: boolean) => void,
|
|
31
|
+
scroll?: boolean,
|
|
32
|
+
axios?: IAceAxios,
|
|
33
|
+
notPaged?: boolean) {
|
|
34
|
+
const queryParams = ref<{
|
|
35
|
+
/**
|
|
36
|
+
* 用户域Id查询参数
|
|
37
|
+
*/
|
|
38
|
+
realmId?: string,
|
|
39
|
+
/**
|
|
40
|
+
* 部门查询参数
|
|
41
|
+
*/
|
|
42
|
+
currentDept?: TreeNodeType,
|
|
43
|
+
/**
|
|
44
|
+
* 用户姓名、用户名或用户拼音过滤参数
|
|
45
|
+
*/
|
|
46
|
+
name?: string,
|
|
47
|
+
/**
|
|
48
|
+
* 排序描述符
|
|
49
|
+
*/
|
|
50
|
+
currentSort?: SortDescriptor,
|
|
51
|
+
/**
|
|
52
|
+
* 用户组查询参数
|
|
53
|
+
*/
|
|
54
|
+
currentGroup?: TreeNodeType,
|
|
55
|
+
/**
|
|
56
|
+
* 自定义组查询参数
|
|
57
|
+
*/
|
|
58
|
+
currentCustomGroup?: TreeNodeType,
|
|
59
|
+
/**
|
|
60
|
+
* 密级过滤
|
|
61
|
+
*/
|
|
62
|
+
classificationLevel?: number,
|
|
63
|
+
}>({})
|
|
64
|
+
|
|
65
|
+
const pageParams = ref<{
|
|
66
|
+
/**
|
|
67
|
+
* 当前页码
|
|
68
|
+
*/
|
|
69
|
+
currentPage: number,
|
|
70
|
+
/**
|
|
71
|
+
* 页内数据行数
|
|
72
|
+
*/
|
|
73
|
+
pageSize: number
|
|
74
|
+
}>({
|
|
75
|
+
currentPage: 1,
|
|
76
|
+
pageSize: 50
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
const queryResult = ref<{
|
|
80
|
+
/**
|
|
81
|
+
* 总数据量
|
|
82
|
+
*/
|
|
83
|
+
total: number,
|
|
84
|
+
/**
|
|
85
|
+
* 查询结果集
|
|
86
|
+
*/
|
|
87
|
+
users: UserReference[]
|
|
88
|
+
}>({
|
|
89
|
+
total: 0,
|
|
90
|
+
users: []
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
if (!axios) axios = createAxiosWithoutCache();
|
|
94
|
+
const userApi = useUserApi(axios);
|
|
95
|
+
const loading = useLoading(axios);
|
|
96
|
+
const queryParamChanged = ref<boolean>(false)
|
|
97
|
+
|
|
98
|
+
function doQuery() {
|
|
99
|
+
queryUsers().then(r => {
|
|
100
|
+
if (onQueryResultReturned) {
|
|
101
|
+
onQueryResultReturned(r, queryParamChanged.value);
|
|
102
|
+
}
|
|
103
|
+
queryParamChanged.value = false;
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const debounceDoQuery = debounce(doQuery, 300)
|
|
108
|
+
|
|
109
|
+
function queryOnParamsChanged() {
|
|
110
|
+
queryResult.value.total = 0;
|
|
111
|
+
queryResult.value.users = [];
|
|
112
|
+
if (pageParams.value.currentPage !== 1) {
|
|
113
|
+
pageParams.value.currentPage = 1;
|
|
114
|
+
} else {
|
|
115
|
+
debounceDoQuery();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
watch(queryParams, () => {
|
|
120
|
+
queryParamChanged.value = true;
|
|
121
|
+
queryOnParamsChanged();
|
|
122
|
+
}, {
|
|
123
|
+
deep: true
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
watch(() => pageParams.value.pageSize, () => {
|
|
127
|
+
queryParamChanged.value = true;
|
|
128
|
+
queryOnParamsChanged();
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
watch(() => pageParams.value.currentPage, () => {
|
|
132
|
+
queryUsers().then(r => {
|
|
133
|
+
if (onQueryResultReturned) {
|
|
134
|
+
onQueryResultReturned(r, queryParamChanged.value);
|
|
135
|
+
}
|
|
136
|
+
queryParamChanged.value = false;
|
|
137
|
+
});
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
async function queryUsers() {
|
|
141
|
+
if (queryPrerequisites && !queryPrerequisites()) {
|
|
142
|
+
return Promise.resolve(undefined);
|
|
143
|
+
}
|
|
144
|
+
if (!queryParams.value.realmId) {
|
|
145
|
+
const defaultRealm = await useRealms().getDefaultRealm();
|
|
146
|
+
queryParams.value.realmId = defaultRealm.id;
|
|
147
|
+
}
|
|
148
|
+
const builder = useUserQueryBuilder();
|
|
149
|
+
const qUser = builder.getQEntity();
|
|
150
|
+
builder.and(qUser.realm.id.eq(queryParams.value.realmId)).and(qUser.recycled.eq(false));
|
|
151
|
+
const currentDept = queryParams.value.currentDept;
|
|
152
|
+
if (currentDept) {
|
|
153
|
+
// 1=1 and user.department.id = currentDepartmentId
|
|
154
|
+
if (currentDept.id == NO_DEPARTMENT) {
|
|
155
|
+
builder.and(qUser.department.isNull())
|
|
156
|
+
} else if (currentDept.id !== ALL_DEPARTMENT) {
|
|
157
|
+
builder.and(qUser.department.sortPath.startWith(currentDept.sortPath));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const classificationLevel = queryParams.value.classificationLevel;
|
|
161
|
+
if (classificationLevel) {
|
|
162
|
+
builder.and(qUser.classifiedLevel.loe(classificationLevel))
|
|
163
|
+
}
|
|
164
|
+
const currentGroup = queryParams.value.currentGroup;
|
|
165
|
+
if (currentGroup) {
|
|
166
|
+
builder.and(qUser.userGroups.any().group.sortPath.startWith(currentGroup.sortPath));
|
|
167
|
+
}
|
|
168
|
+
const currentCustomGroup = queryParams.value.currentCustomGroup;
|
|
169
|
+
if (currentCustomGroup) {
|
|
170
|
+
builder.and(qUser.customGroups.any().customGroup.sortPath
|
|
171
|
+
.startWith(currentCustomGroup.sortPath));
|
|
172
|
+
}
|
|
173
|
+
const name = queryParams.value.name;
|
|
174
|
+
if (name) {
|
|
175
|
+
// and (user.username like %nameQuery% or user.fullName like %nameQuery% or user.pinYinName like %nameQuery%
|
|
176
|
+
const queryText = "%" + name.split('').join('%') + "%"
|
|
177
|
+
builder.and(qUser.username.like(queryText)
|
|
178
|
+
.or(qUser.fullName.like(queryText))
|
|
179
|
+
.or(qUser.pinYinName.like(queryText))
|
|
180
|
+
.or(qUser.mobile.like(queryText)))
|
|
181
|
+
}
|
|
182
|
+
if (customFilter) {
|
|
183
|
+
builder.and(customFilter(qUser));
|
|
184
|
+
}
|
|
185
|
+
const currentSort = queryParams.value.currentSort;
|
|
186
|
+
if (currentSort) {
|
|
187
|
+
builder.orderBy(currentSort)
|
|
188
|
+
}
|
|
189
|
+
const filter = builder.build();
|
|
190
|
+
if (notPaged) {
|
|
191
|
+
return userApi.queryUserRefs(filter).then(res => {
|
|
192
|
+
queryResult.value.users = res;
|
|
193
|
+
return res;
|
|
194
|
+
})
|
|
195
|
+
} else {
|
|
196
|
+
const currentPage = pageParams.value.currentPage - 1;
|
|
197
|
+
return userApi.queryUserRefsPaged(filter, currentPage, pageParams.value.pageSize)
|
|
198
|
+
.then(res => {
|
|
199
|
+
if (scroll && currentPage > 0) {
|
|
200
|
+
queryResult.value.users.push(...res.content);
|
|
201
|
+
} else {
|
|
202
|
+
queryResult.value.users = res.content;
|
|
203
|
+
}
|
|
204
|
+
queryResult.value.total = res.totalElements;
|
|
205
|
+
return res.content;
|
|
206
|
+
})
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
/**
|
|
212
|
+
* 查询的参数
|
|
213
|
+
*/
|
|
214
|
+
queryParams,
|
|
215
|
+
/**
|
|
216
|
+
* 分页参数
|
|
217
|
+
*/
|
|
218
|
+
pageParams,
|
|
219
|
+
/**
|
|
220
|
+
* 查询结果
|
|
221
|
+
*/
|
|
222
|
+
queryResult,
|
|
223
|
+
/**
|
|
224
|
+
* 查询方法
|
|
225
|
+
*/
|
|
226
|
+
queryUsers,
|
|
227
|
+
/**
|
|
228
|
+
* loading状态
|
|
229
|
+
*/
|
|
230
|
+
loading
|
|
231
|
+
}
|
|
232
|
+
}
|
package/packages/index.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import {type App, type Plugin} from "vue";
|
|
2
|
-
import * as components from "./components";
|
|
3
|
-
import {installDirectives} from "./directives";
|
|
4
|
-
|
|
5
|
-
export * from "./components";
|
|
6
|
-
export const AceVueUI: Plugin = {
|
|
7
|
-
install(app: App<Element>) {
|
|
8
|
-
for (const [key, comp] of Object.entries(components)) {
|
|
9
|
-
app.component(key, comp);
|
|
10
|
-
}
|
|
11
|
-
installDirectives(app)
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export * from "./hooks/useBackendValidations"
|
|
16
|
-
export * from "./hooks/useTreeData"
|
|
17
|
-
export * from "./hooks/useAppInstances"
|
|
18
|
-
export * from "./directives"
|
|
19
|
-
export * from "./hooks/useDateTimeShortCuts"
|
|
20
|
-
export * from "./components/scrollbar/utils"
|
|
21
|
-
export * from "./hooks/useBridage"
|
|
22
|
-
export * from "./hooks/useRealms"
|
|
1
|
+
import {type App, type Plugin} from "vue";
|
|
2
|
+
import * as components from "./components";
|
|
3
|
+
import {installDirectives} from "./directives";
|
|
4
|
+
|
|
5
|
+
export * from "./components";
|
|
6
|
+
export const AceVueUI: Plugin = {
|
|
7
|
+
install(app: App<Element>) {
|
|
8
|
+
for (const [key, comp] of Object.entries(components)) {
|
|
9
|
+
app.component(key, comp);
|
|
10
|
+
}
|
|
11
|
+
installDirectives(app)
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export * from "./hooks/useBackendValidations"
|
|
16
|
+
export * from "./hooks/useTreeData"
|
|
17
|
+
export * from "./hooks/useAppInstances"
|
|
18
|
+
export * from "./directives"
|
|
19
|
+
export * from "./hooks/useDateTimeShortCuts"
|
|
20
|
+
export * from "./components/scrollbar/utils"
|
|
21
|
+
export * from "./hooks/useBridage"
|