@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.
@@ -3,7 +3,7 @@
3
3
  })(this, function(exports2, vue, bkuiVue) {
4
4
  "use strict";
5
5
  var __vite_style__ = document.createElement("style");
6
- __vite_style__.textContent = ".user-tag[data-v-203c36cb] {\n margin-right: 4px;\n}\n.user-tag.draggable[data-v-203c36cb] {\n cursor: move;\n}\n.user-tag.active[data-v-203c36cb] {\n background-color: #e1ecff;\n border-color: #3a84ff;\n}\n.user-tag .tag-content .user-name[data-v-203c36cb] {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 12px;\n}\n.user-tag .tag-content .tenant-name[data-v-203c36cb] {\n color: #f59500;\n margin-left: 3px;\n white-space: nowrap;\n padding: 0 3px;\n border-radius: 2px;\n}.bk-user-selector-popover.bk-popover.bk-pop2-content {\n padding: 0;\n}.multiple-selector[data-v-50540b99] {\n position: relative;\n width: 100%;\n}\n.multiple-selector .tags-container[data-v-50540b99] {\n min-height: 32px;\n border: 1px solid #dcdee5;\n border-radius: 2px;\n padding: 1px 4px;\n transition: all 0.2s ease;\n background-color: #fff;\n}\n.multiple-selector .tags-container.focused[data-v-50540b99] {\n border-color: #3a84ff;\n box-shadow: 0 0 0 2px rgba(58, 132, 255, 0.1);\n}\n.multiple-selector .tags-container.collapsed[data-v-50540b99] {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n}\n.multiple-selector .tag-list[data-v-50540b99] {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n}\n.multiple-selector .tag-wrapper[data-v-50540b99] {\n display: inline-flex;\n align-items: center;\n max-width: 100%;\n}\n.multiple-selector .search-input[data-v-50540b99] {\n outline: none;\n border: none;\n height: 28px;\n min-width: 10px;\n background: transparent;\n}\n.multiple-selector .search-input[data-v-50540b99]::placeholder {\n color: #c4c6cc;\n}\n.multiple-selector .search-input.inline[data-v-50540b99] {\n min-width: 10px;\n}\n.multiple-selector .search-input.last[data-v-50540b99], .multiple-selector .search-input.collapsed[data-v-50540b99] {\n flex: 1;\n min-width: 60px;\n}\n.dropdown-content[data-v-50540b99] {\n min-height: 40px;\n max-height: 300px;\n overflow-y: auto;\n padding: 5px 0;\n}\n.dropdown-content .no-data[data-v-50540b99] {\n padding: 10px;\n text-align: center;\n color: #979ba5;\n}\n.dropdown-content .user-option[data-v-50540b99] {\n padding: 8px 12px;\n cursor: pointer;\n display: flex;\n align-items: center;\n height: 32px;\n}\n.dropdown-content .user-option[data-v-50540b99]:hover {\n background-color: #f5f7fa;\n}\n.dropdown-content .user-option .tenant-name[data-v-50540b99] {\n color: #f59500;\n margin-left: 4px;\n padding: 0 4px;\n}\n.me-tag[data-v-50540b99] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background-color: #e1ecff;\n color: #4d4f56;\n border-radius: 50%;\n padding: 0 8px;\n height: 24px;\n width: 24px;\n cursor: pointer;\n font-size: 12px;\n position: absolute;\n right: 8px;\n top: 50%;\n transform: translateY(-50%);\n z-index: 1;\n}\n.me-tag[data-v-50540b99]:hover {\n background-color: #cddffe;\n color: #3a84ff;\n}\n.me-tag.disabled[data-v-50540b99] {\n background-color: #f0f1f5;\n color: #c4c6cc;\n cursor: not-allowed;\n}.single-selector[data-v-308925e9] {\n position: relative;\n width: 100%;\n}\n.input-container[data-v-308925e9] {\n position: relative;\n display: flex;\n align-items: center;\n min-height: 32px;\n border: 1px solid #dcdee5;\n border-radius: 2px;\n padding: 0 8px;\n background-color: #fff;\n}\n.input-container[data-v-308925e9]:focus-within {\n border-color: #3a84ff;\n box-shadow: 0 0 0 2px rgba(58, 132, 255, 0.1);\n}\n.search-input[data-v-308925e9] {\n flex: 1;\n outline: none;\n border: none;\n height: 30px;\n background: transparent;\n}\n.search-input[data-v-308925e9]::placeholder {\n color: #c4c6cc;\n}\n.selected-user[data-v-308925e9] {\n display: inline-flex;\n align-items: center;\n background-color: #f0f1f5;\n border-radius: 2px;\n padding: 0 8px;\n margin-right: 8px;\n height: 24px;\n max-width: calc(100% - 32px);\n}\n.selected-user .tenant-name[data-v-308925e9] {\n color: #f59500;\n margin-left: 4px;\n}\n.selected-user .close-icon[data-v-308925e9] {\n margin-left: 4px;\n cursor: pointer;\n font-style: normal;\n}\n.dropdown-content[data-v-308925e9] {\n min-height: 40px;\n max-height: 300px;\n overflow-y: auto;\n padding: 5px 0;\n}\n.dropdown-content .no-data[data-v-308925e9] {\n padding: 10px;\n text-align: center;\n color: #979ba5;\n}\n.dropdown-content .user-option[data-v-308925e9] {\n padding: 8px 12px;\n cursor: pointer;\n display: flex;\n align-items: center;\n height: 32px;\n}\n.dropdown-content .user-option[data-v-308925e9]:hover {\n background-color: #f5f7fa;\n}\n.dropdown-content .user-option .tenant-name[data-v-308925e9] {\n color: #f59500;\n margin-left: 4px;\n padding: 0 4px;\n}\n.me-tag[data-v-308925e9] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background-color: #e1ecff;\n color: #4d4f56;\n border-radius: 50%;\n padding: 0 8px;\n height: 24px;\n width: 24px;\n cursor: pointer;\n font-size: 12px;\n position: absolute;\n right: 8px;\n top: 50%;\n transform: translateY(-50%);\n z-index: 1;\n}\n.me-tag[data-v-308925e9]:hover {\n background-color: #cddffe;\n color: #3a84ff;\n}\n.me-tag.disabled[data-v-308925e9] {\n background-color: #f0f1f5;\n color: #c4c6cc;\n cursor: not-allowed;\n}.bk-user-selector[data-v-fe084750] {\n width: 100%;\n position: relative;\n font-size: 12px;\n}/*$vite$:1*/";
6
+ __vite_style__.textContent = ".me-tag[data-v-887b7c44] {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background-color: #e1ecff;\n color: #4d4f56;\n border-radius: 50%;\n padding: 0 8px;\n height: 24px;\n width: 24px;\n cursor: pointer;\n font-size: 12px;\n position: absolute;\n right: 8px;\n top: 50%;\n transform: translateY(-50%);\n z-index: 1;\n}\n.me-tag[data-v-887b7c44]:hover {\n background-color: #cddffe;\n color: #3a84ff;\n}\n.me-tag.disabled[data-v-887b7c44] {\n background-color: #f0f1f5;\n color: #c4c6cc;\n cursor: not-allowed;\n}.dropdown-content[data-v-c68dfcac] {\n min-height: 40px;\n max-height: 300px;\n overflow-y: auto;\n padding: 5px 0;\n}\n.dropdown-content .no-data[data-v-c68dfcac] {\n padding: 10px;\n text-align: center;\n color: #979ba5;\n}\n.dropdown-content .user-group .group-header[data-v-c68dfcac] {\n padding: 8px 12px;\n color: #979ba5;\n display: flex;\n align-items: center;\n}\n.dropdown-content .user-group .group-header .group-count[data-v-c68dfcac] {\n margin-left: 4px;\n}\n.dropdown-content .user-option[data-v-c68dfcac] {\n padding: 8px 12px;\n cursor: pointer;\n display: flex;\n align-items: center;\n height: 32px;\n}\n.dropdown-content .user-option[data-v-c68dfcac]:hover {\n background-color: #f5f7fa;\n}\n.dropdown-content .user-option .tenant-name[data-v-c68dfcac] {\n color: #f59500;\n margin-left: 4px;\n padding: 0 4px;\n}.bk-user-selector-popover.bk-popover.bk-pop2-content {\n padding: 0;\n}.user-tag[data-v-203c36cb] {\n margin-right: 4px;\n}\n.user-tag.draggable[data-v-203c36cb] {\n cursor: move;\n}\n.user-tag.active[data-v-203c36cb] {\n background-color: #e1ecff;\n border-color: #3a84ff;\n}\n.user-tag .tag-content .user-name[data-v-203c36cb] {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 12px;\n}\n.user-tag .tag-content .tenant-name[data-v-203c36cb] {\n color: #f59500;\n margin-left: 3px;\n white-space: nowrap;\n padding: 0 3px;\n border-radius: 2px;\n}.multiple-selector[data-v-a09f11c3] {\n position: relative;\n width: 100%;\n}\n.multiple-selector .tags-container[data-v-a09f11c3] {\n min-height: 32px;\n border: 1px solid #dcdee5;\n border-radius: 2px;\n padding: 1px 10px 1px 8px;\n transition: all 0.2s ease;\n background-color: #fff;\n}\n.multiple-selector .tags-container.focused[data-v-a09f11c3] {\n border-color: #3a84ff;\n box-shadow: 0 0 0 2px rgba(58, 132, 255, 0.1);\n}\n.multiple-selector .tags-container.collapsed[data-v-a09f11c3] {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n}\n.multiple-selector .tag-list[data-v-a09f11c3] {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n}\n.multiple-selector .tag-wrapper[data-v-a09f11c3] {\n display: inline-flex;\n align-items: center;\n max-width: 100%;\n}\n.multiple-selector .search-input[data-v-a09f11c3] {\n outline: none;\n border: none;\n height: 28px;\n min-width: 10px;\n background: transparent;\n}\n.multiple-selector .search-input[data-v-a09f11c3]::placeholder {\n color: #c4c6cc;\n}\n.multiple-selector .search-input.inline[data-v-a09f11c3] {\n min-width: 10px;\n}\n.multiple-selector .search-input.last[data-v-a09f11c3], .multiple-selector .search-input.collapsed[data-v-a09f11c3] {\n flex: 1;\n min-width: 60px;\n}.single-selector[data-v-8b8dd0fd] {\n position: relative;\n width: 100%;\n}\n.input-container[data-v-8b8dd0fd] {\n position: relative;\n display: flex;\n align-items: center;\n min-height: 32px;\n border: 1px solid #dcdee5;\n border-radius: 2px;\n padding: 0 8px;\n background-color: #fff;\n}\n.input-container[data-v-8b8dd0fd]:focus-within {\n border-color: #3a84ff;\n box-shadow: 0 0 0 2px rgba(58, 132, 255, 0.1);\n}\n.search-input[data-v-8b8dd0fd] {\n flex: 1;\n outline: none;\n border: none;\n height: 30px;\n background: transparent;\n}\n.search-input[data-v-8b8dd0fd]::placeholder {\n color: #c4c6cc;\n}\n.selected-user[data-v-8b8dd0fd] {\n display: inline-flex;\n align-items: center;\n background-color: #f0f1f5;\n border-radius: 2px;\n padding: 0 8px;\n margin-right: 8px;\n height: 24px;\n max-width: calc(100% - 32px);\n}\n.selected-user .tenant-name[data-v-8b8dd0fd] {\n color: #f59500;\n margin-left: 4px;\n}\n.selected-user .close-icon[data-v-8b8dd0fd] {\n margin-left: 4px;\n cursor: pointer;\n font-style: normal;\n}.bk-user-selector[data-v-bc7b4ccd] {\n width: 100%;\n position: relative;\n font-size: 12px;\n}/*$vite$:1*/";
7
7
  document.head.appendChild(__vite_style__);
8
8
  const getTenants = async (apiBaseUrl, tenantId) => {
9
9
  if (!apiBaseUrl || !tenantId) {
@@ -2965,6 +2965,270 @@
2965
2965
  clearSearch
2966
2966
  };
2967
2967
  };
2968
+ const _sfc_main$5 = /* @__PURE__ */ vue.defineComponent({
2969
+ ...{
2970
+ name: "MeTag"
2971
+ },
2972
+ __name: "me-tag",
2973
+ props: {
2974
+ /**
2975
+ * 当前用户ID
2976
+ */
2977
+ currentUserId: {
2978
+ type: String,
2979
+ default: ""
2980
+ },
2981
+ /**
2982
+ * 是否禁用
2983
+ */
2984
+ isDisabled: {
2985
+ type: Boolean,
2986
+ default: false
2987
+ }
2988
+ },
2989
+ emits: ["click"],
2990
+ setup(__props, { emit: __emit }) {
2991
+ const props = __props;
2992
+ const emit = __emit;
2993
+ const handleClick = () => {
2994
+ if (props.isDisabled) return;
2995
+ emit("click");
2996
+ };
2997
+ return (_ctx, _cache) => {
2998
+ return __props.currentUserId ? (vue.openBlock(), vue.createElementBlock(
2999
+ "div",
3000
+ {
3001
+ key: 0,
3002
+ class: vue.normalizeClass(["me-tag", { disabled: __props.isDisabled }]),
3003
+ onClick: vue.withModifiers(handleClick, ["stop"])
3004
+ },
3005
+ " 我 ",
3006
+ 2
3007
+ /* CLASS */
3008
+ )) : vue.createCommentVNode("v-if", true);
3009
+ };
3010
+ }
3011
+ });
3012
+ const _export_sfc = (sfc, props) => {
3013
+ const target = sfc.__vccOpts || sfc;
3014
+ for (const [key, val] of props) {
3015
+ target[key] = val;
3016
+ }
3017
+ return target;
3018
+ };
3019
+ const MeTag = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-887b7c44"]]);
3020
+ const _hoisted_1$4 = {
3021
+ key: 0,
3022
+ class: "no-data"
3023
+ };
3024
+ const _hoisted_2$3 = { class: "group-name" };
3025
+ const _hoisted_3$3 = { class: "group-count" };
3026
+ const _hoisted_4$1 = ["onMousedown"];
3027
+ const _hoisted_5 = {
3028
+ key: 0,
3029
+ class: "tenant-name"
3030
+ };
3031
+ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
3032
+ ...{
3033
+ name: "SelectionPopover"
3034
+ },
3035
+ __name: "selection-popover",
3036
+ props: {
3037
+ /**
3038
+ * 是否显示下拉菜单
3039
+ */
3040
+ isShow: {
3041
+ type: Boolean,
3042
+ default: false
3043
+ },
3044
+ /**
3045
+ * 容器宽度
3046
+ */
3047
+ containerWidth: {
3048
+ type: [Number, String],
3049
+ default: "auto"
3050
+ },
3051
+ /**
3052
+ * 是否加载中
3053
+ */
3054
+ loading: {
3055
+ type: Boolean,
3056
+ default: false
3057
+ },
3058
+ /**
3059
+ * 搜索结果选项
3060
+ */
3061
+ options: {
3062
+ type: Array,
3063
+ default: () => []
3064
+ },
3065
+ /**
3066
+ * 搜索关键词
3067
+ */
3068
+ searchQuery: {
3069
+ type: String,
3070
+ default: ""
3071
+ },
3072
+ /**
3073
+ * 当前租户ID
3074
+ */
3075
+ tenantId: {
3076
+ type: String,
3077
+ default: ""
3078
+ },
3079
+ /**
3080
+ * 租户信息映射
3081
+ */
3082
+ tenants: {
3083
+ type: Object,
3084
+ default: () => ({})
3085
+ },
3086
+ /**
3087
+ * 用户组
3088
+ */
3089
+ userGroup: {
3090
+ type: Array,
3091
+ default: () => []
3092
+ },
3093
+ /**
3094
+ * 用户组名称
3095
+ */
3096
+ userGroupName: {
3097
+ type: String,
3098
+ default: "用户群组"
3099
+ }
3100
+ },
3101
+ emits: ["select-user"],
3102
+ setup(__props, { emit: __emit }) {
3103
+ const props = __props;
3104
+ const emit = __emit;
3105
+ const groupedUsers = vue.computed(() => {
3106
+ const groups = {};
3107
+ console.log("props.options", props.options);
3108
+ if (Array.isArray(props.userGroup) && props.userGroup.length > 0) {
3109
+ groups[props.userGroupName] = props.userGroup.map((group) => ({
3110
+ id: group.id,
3111
+ name: group.name,
3112
+ tenantId: ""
3113
+ }));
3114
+ }
3115
+ props.options.forEach((user) => {
3116
+ const groupName = user.data_source_type === "real" ? "用户" : "虚拟账号";
3117
+ if (!groups[groupName]) {
3118
+ groups[groupName] = [];
3119
+ }
3120
+ groups[groupName].push(user);
3121
+ });
3122
+ return groups;
3123
+ });
3124
+ const selectUser = (user) => {
3125
+ emit("select-user", user);
3126
+ };
3127
+ return (_ctx, _cache) => {
3128
+ return vue.openBlock(), vue.createBlock(vue.unref(bkuiVue.Popover), {
3129
+ "ext-cls": "bk-user-selector-popover",
3130
+ arrow: false,
3131
+ "is-show": __props.isShow,
3132
+ width: __props.containerWidth,
3133
+ placement: "bottom-start",
3134
+ theme: "light",
3135
+ trigger: "manual"
3136
+ }, {
3137
+ content: vue.withCtx(() => [
3138
+ vue.createVNode(vue.unref(bkuiVue.Loading), {
3139
+ class: "dropdown-content",
3140
+ loading: __props.loading,
3141
+ size: "mini",
3142
+ mode: "spin"
3143
+ }, {
3144
+ default: vue.withCtx(() => [
3145
+ __props.options.length === 0 && __props.userGroup.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$4, [
3146
+ vue.createElementVNode(
3147
+ "span",
3148
+ null,
3149
+ vue.toDisplayString(__props.searchQuery.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
3150
+ 1
3151
+ /* TEXT */
3152
+ )
3153
+ ])) : (vue.openBlock(true), vue.createElementBlock(
3154
+ vue.Fragment,
3155
+ { key: 1 },
3156
+ vue.renderList(groupedUsers.value, (group, groupName) => {
3157
+ return vue.openBlock(), vue.createElementBlock("div", {
3158
+ class: "user-group",
3159
+ key: groupName
3160
+ }, [
3161
+ vue.createElementVNode(
3162
+ "div",
3163
+ {
3164
+ class: "group-header",
3165
+ onMousedown: _cache[0] || (_cache[0] = vue.withModifiers(() => {
3166
+ }, ["prevent"]))
3167
+ },
3168
+ [
3169
+ vue.createElementVNode(
3170
+ "span",
3171
+ _hoisted_2$3,
3172
+ vue.toDisplayString(groupName),
3173
+ 1
3174
+ /* TEXT */
3175
+ ),
3176
+ vue.createElementVNode(
3177
+ "span",
3178
+ _hoisted_3$3,
3179
+ "(" + vue.toDisplayString(group.length) + ")",
3180
+ 1
3181
+ /* TEXT */
3182
+ )
3183
+ ],
3184
+ 32
3185
+ /* NEED_HYDRATION */
3186
+ ),
3187
+ (vue.openBlock(true), vue.createElementBlock(
3188
+ vue.Fragment,
3189
+ null,
3190
+ vue.renderList(group, (user) => {
3191
+ return vue.openBlock(), vue.createElementBlock("div", {
3192
+ class: "user-option",
3193
+ key: user.id,
3194
+ onMousedown: vue.withModifiers(($event) => selectUser(user), ["prevent"])
3195
+ }, [
3196
+ vue.createElementVNode(
3197
+ "span",
3198
+ null,
3199
+ vue.toDisplayString(user.name),
3200
+ 1
3201
+ /* TEXT */
3202
+ ),
3203
+ user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (vue.openBlock(), vue.createElementBlock(
3204
+ "span",
3205
+ _hoisted_5,
3206
+ "@" + vue.toDisplayString(__props.tenants[user.tenantId]),
3207
+ 1
3208
+ /* TEXT */
3209
+ )) : vue.createCommentVNode("v-if", true)
3210
+ ], 40, _hoisted_4$1);
3211
+ }),
3212
+ 128
3213
+ /* KEYED_FRAGMENT */
3214
+ ))
3215
+ ]);
3216
+ }),
3217
+ 128
3218
+ /* KEYED_FRAGMENT */
3219
+ ))
3220
+ ]),
3221
+ _: 1
3222
+ /* STABLE */
3223
+ }, 8, ["loading"])
3224
+ ]),
3225
+ _: 1
3226
+ /* STABLE */
3227
+ }, 8, ["is-show", "width"]);
3228
+ };
3229
+ }
3230
+ });
3231
+ const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-c68dfcac"]]);
2968
3232
  const _hoisted_1$3 = { class: "tag-content" };
