@blueking/bk-user-selector 0.0.6 → 0.0.8
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 +39 -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 +371 -206
- package/vue2/index.iife.min.js +371 -206
- package/vue2/index.umd.min.js +371 -206
- package/vue2/vue2.css +83 -129
- package/vue3/index.es.min.js +370 -206
- package/vue3/index.iife.min.js +370 -206
- package/vue3/index.umd.min.js +369 -205
- package/vue3/vue3.css +83 -129
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, bkTooltips, 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 */
|
|
@@ -3470,7 +3733,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3470
3733
|
/* KEYED_FRAGMENT */
|
|
3471
3734
|
)),
|
|
3472
3735
|
createCommentVNode(" 显示折叠标签数量 "),
|
|
3473
|
-
hiddenCount.value > 0 ? (openBlock(), createBlock(unref(Tag), {
|
|
3736
|
+
hiddenCount.value > 0 ? withDirectives((openBlock(), createBlock(unref(Tag), {
|
|
3474
3737
|
key: 0,
|
|
3475
3738
|
onClick: withModifiers(handleFocus, ["stop"])
|
|
3476
3739
|
}, {
|
|
@@ -3483,30 +3746,29 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3483
3746
|
]),
|
|
3484
3747
|
_: 1
|
|
3485
3748
|
/* STABLE */
|
|
3486
|
-
}))
|
|
3749
|
+
})), [
|
|
3750
|
+
[unref(bkTooltips), {
|
|
3751
|
+
content: __props.selectedUsers.slice(visibleUsers.value.length).map((user) => user.display_name).join(","),
|
|
3752
|
+
placement: "top"
|
|
3753
|
+
}]
|
|
3754
|
+
]) : createCommentVNode("v-if", true),
|
|
3487
3755
|
createCommentVNode(" 搜索输入框 "),
|
|
3488
3756
|
withDirectives(createElementVNode("input", {
|
|
3489
3757
|
ref_key: "collapsedInputRef",
|
|
3490
3758
|
ref: collapsedInputRef,
|
|
3491
3759
|
class: "search-input collapsed",
|
|
3492
|
-
"onUpdate:modelValue": _cache[
|
|
3760
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
3493
3761
|
placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
|
|
3494
3762
|
onFocus: handleFocus
|
|
3495
3763
|
}, null, 40, _hoisted_3$1), [
|
|
3496
3764
|
[vModelText, unref(searchQuery)]
|
|
3497
3765
|
]),
|
|
3498
3766
|
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)
|
|
3767
|
+
createVNode(MeTag, {
|
|
3768
|
+
"current-user-id": __props.currentUserId,
|
|
3769
|
+
"is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user[props.exactSearchKey] === __props.currentUserId),
|
|
3770
|
+
onClick: addCurrentUser
|
|
3771
|
+
}, null, 8, ["current-user-id", "is-disabled"])
|
|
3510
3772
|
],
|
|
3511
3773
|
512
|
|
3512
3774
|
/* NEED_PATCH */
|
|
@@ -3516,75 +3778,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3516
3778
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
3517
3779
|
)),
|
|
3518
3780
|
createCommentVNode(" 下拉选项列表 "),
|
|
3519
|
-
createVNode(
|
|
3520
|
-
"
|
|
3521
|
-
arrow: false,
|
|
3781
|
+
createVNode(SelectionPopover, {
|
|
3782
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
3522
3783
|
"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"])
|
|
3784
|
+
loading: unref(searchLoading),
|
|
3785
|
+
options: options.value,
|
|
3786
|
+
"search-query": unref(searchQuery),
|
|
3787
|
+
"tenant-id": __props.tenantId,
|
|
3788
|
+
tenants: __props.tenants,
|
|
3789
|
+
"user-group": __props.userGroup,
|
|
3790
|
+
"user-group-name": __props.userGroupName,
|
|
3791
|
+
onSelectUser: addUser
|
|
3792
|
+
}, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
3580
3793
|
])), [
|
|
3581
3794
|
[unref(clickoutside), handleClickOutside]
|
|
3582
3795
|
]);
|
|
3583
3796
|
};
|
|
3584
3797
|
}
|
|
3585
3798
|
});
|
|
3586
|
-
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
3587
|
-
const _withScopeId = (n) => (pushScopeId("data-v-
|
|
3799
|
+
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a09f11c3"]]);
|
|
3800
|
+
const _withScopeId = (n) => (pushScopeId("data-v-8b8dd0fd"), n = n(), popScopeId(), n);
|
|
3588
3801
|
const _hoisted_1$1 = { class: "input-container" };
|
|
3589
3802
|
const _hoisted_2 = {
|
|
3590
3803
|
key: 0,
|
|
@@ -3598,15 +3811,6 @@ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElem
|
|
|
3598
3811
|
/* HOISTED */
|
|
3599
3812
|
));
|
|
3600
3813
|
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
3814
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
3611
3815
|
...{
|
|
3612
3816
|
name: "BkUserSelectorSingle"
|
|
@@ -3614,12 +3818,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3614
3818
|
__name: "single-selector",
|
|
3615
3819
|
props: {
|
|
3616
3820
|
modelValue: {},
|
|
3617
|
-
|
|
3821
|
+
tenants: {},
|
|
3618
3822
|
apiBaseUrl: {},
|
|
3619
3823
|
tenantId: {},
|
|
3620
|
-
|
|
3824
|
+
placeholder: {},
|
|
3621
3825
|
currentUserId: {},
|
|
3622
|
-
exactSearchKey: {}
|
|
3826
|
+
exactSearchKey: {},
|
|
3827
|
+
userGroup: {},
|
|
3828
|
+
userGroupName: {}
|
|
3623
3829
|
},
|
|
3624
3830
|
emits: ["update:modelValue", "change"],
|
|
3625
3831
|
setup(__props, { emit: __emit }) {
|
|
@@ -3633,7 +3839,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3633
3839
|
const searchQuery = ref("");
|
|
3634
3840
|
const showDropdown = ref(false);
|
|
3635
3841
|
const selectedUserInfo = computed(() => {
|
|
3636
|
-
|
|
3842
|
+
const userGroup = (props.userGroup || []).map((group) => ({
|
|
3843
|
+
id: group.id,
|
|
3844
|
+
name: group.name,
|
|
3845
|
+
tenantId: ""
|
|
3846
|
+
}));
|
|
3847
|
+
const list = [...options.value, ...userGroup];
|
|
3848
|
+
const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
|
|
3849
|
+
emit("change", selectedUserInfo2 || null);
|
|
3850
|
+
return selectedUserInfo2;
|
|
3637
3851
|
});
|
|
3638
3852
|
onBeforeMount(async () => {
|
|
3639
3853
|
if (typeof props.modelValue === "string" && props.modelValue) {
|
|
@@ -3657,7 +3871,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3657
3871
|
const formattedResults = formatUsers(result);
|
|
3658
3872
|
if (formattedResults.length > 0) {
|
|
3659
3873
|
options.value = formattedResults;
|
|
3660
|
-
|
|
3874
|
+
addUser(formattedResults[0]);
|
|
3661
3875
|
}
|
|
3662
3876
|
} catch (error) {
|
|
3663
3877
|
console.error("获取当前用户信息失败:", error);
|
|
@@ -3671,7 +3885,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3671
3885
|
isLoading.value = true;
|
|
3672
3886
|
try {
|
|
3673
3887
|
const result = await searchUsers(props.apiBaseUrl, props.tenantId, keyword);
|
|
3674
|
-
options.value = formatUsers(result);
|
|
3888
|
+
options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
|
|
3675
3889
|
console.log("options.value", options.value);
|
|
3676
3890
|
} catch (error) {
|
|
3677
3891
|
console.error("获取用户列表失败:", error);
|
|
@@ -3680,7 +3894,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3680
3894
|
isLoading.value = false;
|
|
3681
3895
|
}
|
|
3682
3896
|
};
|
|
3683
|
-
const
|
|
3897
|
+
const addUser = (user) => {
|
|
3898
|
+
console.log("addUser", user);
|
|
3684
3899
|
selectedUser.value = user.id;
|
|
3685
3900
|
searchQuery.value = "";
|
|
3686
3901
|
showDropdown.value = false;
|
|
@@ -3690,7 +3905,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3690
3905
|
searchQuery.value = "";
|
|
3691
3906
|
};
|
|
3692
3907
|
const handleInputFocus = () => {
|
|
3693
|
-
if (searchQuery.value.length >= 2) {
|
|
3908
|
+
if (searchQuery.value.length >= 2 || Array.isArray(props.userGroup) && props.userGroup.length > 0) {
|
|
3694
3909
|
showDropdown.value = true;
|
|
3695
3910
|
}
|
|
3696
3911
|
};
|
|
@@ -3703,12 +3918,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3703
3918
|
showDropdown.value = false;
|
|
3704
3919
|
};
|
|
3705
3920
|
watch(selectedUser, (newVal) => {
|
|
3921
|
+
console.log("selectedUser", newVal);
|
|
3706
3922
|
emit("update:modelValue", newVal);
|
|
3707
|
-
const selectedUserInfo2 = options.value.find((user) => user.id === newVal);
|
|
3708
|
-
emit("change", selectedUserInfo2 || null);
|
|
3709
3923
|
});
|
|
3710
3924
|
return (_ctx, _cache) => {
|
|
3711
|
-
var _a;
|
|
3712
3925
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
3713
3926
|
ref_key: "containerRef",
|
|
3714
3927
|
ref: containerRef,
|
|
@@ -3750,87 +3963,32 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
3750
3963
|
[vModelText, searchQuery.value]
|
|
3751
3964
|
]),
|
|
3752
3965
|
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)
|
|
3966
|
+
createVNode(MeTag, {
|
|
3967
|
+
"is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey || "bk_username"] === _ctx.currentUserId,
|
|
3968
|
+
"current-user-id": _ctx.currentUserId,
|
|
3969
|
+
onClick: addCurrentUser
|
|
3970
|
+
}, null, 8, ["is-disabled", "current-user-id"])
|
|
3764
3971
|
]),
|
|
3765
|
-
createCommentVNode("
|
|
3766
|
-
createVNode(
|
|
3767
|
-
"
|
|
3768
|
-
arrow: false,
|
|
3972
|
+
createCommentVNode(" 使用新的公共下拉选项组件 "),
|
|
3973
|
+
createVNode(SelectionPopover, {
|
|
3974
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
3769
3975
|
"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"])
|
|
3976
|
+
loading: isLoading.value,
|
|
3977
|
+
options: options.value,
|
|
3978
|
+
"search-query": searchQuery.value,
|
|
3979
|
+
"tenant-id": _ctx.tenantId,
|
|
3980
|
+
tenants: _ctx.tenants,
|
|
3981
|
+
"user-group": _ctx.userGroup,
|
|
3982
|
+
"user-group-name": _ctx.userGroupName,
|
|
3983
|
+
onSelectUser: addUser
|
|
3984
|
+
}, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
3827
3985
|
])), [
|
|
3828
3986
|
[unref(clickoutside), handleClickOutside]
|
|
3829
3987
|
]);
|
|
3830
3988
|
};
|
|
3831
3989
|
}
|
|
3832
3990
|
});
|
|
3833
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
3991
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
|
|
3834
3992
|
const _hoisted_1 = { class: "bk-user-selector" };
|
|
3835
3993
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3836
3994
|
...{
|
|
@@ -3838,14 +3996,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3838
3996
|
},
|
|
3839
3997
|
__name: "user-selector",
|
|
3840
3998
|
props: {
|
|
3841
|
-
apiBaseUrl: { default: "" },
|
|
3842
|
-
tenantId: { default: "" },
|
|
3843
|
-
placeholder: { default: "请输入人员名称搜索" },
|
|
3844
3999
|
modelValue: { default: "" },
|
|
3845
4000
|
draggable: { type: Boolean, default: false },
|
|
3846
4001
|
multiple: { type: Boolean, default: false },
|
|
4002
|
+
apiBaseUrl: { default: "" },
|
|
4003
|
+
tenantId: { default: "" },
|
|
4004
|
+
placeholder: { default: "请输入人员名称搜索" },
|
|
3847
4005
|
currentUserId: { default: "" },
|
|
3848
|
-
exactSearchKey: { default: "" }
|
|
4006
|
+
exactSearchKey: { default: "bk_username" },
|
|
4007
|
+
userGroup: { default: () => [] },
|
|
4008
|
+
userGroupName: { default: "用户群组" }
|
|
3849
4009
|
},
|
|
3850
4010
|
emits: ["update:modelValue", "change"],
|
|
3851
4011
|
setup(__props, { emit: __emit }) {
|
|
@@ -3905,8 +4065,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3905
4065
|
placeholder: _ctx.placeholder,
|
|
3906
4066
|
"tenant-id": _ctx.tenantId,
|
|
3907
4067
|
tenants: unref(tenants),
|
|
4068
|
+
"user-group": _ctx.userGroup,
|
|
4069
|
+
"user-group-name": _ctx.userGroupName,
|
|
3908
4070
|
onChange: handleUpdateUser
|
|
3909
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants"])) : (openBlock(), createElementBlock(
|
|
4071
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
|
|
3910
4072
|
Fragment,
|
|
3911
4073
|
{ key: 1 },
|
|
3912
4074
|
[
|
|
@@ -3922,8 +4084,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3922
4084
|
"selected-users": selectedUsers.value,
|
|
3923
4085
|
"tenant-id": _ctx.tenantId,
|
|
3924
4086
|
tenants: unref(tenants),
|
|
4087
|
+
"user-group": _ctx.userGroup,
|
|
4088
|
+
"user-group-name": _ctx.userGroupName,
|
|
3925
4089
|
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
3926
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants"])
|
|
4090
|
+
}, 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
4091
|
],
|
|
3928
4092
|
2112
|
|
3929
4093
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -3932,7 +4096,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
3932
4096
|
};
|
|
3933
4097
|
}
|
|
3934
4098
|
});
|
|
3935
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4099
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
|
|
3936
4100
|
export {
|
|
3937
4101
|
BkUserSelector,
|
|
3938
4102
|
BkUserSelector as default
|