@jari-ace/element-plus-component 0.1.0 → 0.1.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/README.md +18 -18
- package/dist/components/tip/index.d.ts +1 -35
- package/dist/components/tip/index.d.ts.map +1 -1
- package/dist/components/upload/index.d.ts +1 -1
- package/dist/components/upload/index.d.ts.map +1 -1
- package/dist/hooks/useBridage.d.ts +3 -3
- package/dist/hooks/useBridage.d.ts.map +1 -1
- package/dist/hooks/useBridage.js +29 -22
- package/dist/hooks/useBridage.js.map +1 -1
- package/dist/hooks/useUserRefQuery.d.ts +2 -2
- package/lib/index.css +1 -1
- package/lib/index.js +32 -28
- 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/form/JaForm.vue +126 -126
- package/packages/components/form/index.ts +5 -5
- package/packages/components/form/types.ts +4 -4
- package/packages/components/formItem/JaFormItem.vue +68 -68
- package/packages/components/formItem/index.ts +4 -4
- package/packages/components/index.ts +33 -33
- 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 +142 -142
- 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 +86 -86
- 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 +366 -366
- package/packages/components/userSelectDialog/index.ts +6 -6
- package/packages/components/userSelectDialog/src/userSelectDialog.vue +447 -447
- 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 +55 -55
- package/packages/hooks/useBridage.ts +157 -148
- package/packages/hooks/useDateTimeShortCuts.ts +65 -65
- package/packages/hooks/useTreeData.ts +45 -45
- package/packages/hooks/useUserRefQuery.ts +222 -222
- package/packages/index.ts +21 -21
- 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
|
@@ -1,366 +1,366 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
ElButton,
|
|
4
|
-
ElIcon,
|
|
5
|
-
ElInput,
|
|
6
|
-
ElPopover,
|
|
7
|
-
ElText,
|
|
8
|
-
ElSpace
|
|
9
|
-
} from "element-plus";
|
|
10
|
-
import {computed, type PropType, ref, shallowRef, watch} from "vue"
|
|
11
|
-
import {
|
|
12
|
-
Delete,
|
|
13
|
-
Finished,
|
|
14
|
-
Notebook,
|
|
15
|
-
Plus,
|
|
16
|
-
Search, Setting,
|
|
17
|
-
StarFilled
|
|
18
|
-
} from "@element-plus/icons-vue";
|
|
19
|
-
import {
|
|
20
|
-
type BooleanResultExpression,
|
|
21
|
-
createAxiosWithoutCache,
|
|
22
|
-
QUser, useLoginUser,
|
|
23
|
-
type UserReference,
|
|
24
|
-
useUserApi, useUserQueryBuilder
|
|
25
|
-
} from "@jari-ace/app-bolts";
|
|
26
|
-
import {useUserRefQuery} from "../../../hooks/useUserRefQuery";
|
|
27
|
-
import vShortcut from "../../../directives/shortcut"
|
|
28
|
-
import {JaUserInfoTag} from "../../userTag"
|
|
29
|
-
import {JaButton} from "../../button";
|
|
30
|
-
import {JaUserSelectDialog} from "../../userSelectDialog";
|
|
31
|
-
import {JaScrollbar} from "../../scrollbar";
|
|
32
|
-
import CustomGroupManager from "./CustomGroupManager.vue";
|
|
33
|
-
import JaUserList from "./JaUserList.vue";
|
|
34
|
-
|
|
35
|
-
const props = defineProps({
|
|
36
|
-
/**
|
|
37
|
-
* 可选择用户的用户域ID
|
|
38
|
-
*/
|
|
39
|
-
realmId: {type: String, required: false, default: 1},
|
|
40
|
-
/**
|
|
41
|
-
* 弹出下拉选框的快捷键
|
|
42
|
-
*/
|
|
43
|
-
shortcut: {type: String, required: false, default: "Ctrl+Alt+U"},
|
|
44
|
-
/**
|
|
45
|
-
* 是否多选模式
|
|
46
|
-
*/
|
|
47
|
-
multiple: {type: Boolean, required: false, default: false},
|
|
48
|
-
/**
|
|
49
|
-
* 自定义筛选过滤条件,可以在此回调方法内使用qUser参数构造自定义的查询条件。例如 qUser => qUser.fullName.startWith('王')
|
|
50
|
-
*/
|
|
51
|
-
customFilter: {
|
|
52
|
-
type: Function as PropType<(qUser: InstanceType<typeof QUser>) => BooleanResultExpression>,
|
|
53
|
-
required: false
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* 最多显示多少已选中的用户数量
|
|
57
|
-
*/
|
|
58
|
-
maxShowCount: {type: Number, required: false, default: 20},
|
|
59
|
-
/**
|
|
60
|
-
* 高度,默认100%
|
|
61
|
-
*/
|
|
62
|
-
height: {type: [Number, String], required: false, default: '100%'},
|
|
63
|
-
/**
|
|
64
|
-
* 最大高度
|
|
65
|
-
*/
|
|
66
|
-
maxHeight: {type: [Number, String], required: false},
|
|
67
|
-
})
|
|
68
|
-
const localRealmId = ref<string>();
|
|
69
|
-
|
|
70
|
-
function loadRealmId() {
|
|
71
|
-
if (props.realmId) {
|
|
72
|
-
localRealmId.value = props.realmId;
|
|
73
|
-
} else {
|
|
74
|
-
localRealmId.value = useLoginUser().realmId;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
loadRealmId();
|
|
79
|
-
|
|
80
|
-
watch(() => props.realmId, loadRealmId)
|
|
81
|
-
|
|
82
|
-
const minLengthToTriggerUserQuery = 0;
|
|
83
|
-
const axios = createAxiosWithoutCache();
|
|
84
|
-
const api = useUserApi(axios);
|
|
85
|
-
const users = shallowRef<UserReference[]>([]);
|
|
86
|
-
const selectedUsers = defineModel<UserReference[] | UserReference | null>({
|
|
87
|
-
required: true
|
|
88
|
-
});
|
|
89
|
-
const inputSearchText = ref<typeof ElInput>();
|
|
90
|
-
const popoverVisible = ref(false);
|
|
91
|
-
const {queryResult, queryParams, pageParams, loading} = useUserRefQuery(
|
|
92
|
-
() => queryParams.value.name != undefined && queryParams.value.name.length
|
|
93
|
-
> minLengthToTriggerUserQuery,
|
|
94
|
-
props.customFilter,
|
|
95
|
-
(r, paramsChanged) => {
|
|
96
|
-
if (r) {
|
|
97
|
-
users.value = queryResult.value.users;
|
|
98
|
-
if (paramsChanged) {
|
|
99
|
-
scrollbar.value?.elScrollbar?.scrollTo(0, 0);
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
onPopoverShow();
|
|
103
|
-
}
|
|
104
|
-
}, true, axios, false);
|
|
105
|
-
const btn = ref<typeof ElButton>();
|
|
106
|
-
const scrollbar = ref<InstanceType<typeof JaScrollbar>>();
|
|
107
|
-
const dialogUserSelector = ref<InstanceType<typeof JaUserSelectDialog>>();
|
|
108
|
-
const dlgCustomGroupManager = ref<InstanceType<typeof CustomGroupManager>>();
|
|
109
|
-
const userList = ref<InstanceType<typeof JaUserList>>();
|
|
110
|
-
|
|
111
|
-
function switchUserSelect(u: UserReference) {
|
|
112
|
-
if (props.multiple) {
|
|
113
|
-
if (!Array.isArray(selectedUsers.value)) {
|
|
114
|
-
throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
|
|
115
|
-
}
|
|
116
|
-
const index = selectedUsers.value.findIndex(su => su.id == u.id);
|
|
117
|
-
if (index < 0) {
|
|
118
|
-
selectedUsers.value.push(u);
|
|
119
|
-
} else {
|
|
120
|
-
selectedUsers.value.splice(index, 1);
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
selectedUsers.value = u;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
function onPopoverShow() {
|
|
129
|
-
if (!queryParams.value.realmId || queryParams.value.realmId !== localRealmId.value) {
|
|
130
|
-
queryParams.value.realmId = localRealmId.value
|
|
131
|
-
}
|
|
132
|
-
if (queryParams.value.name && queryParams.value.name.length > minLengthToTriggerUserQuery) {
|
|
133
|
-
queryParams.value.name = undefined;
|
|
134
|
-
}
|
|
135
|
-
const builder = useUserQueryBuilder();
|
|
136
|
-
if (props.customFilter) {
|
|
137
|
-
const qUser = builder.getQEntity();
|
|
138
|
-
builder.and(props.customFilter(qUser));
|
|
139
|
-
}
|
|
140
|
-
api.getBookmarkedUsers(builder.build()).then(r => {
|
|
141
|
-
users.value = r;
|
|
142
|
-
})
|
|
143
|
-
setTimeout(() => {
|
|
144
|
-
inputSearchText.value?.focus();
|
|
145
|
-
}, 300)
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function onPopoverHide() {
|
|
149
|
-
btn.value?.$el.focus();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function onSaveToCustomGroupClick() {
|
|
153
|
-
dlgCustomGroupManager.value?.show();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function onDeselected(uid?: string) {
|
|
157
|
-
if (Array.isArray(selectedUsers.value)) {
|
|
158
|
-
const index = selectedUsers.value.findIndex(su => su.id == uid);
|
|
159
|
-
if (index >= 0) {
|
|
160
|
-
selectedUsers.value.splice(index, 1)
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
selectedUsers.value = null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function onInputArrowDown() {
|
|
168
|
-
userList.value.scrollDown();
|
|
169
|
-
inputSearchText.value?.focus();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function onInputArrowUp() {
|
|
173
|
-
userList.value.scrollUp();
|
|
174
|
-
inputSearchText.value?.focus();
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function onInputKeyEnter() {
|
|
178
|
-
switchUserSelect(users.value[userList.value?.activeIndex]);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function popup() {
|
|
182
|
-
popoverVisible.value = true;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function selectAll() {
|
|
186
|
-
const arr = (
|
|
187
|
-
selectedUsers.value as UserReference[]
|
|
188
|
-
);
|
|
189
|
-
arr.push(...users.value.filter(u => !arr.some(su => su.id === u.id)));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function clearSelection() {
|
|
193
|
-
if (props.multiple) {
|
|
194
|
-
selectedUsers.value = [];
|
|
195
|
-
} else {
|
|
196
|
-
selectedUsers.value = null;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function onArrowKeyDown() {
|
|
201
|
-
inputSearchText.value?.focus();
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const selectedForBinding = computed(() => {
|
|
205
|
-
if (props.multiple && Array.isArray(selectedUsers.value)) {
|
|
206
|
-
return selectedUsers.value;
|
|
207
|
-
} else if (!props.multiple && !Array.isArray(selectedUsers.value)) {
|
|
208
|
-
if (selectedUsers.value) {
|
|
209
|
-
return [selectedUsers.value as UserReference];
|
|
210
|
-
} else {
|
|
211
|
-
return [] as UserReference[];
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
|
|
215
|
-
}
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
function showUserSelectDialog() {
|
|
219
|
-
dialogUserSelector.value?.show();
|
|
220
|
-
popoverVisible.value = false;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const selectedUsersForRender = computed(() => selectedForBinding.value.slice(0, props.maxShowCount))
|
|
224
|
-
|
|
225
|
-
</script>
|
|
226
|
-
|
|
227
|
-
<template>
|
|
228
|
-
<ja-scrollbar :max-height="props.maxHeight" :height="props.height" v-bind="$attrs"
|
|
229
|
-
style="overflow-x: hidden;">
|
|
230
|
-
<div class="ja-user-picker__root" v-shortcut:[props.shortcut]="popup">
|
|
231
|
-
<el-popover ref="bookmarkDropdown" @show="onPopoverShow" @hide="onPopoverHide"
|
|
232
|
-
width="auto" teleported
|
|
233
|
-
v-model:visible="popoverVisible">
|
|
234
|
-
<template #reference>
|
|
235
|
-
<el-button circle :icon="Plus" :size="'small'" ref="btn"
|
|
236
|
-
@mouseover="popoverVisible=true">
|
|
237
|
-
</el-button>
|
|
238
|
-
</template>
|
|
239
|
-
<template #default>
|
|
240
|
-
<div class="ja-user-picker-bookmark__dropdown">
|
|
241
|
-
<div
|
|
242
|
-
style="width: 100%; display: flex; align-content: center; justify-content: end; margin-bottom: 4px;">
|
|
243
|
-
<el-space style="flex:auto">
|
|
244
|
-
<ja-button circle size="small" @click="showUserSelectDialog" plain
|
|
245
|
-
type="primary" tooltip="对话框筛选(大批量选择)"
|
|
246
|
-
shortcut="Ctrl+Alt+I" :icon="Notebook">
|
|
247
|
-
</ja-button>
|
|
248
|
-
<ja-button circle size="small" @click="clearSelection" type="danger"
|
|
249
|
-
plain :icon="Delete"
|
|
250
|
-
tooltip="清空选择" shortcut="Alt+C">
|
|
251
|
-
</ja-button>
|
|
252
|
-
<ja-button circle size="small" @click="selectAll" type="success"
|
|
253
|
-
plain :icon="Finished"
|
|
254
|
-
tooltip="全选(已加载的数据)" shortcut="Ctrl+A"
|
|
255
|
-
v-if="props.multiple">
|
|
256
|
-
</ja-button>
|
|
257
|
-
<ja-button circle size="small" @click="onSaveToCustomGroupClick"
|
|
258
|
-
type="warning" :icon="Setting" plain
|
|
259
|
-
tooltip="将已选中用户保存为自定义组,方便以后选择使用">
|
|
260
|
-
</ja-button>
|
|
261
|
-
</el-space>
|
|
262
|
-
<div style="color: var(--el-color-info-light-5);">
|
|
263
|
-
弹出快捷键:{{ props.shortcut }}
|
|
264
|
-
</div>
|
|
265
|
-
</div>
|
|
266
|
-
<el-input v-model="queryParams.name" ref="inputSearchText"
|
|
267
|
-
:suffix-icon="Search"
|
|
268
|
-
placeholder="请输入拼音名、姓名或手机号查询"
|
|
269
|
-
autocomplete="off"
|
|
270
|
-
@keydown.enter="onInputKeyEnter"
|
|
271
|
-
@keydown.up.stop.prevent="onInputArrowUp"
|
|
272
|
-
@keydown.down.stop.prevent="onInputArrowDown">
|
|
273
|
-
</el-input>
|
|
274
|
-
|
|
275
|
-
<div class="dropdown-header">
|
|
276
|
-
<el-text>
|
|
277
|
-
<el-icon
|
|
278
|
-
v-if="queryParams.name && queryParams.name.length > minLengthToTriggerUserQuery">
|
|
279
|
-
<Search></Search>
|
|
280
|
-
</el-icon>
|
|
281
|
-
<el-icon v-else color="#FFBF29">
|
|
282
|
-
<StarFilled></StarFilled>
|
|
283
|
-
</el-icon>
|
|
284
|
-
{{
|
|
285
|
-
queryParams.name && queryParams.name.length
|
|
286
|
-
> minLengthToTriggerUserQuery ? "查询结果" : "常用人员"
|
|
287
|
-
}}
|
|
288
|
-
</el-text>
|
|
289
|
-
</div>
|
|
290
|
-
<ja-user-list
|
|
291
|
-
ref="userList"
|
|
292
|
-
:total="queryResult.total"
|
|
293
|
-
:empty-text="queryParams.name && queryParams.name.length > minLengthToTriggerUserQuery ? undefined : '无可选常用人员'"
|
|
294
|
-
multiple
|
|
295
|
-
:page-size="pageParams.pageSize"
|
|
296
|
-
:loading="loading"
|
|
297
|
-
:users="users"
|
|
298
|
-
:height="300"
|
|
299
|
-
v-model="selectedUsers"
|
|
300
|
-
v-model:page="pageParams.currentPage"
|
|
301
|
-
@item-clicked="onArrowKeyDown"
|
|
302
|
-
@arrow-key-down="onArrowKeyDown"></ja-user-list>
|
|
303
|
-
</div>
|
|
304
|
-
</template>
|
|
305
|
-
</el-popover>
|
|
306
|
-
<ja-user-info-tag v-for="u in selectedUsersForRender" :key="u.id" :user-id="u.id"
|
|
307
|
-
:full-name="u.fullName" closable :has-avatar="u.hasAvatar"
|
|
308
|
-
@closed="onDeselected">
|
|
309
|
-
</ja-user-info-tag>
|
|
310
|
-
<div class="more-tag" v-if="selectedForBinding.length > props.maxShowCount">
|
|
311
|
-
+{{ selectedForBinding.length - props.maxShowCount }}人
|
|
312
|
-
</div>
|
|
313
|
-
<div v-if="selectedForBinding.length === 0">
|
|
314
|
-
<el-text type="info"> <暂无选中人员></el-text>
|
|
315
|
-
</div>
|
|
316
|
-
<ja-user-select-dialog ref="dialogUserSelector"
|
|
317
|
-
:multiple="props.multiple"
|
|
318
|
-
:realm-id="localRealmId"
|
|
319
|
-
:customFilter="props.customFilter"
|
|
320
|
-
v-model="selectedUsers"></ja-user-select-dialog>
|
|
321
|
-
</div>
|
|
322
|
-
</ja-scrollbar>
|
|
323
|
-
<custom-group-manager ref="dlgCustomGroupManager"
|
|
324
|
-
:users="Array.isArray(selectedUsers)? selectedUsers as UserReference[] : (selectedUsers ? [selectedUsers] : null)"></custom-group-manager>
|
|
325
|
-
</template>
|
|
326
|
-
|
|
327
|
-
<style scoped lang="scss">
|
|
328
|
-
.ja-user-picker__root {
|
|
329
|
-
display: flex;
|
|
330
|
-
flex-wrap: wrap;
|
|
331
|
-
justify-content: left;
|
|
332
|
-
align-items: center;
|
|
333
|
-
gap: 4px;
|
|
334
|
-
padding: 8px 0;
|
|
335
|
-
|
|
336
|
-
.more-tag {
|
|
337
|
-
border-radius: 28px;
|
|
338
|
-
height: 28px;
|
|
339
|
-
padding: 2px 5px;
|
|
340
|
-
background-color: #E8F5FF;
|
|
341
|
-
color: #00164D;
|
|
342
|
-
border: 1px solid #C1CCD7;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
:deep(.el-popover) {
|
|
347
|
-
padding: 0 !important;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
.ja-user-picker-bookmark__dropdown {
|
|
351
|
-
padding: 0;
|
|
352
|
-
margin: 0;
|
|
353
|
-
|
|
354
|
-
.dropdown-header {
|
|
355
|
-
padding: 8px 0;
|
|
356
|
-
width: 280px;
|
|
357
|
-
cursor: default;
|
|
358
|
-
font-weight: 600;
|
|
359
|
-
|
|
360
|
-
.el-text {
|
|
361
|
-
font-weight: 600;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
</style>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
ElButton,
|
|
4
|
+
ElIcon,
|
|
5
|
+
ElInput,
|
|
6
|
+
ElPopover,
|
|
7
|
+
ElText,
|
|
8
|
+
ElSpace
|
|
9
|
+
} from "element-plus";
|
|
10
|
+
import {computed, type PropType, ref, shallowRef, watch} from "vue"
|
|
11
|
+
import {
|
|
12
|
+
Delete,
|
|
13
|
+
Finished,
|
|
14
|
+
Notebook,
|
|
15
|
+
Plus,
|
|
16
|
+
Search, Setting,
|
|
17
|
+
StarFilled
|
|
18
|
+
} from "@element-plus/icons-vue";
|
|
19
|
+
import {
|
|
20
|
+
type BooleanResultExpression,
|
|
21
|
+
createAxiosWithoutCache,
|
|
22
|
+
QUser, useLoginUser,
|
|
23
|
+
type UserReference,
|
|
24
|
+
useUserApi, useUserQueryBuilder
|
|
25
|
+
} from "@jari-ace/app-bolts";
|
|
26
|
+
import {useUserRefQuery} from "../../../hooks/useUserRefQuery";
|
|
27
|
+
import vShortcut from "../../../directives/shortcut"
|
|
28
|
+
import {JaUserInfoTag} from "../../userTag"
|
|
29
|
+
import {JaButton} from "../../button";
|
|
30
|
+
import {JaUserSelectDialog} from "../../userSelectDialog";
|
|
31
|
+
import {JaScrollbar} from "../../scrollbar";
|
|
32
|
+
import CustomGroupManager from "./CustomGroupManager.vue";
|
|
33
|
+
import JaUserList from "./JaUserList.vue";
|
|
34
|
+
|
|
35
|
+
const props = defineProps({
|
|
36
|
+
/**
|
|
37
|
+
* 可选择用户的用户域ID
|
|
38
|
+
*/
|
|
39
|
+
realmId: {type: String, required: false, default: 1},
|
|
40
|
+
/**
|
|
41
|
+
* 弹出下拉选框的快捷键
|
|
42
|
+
*/
|
|
43
|
+
shortcut: {type: String, required: false, default: "Ctrl+Alt+U"},
|
|
44
|
+
/**
|
|
45
|
+
* 是否多选模式
|
|
46
|
+
*/
|
|
47
|
+
multiple: {type: Boolean, required: false, default: false},
|
|
48
|
+
/**
|
|
49
|
+
* 自定义筛选过滤条件,可以在此回调方法内使用qUser参数构造自定义的查询条件。例如 qUser => qUser.fullName.startWith('王')
|
|
50
|
+
*/
|
|
51
|
+
customFilter: {
|
|
52
|
+
type: Function as PropType<(qUser: InstanceType<typeof QUser>) => BooleanResultExpression>,
|
|
53
|
+
required: false
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* 最多显示多少已选中的用户数量
|
|
57
|
+
*/
|
|
58
|
+
maxShowCount: {type: Number, required: false, default: 20},
|
|
59
|
+
/**
|
|
60
|
+
* 高度,默认100%
|
|
61
|
+
*/
|
|
62
|
+
height: {type: [Number, String], required: false, default: '100%'},
|
|
63
|
+
/**
|
|
64
|
+
* 最大高度
|
|
65
|
+
*/
|
|
66
|
+
maxHeight: {type: [Number, String], required: false},
|
|
67
|
+
})
|
|
68
|
+
const localRealmId = ref<string>();
|
|
69
|
+
|
|
70
|
+
function loadRealmId() {
|
|
71
|
+
if (props.realmId) {
|
|
72
|
+
localRealmId.value = props.realmId;
|
|
73
|
+
} else {
|
|
74
|
+
localRealmId.value = useLoginUser().realmId;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
loadRealmId();
|
|
79
|
+
|
|
80
|
+
watch(() => props.realmId, loadRealmId)
|
|
81
|
+
|
|
82
|
+
const minLengthToTriggerUserQuery = 0;
|
|
83
|
+
const axios = createAxiosWithoutCache();
|
|
84
|
+
const api = useUserApi(axios);
|
|
85
|
+
const users = shallowRef<UserReference[]>([]);
|
|
86
|
+
const selectedUsers = defineModel<UserReference[] | UserReference | null>({
|
|
87
|
+
required: true
|
|
88
|
+
});
|
|
89
|
+
const inputSearchText = ref<typeof ElInput>();
|
|
90
|
+
const popoverVisible = ref(false);
|
|
91
|
+
const {queryResult, queryParams, pageParams, loading} = useUserRefQuery(
|
|
92
|
+
() => queryParams.value.name != undefined && queryParams.value.name.length
|
|
93
|
+
> minLengthToTriggerUserQuery,
|
|
94
|
+
props.customFilter,
|
|
95
|
+
(r, paramsChanged) => {
|
|
96
|
+
if (r) {
|
|
97
|
+
users.value = queryResult.value.users;
|
|
98
|
+
if (paramsChanged) {
|
|
99
|
+
scrollbar.value?.elScrollbar?.scrollTo(0, 0);
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
onPopoverShow();
|
|
103
|
+
}
|
|
104
|
+
}, true, axios, false);
|
|
105
|
+
const btn = ref<typeof ElButton>();
|
|
106
|
+
const scrollbar = ref<InstanceType<typeof JaScrollbar>>();
|
|
107
|
+
const dialogUserSelector = ref<InstanceType<typeof JaUserSelectDialog>>();
|
|
108
|
+
const dlgCustomGroupManager = ref<InstanceType<typeof CustomGroupManager>>();
|
|
109
|
+
const userList = ref<InstanceType<typeof JaUserList>>();
|
|
110
|
+
|
|
111
|
+
function switchUserSelect(u: UserReference) {
|
|
112
|
+
if (props.multiple) {
|
|
113
|
+
if (!Array.isArray(selectedUsers.value)) {
|
|
114
|
+
throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
|
|
115
|
+
}
|
|
116
|
+
const index = selectedUsers.value.findIndex(su => su.id == u.id);
|
|
117
|
+
if (index < 0) {
|
|
118
|
+
selectedUsers.value.push(u);
|
|
119
|
+
} else {
|
|
120
|
+
selectedUsers.value.splice(index, 1);
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
selectedUsers.value = u;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
function onPopoverShow() {
|
|
129
|
+
if (!queryParams.value.realmId || queryParams.value.realmId !== localRealmId.value) {
|
|
130
|
+
queryParams.value.realmId = localRealmId.value
|
|
131
|
+
}
|
|
132
|
+
if (queryParams.value.name && queryParams.value.name.length > minLengthToTriggerUserQuery) {
|
|
133
|
+
queryParams.value.name = undefined;
|
|
134
|
+
}
|
|
135
|
+
const builder = useUserQueryBuilder();
|
|
136
|
+
if (props.customFilter) {
|
|
137
|
+
const qUser = builder.getQEntity();
|
|
138
|
+
builder.and(props.customFilter(qUser));
|
|
139
|
+
}
|
|
140
|
+
api.getBookmarkedUsers(builder.build()).then(r => {
|
|
141
|
+
users.value = r;
|
|
142
|
+
})
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
inputSearchText.value?.focus();
|
|
145
|
+
}, 300)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function onPopoverHide() {
|
|
149
|
+
btn.value?.$el.focus();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function onSaveToCustomGroupClick() {
|
|
153
|
+
dlgCustomGroupManager.value?.show();
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function onDeselected(uid?: string) {
|
|
157
|
+
if (Array.isArray(selectedUsers.value)) {
|
|
158
|
+
const index = selectedUsers.value.findIndex(su => su.id == uid);
|
|
159
|
+
if (index >= 0) {
|
|
160
|
+
selectedUsers.value.splice(index, 1)
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
selectedUsers.value = null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function onInputArrowDown() {
|
|
168
|
+
userList.value.scrollDown();
|
|
169
|
+
inputSearchText.value?.focus();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function onInputArrowUp() {
|
|
173
|
+
userList.value.scrollUp();
|
|
174
|
+
inputSearchText.value?.focus();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function onInputKeyEnter() {
|
|
178
|
+
switchUserSelect(users.value[userList.value?.activeIndex]);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function popup() {
|
|
182
|
+
popoverVisible.value = true;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function selectAll() {
|
|
186
|
+
const arr = (
|
|
187
|
+
selectedUsers.value as UserReference[]
|
|
188
|
+
);
|
|
189
|
+
arr.push(...users.value.filter(u => !arr.some(su => su.id === u.id)));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function clearSelection() {
|
|
193
|
+
if (props.multiple) {
|
|
194
|
+
selectedUsers.value = [];
|
|
195
|
+
} else {
|
|
196
|
+
selectedUsers.value = null;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function onArrowKeyDown() {
|
|
201
|
+
inputSearchText.value?.focus();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const selectedForBinding = computed(() => {
|
|
205
|
+
if (props.multiple && Array.isArray(selectedUsers.value)) {
|
|
206
|
+
return selectedUsers.value;
|
|
207
|
+
} else if (!props.multiple && !Array.isArray(selectedUsers.value)) {
|
|
208
|
+
if (selectedUsers.value) {
|
|
209
|
+
return [selectedUsers.value as UserReference];
|
|
210
|
+
} else {
|
|
211
|
+
return [] as UserReference[];
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
throw new Error("UserPicker组件设置为多选模式(multiple)时,v-model必须绑定UserReference数组")
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
function showUserSelectDialog() {
|
|
219
|
+
dialogUserSelector.value?.show();
|
|
220
|
+
popoverVisible.value = false;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const selectedUsersForRender = computed(() => selectedForBinding.value.slice(0, props.maxShowCount))
|
|
224
|
+
|
|
225
|
+
</script>
|
|
226
|
+
|
|
227
|
+
<template>
|
|
228
|
+
<ja-scrollbar :max-height="props.maxHeight" :height="props.height" v-bind="$attrs"
|
|
229
|
+
style="overflow-x: hidden;">
|
|
230
|
+
<div class="ja-user-picker__root" v-shortcut:[props.shortcut]="popup">
|
|
231
|
+
<el-popover ref="bookmarkDropdown" @show="onPopoverShow" @hide="onPopoverHide"
|
|
232
|
+
width="auto" teleported
|
|
233
|
+
v-model:visible="popoverVisible">
|
|
234
|
+
<template #reference>
|
|
235
|
+
<el-button circle :icon="Plus" :size="'small'" ref="btn"
|
|
236
|
+
@mouseover="popoverVisible=true">
|
|
237
|
+
</el-button>
|
|
238
|
+
</template>
|
|
239
|
+
<template #default>
|
|
240
|
+
<div class="ja-user-picker-bookmark__dropdown">
|
|
241
|
+
<div
|
|
242
|
+
style="width: 100%; display: flex; align-content: center; justify-content: end; margin-bottom: 4px;">
|
|
243
|
+
<el-space style="flex:auto">
|
|
244
|
+
<ja-button circle size="small" @click="showUserSelectDialog" plain
|
|
245
|
+
type="primary" tooltip="对话框筛选(大批量选择)"
|
|
246
|
+
shortcut="Ctrl+Alt+I" :icon="Notebook">
|
|
247
|
+
</ja-button>
|
|
248
|
+
<ja-button circle size="small" @click="clearSelection" type="danger"
|
|
249
|
+
plain :icon="Delete"
|
|
250
|
+
tooltip="清空选择" shortcut="Alt+C">
|
|
251
|
+
</ja-button>
|
|
252
|
+
<ja-button circle size="small" @click="selectAll" type="success"
|
|
253
|
+
plain :icon="Finished"
|
|
254
|
+
tooltip="全选(已加载的数据)" shortcut="Ctrl+A"
|
|
255
|
+
v-if="props.multiple">
|
|
256
|
+
</ja-button>
|
|
257
|
+
<ja-button circle size="small" @click="onSaveToCustomGroupClick"
|
|
258
|
+
type="warning" :icon="Setting" plain
|
|
259
|
+
tooltip="将已选中用户保存为自定义组,方便以后选择使用">
|
|
260
|
+
</ja-button>
|
|
261
|
+
</el-space>
|
|
262
|
+
<div style="color: var(--el-color-info-light-5);">
|
|
263
|
+
弹出快捷键:{{ props.shortcut }}
|
|
264
|
+
</div>
|
|
265
|
+
</div>
|
|
266
|
+
<el-input v-model="queryParams.name" ref="inputSearchText"
|
|
267
|
+
:suffix-icon="Search"
|
|
268
|
+
placeholder="请输入拼音名、姓名或手机号查询"
|
|
269
|
+
autocomplete="off"
|
|
270
|
+
@keydown.enter="onInputKeyEnter"
|
|
271
|
+
@keydown.up.stop.prevent="onInputArrowUp"
|
|
272
|
+
@keydown.down.stop.prevent="onInputArrowDown">
|
|
273
|
+
</el-input>
|
|
274
|
+
|
|
275
|
+
<div class="dropdown-header">
|
|
276
|
+
<el-text>
|
|
277
|
+
<el-icon
|
|
278
|
+
v-if="queryParams.name && queryParams.name.length > minLengthToTriggerUserQuery">
|
|
279
|
+
<Search></Search>
|
|
280
|
+
</el-icon>
|
|
281
|
+
<el-icon v-else color="#FFBF29">
|
|
282
|
+
<StarFilled></StarFilled>
|
|
283
|
+
</el-icon>
|
|
284
|
+
{{
|
|
285
|
+
queryParams.name && queryParams.name.length
|
|
286
|
+
> minLengthToTriggerUserQuery ? "查询结果" : "常用人员"
|
|
287
|
+
}}
|
|
288
|
+
</el-text>
|
|
289
|
+
</div>
|
|
290
|
+
<ja-user-list
|
|
291
|
+
ref="userList"
|
|
292
|
+
:total="queryResult.total"
|
|
293
|
+
:empty-text="queryParams.name && queryParams.name.length > minLengthToTriggerUserQuery ? undefined : '无可选常用人员'"
|
|
294
|
+
multiple
|
|
295
|
+
:page-size="pageParams.pageSize"
|
|
296
|
+
:loading="loading"
|
|
297
|
+
:users="users"
|
|
298
|
+
:height="300"
|
|
299
|
+
v-model="selectedUsers"
|
|
300
|
+
v-model:page="pageParams.currentPage"
|
|
301
|
+
@item-clicked="onArrowKeyDown"
|
|
302
|
+
@arrow-key-down="onArrowKeyDown"></ja-user-list>
|
|
303
|
+
</div>
|
|
304
|
+
</template>
|
|
305
|
+
</el-popover>
|
|
306
|
+
<ja-user-info-tag v-for="u in selectedUsersForRender" :key="u.id" :user-id="u.id"
|
|
307
|
+
:full-name="u.fullName" closable :has-avatar="u.hasAvatar"
|
|
308
|
+
@closed="onDeselected">
|
|
309
|
+
</ja-user-info-tag>
|
|
310
|
+
<div class="more-tag" v-if="selectedForBinding.length > props.maxShowCount">
|
|
311
|
+
+{{ selectedForBinding.length - props.maxShowCount }}人
|
|
312
|
+
</div>
|
|
313
|
+
<div v-if="selectedForBinding.length === 0">
|
|
314
|
+
<el-text type="info"> <暂无选中人员></el-text>
|
|
315
|
+
</div>
|
|
316
|
+
<ja-user-select-dialog ref="dialogUserSelector"
|
|
317
|
+
:multiple="props.multiple"
|
|
318
|
+
:realm-id="localRealmId"
|
|
319
|
+
:customFilter="props.customFilter"
|
|
320
|
+
v-model="selectedUsers"></ja-user-select-dialog>
|
|
321
|
+
</div>
|
|
322
|
+
</ja-scrollbar>
|
|
323
|
+
<custom-group-manager ref="dlgCustomGroupManager"
|
|
324
|
+
:users="Array.isArray(selectedUsers)? selectedUsers as UserReference[] : (selectedUsers ? [selectedUsers] : null)"></custom-group-manager>
|
|
325
|
+
</template>
|
|
326
|
+
|
|
327
|
+
<style scoped lang="scss">
|
|
328
|
+
.ja-user-picker__root {
|
|
329
|
+
display: flex;
|
|
330
|
+
flex-wrap: wrap;
|
|
331
|
+
justify-content: left;
|
|
332
|
+
align-items: center;
|
|
333
|
+
gap: 4px;
|
|
334
|
+
padding: 8px 0;
|
|
335
|
+
|
|
336
|
+
.more-tag {
|
|
337
|
+
border-radius: 28px;
|
|
338
|
+
height: 28px;
|
|
339
|
+
padding: 2px 5px;
|
|
340
|
+
background-color: #E8F5FF;
|
|
341
|
+
color: #00164D;
|
|
342
|
+
border: 1px solid #C1CCD7;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
:deep(.el-popover) {
|
|
347
|
+
padding: 0 !important;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.ja-user-picker-bookmark__dropdown {
|
|
351
|
+
padding: 0;
|
|
352
|
+
margin: 0;
|
|
353
|
+
|
|
354
|
+
.dropdown-header {
|
|
355
|
+
padding: 8px 0;
|
|
356
|
+
width: 280px;
|
|
357
|
+
cursor: default;
|
|
358
|
+
font-weight: 600;
|
|
359
|
+
|
|
360
|
+
.el-text {
|
|
361
|
+
font-weight: 600;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
</style>
|