2969
3233
  const _hoisted_2$2 = { class: "user-name" };
2970
3234
  const _hoisted_3$2 = {
@@ -3024,26 +3288,10 @@
3024
3288
  };
3025
3289
  }
3026
3290
  });
3027
- const _export_sfc = (sfc, props) => {
3028
- const target = sfc.__vccOpts || sfc;
3029
- for (const [key, val] of props) {
3030
- target[key] = val;
3031
- }
3032
- return target;
3033
- };
3034
3291
  const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-203c36cb"]]);
3035
3292
  const _hoisted_1$2 = ["onClick"];
3036
3293
  const _hoisted_2$1 = ["placeholder"];
3037
3294
  const _hoisted_3$1 = ["placeholder"];
3038
- const _hoisted_4$1 = {
3039
- key: 0,
3040
- class: "no-data"
3041
- };
3042
- const _hoisted_5$1 = ["onMousedown"];
3043
- const _hoisted_6$1 = {
3044
- key: 0,
3045
- class: "tenant-name"
3046
- };
3047
3295
  const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
3048
3296
  ...{
3049
3297
  name: "BkUserSelectorMultiple"
@@ -3112,6 +3360,20 @@
3112
3360
  exactSearchKey: {
3113
3361
  type: String,
3114
3362
  default: "bk_username"
3363
+ },
3364
+ /**
3365
+ * 用户组
3366
+ */
3367
+ userGroup: {
3368
+ type: Array,
3369
+ default: () => []
3370
+ },
3371
+ /**
3372
+ * 用户组名称
3373
+ */
3374
+ userGroupName: {
3375
+ type: String,
3376
+ default: "用户群组"
3115
3377
  }
3116
3378
  },
