@jari-ace/element-plus-component 0.1.0 → 0.1.6

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 (148) hide show
  1. package/README.md +18 -18
  2. package/dist/components/enumPicker/index.d.ts +4 -0
  3. package/dist/components/enumPicker/index.d.ts.map +1 -0
  4. package/dist/components/enumPicker/index.js +4 -0
  5. package/dist/components/enumPicker/index.js.map +1 -0
  6. package/dist/components/enumPicker/src/EnumPicker.vue.d.ts +29 -0
  7. package/dist/components/enumPicker/src/EnumPicker.vue.d.ts.map +1 -0
  8. package/dist/components/enumPicker/src/EnumPicker.vue.js +140 -0
  9. package/dist/components/enumPicker/src/EnumPicker.vue.js.map +1 -0
  10. package/dist/components/form/JaForm.vue.d.ts +23 -126
  11. package/dist/components/form/JaForm.vue.d.ts.map +1 -1
  12. package/dist/components/form/JaForm.vue.js +127 -192
  13. package/dist/components/form/JaForm.vue.js.map +1 -1
  14. package/dist/components/formItem/JaFormItem.vue.d.ts +12 -12
  15. package/dist/components/index.d.ts +1 -0
  16. package/dist/components/index.d.ts.map +1 -1
  17. package/dist/components/index.js +1 -0
  18. package/dist/components/index.js.map +1 -1
  19. package/dist/components/rolePicker/baseRolePicker.vue.d.ts.map +1 -1
  20. package/dist/components/rolePicker/baseRolePicker.vue.js +1 -0
  21. package/dist/components/rolePicker/baseRolePicker.vue.js.map +1 -1
  22. package/dist/components/userTag/UserInfoTag.vue.d.ts +1 -1
  23. package/dist/hooks/useBackendValidations.d.ts +7 -1
  24. package/dist/hooks/useBackendValidations.d.ts.map +1 -1
  25. package/dist/hooks/useBackendValidations.js +21 -2
  26. package/dist/hooks/useBackendValidations.js.map +1 -1
  27. package/dist/hooks/useBridage.d.ts +3 -3
  28. package/dist/hooks/useBridage.d.ts.map +1 -1
  29. package/dist/hooks/useBridage.js +29 -22
  30. package/dist/hooks/useBridage.js.map +1 -1
  31. package/lib/index.css +1 -1
  32. package/lib/index.js +1437 -1283
  33. package/lib/index.umd.cjs +2 -2
  34. package/package.json +61 -61
  35. package/packages/components/autoComplete/JaAutoComplete.vue +47 -47
  36. package/packages/components/autoComplete/index.ts +5 -5
  37. package/packages/components/avatar/JaAvatar.vue +126 -126
  38. package/packages/components/avatar/avatarToken.ts +11 -11
  39. package/packages/components/avatar/defaultImg.ts +14 -14
  40. package/packages/components/avatar/index.ts +7 -7
  41. package/packages/components/button/JaButton.vue +51 -51
  42. package/packages/components/button/index.ts +4 -4
  43. package/packages/components/channelPicker/index.ts +7 -7
  44. package/packages/components/channelPicker/src/ChannelPicker.vue +43 -43
  45. package/packages/components/channelPicker/src/JaChannelPicker.vue +42 -42
  46. package/packages/components/checkbox/JaCheckbox.vue +73 -73
  47. package/packages/components/checkbox/index.ts +4 -4
  48. package/packages/components/checkboxGroup/JaCheckboxGroup.vue +45 -45
  49. package/packages/components/checkboxGroup/index.ts +4 -4
  50. package/packages/components/customGroupTree/index.ts +10 -10
  51. package/packages/components/customGroupTree/src/customGroupTree.vue +91 -91
  52. package/packages/components/datePicker/JaDatePicker.vue +52 -52
  53. package/packages/components/datePicker/index.ts +4 -4
  54. package/packages/components/departmentPicker/index.ts +4 -4
  55. package/packages/components/departmentPicker/src/DepartmentPicker.vue +107 -107
  56. package/packages/components/departmentPicker/src/consts.ts +2 -2
  57. package/packages/components/departmentTree/index.ts +10 -10
  58. package/packages/components/departmentTree/src/departmentTree.vue +135 -135
  59. package/packages/components/dropdownButton/JaDropdownButton.vue +59 -59
  60. package/packages/components/dropdownButton/index.ts +4 -4
  61. package/packages/components/enumList/EnumListInput.vue +107 -107
  62. package/packages/components/enumList/JaEnumList.vue +39 -39
  63. package/packages/components/enumList/index.ts +7 -7
  64. package/packages/components/enumPicker/index.ts +5 -0
  65. package/packages/components/enumPicker/src/EnumPicker.vue +103 -0
  66. package/packages/components/form/JaForm.vue +186 -126
  67. package/packages/components/form/index.ts +5 -5
  68. package/packages/components/form/types.ts +4 -4
  69. package/packages/components/formItem/JaFormItem.vue +68 -68
  70. package/packages/components/formItem/index.ts +4 -4
  71. package/packages/components/index.ts +34 -33
  72. package/packages/components/input/JaInput.vue +143 -143
  73. package/packages/components/input/index.ts +4 -4
  74. package/packages/components/inputI18n/I18nBundleEditor.vue +76 -76
  75. package/packages/components/inputI18n/InputI18n.vue +142 -142
  76. package/packages/components/inputI18n/JaInputI18n.vue +50 -50
  77. package/packages/components/inputI18n/index.ts +8 -8
  78. package/packages/components/inputNumber/JaInputNumber.vue +98 -98
  79. package/packages/components/inputNumber/index.ts +4 -4
  80. package/packages/components/mapItemList/JaMapItemList.vue +35 -35
  81. package/packages/components/mapItemList/MapItemListInput.vue +191 -191
  82. package/packages/components/mapItemList/index.ts +7 -7
  83. package/packages/components/numberList/JaNumberList.vue +36 -36
  84. package/packages/components/numberList/NumberListInput.vue +111 -111
  85. package/packages/components/numberList/index.ts +7 -7
  86. package/packages/components/properyPicker/JaPropertyPicker.vue +38 -38
  87. package/packages/components/properyPicker/PropertyPicker.vue +314 -314
  88. package/packages/components/properyPicker/index.ts +7 -7
  89. package/packages/components/radioGroup/JaRadioGroup.vue +50 -50
  90. package/packages/components/radioGroup/index.ts +4 -4
  91. package/packages/components/rolePicker/RoleEditor.vue +129 -129
  92. package/packages/components/rolePicker/RolePicker.vue +44 -44
  93. package/packages/components/rolePicker/RolePickerRaw.vue +56 -56
  94. package/packages/components/rolePicker/baseRolePicker.vue +87 -86
  95. package/packages/components/rolePicker/index.ts +10 -10
  96. package/packages/components/scrollbar/Scrollbar.vue +89 -89
  97. package/packages/components/scrollbar/index.ts +5 -5
  98. package/packages/components/scrollbar/utils.ts +17 -17
  99. package/packages/components/select/JaSelect.vue +48 -48
  100. package/packages/components/select/index.ts +4 -4
  101. package/packages/components/stringList/JaStringList.vue +36 -36
  102. package/packages/components/stringList/StringListInput.vue +96 -96
  103. package/packages/components/stringList/index.ts +7 -7
  104. package/packages/components/switch/JaSwitch.vue +50 -50
  105. package/packages/components/switch/index.ts +4 -4
  106. package/packages/components/timePicker/JaTimePicker.vue +52 -52
  107. package/packages/components/timePicker/index.ts +5 -5
  108. package/packages/components/tip/index.ts +4 -4
  109. package/packages/components/tip/src/AceTip.vue +43 -43
  110. package/packages/components/upload/index.ts +6 -6
  111. package/packages/components/upload/src/Upload.vue +25 -25
  112. package/packages/components/upload/src/type.ts +3 -3
  113. package/packages/components/userGroupPicker/index.ts +4 -4
  114. package/packages/components/userGroupPicker/src/UserGroupPicker.vue +94 -94
  115. package/packages/components/userGroupTree/index.ts +10 -10
  116. package/packages/components/userGroupTree/src/userGroupTree.vue +149 -149
  117. package/packages/components/userPicker/index.ts +10 -10
  118. package/packages/components/userPicker/src/CustomGroupManager.vue +189 -189
  119. package/packages/components/userPicker/src/JaUserList.vue +283 -283
  120. package/packages/components/userPicker/src/JaUserPicker.vue +37 -37
  121. package/packages/components/userPicker/src/UserPicker.vue +366 -366
  122. package/packages/components/userSelectDialog/index.ts +6 -6
  123. package/packages/components/userSelectDialog/src/userSelectDialog.vue +447 -447
  124. package/packages/components/userTag/UserInfoTag.vue +397 -397
  125. package/packages/components/userTag/index.ts +6 -6
  126. package/packages/components/userTag/sharedAxios.ts +8 -8
  127. package/packages/directives/auth/index.ts +41 -41
  128. package/packages/directives/autofocus/index.ts +29 -29
  129. package/packages/directives/index.ts +10 -10
  130. package/packages/directives/shortcut/index.ts +192 -192
  131. package/packages/hooks/useAppInstances.ts +34 -34
  132. package/packages/hooks/useBackendValidations.ts +34 -8
  133. package/packages/hooks/useBridage.ts +157 -148
  134. package/packages/hooks/useDateTimeShortCuts.ts +65 -65
  135. package/packages/hooks/useTreeData.ts +45 -45
  136. package/packages/hooks/useUserRefQuery.ts +222 -222
  137. package/packages/index.ts +21 -21
  138. package/packages/list.json +7 -7
  139. package/packages/types/custom.d.ts +13 -13
  140. package/packages/types/window.d.ts +16 -16
  141. package/packages/utils/install.ts +43 -43
  142. package/packages/utils/objectUtils.ts +31 -31
  143. package/theme-style/fonts/iconfont.json +5196 -5196
  144. package/theme-style/index.scss +10 -10
  145. package/theme-style/styles/element-plus-var.scss +1419 -1419
  146. package/theme-style/styles/iconfont.css +2979 -2979
  147. package/theme-style/styles/theme-var.scss +72 -72
  148. package/theme-style/styles/transition.scss +122 -122
