@jari-ace/element-plus-component 0.1.10 → 0.2.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.
Files changed (156) hide show
  1. package/README.md +1 -18
  2. package/dist/components/form/JaForm.vue.d.ts +0 -3
  3. package/dist/components/form/JaForm.vue.d.ts.map +1 -1
  4. package/dist/components/form/JaForm.vue.js +68 -22
  5. package/dist/components/form/JaForm.vue.js.map +1 -1
  6. package/dist/components/formItem/JaFormItem.vue.d.ts +0 -4
  7. package/dist/components/formItem/JaFormItem.vue.d.ts.map +1 -1
  8. package/dist/components/formItem/JaFormItem.vue.js +8 -26
  9. package/dist/components/formItem/JaFormItem.vue.js.map +1 -1
  10. package/dist/components/userPicker/src/UserPicker.vue.d.ts +17 -0
  11. package/dist/components/userPicker/src/UserPicker.vue.d.ts.map +1 -1
  12. package/dist/components/userPicker/src/UserPicker.vue.js +15 -0
  13. package/dist/components/userPicker/src/UserPicker.vue.js.map +1 -1
  14. package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts +17 -0
  15. package/dist/components/userSelectDialog/src/userSelectDialog.vue.d.ts.map +1 -1
  16. package/dist/components/userSelectDialog/src/userSelectDialog.vue.js +15 -0
  17. package/dist/components/userSelectDialog/src/userSelectDialog.vue.js.map +1 -1
  18. package/dist/hooks/useBackendValidations.js +0 -1
  19. package/dist/hooks/useBackendValidations.js.map +1 -1
  20. package/dist/hooks/useClassificationLevels.d.ts +21 -0
  21. package/dist/hooks/useClassificationLevels.d.ts.map +1 -0
  22. package/dist/hooks/useClassificationLevels.js +55 -0
  23. package/dist/hooks/useClassificationLevels.js.map +1 -0
  24. package/dist/hooks/useUserRefQuery.d.ts +6 -0
  25. package/dist/hooks/useUserRefQuery.d.ts.map +1 -1
  26. package/dist/hooks/useUserRefQuery.js +4 -0
  27. package/dist/hooks/useUserRefQuery.js.map +1 -1
  28. package/dist/index.d.ts +2 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +2 -0
  31. package/dist/index.js.map +1 -1
  32. package/lib/index.css +1 -1
  33. package/lib/index.js +1808 -1774
  34. package/lib/index.umd.cjs +2 -2
  35. package/package.json +61 -61
  36. package/packages/components/autoComplete/JaAutoComplete.vue +47 -47
  37. package/packages/components/autoComplete/index.ts +5 -5
  38. package/packages/components/avatar/JaAvatar.vue +126 -126
  39. package/packages/components/avatar/avatarToken.ts +11 -11
  40. package/packages/components/avatar/defaultImg.ts +14 -14
  41. package/packages/components/avatar/index.ts +7 -7
  42. package/packages/components/button/JaButton.vue +51 -51
  43. package/packages/components/button/index.ts +4 -4
  44. package/packages/components/channelPicker/index.ts +7 -7
  45. package/packages/components/channelPicker/src/ChannelPicker.vue +43 -43
  46. package/packages/components/channelPicker/src/JaChannelPicker.vue +42 -42
  47. package/packages/components/checkbox/JaCheckbox.vue +73 -73
  48. package/packages/components/checkbox/index.ts +4 -4
  49. package/packages/components/checkboxGroup/JaCheckboxGroup.vue +45 -45
  50. package/packages/components/checkboxGroup/index.ts +4 -4
  51. package/packages/components/customGroupTree/index.ts +10 -10
  52. package/packages/components/customGroupTree/src/customGroupTree.vue +91 -91
  53. package/packages/components/datePicker/JaDatePicker.vue +52 -52
  54. package/packages/components/datePicker/index.ts +4 -4
  55. package/packages/components/departmentPicker/index.ts +4 -4
  56. package/packages/components/departmentPicker/src/DepartmentPicker.vue +107 -107
  57. package/packages/components/departmentPicker/src/consts.ts +2 -2
  58. package/packages/components/departmentTree/index.ts +10 -10
  59. package/packages/components/departmentTree/src/departmentTree.vue +135 -135
  60. package/packages/components/dropdownButton/JaDropdownButton.vue +59 -59
  61. package/packages/components/dropdownButton/index.ts +4 -4
  62. package/packages/components/enumList/EnumListInput.vue +107 -107
  63. package/packages/components/enumList/JaEnumList.vue +39 -39
  64. package/packages/components/enumList/index.ts +7 -7
  65. package/packages/components/enumPicker/index.ts +5 -5
  66. package/packages/components/enumPicker/src/EnumPicker.vue +103 -103
  67. package/packages/components/form/JaForm.vue +186 -146
  68. package/packages/components/form/index.ts +5 -5
  69. package/packages/components/form/types.ts +4 -4
  70. package/packages/components/formItem/JaFormItem.vue +68 -87
  71. package/packages/components/formItem/index.ts +4 -4
  72. package/packages/components/index.ts +34 -34
  73. package/packages/components/input/JaInput.vue +143 -143
  74. package/packages/components/input/index.ts +4 -4
  75. package/packages/components/inputI18n/I18nBundleEditor.vue +76 -76
  76. package/packages/components/inputI18n/InputI18n.vue +146 -146
  77. package/packages/components/inputI18n/JaInputI18n.vue +50 -50
  78. package/packages/components/inputI18n/index.ts +8 -8
  79. package/packages/components/inputNumber/JaInputNumber.vue +98 -98
  80. package/packages/components/inputNumber/index.ts +4 -4
  81. package/packages/components/mapItemList/JaMapItemList.vue +35 -35
  82. package/packages/components/mapItemList/MapItemListInput.vue +191 -191
  83. package/packages/components/mapItemList/index.ts +7 -7
  84. package/packages/components/numberList/JaNumberList.vue +36 -36
  85. package/packages/components/numberList/NumberListInput.vue +111 -111
  86. package/packages/components/numberList/index.ts +7 -7
  87. package/packages/components/properyPicker/JaPropertyPicker.vue +38 -38
  88. package/packages/components/properyPicker/PropertyPicker.vue +314 -314
  89. package/packages/components/properyPicker/index.ts +7 -7
  90. package/packages/components/radioGroup/JaRadioGroup.vue +50 -50
  91. package/packages/components/radioGroup/index.ts +4 -4
  92. package/packages/components/rolePicker/RoleEditor.vue +129 -129
  93. package/packages/components/rolePicker/RolePicker.vue +44 -44
  94. package/packages/components/rolePicker/RolePickerRaw.vue +56 -56
  95. package/packages/components/rolePicker/baseRolePicker.vue +87 -87
  96. package/packages/components/rolePicker/index.ts +10 -10
  97. package/packages/components/scrollbar/Scrollbar.vue +89 -89
  98. package/packages/components/scrollbar/index.ts +5 -5
  99. package/packages/components/scrollbar/utils.ts +17 -17
  100. package/packages/components/select/JaSelect.vue +48 -48
  101. package/packages/components/select/index.ts +4 -4
  102. package/packages/components/stringList/JaStringList.vue +36 -36
  103. package/packages/components/stringList/StringListInput.vue +96 -96
  104. package/packages/components/stringList/index.ts +7 -7
  105. package/packages/components/switch/JaSwitch.vue +50 -50
  106. package/packages/components/switch/index.ts +4 -4
  107. package/packages/components/timePicker/JaTimePicker.vue +52 -52
  108. package/packages/components/timePicker/index.ts +5 -5
  109. package/packages/components/tip/index.ts +4 -4
  110. package/packages/components/tip/src/AceTip.vue +43 -43
  111. package/packages/components/upload/index.ts +6 -6
  112. package/packages/components/upload/src/Upload.vue +25 -25
  113. package/packages/components/upload/src/type.ts +3 -3
  114. package/packages/components/userGroupPicker/index.ts +4 -4
  115. package/packages/components/userGroupPicker/src/UserGroupPicker.vue +94 -94
  116. package/packages/components/userGroupTree/index.ts +10 -10
  117. package/packages/components/userGroupTree/src/userGroupTree.vue +149 -149
  118. package/packages/components/userPicker/index.ts +10 -10
  119. package/packages/components/userPicker/src/CustomGroupManager.vue +189 -189
  120. package/packages/components/userPicker/src/JaUserList.vue +283 -283
  121. package/packages/components/userPicker/src/JaUserPicker.vue +37 -37
  122. package/packages/components/userPicker/src/UserPicker.vue +376 -368
  123. package/packages/components/userSelectDialog/index.ts +6 -6
  124. package/packages/components/userSelectDialog/src/userSelectDialog.vue +462 -455
  125. package/packages/components/userTag/UserInfoTag.vue +397 -397
  126. package/packages/components/userTag/index.ts +6 -6
  127. package/packages/components/userTag/sharedAxios.ts +8 -8
  128. package/packages/directives/auth/index.ts +41 -41
  129. package/packages/directives/autofocus/index.ts +29 -29
  130. package/packages/directives/index.ts +10 -10
  131. package/packages/directives/shortcut/index.ts +192 -192
  132. package/packages/hooks/useAppInstances.ts +34 -34
  133. package/packages/hooks/useBackendValidations.ts +81 -81
  134. package/packages/hooks/useBridage.ts +157 -157
  135. package/packages/hooks/useClassificationLevels.ts +62 -0
  136. package/packages/hooks/useDateTimeShortCuts.ts +65 -65
  137. package/packages/hooks/useRealms.ts +28 -28
  138. package/packages/hooks/useTreeData.ts +45 -45
  139. package/packages/hooks/useUserRefQuery.ts +232 -224
  140. package/packages/index.ts +24 -22
  141. package/packages/list.json +7 -7
  142. package/packages/types/custom.d.ts +13 -13
  143. package/packages/types/window.d.ts +16 -16
  144. package/packages/utils/install.ts +43 -43
  145. package/packages/utils/objectUtils.ts +31 -31
  146. package/theme-style/fonts/iconfont.json +5196 -5196
  147. package/theme-style/index.scss +10 -10
  148. package/theme-style/styles/element-plus-var.scss +1419 -1419
  149. package/theme-style/styles/iconfont.css +2979 -2979
  150. package/theme-style/styles/theme-var.scss +72 -72
  151. package/theme-style/styles/transition.scss +122 -122
  152. package/dist/utils/formUtils.d.ts +0 -7
  153. package/dist/utils/formUtils.d.ts.map +0 -1
  154. package/dist/utils/formUtils.js +0 -54
  155. package/dist/utils/formUtils.js.map +0 -1
  156. 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