3117
3379
  emits: ["update:selectedUsers", "add-user", "remove-user"],
@@ -3137,6 +3399,9 @@
3137
3399
  const sortableInstance = vue.ref(null);
3138
3400
  const visibleUsers = vue.ref([]);
3139
3401
  const hiddenCount = vue.ref(0);
3402
+ const options = vue.computed(() => {
3403
+ return searchResults.value.filter((user) => !props.selectedUsers.some((selectedUser) => selectedUser.id === user.id));
3404
+ });
3140
3405
  const initSortable = () => {
3141
3406
  if (!props.draggable || !sortableContainerRef.value) return;
3142
3407
  if (sortableInstance.value) {
@@ -3174,7 +3439,11 @@
3174
3439
  };
3175
3440
  const handleFocus = () => {
3176
3441
  isFocused.value = true;
3177
- showDropdown.value = false;
3442
+ if (props.userGroup.length > 0) {
3443
+ showDropdown.value = true;
3444
+ } else {
3445
+ showDropdown.value = false;
3446
+ }
3178
3447
  activeTagIndex.value = -1;
3179
3448
  vue.nextTick(() => {
3180
3449
  if (lastInputRef.value) {
@@ -3425,17 +3694,11 @@
3425
3694
  [vue.vModelText, vue.unref(searchQuery)]
3426
3695
  ]) : vue.createCommentVNode("v-if", true),
3427
3696
  vue.createCommentVNode(' "我"标签 '),
3428
- __props.currentUserId ? (vue.openBlock(), vue.createElementBlock(
3429
- "div",
3430
- {
3431
- key: 1,
3432
- class: vue.normalizeClass(["me-tag", { disabled: __props.currentUserId && __props.selectedUsers.some((user) => user.id === __props.currentUserId) }]),
3433
- onClick: _cache[2] || (_cache[2] = vue.withModifiers(($event) => addCurrentUser(), ["stop"]))
3434
- },
3435
- " 我 ",
3436
- 2
3437
- /* CLASS */
3438
- )) : vue.createCommentVNode("v-if", true)
3697
+ vue.createVNode(MeTag, {
3698
+ "current-user-id": __props.currentUserId,
3699
+ "is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user.id === __props.currentUserId),
3700
+ onClick: addCurrentUser
3701
+ }, null, 8, ["current-user-id", "is-disabled"])
3439
3702
  ],
3440
3703
  512
3441
3704
  /* NEED_PATCH */
@@ -3475,7 +3738,7 @@
3475
3738
  /* KEYED_FRAGMENT */
3476
3739
  )),