@@ -1,283 +1,283 @@
1
- <script setup lang="ts">
2
-
3
- import {ElEmpty, ElIcon, ElScrollbar, vLoading} from "element-plus";
4
- import {Check} from "@element-plus/icons-vue";
5
- import {JaUserInfoTag} from "../../userTag";
6
- import {computed, nextTick, onUnmounted, ref, watch} from "vue";
7
- import type {UserReference} from "@jari-ace/app-bolts";
8
- import throttle from "lodash-es/throttle";
9
-
10
- const props = defineProps<{
11
- emptyText: string,
12
- multiple?: boolean,
13
- total: number,
14
- pageSize: number,
15
- height?: number | string,
16
- loading: boolean,
17
- users: UserReference[]
18
- }>();
19
- const activeIndex = ref(0);
20
- const scrollbar = ref<InstanceType<typeof ElScrollbar>>();
21
- const tolerance = 1;
22
- const isDragSelecting = ref(false);
23
- const selectedUsers = defineModel<UserReference[] | UserReference | null>({
24
- required: true
25
- });
26
- const page = defineModel<number>("page", {
27
- required: true
28
- })
29
- const emits = defineEmits(["arrowKeyDown", "itemClicked"]);
30
- const handleScroll = () => {
31
- const scrollElement = scrollbar.value?.wrapRef;
32
- if (scrollElement) {
33
- const isBottom = scrollElement.scrollHeight - scrollElement.scrollTop
34
- <= scrollElement.clientHeight + tolerance;
35
-
36
- if (isBottom) {
37
- if (page.value < props.total / props.pageSize) {
38
- page.value++;
39
- }
40
- // 在这里执行事件方法
41
- }
42
- }
43
- };
44
- const throttleScroll = throttle(handleScroll, 200);
45
-
46
- function switchUserSelect(u: UserReference) {
47
- if (props.multiple) {
48
- if (!Array.isArray(selectedUsers.value)) {
49
- throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
50
- }
51
- const index = selectedUsers.value.findIndex(su => su.id == u.id);
52
- if (index < 0) {
53
- selectedUsers.value.push(u);
54
- } else {
55
- selectedUsers.value.splice(index, 1);
56
- }
57
- } else {
58
- selectedUsers.value = u;
59
- }
60
- }
61
-
62
- let clickedUser: UserReference;
63
-
64
- function onMouseDown(u: UserReference) {
65
- switchUserSelect(u)
66
- isDragSelecting.value = true;
67
- clickedUser = u;
68
- }
69
-
70
- function onMouseUp() {
71
- isDragSelecting.value = false;
72
- emits("itemClicked", clickedUser);
73
- clickedUser = undefined;
74
- }
75
-
76
- function onMouseEnter(u: UserReference) {
77
- if (isDragSelecting.value) {
78
- switchUserSelect(u);
79
- }
80
- }
81
-
82
- function onInputArrowDown() {
83
- if (activeIndex.value < props.users.length - 1) {
84
- activeIndex.value++;
85
- }
86
- scrollToActive();
87
- }
88
-
89
- function onInputArrowUp() {
90
- if (activeIndex.value > 0) {
91
- activeIndex.value--;
92
- }
93
- scrollToActive();
94
- }
95
-
96
- const scrollToActive = () => {
97
- nextTick(() => {
98
- const scrollWrapper = scrollbar.value?.$refs.wrapRef as HTMLElement;
99
- const activeItem = scrollWrapper?.querySelectorAll('li')[activeIndex.value] as HTMLElement;
100
- if (activeItem && scrollWrapper) {
101
- const itemTop = (
102
- activeItem as HTMLElement
103
- ).offsetTop;
104
- const itemBottom = activeItem.offsetTop + activeItem.offsetHeight;
105
- const visibleTop = scrollWrapper.scrollTop;
106
- const visibleBottom = scrollWrapper.scrollTop + scrollWrapper.clientHeight;
107
- if (itemBottom > visibleBottom) {
108
- scrollbar.value?.scrollTo(0,
109
- itemBottom - scrollWrapper.clientHeight + activeItem.offsetHeight - 38);
110
- } else if (itemTop < visibleTop) {
111
- scrollbar.value?.scrollTo(0, itemTop);
112
- }
113
- }
114
- });
115
- };
116
-
117
- const throttleDown = throttle(onInputArrowDown, 100);
118
- const throttleUp = throttle(onInputArrowUp, 100);
119
-
120
- function onMouseOver(event: MouseEvent, index: number) {
121
- activeIndex.value = index
122
- isDragSelecting.value = event.buttons > 0;
123
- if (isDragSelecting.value) {
124
- const scrollWrapper = scrollbar.value?.$refs.wrapRef as HTMLElement;
125
- const activeItem = event.target as HTMLElement;
126
- if (activeItem && scrollWrapper) {
127
- const itemTop = (
128
- activeItem as HTMLElement
129
- ).offsetTop;
130
- const itemBottom = activeItem.offsetTop + activeItem.offsetHeight;
131
- const visibleTop = scrollWrapper.scrollTop;
132
- const visibleBottom = scrollWrapper.scrollTop + scrollWrapper.clientHeight;
133
- if (itemBottom + 20 > visibleBottom) {
134
- throttleDown();
135
- } else if (itemTop < visibleTop + 20) {
136
- throttleUp();
137
- }
138
- }
139
- }
140
- }
141
-
142
- function userSelected(u: UserReference) {
143
- return selectedForBinding.value.some(su => su.id === u.id);
144
- }
145
-
146
- const userTagTheme = (u: UserReference) => {
147
- if (selectedForBinding.value.some(su => su.id === u.id)) {
148
- return "autumnOrange"
149
- } else {
150
- return "skyGray"
151
- }
152
- }
153
-
154
- const selectedForBinding = computed(() => {
155
- if (props.multiple && Array.isArray(selectedUsers.value)) {
156
- return selectedUsers.value;
157
- } else if (!props.multiple && !Array.isArray(selectedUsers.value)) {
158
- if (selectedUsers.value) {
159
- return [selectedUsers.value as UserReference];
160
- } else {
161
- return [] as UserReference[];
162
- }
163
- } else {
164
- throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
165
- }
166
- })
167
-
168
- function getUserItemClass(index: number) {
169
- return index === activeIndex.value ? "active" : "";
170
- }
171
-
172
- const listLoading = computed(() => props.loading && props.users.length == 0);
173
-
174
- defineExpose({
175
- scrollUp() {
176
- onInputArrowUp();
177
- },
178
- scrollDown() {
179
- onInputArrowDown();
180
- },
181
- activeIndex
182
- })
183
-
184
- watch(() => props.users, () => {
185
- activeIndex.value = 0;
186
- }, {
187
- deep: false
188
- })
189
-
190
- onUnmounted(() => {
191
- throttleDown.cancel()
192
- throttleUp.cancel()
193
- throttleScroll.cancel()
194
- })
195
- </script>
196
-
197
- <template>
198
- <div class="ja-user-list">
199
- <el-scrollbar :height="height" ref="scrollbar" always
200
- @scroll="throttleScroll" v-loading="listLoading">
201
- <ul v-if="users.length > 0"
202
- @mouseup="onMouseUp">
203
- <li v-for="(u, index) in users" :key="u.id"
204
- :class="getUserItemClass(index)"
205
- @mouseenter="isDragSelecting && onMouseEnter(u)"
206
- @mousedown="onMouseDown(u)"
207
- @mouseover="onMouseOver($event, index)">
208
- <el-icon color="#0D6A9F">
209
- <Check v-if="userSelected(u)"/>
210
- </el-icon>
211
- <ja-user-info-tag :user-id="u.id" :full-name="u.fullName"
212
- :has-avatar="u.hasAvatar"
213
- placement="left-start"
214
- :theme="userTagTheme(u)"></ja-user-info-tag>
215
- </li>
216
- </ul>
217
- <el-empty v-else
218
- :description="emptyText"></el-empty>
219
- </el-scrollbar>
220
- <div class="page-indicator"
221
- v-if="users.length > 0">
222
- <div class="nb-spinner" v-show="loading"></div>
223
- 已加载
224
- {{ page }}
225
- /{{ Math.ceil(total / pageSize) }}页
226
- </div>
227
- </div>
228
- </template>
229
-
230
- <style scoped lang="scss">
231
- .ja-user-list {
232
- user-select: none;
233
- position: relative;
234
- overflow: hidden;
235
-
236
- ul {
237
- padding: 0;
238
- margin: 0;
239
-
240
- li {
241
- height: 38px;
242
- display: flex;
243
- align-items: center;
244
- gap: 4px;
245
-
246
- &.active {
247
- background-color: var(--el-color-primary-light-9);
248
- }
249
- }
250
- }
251
-
252
- .page-indicator {
253
- position: absolute;
254
- right: 20px;
255
- bottom: 12px;
256
- color: var(--el-color-info-light-5);
257
- display: flex;
258
- align-items: center;
259
- gap: 4px;
260
-
261
- .nb-spinner {
262
- width: 16px;
263
- height: 16px;
264
- border-radius: 50%;
265
- background-color: transparent;
266
- display: inline-block;
267
- border: 2px solid #ccc;
268
- border-top-color: #009688;
269
- animation: 1s spin linear infinite;
270
- }
271
-
272
- @keyframes spin {
273
- from {
274
- transform: rotate(0deg);
275
- }
276
- to {
277
- transform: rotate(360deg);
278
- }
279
- }
280
- }
281
- }
282
-
283
- </style>
1
+ <script setup lang="ts">
2
+
3
+ import {ElEmpty, ElIcon, ElScrollbar, vLoading} from "element-plus";
4
+ import {Check} from "@element-plus/icons-vue";
5
+ import {JaUserInfoTag} from "../../userTag";
6
+ import {computed, nextTick, onUnmounted, ref, watch} from "vue";
7
+ import type {UserReference} from "@jari-ace/app-bolts";
8
+ import throttle from "lodash-es/throttle";
9
+
10
+ const props = defineProps<{
11
+ emptyText: string,
12
+ multiple?: boolean,
13
+ total: number,
14
+ pageSize: number,
15
+ height?: number | string,
16
+ loading: boolean,
17
+ users: UserReference[]
18
+ }>();
19
+ const activeIndex = ref(0);
20
+ const scrollbar = ref<InstanceType<typeof ElScrollbar>>();
21
+ const tolerance = 1;
22
+ const isDragSelecting = ref(false);
23
+ const selectedUsers = defineModel<UserReference[] | UserReference | null>({
24
+ required: true
25
+ });
26
+ const page = defineModel<number>("page", {
27
+ required: true
28
+ })
29
+ const emits = defineEmits(["arrowKeyDown", "itemClicked"]);
30
+ const handleScroll = () => {
31
+ const scrollElement = scrollbar.value?.wrapRef;
32
+ if (scrollElement) {
33
+ const isBottom = scrollElement.scrollHeight - scrollElement.scrollTop
34
+ <= scrollElement.clientHeight + tolerance;
35
+
36
+ if (isBottom) {
37
+ if (page.value < props.total / props.pageSize) {
38
+ page.value++;
39
+ }
40
+ // 在这里执行事件方法
41
+ }
42
+ }
43
+ };
44
+ const throttleScroll = throttle(handleScroll, 200);
45
+
46
+ function switchUserSelect(u: UserReference) {
47
+ if (props.multiple) {
48
+ if (!Array.isArray(selectedUsers.value)) {
49
+ throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
50
+ }
51
+ const index = selectedUsers.value.findIndex(su => su.id == u.id);
52
+ if (index < 0) {
53
+ selectedUsers.value.push(u);
54
+ } else {
55
+ selectedUsers.value.splice(index, 1);
56
+ }
57
+ } else {
58
+ selectedUsers.value = u;
59
+ }
60
+ }
61
+
62
+ let clickedUser: UserReference;
63
+
64
+ function onMouseDown(u: UserReference) {
65
+ switchUserSelect(u)
66
+ isDragSelecting.value = true;
67
+ clickedUser = u;
68
+ }
69
+
70
+ function onMouseUp() {
71
+ isDragSelecting.value = false;
72
+ emits("itemClicked", clickedUser);
73
+ clickedUser = undefined;
74
+ }
75
+
76
+ function onMouseEnter(u: UserReference) {
77
+ if (isDragSelecting.value) {
78
+ switchUserSelect(u);
79
+ }
80
+ }
81
+
82
+ function onInputArrowDown() {
83
+ if (activeIndex.value < props.users.length - 1) {
84
+ activeIndex.value++;
85
+ }
86
+ scrollToActive();
87
+ }
88
+
89
+ function onInputArrowUp() {
90
+ if (activeIndex.value > 0) {
91
+ activeIndex.value--;
92
+ }
93
+ scrollToActive();
94
+ }
95
+
96
+ const scrollToActive = () => {
97
+ nextTick(() => {
98
+ const scrollWrapper = scrollbar.value?.$refs.wrapRef as HTMLElement;
99
+ const activeItem = scrollWrapper?.querySelectorAll('li')[activeIndex.value] as HTMLElement;
100
+ if (activeItem && scrollWrapper) {
101
+ const itemTop = (
102
+ activeItem as HTMLElement
103
+ ).offsetTop;
104
+ const itemBottom = activeItem.offsetTop + activeItem.offsetHeight;
105
+ const visibleTop = scrollWrapper.scrollTop;
106
+ const visibleBottom = scrollWrapper.scrollTop + scrollWrapper.clientHeight;
107
+ if (itemBottom > visibleBottom) {
108
+ scrollbar.value?.scrollTo(0,
109
+ itemBottom - scrollWrapper.clientHeight + activeItem.offsetHeight - 38);
110
+ } else if (itemTop < visibleTop) {
111
+ scrollbar.value?.scrollTo(0, itemTop);
112
+ }
113
+ }
114
+ });
115
+ };
116
+
117
+ const throttleDown = throttle(onInputArrowDown, 100);
118
+ const throttleUp = throttle(onInputArrowUp, 100);
119
+
120
+ function onMouseOver(event: MouseEvent, index: number) {
121
+ activeIndex.value = index
122
+ isDragSelecting.value = event.buttons > 0;
123
+ if (isDragSelecting.value) {
124
+ const scrollWrapper = scrollbar.value?.$refs.wrapRef as HTMLElement;
125
+ const activeItem = event.target as HTMLElement;
126
+ if (activeItem && scrollWrapper) {
127
+ const itemTop = (
128
+ activeItem as HTMLElement
129
+ ).offsetTop;
130
+ const itemBottom = activeItem.offsetTop + activeItem.offsetHeight;
131
+ const visibleTop = scrollWrapper.scrollTop;
132
+ const visibleBottom = scrollWrapper.scrollTop + scrollWrapper.clientHeight;
133
+ if (itemBottom + 20 > visibleBottom) {
134
+ throttleDown();
135
+ } else if (itemTop < visibleTop + 20) {
136
+ throttleUp();
137
+ }
138
+ }
139
+ }
140
+ }
141
+
142
+ function userSelected(u: UserReference) {
143
+ return selectedForBinding.value.some(su => su.id === u.id);
144
+ }
145
+
146
+ const userTagTheme = (u: UserReference) => {
147
+ if (selectedForBinding.value.some(su => su.id === u.id)) {
148
+ return "autumnOrange"
149
+ } else {
150
+ return "skyGray"
151
+ }
152
+ }
153
+
154
+ const selectedForBinding = computed(() => {
155
+ if (props.multiple && Array.isArray(selectedUsers.value)) {
156
+ return selectedUsers.value;
157
+ } else if (!props.multiple && !Array.isArray(selectedUsers.value)) {
158
+ if (selectedUsers.value) {
159
+ return [selectedUsers.value as UserReference];
160
+ } else {
161
+ return [] as UserReference[];
162
+ }
163
+ } else {
164
+ throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
165
+ }
166
+ })
167
+
168
+ function getUserItemClass(index: number) {
169
+ return index === activeIndex.value ? "active" : "";
170
+ }
171
+
172
+ const listLoading = computed(() => props.loading && props.users.length == 0);
173
+
174
+ defineExpose({
175
+ scrollUp() {
176
+ onInputArrowUp();
177
+ },
178
+ scrollDown() {
179
+ onInputArrowDown();
180
+ },
181
+ activeIndex
182
+ })
183
+
184
+ watch(() => props.users, () => {
185
+ activeIndex.value = 0;
186
+ }, {
187
+ deep: false
188
+ })
189
+
190
+ onUnmounted(() => {
191
+ throttleDown.cancel()
192
+ throttleUp.cancel()
193
+ throttleScroll.cancel()
194
+ })
195
+ </script>
196
+
197
+ <template>
198
+ <div class="ja-user-list">
199
+ <el-scrollbar :height="height" ref="scrollbar" always
200
+ @scroll="throttleScroll" v-loading="listLoading">
201
+ <ul v-if="users.length > 0"
202
+ @mouseup="onMouseUp">
203
+ <li v-for="(u, index) in users" :key="u.id"
204
+ :class="getUserItemClass(index)"
205
+ @mouseenter="isDragSelecting && onMouseEnter(u)"
206
+ @mousedown="onMouseDown(u)"
207
+ @mouseover="onMouseOver($event, index)">
208
+ <el-icon color="#0D6A9F">
209
+ <Check v-if="userSelected(u)"/>
210
+ </el-icon>
211
+ <ja-user-info-tag :user-id="u.id" :full-name="u.fullName"
212
+ :has-avatar="u.hasAvatar"
213
+ placement="left-start"
214
+ :theme="userTagTheme(u)"></ja-user-info-tag>
215
+ </li>
216
+ </ul>
217
+ <el-empty v-else
218
+ :description="emptyText"></el-empty>
219
+ </el-scrollbar>
220
+ <div class="page-indicator"
221
+ v-if="users.length > 0">
222
+ <div class="nb-spinner" v-show="loading"></div>
223
+ 已加载
224
+ {{ page }}
225
+ /{{ Math.ceil(total / pageSize) }}页
226
+ </div>
227
+ </div>
228
+ </template>
229
+
230
+ <style scoped lang="scss">
231
+ .ja-user-list {
232
+ user-select: none;
233
+ position: relative;
234
+ overflow: hidden;
235
+
236
+ ul {
237
+ padding: 0;
238
+ margin: 0;
239
+
240
+ li {
241
+ height: 38px;
242
+ display: flex;
243
+ align-items: center;
244
+ gap: 4px;
245
+
246
+ &.active {
247
+ background-color: var(--el-color-primary-light-9);
248
+ }
249
+ }
250
+ }
251
+
252
+ .page-indicator {
253
+ position: absolute;
254
+ right: 20px;
255
+ bottom: 12px;
256
+ color: var(--el-color-info-light-5);
257
+ display: flex;
258
+ align-items: center;
259
+ gap: 4px;
260
+
261
+ .nb-spinner {
262
+ width: 16px;
263
+ height: 16px;
264
+ border-radius: 50%;
265
+ background-color: transparent;
266
+ display: inline-block;
267
+ border: 2px solid #ccc;
268
+ border-top-color: #009688;
269
+ animation: 1s spin linear infinite;
270
+ }
271
+
272
+ @keyframes spin {
273
+ from {
274
+ transform: rotate(0deg);
275
+ }
276
+ to {
277
+ transform: rotate(360deg);
278
+ }
279
+ }
280
+ }
281
+ }
282
+
283
+ </style>
@@ -1,37 +1,37 @@
1
- <script setup lang="ts">
2
- import UserPicker from "./UserPicker.vue";
3
- import {inject, watch, ref} from "vue";
4
- import {getValue, setValue} from "../../../utils/objectUtils";
5
- import type {ValidationInstance} from "../../../hooks/useBackendValidations";
6
- import type {UserReference} from "@jari-ace/app-bolts";
7
-
8
- const model = inject('aceFormModel') as Record<string, never>
9
- const prop = inject('aceFormItemProp') as string
10
- const validator = inject('aceFormValidator') as ValidationInstance
11
- const emit = defineEmits<{
12
- change: [value: UserReference[]]
13
- }>()
14
-
15
- function onChange(value: UserReference[]) {
16
- validator.removeFieldError(prop)
17
- setValue(model.formData, prop, mv.value);
18
- emit('change', value)
19
- }
20
-
21
- const mv = ref(getValue(model.formData, prop) as UserReference[] ?? []);
22
- watch(() => model.formData, () => {
23
- mv.value = getValue(model.formData, prop) as UserReference[] ?? []
24
- }, {
25
- deep: true
26
- })
27
- </script>
28
-
29
- <template>
30
- <user-picker v-model="mv"
31
- @change="onChange"
32
- v-bind="$attrs"/>
33
- </template>
34
-
35
- <style scoped lang="scss">
36
-
37
- </style>
1
+ <script setup lang="ts">
2
+ import UserPicker from "./UserPicker.vue";
3
+ import {inject, watch, ref} from "vue";
4
+ import {getValue, setValue} from "../../../utils/objectUtils";
5
+ import type {ValidationInstance} from "../../../hooks/useBackendValidations";
6
+ import type {UserReference} from "@jari-ace/app-bolts";
7
+
8
+ const model = inject('aceFormModel') as Record<string, never>
9
+ const prop = inject('aceFormItemProp') as string
10
+ const validator = inject('aceFormValidator') as ValidationInstance
11
+ const emit = defineEmits<{
12
+ change: [value: UserReference[]]
13
+ }>()
14
+
15
+ function onChange(value: UserReference[]) {
16
+ validator.removeFieldError(prop)
17
+ setValue(model.formData, prop, mv.value);
18
+ emit('change', value)
19
+ }
20
+
21
+ const mv = ref(getValue(model.formData, prop) as UserReference[] ?? []);
22
+ watch(() => model.formData, () => {
23
+ mv.value = getValue(model.formData, prop) as UserReference[] ?? []
24
+ }, {
25
+ deep: true
26
+ })
27
+ </script>
28
+
29
+ <template>
30
+ <user-picker v-model="mv"
31
+ @change="onChange"
32
+ v-bind="$attrs"/>
33
+ </template>
34
+
35
+ <style scoped lang="scss">
36
+
37
+ </style>