- const pageParams = ref<{
62
- /**
63
- * 当前页码
64
- */
65
- currentPage: number,
66
- /**
67
- * 页内数据行数
68
- */
69
- pageSize: number
70
- }>({
71
- currentPage: 1,
72
- pageSize: 50
73
- })
74
-
75
- const queryResult = ref<{
76
- /**
77
- * 总数据量
78
- */
79
- total: number,
80
- /**
81
- * 查询结果集
82
- */
83
- users: UserReference[]
84
- }>({
85
- total: 0,
86
- users: []
87
- })
88
-
89
- if (!axios) axios = createAxiosWithoutCache();
90
- const userApi = useUserApi(axios);
91
- const loading = useLoading(axios);
92
- const queryParamChanged = ref<boolean>(false)
93
-
94
- function doQuery() {
95
- queryUsers().then(r => {
96
- if (onQueryResultReturned) {
97
- onQueryResultReturned(r, queryParamChanged.value);
98
- }
99
- queryParamChanged.value = false;
100
- })
101
- }
102
-
103
- const debounceDoQuery = debounce(doQuery, 300)
104
-
105
- function queryOnParamsChanged() {
106
- queryResult.value.total = 0;
107
- queryResult.value.users = [];
108
- if (pageParams.value.currentPage !== 1) {
109
- pageParams.value.currentPage = 1;
110
- } else {
111
- debounceDoQuery();
112
- }
113
- }
114
-
115
- watch(queryParams, () => {
116
- queryParamChanged.value = true;
117
- queryOnParamsChanged();
118
- }, {
119
- deep: true
120
- })
121
-
122
- watch(() => pageParams.value.pageSize, () => {
123
- queryParamChanged.value = true;
124
- queryOnParamsChanged();
125
- })
126
-
127
- watch(() => pageParams.value.currentPage, () => {
128
- queryUsers().then(r => {
129
- if (onQueryResultReturned) {
130
- onQueryResultReturned(r, queryParamChanged.value);
131
- }
132
- queryParamChanged.value = false;
133
- });
134
- })
135
-
136
- async function queryUsers() {
137
- if (queryPrerequisites && !queryPrerequisites()) {
138
- return Promise.resolve(undefined);
139
- }
140
- if (!queryParams.value.realmId) {
141
- const defaultRealm = await useRealms().getDefaultRealm();
142
- queryParams.value.realmId = defaultRealm.id;
143
- }
144
- const builder = useUserQueryBuilder();
145
- const qUser = builder.getQEntity();
146
- builder.and(qUser.realm.id.eq(queryParams.value.realmId)).and(qUser.recycled.eq(false));
147
- const currentDept = queryParams.value.currentDept;
148
- if (currentDept) {
149
- // 1=1 and user.department.id = currentDepartmentId
150
- if (currentDept.id == NO_DEPARTMENT) {
151
- builder.and(qUser.department.isNull())
152
- } else if (currentDept.id !== ALL_DEPARTMENT) {
153
- builder.and(qUser.department.sortPath.startWith(currentDept.sortPath));
154
- }
155
- }
156
- const currentGroup = queryParams.value.currentGroup;
157
- if (currentGroup) {
158
- builder.and(qUser.userGroups.any().group.sortPath.startWith(currentGroup.sortPath));
159
- }
160
- const currentCustomGroup = queryParams.value.currentCustomGroup;
161
- if (currentCustomGroup) {
162
- builder.and(qUser.customGroups.any().customGroup.sortPath
163
- .startWith(currentCustomGroup.sortPath));
164
- }
165
- const name = queryParams.value.name;
166
- if (name) {
167
- // and (user.username like %nameQuery% or user.fullName like %nameQuery% or user.pinYinName like %nameQuery%
168
- const queryText = "%" + name.split('').join('%') + "%"
169
- builder.and(qUser.username.like(queryText)
170
- .or(qUser.fullName.like(queryText))
171
- .or(qUser.pinYinName.like(queryText))
172
- .or(qUser.mobile.like(queryText)))
173
- }
174
- if (customFilter) {
175
- builder.and(customFilter(qUser));
176
- }
177
- const currentSort = queryParams.value.currentSort;
178
- if (currentSort) {
179
- builder.orderBy(currentSort)
180
- }
181
- const filter = builder.build();
182
- if (notPaged) {
183
- return userApi.queryUserRefs(filter).then(res => {
184
- queryResult.value.users = res;
185
- return res;
186
- })
187
- } else {
188
- const currentPage = pageParams.value.currentPage - 1;
189
- return userApi.queryUserRefsPaged(filter, currentPage, pageParams.value.pageSize)
190
- .then(res => {
191
- if (scroll && currentPage > 0) {
192
- queryResult.value.users.push(...res.content);
193
- } else {
194
- queryResult.value.users = res.content;
195
- }
196
- queryResult.value.total = res.totalElements;
197
- return res.content;
198
- })
199
- }
200
- }
201
-
202
- return {
203
- /**
204
- * 查询的参数
205
- */
206
- queryParams,
207
- /**
208
- * 分页参数
209
- */
210
- pageParams,
211
- /**
212
- * 查询结果
213
- */
214
- queryResult,
215
- /**
216
- * 查询方法
217
- */
218
- queryUsers,
219
- /**
220
- * loading状态
221
- */
222
- loading
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,24 @@
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"
22
+ export * from "./hooks/useRealms"
23
+ export * from "./hooks/useUserRefQuery"
24
+ export * from "./hooks/useClassificationLevels"