3477
3740
  vue.createCommentVNode(" 显示折叠标签数量 "),
3478
- hiddenCount.value > 0 ? (vue.openBlock(), vue.createBlock(vue.unref(bkuiVue.Tag), {
3741
+ hiddenCount.value > 0 ? vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(bkuiVue.Tag), {
3479
3742
  key: 0,
3480
3743
  onClick: vue.withModifiers(handleFocus, ["stop"])
3481
3744
  }, {
@@ -3488,30 +3751,29 @@
3488
3751
  ]),
3489
3752
  _: 1
3490
3753
  /* STABLE */
3491
- })) : vue.createCommentVNode("v-if", true),
3754
+ })), [
3755
+ [vue.unref(bkuiVue.bkTooltips), {
3756
+ content: __props.selectedUsers.slice(visibleUsers.value.length).map((user) => user.display_name).join(","),
3757
+ placement: "top"
3758
+ }]
3759
+ ]) : vue.createCommentVNode("v-if", true),
3492
3760
  vue.createCommentVNode(" 搜索输入框 "),
3493
3761
  vue.withDirectives(vue.createElementVNode("input", {
3494
3762
  ref_key: "collapsedInputRef",
3495
3763
  ref: collapsedInputRef,
3496
3764
  class: "search-input collapsed",
3497
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => vue.isRef(searchQuery) ? searchQuery.value = $event : null),
3765
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => vue.isRef(searchQuery) ? searchQuery.value = $event : null),
3498
3766
  placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
3499
3767
  onFocus: handleFocus
3500
3768
  }, null, 40, _hoisted_3$1), [
3501
3769
  [vue.vModelText, vue.unref(searchQuery)]
3502
3770
  ]),
