@blueking/bk-user-selector 0.0.6 → 0.0.7
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 +24 -0
- package/package.json +1 -1
- package/typings/components/me-tag.vue.d.ts +39 -0
- package/typings/components/multiple-selector.vue.d.ts +40 -1
- package/typings/components/selection-popover.vue.d.ts +154 -0
- package/typings/components/user-selector.vue.d.ts +10 -1
- package/typings/types/index.d.ts +36 -39
- package/vue2/index.es.min.js +362 -203
- package/vue2/index.iife.min.js +362 -203
- package/vue2/index.umd.min.js +362 -203
- package/vue2/vue2.css +82 -128
- package/vue3/index.es.min.js +363 -204
- package/vue3/index.iife.min.js +362 -203
- package/vue3/index.umd.min.js +362 -203
- package/vue3/vue3.css +82 -128
package/vue3/index.es.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref, onBeforeMount, defineComponent,
|
|
2
|
-
import {
|
|
1
|
+
import { ref, onBeforeMount, defineComponent, createElementBlock, createCommentVNode, openBlock, withModifiers, normalizeClass, computed, createBlock, unref, withCtx, createVNode, createElementVNode, toDisplayString, Fragment, renderList, watch, nextTick, onMounted, withDirectives, isRef, vModelText, createTextVNode, pushScopeId, popScopeId } from "vue";
|
|
2
|
+
import { Popover, Loading, Tag, clickoutside } from "bkui-vue";
|
|
3
3
|
const getTenants = async (apiBaseUrl, tenantId) => {
|
|
4
4
|
if (!apiBaseUrl || !tenantId) {
|
|
5
5
|
console.warn("获取租户信息需要提供有效的apiBaseUrl和租户ID");
|
|
@@ -2960,6 +2960,270 @@ const useUserSearch = (apiBaseUrl, tenantId) => {
|
|
|
2960
2960
|
clearSearch
|
|
2961
2961
|
};
|
|
2962
2962
|
};
|
|
2963
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
2964
|
+
...{
|
|
2965
|
+
name: "MeTag"
|
|
2966
|
+
},
|
|
2967
|
+
__name: "me-tag",
|
|
2968
|
+
props: {
|
|
2969
|
+
/**
|
|
2970
|
+
* 当前用户ID
|
|
2971
|
+
*/
|
|
2972
|
+
currentUserId: {
|
|
2973
|
+
type: String,
|
|
2974
|
+
default: ""
|
|
2975
|
+
},
|
|
2976
|
+
/**
|
|
2977
|
+
* 是否禁用
|
|
2978
|
+
*/
|
|
2979
|
+
isDisabled: {
|
|
2980
|
+
type: Boolean,
|
|
2981
|
+
default: false
|
|
2982
|
+
}
|
|
2983
|
+
},
|
|
2984
|
+
emits: ["click"],
|
|
2985
|
+
setup(__props, { emit: __emit }) {
|
|
2986
|
+
const props = __props;
|
|
2987
|
+
const emit = __emit;
|
|
2988
|
+
const handleClick = () => {
|
|
2989
|
+
if (props.isDisabled) return;
|
|
2990
|
+
emit("click");
|
|
2991
|
+
};
|
|
2992
|
+
return (_ctx, _cache) => {
|
|
2993
|
+
return __props.currentUserId ? (openBlock(), createElementBlock(
|
|
2994
|
+
"div",
|
|
2995
|
+
{
|
|
2996
|
+
key: 0,
|
|
2997
|
+
class: normalizeClass(["me-tag", { disabled: __props.isDisabled }]),
|
|
2998
|
+
onClick: withModifiers(handleClick, ["stop"])
|
|
2999
|
+
},
|
|
3000
|
+
" 我 ",
|
|
3001
|
+
2
|
|
3002
|
+
/* CLASS */
|
|
3003
|
+
)) : createCommentVNode("v-if", true);
|
|
3004
|
+
};
|
|
3005
|
+
}
|
|
3006
|
+
});
|
|
3007
|
+
const _export_sfc = (sfc, props) => {
|
|
3008
|
+
const target = sfc.__vccOpts || sfc;
|
|
3009
|
+
for (const [key, val] of props) {
|
|
3010
|
+
target[key] = val;
|
|
3011
|
+
}
|
|
3012
|
+
return target;
|
|
3013
|
+
};
|
|
3014
|
+
const MeTag = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-887b7c44"]]);
|
|
3015
|
+
const _hoisted_1$4 = {
|
|
3016
|
+
key: 0,
|
|
3017
|
+
class: "no-data"
|
|
3018
|
+
};
|
|
3019
|
+
const _hoisted_2$3 = { class: "group-name" };
|
|
3020
|
+
const _hoisted_3$3 = { class: "group-count" };
|
|
3021
|
+
const _hoisted_4$1 = ["onMousedown"];
|
|
3022
|
+
const _hoisted_5 = {
|
|
3023
|
+
key: 0,
|
|
3024
|
+
class: "tenant-name"
|
|
3025
|
+
};
|
|
3026
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
3027
|
+
...{
|
|
3028
|
+
name: "SelectionPopover"
|
|
3029
|
+
},
|
|
3030
|
+
__name: "selection-popover",
|
|
3031
|
+
props: {
|
|
3032
|
+
/**
|
|
3033
|
+
* 是否显示下拉菜单
|
|
3034
|
+
*/
|
|
3035
|
+
isShow: {
|
|
3036
|
+
type: Boolean,
|
|
3037
|
+
default: false
|
|
3038
|
+
},
|
|
3039
|
+
/**
|
|
3040
|
+
* 容器宽度
|
|
3041
|
+
*/
|
|
3042
|
+
containerWidth: {
|
|
3043
|
+
type: [Number, String],
|
|
3044
|
+
default: "auto"
|
|
3045
|
+
},
|
|
3046
|
+
/**
|
|
3047
|
+
* 是否加载中
|
|
3048
|
+
*/
|
|
3049
|
+
loading: {
|
|
3050
|
+
type: Boolean,
|
|
3051
|
+
default: false
|
|
3052
|
+
},
|
|
3053
|
+
/**
|
|
3054
|
+
* 搜索结果选项
|
|
3055
|
+
*/
|
|
3056
|
+
options: {
|
|
3057
|
+
type: Array,
|
|
3058
|
+
default: () => []
|
|
3059
|
+
},
|
|
3060
|
+
/**
|
|
3061
|
+
* 搜索关键词
|
|
3062
|
+
*/
|
|
3063
|
+
searchQuery: {
|
|
3064
|
+
type: String,
|
|
3065
|
+
default: ""
|
|
3066
|
+
},
|
|
3067
|
+
/**
|
|
3068
|
+
* 当前租户ID
|
|
3069
|
+
*/
|
|
3070
|
+
tenantId: {
|
|
3071
|
+
type: String,
|
|
3072
|
+
default: ""
|
|
3073
|
+
},
|
|
3074
|
+
/**
|
|
3075
|
+
* 租户信息映射
|
|
3076
|
+
*/
|
|
3077
|
+
tenants: {
|
|
3078
|
+
type: Object,
|
|
3079
|
+
default: () => ({})
|
|
3080
|
+
},
|
|
3081
|
+
/**
|
|
3082
|
+
* 用户组
|
|
3083
|
+
*/
|
|
3084
|
+
userGroup: {
|
|
3085
|
+
type: Array,
|
|
3086
|
+
default: () => []
|
|
3087
|
+
},
|
|
3088
|
+
/**
|
|
3089
|
+
* 用户组名称
|
|
3090
|
+
*/
|
|
3091
|
+
userGroupName: {
|
|
3092
|
+
type: String,
|
|
3093
|
+
default: "用户群组"
|
|
3094
|
+
}
|
|
3095
|
+
},
|
|
3096
|
+
emits: ["select-user"],
|
|
3097
|
+
setup(__props, { emit: __emit }) {
|
|
3098
|
+
const props = __props;
|
|
3099
|
+
const emit = __emit;
|
|
3100
|
+
const groupedUsers = computed(() => {
|
|
3101
|
+
const groups = {};
|
|
3102
|
+
console.log("props.options", props.options);
|
|
3103
|
+
if (Array.isArray(props.userGroup) && props.userGroup.length > 0) {
|
|
3104
|
+
groups[props.userGroupName] = props.userGroup.map((group) => ({
|
|
3105
|
+
id: group.id,
|
|
3106
|
+
name: group.name,
|
|
3107
|
+
tenantId: ""
|
|
3108
|
+
}));
|
|
3109
|
+
}
|
|
3110
|
+
props.options.forEach((user) => {
|
|
3111
|
+
const groupName = user.data_source_type === "real" ? "用户" : "虚拟账号";
|
|
3112
|
+
if (!groups[groupName]) {
|
|
3113
|
+
groups[groupName] = [];
|
|
3114
|
+
}
|
|
3115
|
+
groups[groupName].push(user);
|
|
3116
|
+
});
|
|
3117
|
+
return groups;
|
|
3118
|
+
});
|
|
3119
|
+
const selectUser = (user) => {
|
|
3120
|
+
emit("select-user", user);
|
|
3121
|
+
};
|
|
3122
|
+
return (_ctx, _cache) => {
|
|
3123
|
+
return openBlock(), createBlock(unref(Popover), {
|
|
3124
|
+
"ext-cls": "bk-user-selector-popover",
|
|
3125
|
+
arrow: false,
|
|
3126
|
+
"is-show": __props.isShow,
|
|
3127
|
+
width: __props.containerWidth,
|
|
3128
|
+
placement: "bottom-start",
|
|
3129
|
+
theme: "light",
|
|
3130
|
+
trigger: "manual"
|
|
3131
|
+
}, {
|
|
3132
|
+
content: withCtx(() => [
|
|
3133
|
+
createVNode(unref(Loading), {
|
|
3134
|
+
class: "dropdown-content",
|
|
3135
|
+
loading: __props.loading,
|
|
3136
|
+
size: "mini",
|
|
3137
|
+
mode: "spin"
|
|
3138
|
+
}, {
|
|
3139
|
+
default: withCtx(() => [
|
|
3140
|
+
__props.options.length === 0 && __props.userGroup.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
|
|
3141
|
+
createElementVNode(
|
|
3142
|
+
"span",
|
|
3143
|
+
null,
|
|
3144
|
+
toDisplayString(__props.searchQuery.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
|
|
3145
|
+
1
|
|
3146
|
+
/* TEXT */
|
|
3147
|
+
)
|
|
3148
|
+
])) : (openBlock(true), createElementBlock(
|
|
3149
|
+
Fragment,
|
|
3150
|
+
{ key: 1 },
|
|
3151
|
+
renderList(groupedUsers.value, (group, groupName) => {
|
|
3152
|
+
return openBlock(), createElementBlock("div", {
|
|
3153
|
+
class: "user-group",
|
|
3154
|
+
key: groupName
|
|
3155
|
+
}, [
|
|
3156
|
+
createElementVNode(
|
|
3157
|
+
"div",
|
|
3158
|
+
{
|
|
3159
|
+
class: "group-header",
|
|
3160
|
+
onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
3161
|
+
}, ["prevent"]))
|
|
3162
|
+
},
|
|
3163
|
+
[
|
|
3164
|
+
createElementVNode(
|
|
3165
|
+
"span",
|
|
3166
|
+
_hoisted_2$3,
|
|
3167
|
+
toDisplayString(groupName),
|
|
3168
|
+
1
|
|
3169
|
+
/* TEXT */
|
|
3170
|
+
),
|
|
3171
|
+
createElementVNode(
|
|
3172
|
+
"span",
|
|
3173
|
+
_hoisted_3$3,
|
|
3174
|
+
"(" + toDisplayString(group.length) + ")",
|
|
3175
|
+
1
|
|
3176
|
+
/* TEXT */
|
|
3177
|
+
)
|
|
3178
|
+
],
|
|
3179
|
+
32
|
|
3180
|
+
/* NEED_HYDRATION */
|
|
3181
|
+
),
|
|
3182
|
+
(openBlock(true), createElementBlock(
|
|
3183
|
+
Fragment,
|
|
3184
|
+
null,
|
|
3185
|
+
renderList(group, (user) => {
|
|
3186
|
+
return openBlock(), createElementBlock("div", {
|
|
3187
|
+
class: "user-option",
|
|
3188
|
+
key: user.id,
|
|
3189
|
+
onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
|
|
3190
|
+
}, [
|
|
3191
|
+
createElementVNode(
|
|
3192
|
+
"span",
|
|
3193
|
+
null,
|
|
3194
|
+
toDisplayString(user.name),
|
|
3195
|
+
1
|
|
3196
|
+
/* TEXT */
|
|
3197
|
+
),
|
|
3198
|
+
user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
3199
|
+
"span",
|
|
3200
|
+
_hoisted_5,
|
|
3201
|
+
"@" + toDisplayString(__props.tenants[user.tenantId]),
|
|
3202
|
+
1
|
|
3203
|
+
/* TEXT */
|
|
3204
|
+
)) : createCommentVNode("v-if", true)
|
|
3205
|
+
], 40, _hoisted_4$1);
|
|
3206
|
+
}),
|
|
3207
|
+
128
|
|
3208
|
+
/* KEYED_FRAGMENT */
|
|
3209
|
+
))
|
|
3210
|
+
]);
|
|
3211
|
+
}),
|
|
3212
|
+
128
|
|
3213
|
+
/* KEYED_FRAGMENT */
|
|
3214
|
+
))
|
|
3215
|
+
]),
|
|
3216
|
+
_: 1
|
|
3217
|
+
/* STABLE */
|
|
3218
|
+
}, 8, ["loading"])
|
|
3219
|
+
]),
|
|
3220
|
+
_: 1
|
|
3221
|
+
/* STABLE */
|
|
3222
|
+
}, 8, ["is-show", "width"]);
|
|
3223
|
+
};
|
|
3224
|
+
}
|
|
3225
|
+
});
|
|
3226
|
+
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-c68dfcac"]]);
|
|
2963
3227
|
const _hoisted_1$3 = { class: "tag-content" };
|
|
2964
3228
|
const _hoisted_2$2 = { class: "user-name" };
|
|
2965
3229
|
const _hoisted_3$2 = {
|
|
@@ -3019,26 +3283,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
3019
3283
|
};
|
|
3020
3284
|
}
|
|
3021
3285
|
});
|
|
3022
|
-
const _export_sfc = (sfc, props) => {
|
|
3023
|
-
const target = sfc.__vccOpts || sfc;
|
|
3024
|
-
for (const [key, val] of props) {
|
|
3025
|
-
target[key] = val;
|
|
3026
|
-
}
|
|
3027
|
-
return target;
|
|
3028
|
-
};
|
|
3029
3286
|
const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-203c36cb"]]);
|
|
3030
3287
|
const _hoisted_1$2 = ["onClick"];
|
|
3031
3288
|
const _hoisted_2$1 = ["placeholder"];
|
|
3032
3289
|
const _hoisted_3$1 = ["placeholder"];
|
|
3033
|
-
const _hoisted_4$1 = {
|
|
3034
|
-
key: 0,
|
|
3035
|
-
class: "no-data"
|
|
3036
|
-
};
|
|
3037
|
-
const _hoisted_5$1 = ["onMousedown"];
|
|
3038
|
-
const _hoisted_6$1 = {
|
|
3039
|
-
key: 0,
|
|
3040
|
-
class: "tenant-name"
|
|
3041
|
-
};
|
|
3042
3290
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3043
3291
|
...{
|
|
3044
3292
|
name: "BkUserSelectorMultiple"
|
|
@@ -3107,6 +3355,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3107
3355
|
exactSearchKey: {
|
|
3108
3356
|
type: String,
|
|
3109
3357
|
default: "bk_username"
|
|
3358
|
+
},
|
|
3359
|
+
/**
|
|
3360
|
+
* 用户组
|
|
3361
|
+
*/
|
|
3362
|
+
userGroup: {
|
|
3363
|
+
type: Array,
|
|
3364
|
+
default: () => []
|
|
3365
|
+
},
|
|
3366
|
+
/**
|
|
3367
|
+
* 用户组名称
|
|
3368
|
+
*/
|
|
3369
|
+
userGroupName: {
|
|
3370
|
+
type: String,
|
|
3371
|
+
default: "用户群组"
|
|
3110
3372
|
}
|
|
3111
3373
|
},
|
|
3112
3374
|
emits: ["update:selectedUsers", "add-user", "remove-user"],
|
|
@@ -3132,6 +3394,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3132
3394
|
const sortableInstance = ref(null);
|
|
3133
3395
|
const visibleUsers = ref([]);
|
|
3134
3396
|
const hiddenCount = ref(0);
|
|
3397
|
+
const options = computed(() => {
|
|
3398
|
+
return searchResults.value.filter((user) => !props.selectedUsers.some((selectedUser) => selectedUser.id === user.id));
|
|
3399
|
+
});
|
|
3135
3400
|
const initSortable = () => {
|
|
3136
3401
|
if (!props.draggable || !sortableContainerRef.value) return;
|
|
3137
3402
|
if (sortableInstance.value) {
|
|
@@ -3169,7 +3434,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3169
3434
|
};
|
|
3170
3435
|
const handleFocus = () => {
|
|
3171
3436
|
isFocused.value = true;
|
|
3172
|
-
|
|
3437
|
+
if (props.userGroup.length > 0) {
|
|
3438
|
+
showDropdown.value = true;
|
|
3439
|
+
} else {
|
|
3440
|
+
showDropdown.value = false;
|
|
3441
|
+
}
|
|
3173
3442
|
activeTagIndex.value = -1;
|
|
3174
3443
|
nextTick(() => {
|
|
3175
3444
|
if (lastInputRef.value) {
|
|
@@ -3420,17 +3689,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3420
3689
|
[vModelText, unref(searchQuery)]
|
|
3421
3690
|
]) : createCommentVNode("v-if", true),
|
|
3422
3691
|
createCommentVNode(' "我"标签 '),
|
|
3423
|
-
|
|
3424
|
-
"
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
onClick: _cache[2] || (_cache[2] = withModifiers(($event) => addCurrentUser(), ["stop"]))
|
|
3429
|
-
},
|
|
3430
|
-
" 我 ",
|
|
3431
|
-
2
|
|
3432
|
-
/* CLASS */
|
|
3433
|
-
)) : createCommentVNode("v-if", true)
|
|
3692
|
+
createVNode(MeTag, {
|
|
3693
|
+
"current-user-id": __props.currentUserId,
|
|
3694
|
+
"is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user.id === __props.currentUserId),
|
|
3695
|
+
onClick: addCurrentUser
|
|
3696
|
+
}, null, 8, ["current-user-id", "is-disabled"])
|
|
3434
3697
|
],
|
|
3435
3698
|
512
|
|
3436
3699
|
/* NEED_PATCH */
|
|
@@ -3489,24 +3752,18 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3489
3752
|
ref_key: "collapsedInputRef",
|
|
3490
3753
|
ref: collapsedInputRef,
|
|
3491
3754
|
class: "search-input collapsed",
|
|
3492
|
-
"onUpdate:modelValue": _cache[
|
|
3755
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
3493
3756
|
placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
|
|
3494
3757
|
onFocus: handleFocus
|
|
3495
3758
|
}, null, 40, _hoisted_3$1), [
|
|
3496
3759
|
[vModelText, unref(searchQuery)]
|
|
3497
3760
|
]),
|
|
3498
3761
|
createCommentVNode(' 未聚焦状态下的"我"标签 '),
|
|
3499
|
-
|
|
3500
|
-
"
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
onClick: _cache[4] || (_cache[4] = withModifiers(($event) => addCurrentUser(), ["stop"]))
|
|
3505
|
-
},
|
|
3506
|
-
" 我 ",
|
|
3507
|
-
2
|
|
3508
|
-
/* CLASS */
|
|
3509
|
-
)) : createCommentVNode("v-if", true)
|
|
3762
|
+
createVNode(MeTag, {
|
|
3763
|
+
"current-user-id": __props.currentUserId,
|
|
3764
|
+
"is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user[props.exactSearchKey] === __props.currentUserId),
|
|
3765
|
+
onClick: addCurrentUser
|
|
3766
|
+
}, null, 8, ["current-user-id", "is-disabled"])
|
|
3510
3767
|
],
|
|
3511
3768
|
512
|
|
3512
3769
|
/* NEED_PATCH */
|
|
@@ -3516,75 +3773,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3516
3773
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
3517
3774
|
)),
|
|
3518
3775
|
createCommentVNode(" 下拉选项列表 "),
|
|
3519
|
-
createVNode(
|
|
3520
|
-
"
|
|
3521
|
-
arrow: false,
|
|
3776
|
+
createVNode(SelectionPopover, {
|
|
3777
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
3522
3778
|
"is-show": showDropdown.value,
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
size: "mini",
|
|
3533
|
-
mode: "spin"
|
|
3534
|
-
}, {
|
|
3535
|
-
default: withCtx(() => [
|
|
3536
|
-
unref(searchResults).length === 0 ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
|
|
3537
|
-
createElementVNode(
|
|
3538
|
-
"span",
|
|
3539
|
-
null,
|
|
3540
|
-
toDisplayString(unref(searchQuery).length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
|
|
3541
|
-
1
|
|
3542
|
-
/* TEXT */
|
|
3543
|
-
)
|
|
3544
|
-
])) : (openBlock(true), createElementBlock(
|
|
3545
|
-
Fragment,
|
|
3546
|
-
{ key: 1 },
|
|
3547
|
-
renderList(unref(searchResults), (user) => {
|
|
3548
|
-
return openBlock(), createElementBlock("div", {
|
|
3549
|
-
class: "user-option",
|
|
3550
|
-
key: user.id,
|
|
3551
|
-
onMousedown: withModifiers(($event) => addUser(user), ["prevent"])
|
|
3552
|
-
}, [
|
|
3553
|
-
createElementVNode(
|
|
3554
|
-
"span",
|
|
3555
|
-
null,
|
|
3556
|
-
toDisplayString(user.name),
|
|
3557
|
-
1
|
|
3558
|
-
/* TEXT */
|
|
3559
|
-
),
|
|
3560
|
-
user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
3561
|
-
"span",
|
|
3562
|
-
_hoisted_6$1,
|
|
3563
|
-
"@" + toDisplayString(__props.tenants[user.tenantId]),
|
|
3564
|
-
1
|
|
3565
|
-
/* TEXT */
|
|
3566
|
-
)) : createCommentVNode("v-if", true)
|
|
3567
|
-
], 40, _hoisted_5$1);
|
|
3568
|
-
}),
|
|
3569
|
-
128
|
|
3570
|
-
/* KEYED_FRAGMENT */
|
|
3571
|
-
))
|
|
3572
|
-
]),
|
|
3573
|
-
_: 1
|
|
3574
|
-
/* STABLE */
|
|
3575
|
-
}, 8, ["loading"])
|
|
3576
|
-
]),
|
|
3577
|
-
_: 1
|
|
3578
|
-
/* STABLE */
|
|
3579
|
-
}, 8, ["is-show", "width"])
|
|
3779
|
+
loading: unref(searchLoading),
|
|
3780
|
+
options: options.value,
|
|
3781
|
+
"search-query": unref(searchQuery),
|
|
3782
|
+
"tenant-id": __props.tenantId,
|
|
3783
|
+
tenants: __props.tenants,
|
|
3784
|
+
"user-group": __props.userGroup,
|
|
3785
|
+
"user-group-name": __props.userGroupName,
|
|
3786
|
+
onSelectUser: addUser
|
|
3787
|
+
}, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
3580
3788
|
])), [
|
|
3581
3789
|
[unref(clickoutside), handleClickOutside]
|
|
3582
3790
|
]);
|
|
3583
3791
|
};
|
|
3584
3792
|
}
|
|
3585
3793
|
});
|
|
3586
|
-
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
3587
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
3794
|
+
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a8dc735f"]]);
|
|
3795
|
+
const _withScopeId = (n) => (pushScopeId("data-v-8b8dd0fd"), n = n(), popScopeId(), n);
|
|
3588
3796
|
const _hoisted_1$1 = { class: "input-container" };
|
|
3589
3797
|
const _hoisted_2 = {
|
|
3590
3798
|
key: 0,
|
|
@@ -3598,15 +3806,6 @@ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElem
|
|
|
3598
3806
|
/* HOISTED */
|
|
3599
3807
|
));
|
|
3600
3808
|
const _hoisted_4 = ["placeholder"];
|
|
3601
|
-
const _hoisted_5 = {
|
|
3602
|
-
key: 0,
|
|
3603
|
-
class: "no-data"
|
|
3604
|
-
};
|
|
3605
|
-
const _hoisted_6 = ["onMousedown"];
|
|
3606
|
-
const _hoisted_7 = {
|
|
3607
|
-
key: 0,
|
|
3608
|
-
class: "tenant-name"
|
|
3609
|
-
};
|
|
3610
3809
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
3611
3810
|
...{
|
|
3612
3811
|
name: "BkUserSelectorSingle"
|
|
@@ -3614,12 +3813,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3614
3813
|
__name: "single-selector",
|
|
3615
3814
|
props: {
|
|
3616
3815
|
modelValue: {},
|
|
3617
|
-
|
|
3816
|
+
tenants: {},
|
|
3618
3817
|
apiBaseUrl: {},
|
|
3619
3818
|
tenantId: {},
|
|
3620
|
-
|
|
3819
|
+
placeholder: {},
|
|
3621
3820
|
currentUserId: {},
|
|
3622
|
-
exactSearchKey: {}
|
|
3821
|
+
exactSearchKey: {},
|
|
3822
|
+
userGroup: {},
|
|
3823
|
+
userGroupName: {}
|
|
3623
3824
|
},
|
|
3624
3825
|
emits: ["update:modelValue", "change"],
|
|
3625
3826
|
setup(__props, { emit: __emit }) {
|
|
@@ -3633,7 +3834,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3633
3834
|
const searchQuery = ref("");
|
|
3634
3835
|
const showDropdown = ref(false);
|
|
3635
3836
|
const selectedUserInfo = computed(() => {
|
|
3636
|
-
|
|
3837
|
+
const userGroup = (props.userGroup || []).map((group) => ({
|
|
3838
|
+
id: group.id,
|
|
3839
|
+
name: group.name,
|
|
3840
|
+
tenantId: ""
|
|
3841
|
+
}));
|
|
3842
|
+
const list = [...options.value, ...userGroup];
|
|
3843
|
+
const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
|
|
3844
|
+
emit("change", selectedUserInfo2 || null);
|
|
3845
|
+
return selectedUserInfo2;
|
|
3637
3846
|
});
|
|
3638
3847
|
onBeforeMount(async () => {
|
|
3639
3848
|
if (typeof props.modelValue === "string" && props.modelValue) {
|
|
@@ -3657,7 +3866,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3657
3866
|
const formattedResults = formatUsers(result);
|
|
3658
3867
|
if (formattedResults.length > 0) {
|
|
3659
3868
|
options.value = formattedResults;
|
|
3660
|
-
|
|
3869
|
+
addUser(formattedResults[0]);
|
|
3661
3870
|
}
|
|
3662
3871
|
} catch (error) {
|
|
3663
3872
|
console.error("获取当前用户信息失败:", error);
|
|
@@ -3671,7 +3880,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3671
3880
|
isLoading.value = true;
|
|
3672
3881
|
try {
|
|
3673
3882
|
const result = await searchUsers(props.apiBaseUrl, props.tenantId, keyword);
|
|
3674
|
-
options.value = formatUsers(result);
|
|
3883
|
+
options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
|
|
3675
3884
|
console.log("options.value", options.value);
|
|
3676
3885
|
} catch (error) {
|
|
3677
3886
|
console.error("获取用户列表失败:", error);
|
|
@@ -3680,7 +3889,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3680
3889
|
isLoading.value = false;
|
|
3681
3890
|
}
|
|
3682
3891
|
};
|
|
3683
|
-
const
|
|
3892
|
+
const addUser = (user) => {
|
|
3893
|
+
console.log("addUser", user);
|
|
3684
3894
|
selectedUser.value = user.id;
|
|
3685
3895
|
searchQuery.value = "";
|
|
3686
3896
|
showDropdown.value = false;
|
|
@@ -3690,7 +3900,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3690
3900
|
searchQuery.value = "";
|
|
3691
3901
|
};
|
|
3692
3902
|
const handleInputFocus = () => {
|
|
3693
|
-
if (searchQuery.value.length >= 2) {
|
|
3903
|
+
if (searchQuery.value.length >= 2 || Array.isArray(props.userGroup) && props.userGroup.length > 0) {
|
|
3694
3904
|
showDropdown.value = true;
|
|
3695
3905
|
}
|
|
3696
3906
|
};
|
|
@@ -3703,12 +3913,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3703
3913
|
showDropdown.value = false;
|
|
3704
3914
|
};
|
|
3705
3915
|
watch(selectedUser, (newVal) => {
|
|
3916
|
+
console.log("selectedUser", newVal);
|
|
3706
3917
|
emit("update:modelValue", newVal);
|
|
3707
|
-
const selectedUserInfo2 = options.value.find((user) => user.id === newVal);
|
|
3708
|
-
emit("change", selectedUserInfo2 || null);
|
|
3709
3918
|
});
|
|
3710
3919
|
return (_ctx, _cache) => {
|
|
3711
|
-
var _a;
|
|
3712
3920
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
3713
3921
|
ref_key: "containerRef",
|
|
3714
3922
|
ref: containerRef,
|
|
@@ -3750,87 +3958,32 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3750
3958
|
[vModelText, searchQuery.value]
|
|
3751
3959
|
]),
|
|
3752
3960
|
createCommentVNode(' "我"标签 '),
|
|
3753
|
-
|
|
3754
|
-
"
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
onClick: _cache[1] || (_cache[1] = ($event) => addCurrentUser())
|
|
3759
|
-
},
|
|
3760
|
-
" 我 ",
|
|
3761
|
-
2
|
|
3762
|
-
/* CLASS */
|
|
3763
|
-
)) : createCommentVNode("v-if", true)
|
|
3961
|
+
createVNode(MeTag, {
|
|
3962
|
+
"is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey || "bk_username"] === _ctx.currentUserId,
|
|
3963
|
+
"current-user-id": _ctx.currentUserId,
|
|
3964
|
+
onClick: addCurrentUser
|
|
3965
|
+
}, null, 8, ["is-disabled", "current-user-id"])
|
|
3764
3966
|
]),
|
|
3765
|
-
createCommentVNode("
|
|
3766
|
-
createVNode(
|
|
3767
|
-
"
|
|
3768
|
-
arrow: false,
|
|
3967
|
+
createCommentVNode(" 使用新的公共下拉选项组件 "),
|
|
3968
|
+
createVNode(SelectionPopover, {
|
|
3969
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
3769
3970
|
"is-show": showDropdown.value,
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
size: "mini",
|
|
3780
|
-
mode: "spin"
|
|
3781
|
-
}, {
|
|
3782
|
-
default: withCtx(() => [
|
|
3783
|
-
options.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
3784
|
-
createElementVNode(
|
|
3785
|
-
"span",
|
|
3786
|
-
null,
|
|
3787
|
-
toDisplayString(searchQuery.value.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
|
|
3788
|
-
1
|
|
3789
|
-
/* TEXT */
|
|
3790
|
-
)
|
|
3791
|
-
])) : (openBlock(true), createElementBlock(
|
|
3792
|
-
Fragment,
|
|
3793
|
-
{ key: 1 },
|
|
3794
|
-
renderList(options.value, (user) => {
|
|
3795
|
-
return openBlock(), createElementBlock("div", {
|
|
3796
|
-
class: "user-option",
|
|
3797
|
-
key: user.id,
|
|
3798
|
-
onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
|
|
3799
|
-
}, [
|
|
3800
|
-
createElementVNode(
|
|
3801
|
-
"span",
|
|
3802
|
-
null,
|
|
3803
|
-
toDisplayString(user.name),
|
|
3804
|
-
1
|
|
3805
|
-
/* TEXT */
|
|
3806
|
-
),
|
|
3807
|
-
user.tenantId !== _ctx.tenantId && user.tenantId && _ctx.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
3808
|
-
"span",
|
|
3809
|
-
_hoisted_7,
|
|
3810
|
-
"@" + toDisplayString(_ctx.tenants[user.tenantId]),
|
|
3811
|
-
1
|
|
3812
|
-
/* TEXT */
|
|
3813
|
-
)) : createCommentVNode("v-if", true)
|
|
3814
|
-
], 40, _hoisted_6);
|
|
3815
|
-
}),
|
|
3816
|
-
128
|
|
3817
|
-
/* KEYED_FRAGMENT */
|
|
3818
|
-
))
|
|
3819
|
-
]),
|
|
3820
|
-
_: 1
|
|
3821
|
-
/* STABLE */
|
|
3822
|
-
}, 8, ["loading"])
|
|
3823
|
-
]),
|
|
3824
|
-
_: 1
|
|
3825
|
-
/* STABLE */
|
|
3826
|
-
}, 8, ["is-show", "width"])
|
|
3971
|
+
loading: isLoading.value,
|
|
3972
|
+
options: options.value,
|
|
3973
|
+
"search-query": searchQuery.value,
|
|
3974
|
+
"tenant-id": _ctx.tenantId,
|
|
3975
|
+
tenants: _ctx.tenants,
|
|
3976
|
+
"user-group": _ctx.userGroup,
|
|
3977
|
+
"user-group-name": _ctx.userGroupName,
|
|
3978
|
+
onSelectUser: addUser
|
|
3979
|
+
}, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
3827
3980
|
])), [
|
|
3828
3981
|
[unref(clickoutside), handleClickOutside]
|
|
3829
3982
|
]);
|
|
3830
3983
|
};
|
|
3831
3984
|
}
|
|
3832
3985
|
});
|
|
3833
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
3986
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
|
|
3834
3987
|
const _hoisted_1 = { class: "bk-user-selector" };
|
|
3835
3988
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3836
3989
|
...{
|
|
@@ -3838,14 +3991,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3838
3991
|
},
|
|
3839
3992
|
__name: "user-selector",
|
|
3840
3993
|
props: {
|
|
3841
|
-
apiBaseUrl: { default: "" },
|
|
3842
|
-
tenantId: { default: "" },
|
|
3843
|
-
placeholder: { default: "请输入人员名称搜索" },
|
|
3844
3994
|
modelValue: { default: "" },
|
|
3845
3995
|
draggable: { type: Boolean, default: false },
|
|
3846
3996
|
multiple: { type: Boolean, default: false },
|
|
3997
|
+
apiBaseUrl: { default: "" },
|
|
3998
|
+
tenantId: { default: "" },
|
|
3999
|
+
placeholder: { default: "请输入人员名称搜索" },
|
|
3847
4000
|
currentUserId: { default: "" },
|
|
3848
|
-
exactSearchKey: { default: "" }
|
|
4001
|
+
exactSearchKey: { default: "bk_username" },
|
|
4002
|
+
userGroup: { default: () => [] },
|
|
4003
|
+
userGroupName: { default: "用户群组" }
|
|
3849
4004
|
},
|
|
3850
4005
|
emits: ["update:modelValue", "change"],
|
|
3851
4006
|
setup(__props, { emit: __emit }) {
|
|
@@ -3905,8 +4060,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3905
4060
|
placeholder: _ctx.placeholder,
|
|
3906
4061
|
"tenant-id": _ctx.tenantId,
|
|
3907
4062
|
tenants: unref(tenants),
|
|
4063
|
+
"user-group": _ctx.userGroup,
|
|
4064
|
+
"user-group-name": _ctx.userGroupName,
|
|
3908
4065
|
onChange: handleUpdateUser
|
|
3909
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants"])) : (openBlock(), createElementBlock(
|
|
4066
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
|
|
3910
4067
|
Fragment,
|
|
3911
4068
|
{ key: 1 },
|
|
3912
4069
|
[
|
|
@@ -3922,8 +4079,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3922
4079
|
"selected-users": selectedUsers.value,
|
|
3923
4080
|
"tenant-id": _ctx.tenantId,
|
|
3924
4081
|
tenants: unref(tenants),
|
|
4082
|
+
"user-group": _ctx.userGroup,
|
|
4083
|
+
"user-group-name": _ctx.userGroupName,
|
|
3925
4084
|
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
3926
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants"])
|
|
4085
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
3927
4086
|
],
|
|
3928
4087
|
2112
|
|
3929
4088
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -3932,7 +4091,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3932
4091
|
};
|
|
3933
4092
|
}
|
|
3934
4093
|
});
|
|
3935
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4094
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
|
|
3936
4095
|
export {
|
|
3937
4096
|
BkUserSelector,
|
|
3938
4097
|
BkUserSelector as default
|