@blueking/bk-user-selector 0.0.5 → 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 +41 -2
- package/typings/components/selection-popover.vue.d.ts +154 -0
- package/typings/components/user-selector.vue.d.ts +11 -2
- package/typings/types/index.d.ts +41 -40
- package/vue2/index.es.min.js +366 -203
- package/vue2/index.iife.min.js +366 -203
- package/vue2/index.umd.min.js +366 -203
- package/vue2/vue2.css +82 -128
- package/vue3/index.es.min.js +367 -204
- package/vue3/index.iife.min.js +366 -203
- package/vue3/index.umd.min.js +366 -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");
|
|
@@ -77,7 +77,8 @@ const formatUsers = (users) => {
|
|
|
77
77
|
return users.map((user) => ({
|
|
78
78
|
id: user.bk_username,
|
|
79
79
|
name: user.display_name,
|
|
80
|
-
tenantId: user.owner_tenant_id
|
|
80
|
+
tenantId: user.owner_tenant_id,
|
|
81
|
+
...user
|
|
81
82
|
}));
|
|
82
83
|
};
|
|
83
84
|
const useTenantData = (apiBaseUrl, tenantId) => {
|
|
@@ -2959,6 +2960,270 @@ const useUserSearch = (apiBaseUrl, tenantId) => {
|
|
|
2959
2960
|
clearSearch
|
|
2960
2961
|
};
|
|
2961
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"]]);
|
|
2962
3227
|
const _hoisted_1$3 = { class: "tag-content" };
|
|
2963
3228
|
const _hoisted_2$2 = { class: "user-name" };
|
|
2964
3229
|
const _hoisted_3$2 = {
|
|
@@ -3018,26 +3283,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
3018
3283
|
};
|
|
3019
3284
|
}
|
|
3020
3285
|
});
|
|
3021
|
-
const _export_sfc = (sfc, props) => {
|
|
3022
|
-
const target = sfc.__vccOpts || sfc;
|
|
3023
|
-
for (const [key, val] of props) {
|
|
3024
|
-
target[key] = val;
|
|
3025
|
-
}
|
|
3026
|
-
return target;
|
|
3027
|
-
};
|
|
3028
3286
|
const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-203c36cb"]]);
|
|
3029
3287
|
const _hoisted_1$2 = ["onClick"];
|
|
3030
3288
|
const _hoisted_2$1 = ["placeholder"];
|
|
3031
3289
|
const _hoisted_3$1 = ["placeholder"];
|
|
3032
|
-
const _hoisted_4$1 = {
|
|
3033
|
-
key: 0,
|
|
3034
|
-
class: "no-data"
|
|
3035
|
-
};
|
|
3036
|
-
const _hoisted_5$1 = ["onMousedown"];
|
|
3037
|
-
const _hoisted_6$1 = {
|
|
3038
|
-
key: 0,
|
|
3039
|
-
class: "tenant-name"
|
|
3040
|
-
};
|
|
3041
3290
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3042
3291
|
...{
|
|
3043
3292
|
name: "BkUserSelectorMultiple"
|
|
@@ -3106,6 +3355,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3106
3355
|
exactSearchKey: {
|
|
3107
3356
|
type: String,
|
|
3108
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: "用户群组"
|
|
3109
3372
|
}
|
|
3110
3373
|
},
|
|
3111
3374
|
emits: ["update:selectedUsers", "add-user", "remove-user"],
|
|
@@ -3131,6 +3394,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3131
3394
|
const sortableInstance = ref(null);
|
|
3132
3395
|
const visibleUsers = ref([]);
|
|
3133
3396
|
const hiddenCount = ref(0);
|
|
3397
|
+
const options = computed(() => {
|
|
3398
|
+
return searchResults.value.filter((user) => !props.selectedUsers.some((selectedUser) => selectedUser.id === user.id));
|
|
3399
|
+
});
|
|
3134
3400
|
const initSortable = () => {
|
|
3135
3401
|
if (!props.draggable || !sortableContainerRef.value) return;
|
|
3136
3402
|
if (sortableInstance.value) {
|
|
@@ -3168,7 +3434,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3168
3434
|
};
|
|
3169
3435
|
const handleFocus = () => {
|
|
3170
3436
|
isFocused.value = true;
|
|
3171
|
-
|
|
3437
|
+
if (props.userGroup.length > 0) {
|
|
3438
|
+
showDropdown.value = true;
|
|
3439
|
+
} else {
|
|
3440
|
+
showDropdown.value = false;
|
|
3441
|
+
}
|
|
3172
3442
|
activeTagIndex.value = -1;
|
|
3173
3443
|
nextTick(() => {
|
|
3174
3444
|
if (lastInputRef.value) {
|
|
@@ -3419,16 +3689,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3419
3689
|
[vModelText, unref(searchQuery)]
|
|
3420
3690
|
]) : createCommentVNode("v-if", true),
|
|
3421
3691
|
createCommentVNode(' "我"标签 '),
|
|
3422
|
-
|
|
3423
|
-
"
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
},
|
|
3428
|
-
" 我 ",
|
|
3429
|
-
2
|
|
3430
|
-
/* CLASS */
|
|
3431
|
-
)
|
|
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"])
|
|
3432
3697
|
],
|
|
3433
3698
|
512
|
|
3434
3699
|
/* NEED_PATCH */
|
|
@@ -3487,23 +3752,18 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3487
3752
|
ref_key: "collapsedInputRef",
|
|
3488
3753
|
ref: collapsedInputRef,
|
|
3489
3754
|
class: "search-input collapsed",
|
|
3490
|
-
"onUpdate:modelValue": _cache[
|
|
3755
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
3491
3756
|
placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
|
|
3492
3757
|
onFocus: handleFocus
|
|
3493
3758
|
}, null, 40, _hoisted_3$1), [
|
|
3494
3759
|
[vModelText, unref(searchQuery)]
|
|
3495
3760
|
]),
|
|
3496
3761
|
createCommentVNode(' 未聚焦状态下的"我"标签 '),
|
|
3497
|
-
|
|
3498
|
-
"
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
},
|
|
3503
|
-
" 我 ",
|
|
3504
|
-
2
|
|
3505
|
-
/* CLASS */
|
|
3506
|
-
)
|
|
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"])
|
|
3507
3767
|
],
|
|
3508
3768
|
512
|
|
3509
3769
|
/* NEED_PATCH */
|
|
@@ -3513,75 +3773,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3513
3773
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
3514
3774
|
)),
|
|
3515
3775
|
createCommentVNode(" 下拉选项列表 "),
|
|
3516
|
-
createVNode(
|
|
3517
|
-
"
|
|
3518
|
-
arrow: false,
|
|
3776
|
+
createVNode(SelectionPopover, {
|
|
3777
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
3519
3778
|
"is-show": showDropdown.value,
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
size: "mini",
|
|
3530
|
-
mode: "spin"
|
|
3531
|
-
}, {
|
|
3532
|
-
default: withCtx(() => [
|
|
3533
|
-
unref(searchResults).length === 0 ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
|
|
3534
|
-
createElementVNode(
|
|
3535
|
-
"span",
|
|
3536
|
-
null,
|
|
3537
|
-
toDisplayString(unref(searchQuery).length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
|
|
3538
|
-
1
|
|
3539
|
-
/* TEXT */
|
|
3540
|
-
)
|
|
3541
|
-
])) : (openBlock(true), createElementBlock(
|
|
3542
|
-
Fragment,
|
|
3543
|
-
{ key: 1 },
|
|
3544
|
-
renderList(unref(searchResults), (user) => {
|
|
3545
|
-
return openBlock(), createElementBlock("div", {
|
|
3546
|
-
class: "user-option",
|
|
3547
|
-
key: user.id,
|
|
3548
|
-
onMousedown: withModifiers(($event) => addUser(user), ["prevent"])
|
|
3549
|
-
}, [
|
|
3550
|
-
createElementVNode(
|
|
3551
|
-
"span",
|
|
3552
|
-
null,
|
|
3553
|
-
toDisplayString(user.name),
|
|
3554
|
-
1
|
|
3555
|
-
/* TEXT */
|
|
3556
|
-
),
|
|
3557
|
-
user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
3558
|
-
"span",
|
|
3559
|
-
_hoisted_6$1,
|
|
3560
|
-
"@" + toDisplayString(__props.tenants[user.tenantId]),
|
|
3561
|
-
1
|
|
3562
|
-
/* TEXT */
|
|
3563
|
-
)) : createCommentVNode("v-if", true)
|
|
3564
|
-
], 40, _hoisted_5$1);
|
|
3565
|
-
}),
|
|
3566
|
-
128
|
|
3567
|
-
/* KEYED_FRAGMENT */
|
|
3568
|
-
))
|
|
3569
|
-
]),
|
|
3570
|
-
_: 1
|
|
3571
|
-
/* STABLE */
|
|
3572
|
-
}, 8, ["loading"])
|
|
3573
|
-
]),
|
|
3574
|
-
_: 1
|
|
3575
|
-
/* STABLE */
|
|
3576
|
-
}, 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"])
|
|
3577
3788
|
])), [
|
|
3578
3789
|
[unref(clickoutside), handleClickOutside]
|
|
3579
3790
|
]);
|
|
3580
3791
|
};
|
|
3581
3792
|
}
|
|
3582
3793
|
});
|
|
3583
|
-
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
3584
|
-
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);
|
|
3585
3796
|
const _hoisted_1$1 = { class: "input-container" };
|
|
3586
3797
|
const _hoisted_2 = {
|
|
3587
3798
|
key: 0,
|
|
@@ -3595,15 +3806,6 @@ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElem
|
|
|
3595
3806
|
/* HOISTED */
|
|
3596
3807
|
));
|
|
3597
3808
|
const _hoisted_4 = ["placeholder"];
|
|
3598
|
-
const _hoisted_5 = {
|
|
3599
|
-
key: 0,
|
|
3600
|
-
class: "no-data"
|
|
3601
|
-
};
|
|
3602
|
-
const _hoisted_6 = ["onMousedown"];
|
|
3603
|
-
const _hoisted_7 = {
|
|
3604
|
-
key: 0,
|
|
3605
|
-
class: "tenant-name"
|
|
3606
|
-
};
|
|
3607
3809
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
3608
3810
|
...{
|
|
3609
3811
|
name: "BkUserSelectorSingle"
|
|
@@ -3611,12 +3813,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3611
3813
|
__name: "single-selector",
|
|
3612
3814
|
props: {
|
|
3613
3815
|
modelValue: {},
|
|
3614
|
-
|
|
3816
|
+
tenants: {},
|
|
3615
3817
|
apiBaseUrl: {},
|
|
3616
3818
|
tenantId: {},
|
|
3617
|
-
|
|
3819
|
+
placeholder: {},
|
|
3618
3820
|
currentUserId: {},
|
|
3619
|
-
exactSearchKey: {}
|
|
3821
|
+
exactSearchKey: {},
|
|
3822
|
+
userGroup: {},
|
|
3823
|
+
userGroupName: {}
|
|
3620
3824
|
},
|
|
3621
3825
|
emits: ["update:modelValue", "change"],
|
|
3622
3826
|
setup(__props, { emit: __emit }) {
|
|
@@ -3630,7 +3834,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3630
3834
|
const searchQuery = ref("");
|
|
3631
3835
|
const showDropdown = ref(false);
|
|
3632
3836
|
const selectedUserInfo = computed(() => {
|
|
3633
|
-
|
|
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;
|
|
3634
3846
|
});
|
|
3635
3847
|
onBeforeMount(async () => {
|
|
3636
3848
|
if (typeof props.modelValue === "string" && props.modelValue) {
|
|
@@ -3654,7 +3866,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3654
3866
|
const formattedResults = formatUsers(result);
|
|
3655
3867
|
if (formattedResults.length > 0) {
|
|
3656
3868
|
options.value = formattedResults;
|
|
3657
|
-
|
|
3869
|
+
addUser(formattedResults[0]);
|
|
3658
3870
|
}
|
|
3659
3871
|
} catch (error) {
|
|
3660
3872
|
console.error("获取当前用户信息失败:", error);
|
|
@@ -3668,7 +3880,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3668
3880
|
isLoading.value = true;
|
|
3669
3881
|
try {
|
|
3670
3882
|
const result = await searchUsers(props.apiBaseUrl, props.tenantId, keyword);
|
|
3671
|
-
options.value = formatUsers(result);
|
|
3883
|
+
options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
|
|
3672
3884
|
console.log("options.value", options.value);
|
|
3673
3885
|
} catch (error) {
|
|
3674
3886
|
console.error("获取用户列表失败:", error);
|
|
@@ -3677,7 +3889,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3677
3889
|
isLoading.value = false;
|
|
3678
3890
|
}
|
|
3679
3891
|
};
|
|
3680
|
-
const
|
|
3892
|
+
const addUser = (user) => {
|
|
3893
|
+
console.log("addUser", user);
|
|
3681
3894
|
selectedUser.value = user.id;
|
|
3682
3895
|
searchQuery.value = "";
|
|
3683
3896
|
showDropdown.value = false;
|
|
@@ -3687,7 +3900,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3687
3900
|
searchQuery.value = "";
|
|
3688
3901
|
};
|
|
3689
3902
|
const handleInputFocus = () => {
|
|
3690
|
-
if (searchQuery.value.length >= 2) {
|
|
3903
|
+
if (searchQuery.value.length >= 2 || Array.isArray(props.userGroup) && props.userGroup.length > 0) {
|
|
3691
3904
|
showDropdown.value = true;
|
|
3692
3905
|
}
|
|
3693
3906
|
};
|
|
@@ -3700,9 +3913,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3700
3913
|
showDropdown.value = false;
|
|
3701
3914
|
};
|
|
3702
3915
|
watch(selectedUser, (newVal) => {
|
|
3916
|
+
console.log("selectedUser", newVal);
|
|
3703
3917
|
emit("update:modelValue", newVal);
|
|
3704
|
-
const selectedUserInfo2 = options.value.find((user) => user.id === newVal);
|
|
3705
|
-
emit("change", selectedUserInfo2 || null);
|
|
3706
3918
|
});
|
|
3707
3919
|
return (_ctx, _cache) => {
|
|
3708
3920
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
@@ -3725,7 +3937,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3725
3937
|
1
|
|
3726
3938
|
/* TEXT */
|
|
3727
3939
|
),
|
|
3728
|
-
selectedUserInfo.value.tenantId !==
|
|
3940
|
+
selectedUserInfo.value.tenantId !== _ctx.tenantId && selectedUserInfo.value.tenantId && _ctx.tenants[selectedUserInfo.value.tenantId] ? (openBlock(), createElementBlock(
|
|
3729
3941
|
"span",
|
|
3730
3942
|
_hoisted_2,
|
|
3731
3943
|
"@" + toDisplayString(_ctx.tenants[selectedUserInfo.value.tenantId]),
|
|
@@ -3739,94 +3951,39 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3739
3951
|
ref: inputRef,
|
|
3740
3952
|
class: "search-input",
|
|
3741
3953
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchQuery.value = $event),
|
|
3742
|
-
placeholder: selectedUserInfo.value ? "" :
|
|
3954
|
+
placeholder: selectedUserInfo.value ? "" : _ctx.placeholder,
|
|
3743
3955
|
onFocus: handleInputFocus,
|
|
3744
3956
|
onInput: handleInput
|
|
3745
3957
|
}, null, 40, _hoisted_4), [
|
|
3746
3958
|
[vModelText, searchQuery.value]
|
|
3747
3959
|
]),
|
|
3748
3960
|
createCommentVNode(' "我"标签 '),
|
|
3749
|
-
|
|
3750
|
-
"
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
onClick: _cache[1] || (_cache[1] = ($event) => addCurrentUser())
|
|
3755
|
-
},
|
|
3756
|
-
" 我 ",
|
|
3757
|
-
2
|
|
3758
|
-
/* CLASS */
|
|
3759
|
-
)) : 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"])
|
|
3760
3966
|
]),
|
|
3761
|
-
createCommentVNode("
|
|
3762
|
-
createVNode(
|
|
3763
|
-
"
|
|
3764
|
-
arrow: false,
|
|
3967
|
+
createCommentVNode(" 使用新的公共下拉选项组件 "),
|
|
3968
|
+
createVNode(SelectionPopover, {
|
|
3969
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
3765
3970
|
"is-show": showDropdown.value,
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
size: "mini",
|
|
3776
|
-
mode: "spin"
|
|
3777
|
-
}, {
|
|
3778
|
-
default: withCtx(() => [
|
|
3779
|
-
options.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
3780
|
-
createElementVNode(
|
|
3781
|
-
"span",
|
|
3782
|
-
null,
|
|
3783
|
-
toDisplayString(searchQuery.value.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
|
|
3784
|
-
1
|
|
3785
|
-
/* TEXT */
|
|
3786
|
-
)
|
|
3787
|
-
])) : (openBlock(true), createElementBlock(
|
|
3788
|
-
Fragment,
|
|
3789
|
-
{ key: 1 },
|
|
3790
|
-
renderList(options.value, (user) => {
|
|
3791
|
-
return openBlock(), createElementBlock("div", {
|
|
3792
|
-
class: "user-option",
|
|
3793
|
-
key: user.id,
|
|
3794
|
-
onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
|
|
3795
|
-
}, [
|
|
3796
|
-
createElementVNode(
|
|
3797
|
-
"span",
|
|
3798
|
-
null,
|
|
3799
|
-
toDisplayString(user.name),
|
|
3800
|
-
1
|
|
3801
|
-
/* TEXT */
|
|
3802
|
-
),
|
|
3803
|
-
user.tenantId !== props.tenantId && user.tenantId && props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
3804
|
-
"span",
|
|
3805
|
-
_hoisted_7,
|
|
3806
|
-
"@" + toDisplayString(props.tenants[user.tenantId]),
|
|
3807
|
-
1
|
|
3808
|
-
/* TEXT */
|
|
3809
|
-
)) : createCommentVNode("v-if", true)
|
|
3810
|
-
], 40, _hoisted_6);
|
|
3811
|
-
}),
|
|
3812
|
-
128
|
|
3813
|
-
/* KEYED_FRAGMENT */
|
|
3814
|
-
))
|
|
3815
|
-
]),
|
|
3816
|
-
_: 1
|
|
3817
|
-
/* STABLE */
|
|
3818
|
-
}, 8, ["loading"])
|
|
3819
|
-
]),
|
|
3820
|
-
_: 1
|
|
3821
|
-
/* STABLE */
|
|
3822
|
-
}, 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"])
|
|
3823
3980
|
])), [
|
|
3824
3981
|
[unref(clickoutside), handleClickOutside]
|
|
3825
3982
|
]);
|
|
3826
3983
|
};
|
|
3827
3984
|
}
|
|
3828
3985
|
});
|
|
3829
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
3986
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
|
|
3830
3987
|
const _hoisted_1 = { class: "bk-user-selector" };
|
|
3831
3988
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3832
3989
|
...{
|
|
@@ -3834,14 +3991,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3834
3991
|
},
|
|
3835
3992
|
__name: "user-selector",
|
|
3836
3993
|
props: {
|
|
3837
|
-
apiBaseUrl: { default: "" },
|
|
3838
|
-
tenantId: { default: "" },
|
|
3839
|
-
placeholder: { default: "请输入人员名称搜索" },
|
|
3840
3994
|
modelValue: { default: "" },
|
|
3841
3995
|
draggable: { type: Boolean, default: false },
|
|
3842
3996
|
multiple: { type: Boolean, default: false },
|
|
3997
|
+
apiBaseUrl: { default: "" },
|
|
3998
|
+
tenantId: { default: "" },
|
|
3999
|
+
placeholder: { default: "请输入人员名称搜索" },
|
|
3843
4000
|
currentUserId: { default: "" },
|
|
3844
|
-
exactSearchKey: { default: "" }
|
|
4001
|
+
exactSearchKey: { default: "bk_username" },
|
|
4002
|
+
userGroup: { default: () => [] },
|
|
4003
|
+
userGroupName: { default: "用户群组" }
|
|
3845
4004
|
},
|
|
3846
4005
|
emits: ["update:modelValue", "change"],
|
|
3847
4006
|
setup(__props, { emit: __emit }) {
|
|
@@ -3901,8 +4060,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3901
4060
|
placeholder: _ctx.placeholder,
|
|
3902
4061
|
"tenant-id": _ctx.tenantId,
|
|
3903
4062
|
tenants: unref(tenants),
|
|
4063
|
+
"user-group": _ctx.userGroup,
|
|
4064
|
+
"user-group-name": _ctx.userGroupName,
|
|
3904
4065
|
onChange: handleUpdateUser
|
|
3905
|
-
}, 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(
|
|
3906
4067
|
Fragment,
|
|
3907
4068
|
{ key: 1 },
|
|
3908
4069
|
[
|
|
@@ -3918,8 +4079,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3918
4079
|
"selected-users": selectedUsers.value,
|
|
3919
4080
|
"tenant-id": _ctx.tenantId,
|
|
3920
4081
|
tenants: unref(tenants),
|
|
4082
|
+
"user-group": _ctx.userGroup,
|
|
4083
|
+
"user-group-name": _ctx.userGroupName,
|
|
3921
4084
|
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
3922
|
-
}, 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"])
|
|
3923
4086
|
],
|
|
3924
4087
|
2112
|
|
3925
4088
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -3928,7 +4091,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3928
4091
|
};
|
|
3929
4092
|
}
|
|
3930
4093
|
});
|
|
3931
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4094
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
|
|
3932
4095
|
export {
|
|
3933
4096
|
BkUserSelector,
|
|
3934
4097
|
BkUserSelector as default
|