3503
3771
  vue.createCommentVNode(' 未聚焦状态下的"我"标签 '),
3504
- __props.currentUserId ? (vue.openBlock(), vue.createElementBlock(
3505
- "div",
3506
- {
3507
- key: 1,
3508
- class: vue.normalizeClass(["me-tag", { disabled: __props.currentUserId && __props.selectedUsers.some((user) => user[props.exactSearchKey] === __props.currentUserId) }]),
3509
- onClick: _cache[4] || (_cache[4] = vue.withModifiers(($event) => addCurrentUser(), ["stop"]))
3510
- },
3511
- " 我 ",
3512
- 2
3513
- /* CLASS */
3514
- )) : vue.createCommentVNode("v-if", true)
3772
+ vue.createVNode(MeTag, {
3773
+ "current-user-id": __props.currentUserId,
3774
+ "is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user[props.exactSearchKey] === __props.currentUserId),
3775
+ onClick: addCurrentUser
3776
+ }, null, 8, ["current-user-id", "is-disabled"])
3515
3777
  ],
3516
3778
  512
3517
3779
  /* NEED_PATCH */
@@ -3521,75 +3783,26 @@
3521
3783
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
3522
3784
  )),
3523
3785
  vue.createCommentVNode(" 下拉选项列表 "),
3524
- vue.createVNode(vue.unref(bkuiVue.Popover), {
3525
- "ext-cls": "bk-user-selector-popover",
3526
- arrow: false,
3786
+ vue.createVNode(SelectionPopover, {
3787
+ "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
3527
3788
  "is-show": showDropdown.value,
3528
- width: containerRef.value ? containerRef.value.offsetWidth : "auto",
3529
- placement: "bottom-start",
3530
- theme: "light",
3531
- trigger: "manual"
3532
- }, {
3533
- content: vue.withCtx(() => [
3534
- vue.createVNode(vue.unref(bkuiVue.Loading), {
3535
- class: "dropdown-content",
3536
- loading: vue.unref(searchLoading),
3537
- size: "mini",
3538
- mode: "spin"
3539
- }, {
3540
- default: vue.withCtx(() => [
3541
- vue.unref(searchResults).length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$1, [
3542
- vue.createElementVNode(
3543
- "span",
3544
- null,
3545
- vue.toDisplayString(vue.unref(searchQuery).length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
3546
- 1
3547
- /* TEXT */
3548
- )
3549
- ])) : (vue.openBlock(true), vue.createElementBlock(
3550
- vue.Fragment,
3551
- { key: 1 },
3552
- vue.renderList(vue.unref(searchResults), (user) => {
3553
- return vue.openBlock(), vue.createElementBlock("div", {
3554
- class: "user-option",
3555
- key: user.id,
3556
- onMousedown: vue.withModifiers(($event) => addUser(user), ["prevent"])
3557
- }, [
3558
- vue.createElementVNode(
3559
- "span",
3560
- null,
3561
- vue.toDisplayString(user.name),
3562
- 1
3563
- /* TEXT */
3564
- ),
3565
- user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (vue.openBlock(), vue.createElementBlock(
3566
- "span",
3567
- _hoisted_6$1,
3568
- "@" + vue.toDisplayString(__props.tenants[user.tenantId]),
3569
- 1
3570
- /* TEXT */
3571
- )) : vue.createCommentVNode("v-if", true)
3572
- ], 40, _hoisted_5$1);
3573
- }),
3574
- 128
3575
- /* KEYED_FRAGMENT */
3576
- ))
3577
- ]),
3578
- _: 1
3579
- /* STABLE */
3580
- }, 8, ["loading"])
3581
- ]),
3582
- _: 1
3583
- /* STABLE */
3584
- }, 8, ["is-show", "width"])
3789
+ loading: vue.unref(searchLoading),
3790
+ options: options.value,
3791
+ "search-query": vue.unref(searchQuery),
3792
+ "tenant-id": __props.tenantId,
3793
+ tenants: __props.tenants,
3794
+ "user-group": __props.userGroup,
3795
+ "user-group-name": __props.userGroupName,
3796
+ onSelectUser: addUser
3797
+ }, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
3585
3798
  ])), [
3586
3799
  [vue.unref(bkuiVue.clickoutside), handleClickOutside]
3587
3800
  ]);
3588
3801
  };
3589
3802
  }
3590
3803
  });
3591
- const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-50540b99"]]);
3592
- const _withScopeId = (n) => (vue.pushScopeId("data-v-308925e9"), n = n(), vue.popScopeId(), n);
3804
+ const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a09f11c3"]]);
3805
+ const _withScopeId = (n) => (vue.pushScopeId("data-v-8b8dd0fd"), n = n(), vue.popScopeId(), n);
3593
3806
  const _hoisted_1$1 = { class: "input-container" };
3594
3807
  const _hoisted_2 = {
3595
3808
  key: 0,
@@ -3603,15 +3816,6 @@
3603
3816
  /* HOISTED */
3604
3817
  ));
3605
3818
  const _hoisted_4 = ["placeholder"];
3606
- const _hoisted_5 = {
3607
- key: 0,
3608
- class: "no-data"
3609
- };
3610
- const _hoisted_6 = ["onMousedown"];
3611
- const _hoisted_7 = {
3612
- key: 0,
3613
- class: "tenant-name"
3614
- };
3615
3819
  const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
3616
3820
  ...{
3617
3821
  name: "BkUserSelectorSingle"
@@ -3619,12 +3823,14 @@
3619
3823
  __name: "single-selector",
3620
3824
  props: {
3621
3825
  modelValue: {},
3622
- placeholder: {},
3826
+ tenants: {},
3623
3827
  apiBaseUrl: {},
3624
3828
  tenantId: {},
3625
- tenants: {},
3829
+ placeholder: {},
3626
3830
  currentUserId: {},
3627
- exactSearchKey: {}
3831
+ exactSearchKey: {},
3832
+ userGroup: {},
3833
+ userGroupName: {}
3628
3834
  },
3629
3835
  emits: ["update:modelValue", "change"],
3630
3836
  setup(__props, { emit: __emit }) {
@@ -3638,7 +3844,15 @@
3638
3844
  const searchQuery = vue.ref("");
3639
3845
  const showDropdown = vue.ref(false);
3640
3846
  const selectedUserInfo = vue.computed(() => {
3641
- return options.value.find((user) => user.id === selectedUser.value);
3847
+ const userGroup = (props.userGroup || []).map((group) => ({
3848
+ id: group.id,
3849
+ name: group.name,
3850
+ tenantId: ""
3851
+ }));
3852
+ const list = [...options.value, ...userGroup];
3853
+ const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
3854
+ emit("change", selectedUserInfo2 || null);
3855
+ return selectedUserInfo2;
3642
3856
  });
3643
3857
  vue.onBeforeMount(async () => {
3644
3858
  if (typeof props.modelValue === "string" && props.modelValue) {
@@ -3662,7 +3876,7 @@
3662
3876
  const formattedResults = formatUsers(result);
3663
3877
  if (formattedResults.length > 0) {
3664
3878
  options.value = formattedResults;
3665
- selectUser(formattedResults[0]);
3879
+ addUser(formattedResults[0]);
3666
3880
  }
3667
3881
  } catch (error) {
3668
3882
  console.error("获取当前用户信息失败:", error);
@@ -3676,7 +3890,7 @@
3676
3890
  isLoading.value = true;
3677
3891
  try {
3678
3892
  const result = await searchUsers(props.apiBaseUrl, props.tenantId, keyword);
3679
- options.value = formatUsers(result);
3893
+ options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
3680
3894
  console.log("options.value", options.value);
3681
3895
  } catch (error) {
3682
3896
  console.error("获取用户列表失败:", error);
@@ -3685,7 +3899,8 @@
3685
3899
  isLoading.value = false;
3686
3900
  }
3687
3901
  };
3688
- const selectUser = (user) => {
3902
+ const addUser = (user) => {
3903
+ console.log("addUser", user);
3689
3904
  selectedUser.value = user.id;
3690
3905
  searchQuery.value = "";
3691
3906
  showDropdown.value = false;
@@ -3695,7 +3910,7 @@
3695
3910
  searchQuery.value = "";
3696
3911
  };
3697
3912
  const handleInputFocus = () => {
3698
- if (searchQuery.value.length >= 2) {
3913
+ if (searchQuery.value.length >= 2 || Array.isArray(props.userGroup) && props.userGroup.length > 0) {
3699
3914
  showDropdown.value = true;
3700
3915
  }
3701
3916
  };
@@ -3708,12 +3923,10 @@
3708
3923
  showDropdown.value = false;
3709
3924
  };
3710
3925
  vue.watch(selectedUser, (newVal) => {
3926
+ console.log("selectedUser", newVal);
3711
3927
  emit("update:modelValue", newVal);
3712
- const selectedUserInfo2 = options.value.find((user) => user.id === newVal);
3713
- emit("change", selectedUserInfo2 || null);
3714
3928
  });
3715
3929
  return (_ctx, _cache) => {
3716
- var _a;
3717
3930
  return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
3718
3931
  ref_key: "containerRef",
3719
3932
  ref: containerRef,
@@ -3755,87 +3968,32 @@
3755
3968
  [vue.vModelText, searchQuery.value]
3756
3969
  ]),
3757
3970
  vue.createCommentVNode(' "我"标签 '),
3758
- _ctx.currentUserId ? (vue.openBlock(), vue.createElementBlock(
3759
- "div",
3760
- {
3761
- key: 1,
3762
- class: vue.normalizeClass(["me-tag", { disabled: _ctx.currentUserId && ((_a = selectedUserInfo.value) == null ? void 0 : _a[_ctx.exactSearchKey]) === _ctx.currentUserId }]),
3763
- onClick: _cache[1] || (_cache[1] = ($event) => addCurrentUser())
3764
- },
3765
- " 我 ",
3766
- 2
3767
- /* CLASS */
3768
- )) : vue.createCommentVNode("v-if", true)
3971
+ vue.createVNode(MeTag, {
3972
+ "is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey || "bk_username"] === _ctx.currentUserId,
3973
+ "current-user-id": _ctx.currentUserId,
3974
+ onClick: addCurrentUser
3975
+ }, null, 8, ["is-disabled", "current-user-id"])
3769
3976
  ]),
3770
- vue.createCommentVNode(" 下拉选项列表 "),
3771
- vue.createVNode(vue.unref(bkuiVue.Popover), {
3772
- "ext-cls": "bk-user-selector-popover",
3773
- arrow: false,
3977
+ vue.createCommentVNode(" 使用新的公共下拉选项组件 "),
3978
+ vue.createVNode(SelectionPopover, {
3979
+ "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
3774
3980
  "is-show": showDropdown.value,
3775
- width: containerRef.value ? containerRef.value.offsetWidth : "auto",
3776
- placement: "bottom-start",
3777
- theme: "light",
3778
- trigger: "manual"
3779
- }, {
3780
- content: vue.withCtx(() => [
3781
- vue.createVNode(vue.unref(bkuiVue.Loading), {
3782
- class: "dropdown-content",
3783
- loading: isLoading.value,
3784
- size: "mini",
3785
- mode: "spin"
3786
- }, {
3787
- default: vue.withCtx(() => [
3788
- options.value.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5, [
3789
- vue.createElementVNode(
3790
- "span",
3791
- null,
3792
- vue.toDisplayString(searchQuery.value.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
3793
- 1
3794
- /* TEXT */
3795
- )
3796
- ])) : (vue.openBlock(true), vue.createElementBlock(
3797
- vue.Fragment,
3798
- { key: 1 },
3799
- vue.renderList(options.value, (user) => {
3800
- return vue.openBlock(), vue.createElementBlock("div", {
3801
- class: "user-option",
3802
- key: user.id,
3803
- onMousedown: vue.withModifiers(($event) => selectUser(user), ["prevent"])
3804
- }, [
3805
- vue.createElementVNode(
3806
- "span",
3807
- null,
3808
- vue.toDisplayString(user.name),
3809
- 1
3810
- /* TEXT */
3811
- ),
3812
- user.tenantId !== _ctx.tenantId && user.tenantId && _ctx.tenants[user.tenantId] ? (vue.openBlock(), vue.createElementBlock(
3813
- "span",
3814
- _hoisted_7,
3815
- "@" + vue.toDisplayString(_ctx.tenants[user.tenantId]),
3816
- 1
3817
- /* TEXT */
3818
- )) : vue.createCommentVNode("v-if", true)
3819
- ], 40, _hoisted_6);
3820
- }),
3821
- 128
3822
- /* KEYED_FRAGMENT */
3823
- ))
3824
- ]),
3825
- _: 1
3826
- /* STABLE */
3827
- }, 8, ["loading"])
3828
- ]),
3829
- _: 1
3830
- /* STABLE */
3831
- }, 8, ["is-show", "width"])
3981
+ loading: isLoading.value,
3982
+ options: options.value,
3983
+ "search-query": searchQuery.value,
3984
+ "tenant-id": _ctx.tenantId,
3985
+ tenants: _ctx.tenants,
3986
+ "user-group": _ctx.userGroup,
3987
+ "user-group-name": _ctx.userGroupName,
3988
+ onSelectUser: addUser
3989
+ }, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
3832
3990
  ])), [
3833
3991
  [vue.unref(bkuiVue.clickoutside), handleClickOutside]
3834
3992
  ]);
3835
3993
  };
3836
3994
  }
3837
3995
  });
3838
- const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-308925e9"]]);
3996
+ const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
3839
3997
  const _hoisted_1 = { class: "bk-user-selector" };
3840
3998
  const _sfc_main = /* @__PURE__ */ vue.defineComponent({
3841
3999
  ...{
@@ -3843,14 +4001,16 @@
3843
4001
  },
3844
4002
  __name: "user-selector",
3845
4003
  props: {
3846
- apiBaseUrl: { default: "" },
3847
- tenantId: { default: "" },
3848
- placeholder: { default: "请输入人员名称搜索" },
3849
4004
  modelValue: { default: "" },
3850
4005
  draggable: { type: Boolean, default: false },
3851
4006
  multiple: { type: Boolean, default: false },
4007
+ apiBaseUrl: { default: "" },
4008
+ tenantId: { default: "" },
4009
+ placeholder: { default: "请输入人员名称搜索" },
3852
4010
  currentUserId: { default: "" },
3853
- exactSearchKey: { default: "" }
4011
+ exactSearchKey: { default: "bk_username" },
4012
+ userGroup: { default: () => [] },
4013
+ userGroupName: { default: "用户群组" }
3854
4014
  },
3855
4015
  emits: ["update:modelValue", "change"],
3856
4016
  setup(__props, { emit: __emit }) {
@@ -3910,8 +4070,10 @@
3910
4070
  placeholder: _ctx.placeholder,
3911
4071
  "tenant-id": _ctx.tenantId,
3912
4072
  tenants: vue.unref(tenants),
4073
+ "user-group": _ctx.userGroup,
4074
+ "user-group-name": _ctx.userGroupName,
3913
4075
  onChange: handleUpdateUser
3914
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants"])) : (vue.openBlock(), vue.createElementBlock(
4076
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (vue.openBlock(), vue.createElementBlock(
3915
4077
  vue.Fragment,
3916
4078
  { key: 1 },
3917
4079
  [
@@ -3927,8 +4089,10 @@
3927
4089
  "selected-users": selectedUsers.value,
3928
4090
  "tenant-id": _ctx.tenantId,
3929
4091
  tenants: vue.unref(tenants),
4092
+ "user-group": _ctx.userGroup,
4093
+ "user-group-name": _ctx.userGroupName,
3930
4094
  "onUpdate:selectedUsers": handleUpdateSelectedUsers
3931
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants"])
4095
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
3932
4096
  ],
3933
4097
  2112
3934
4098
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
@@ -3937,7 +4101,7 @@
3937
4101
  };
3938
4102
  }
3939
4103
  });
3940
- const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fe084750"]]);
4104
+ const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
3941
4105
  exports2.BkUserSelector = BkUserSelector;
3942
4106
  exports2.default = BkUserSelector;
3943
4107
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });