@blueking/bk-user-selector 0.0.29-beta.1 → 0.0.29-beta.10

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.
@@ -1,5 +1,5 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_vue__ from "@blueking/bkui-library";
2
- import { shallowRef, watchEffect, unref, onScopeDispose, ref, onBeforeMount, defineComponent, openBlock, createElementBlock, normalizeClass, withModifiers, createCommentVNode, h as h$1, computed, createBlock, withCtx, createVNode, createElementVNode, toDisplayString, Fragment, renderList, watch, nextTick, onMounted, withDirectives, isRef, vModelText, createTextVNode, createApp } from "@blueking/bkui-library";
2
+ import { unref, ref, onBeforeMount, defineComponent, openBlock, createElementBlock, normalizeClass, withModifiers, createCommentVNode, h as h$1, computed, createBlock, withCtx, createVNode, createElementVNode, toDisplayString, Fragment, renderList, renderSlot, watch, nextTick, onMounted, withDirectives, isRef, vModelText, createTextVNode, createApp } from "@blueking/bkui-library";
3
3
  var top = "top";
4
4
  var bottom = "bottom";
5
5
  var right = "right";
@@ -10678,10 +10678,15 @@ const generateCallbackName = () => {
10678
10678
  const jsonpRequest = (requestUrl, options = {}) => {
10679
10679
  return new Promise((resolve, reject) => {
10680
10680
  const url = unref(requestUrl);
10681
- const { timeout = 1e3 * 60 * 2, params } = options;
10681
+ const { timeout = 1e3 * 60 * 2, params, withCredentials = true } = options;
10682
10682
  const callbackName = generateCallbackName();
10683
10683
  const script = document.createElement("script");
10684
10684
  let timeoutId;
10685
+ if (withCredentials) {
10686
+ script.crossOrigin = "use-credentials";
10687
+ } else {
10688
+ script.crossOrigin = "anonymous";
10689
+ }
10685
10690
  const cleanup = () => {
10686
10691
  if (timeoutId) {
10687
10692
  clearTimeout(timeoutId);
@@ -10695,7 +10700,7 @@ const jsonpRequest = (requestUrl, options = {}) => {
10695
10700
  };
10696
10701
  window[callbackName] = (data2) => {
10697
10702
  cleanup();
10698
- resolve(data2);
10703
+ resolve(data2.data || data2);
10699
10704
  };
10700
10705
  timeoutId = setTimeout(() => {
10701
10706
  cleanup();
@@ -10711,48 +10716,6 @@ const jsonpRequest = (requestUrl, options = {}) => {
10711
10716
  document.head.appendChild(script);
10712
10717
  });
10713
10718
  };
10714
- const useJSONP = (url, options = {}) => {
10715
- const data2 = shallowRef(null);
10716
- const loading2 = shallowRef(false);
10717
- const error3 = shallowRef(null);
10718
- let abortFlag = false;
10719
- const executeRequest = async (requestUrl) => {
10720
- if (!requestUrl) return;
10721
- loading2.value = true;
10722
- error3.value = null;
10723
- abortFlag = false;
10724
- try {
10725
- const result = await jsonpRequest(requestUrl, options);
10726
- if (!abortFlag) {
10727
- data2.value = result;
10728
- }
10729
- } catch (err) {
10730
- if (!abortFlag) {
10731
- const errorObj = err instanceof Error ? err : new Error(String(err));
10732
- error3.value = errorObj;
10733
- }
10734
- } finally {
10735
- if (!abortFlag) {
10736
- loading2.value = false;
10737
- }
10738
- }
10739
- };
10740
- const stopWatcher = watchEffect(() => {
10741
- executeRequest(unref(url));
10742
- });
10743
- onScopeDispose(() => {
10744
- abortFlag = true;
10745
- stopWatcher();
10746
- });
10747
- return {
10748
- data: data2,
10749
- loading: loading2,
10750
- error: error3,
10751
- refetch: () => {
10752
- executeRequest(unref(url));
10753
- }
10754
- };
10755
- };
10756
10719
  const getTenants = async (apiBaseUrl, tenantId) => {
10757
10720
  if (!apiBaseUrl || !tenantId) {
10758
10721
  console.warn("获取租户信息需要提供有效的apiBaseUrl和租户ID");
@@ -10779,7 +10742,7 @@ const getTenants = async (apiBaseUrl, tenantId) => {
10779
10742
  };
10780
10743
  const searchUsers = async (params) => {
10781
10744
  const { apiBaseUrl, tenantId, keyword, enableMultiTenantMode = true } = params;
10782
- if (enableMultiTenantMode) {
10745
+ if (!enableMultiTenantMode) {
10783
10746
  const userList = await getUserList(apiBaseUrl, {
10784
10747
  keyword,
10785
10748
  pageSize: 100,
@@ -10815,13 +10778,13 @@ const searchUsers = async (params) => {
10815
10778
  const lookupUsers = async (params) => {
10816
10779
  const { apiBaseUrl, tenantId, exactSearchKey = "bk_username", usersList = [], enableMultiTenantMode = true } = params;
10817
10780
  const users = usersList.filter((user) => user).map((user) => user.trim());
10818
- if (enableMultiTenantMode) {
10781
+ if (!enableMultiTenantMode) {
10819
10782
  const userList = await getUserList(apiBaseUrl, {
10820
10783
  userIds: users
10821
10784
  }).catch(() => {
10822
10785
  return [];
10823
10786
  });
10824
- return userList;
10787
+ return users.map((user) => userList.find((u2) => u2.username === user)).filter(Boolean);
10825
10788
  }
10826
10789
  if (users.length === 0 || !apiBaseUrl || !tenantId) {
10827
10790
  console.warn("批量查找用户需要提供有效的apiBaseUrl、租户ID和至少一个用户名");
@@ -10846,18 +10809,26 @@ const lookupUsers = async (params) => {
10846
10809
  return [];
10847
10810
  }
10848
10811
  };
10849
- const formatUsers = (users) => {
10812
+ const formatUsers = (users, enableMultiTenantMode = true) => {
10850
10813
  if (!users || !Array.isArray(users)) return [];
10814
+ if (!enableMultiTenantMode) {
10815
+ return users.map((user) => ({
10816
+ ...user,
10817
+ id: user.username,
10818
+ name: `${user.display_name}(${user.username})`,
10819
+ tenantId: user.owner_tenant_id
10820
+ }));
10821
+ }
10851
10822
  return users.map((user) => ({
10852
- id: user.bk_username || user.username,
10823
+ id: user.bk_username,
10853
10824
  name: user.display_name,
10854
10825
  tenantId: user.owner_tenant_id,
10855
10826
  ...user
10856
10827
  }));
10857
10828
  };
10858
10829
  const getUserList = async (url, params) => {
10859
- const { userIds, keyword, pageSize, page, appCode } = params;
10860
- const { data: userList } = await useJSONP(url, {
10830
+ const { userIds, keyword, pageSize = 20, page, appCode } = params;
10831
+ const data2 = await jsonpRequest(url, {
10861
10832
  params: {
10862
10833
  exact_lookups: (userIds == null ? void 0 : userIds.join(",")) || void 0,
10863
10834
  fuzzy_lookups: keyword || void 0,
@@ -10866,9 +10837,9 @@ const getUserList = async (url, params) => {
10866
10837
  app_code: appCode || "bk-magicbox"
10867
10838
  }
10868
10839
  });
10869
- return userList.value || [];
10840
+ return (data2 == null ? void 0 : data2.results) || [];
10870
10841
  };
10871
- const useTenantData = (apiBaseUrl, tenantId) => {
10842
+ const useTenantData = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
10872
10843
  const tenants = ref({});
10873
10844
  const loading2 = ref(false);
10874
10845
  const fetchTenants = async () => {
@@ -10893,7 +10864,9 @@ const useTenantData = (apiBaseUrl, tenantId) => {
10893
10864
  }
10894
10865
  };
10895
10866
  onBeforeMount(() => {
10896
- fetchTenants();
10867
+ if (enableMultiTenantMode) {
10868
+ fetchTenants();
10869
+ }
10897
10870
  });
10898
10871
  return {
10899
10872
  tenants,
@@ -13695,7 +13668,7 @@ const calculateVisibleTags = (container, items, containerWidth) => {
13695
13668
  }
13696
13669
  return Math.max(1, visibleCount);
13697
13670
  };
13698
- const useUserSearch = (apiBaseUrl, tenantId) => {
13671
+ const useUserSearch = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
13699
13672
  const searchResults = ref([]);
13700
13673
  const loading2 = ref(false);
13701
13674
  const searchQuery = ref("");
@@ -13704,7 +13677,7 @@ const useUserSearch = (apiBaseUrl, tenantId) => {
13704
13677
  searchResults.value = [];
13705
13678
  return;
13706
13679
  }
13707
- if (!apiBaseUrl || !tenantId) {
13680
+ if (enableMultiTenantMode && (!apiBaseUrl || !tenantId)) {
13708
13681
  console.warn("执行用户搜索需要提供有效的API基础URL和租户ID");
13709
13682
  return;
13710
13683
  }
@@ -13714,9 +13687,9 @@ const useUserSearch = (apiBaseUrl, tenantId) => {
13714
13687
  apiBaseUrl,
13715
13688
  tenantId,
13716
13689
  keyword,
13717
- enableMultiTenantMode: true
13690
+ enableMultiTenantMode
13718
13691
  });
13719
- searchResults.value = formatUsers(results);
13692
+ searchResults.value = formatUsers(results, enableMultiTenantMode);
13720
13693
  } catch (error3) {
13721
13694
  console.error("用户搜索失败:", error3);
13722
13695
  searchResults.value = [];
@@ -14058,13 +14031,16 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
14058
14031
  /* STABLE */
14059
14032
  }, 8, ["loading"])
14060
14033
  ]),
14061
- _: 1
14062
- /* STABLE */
14034
+ default: withCtx(() => [
14035
+ renderSlot(_ctx.$slots, "default", {}, void 0, true)
14036
+ ]),
14037
+ _: 3
14038
+ /* FORWARDED */
14063
14039
  }, 8, ["is-show", "offset", "width"]);
14064
14040
  };
14065
14041
  }
14066
14042
  });
14067
- const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-a4132257"]]);
14043
+ const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-6380faf5"]]);
14068
14044
  const _sfc_main$3 = /* @__PURE__ */ defineComponent({
14069
14045
  ...{
14070
14046
  name: "UserTag"
@@ -14148,7 +14124,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
14148
14124
  searchQuery,
14149
14125
  // clearSearch,
14150
14126
  handleSearchInput
14151
- } = useUserSearch(props2.apiBaseUrl, props2.tenantId);
14127
+ } = useUserSearch(props2.apiBaseUrl, props2.tenantId, props2.enableMultiTenantMode);
14152
14128
  const containerRef = ref(null);
14153
14129
  const tagsContainerRef = ref(null);
14154
14130
  const sortableContainerRef = ref(null);
@@ -14166,7 +14142,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
14166
14142
  return searchResults.value.filter((user) => !props2.selectedUsers.some((selectedUser) => selectedUser.id === user.id)).filter((user) => !props2.excludeUserIds.includes(user.id));
14167
14143
  });
14168
14144
  const userGroupFilter = computed(() => {
14169
- return props2.userGroup.filter((group) => !props2.selectedUsers.some((user) => user.id === group.id) && !group.hidden);
14145
+ return props2.userGroup.filter((group) => {
14146
+ var _a, _b;
14147
+ const filtered = !props2.selectedUsers.some((user) => user.id === group.id) && !group.hidden;
14148
+ if (filtered) {
14149
+ return ((_a = group.id) == null ? void 0 : _a.includes(searchQuery.value)) || ((_b = group.name) == null ? void 0 : _b.includes(searchQuery.value));
14150
+ }
14151
+ return false;
14152
+ });
14170
14153
  });
14171
14154
  const initSortable = () => {
14172
14155
  if (!props2.draggable || !sortableContainerRef.value) return;
@@ -14275,7 +14258,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
14275
14258
  usersList: [props2.currentUserId],
14276
14259
  enableMultiTenantMode: props2.enableMultiTenantMode
14277
14260
  });
14278
- const formattedUsers = formatUsers(result);
14261
+ const formattedUsers = formatUsers(result, props2.enableMultiTenantMode);
14279
14262
  if (formattedUsers.length > 0) {
14280
14263
  if (!props2.selectedUsers.some((item) => item.id === formattedUsers[0].id)) {
14281
14264
  emit("update:selectedUsers", [...props2.selectedUsers, formattedUsers[0]]);
@@ -14303,7 +14286,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
14303
14286
  usersList: users,
14304
14287
  enableMultiTenantMode: props2.enableMultiTenantMode
14305
14288
  });
14306
- const formattedUsers = formatUsers(result);
14289
+ const formattedUsers = formatUsers(result, props2.enableMultiTenantMode);
14307
14290
  if (formattedUsers.length > 0) {
14308
14291
  const updatedUsers = [...props2.selectedUsers, ...formattedUsers];
14309
14292
  emit("update:selectedUsers", updatedUsers);
@@ -14406,210 +14389,215 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
14406
14389
  class: normalizeClass(["multiple-selector", { "is-disabled": _ctx.disabled }])
14407
14390
  },
14408
14391
  [
14409
- createCommentVNode(" 聚焦状态 - 可编辑模式 "),
14410
- isFocused.value ? (openBlock(), createElementBlock(
14411
- "div",
14412
- {
14413
- key: 0,
14414
- ref_key: "tagsContainerRef",
14415
- ref: tagsContainerRef,
14416
- class: "tags-container focused",
14417
- onClick: withModifiers(handleContainerClick, ["stop"])
14418
- },
14419
- [
14420
- createCommentVNode(" 用户标签列表 "),
14421
- createElementVNode(
14392
+ createCommentVNode(" 下拉选项列表 "),
14393
+ createVNode(SelectionPopover, {
14394
+ "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
14395
+ "cross-axis-offset": crossAxisOffset.value,
14396
+ "empty-text": _ctx.emptyText,
14397
+ "is-show": showDropdown.value,
14398
+ loading: unref(searchLoading),
14399
+ options: options.value,
14400
+ "render-list-item": _ctx.renderListItem,
14401
+ "search-query": unref(searchQuery),
14402
+ "tenant-id": _ctx.tenantId,
14403
+ tenants: _ctx.tenants,
14404
+ "user-group": userGroupFilter.value,
14405
+ "user-group-name": _ctx.userGroupName,
14406
+ onClickOutside: handleClickOutside,
14407
+ onSelectUser: addUser
14408
+ }, {
14409
+ default: withCtx(() => [
14410
+ createCommentVNode(" 聚焦状态 - 可编辑模式 "),
14411
+ isFocused.value ? (openBlock(), createElementBlock(
14422
14412
  "div",
14423
14413
  {
14424
- ref_key: "sortableContainerRef",
14425
- ref: sortableContainerRef,
14426
- class: "tag-list"
14414
+ key: 0,
14415
+ ref_key: "tagsContainerRef",
14416
+ ref: tagsContainerRef,
14417
+ class: "tags-container focused",
14418
+ onClick: withModifiers(handleContainerClick, ["stop"])
14427
14419
  },
14428
14420
  [
14429
- (openBlock(true), createElementBlock(
14430
- Fragment,
14431
- null,
14432
- renderList(_ctx.selectedUsers, (user, index) => {
14433
- return openBlock(), createElementBlock("div", {
14434
- class: "tag-wrapper",
14435
- key: user.id,
14436
- onClick: withModifiers(($event) => handleTagClick(index), ["stop"])
14437
- }, [
14438
- createVNode(UserTag, {
14439
- active: index === activeTagIndex.value,
14440
- "current-tenant-id": _ctx.tenantId,
14441
- draggable: _ctx.draggable,
14442
- "render-tag": _ctx.renderTag,
14443
- tenants: _ctx.tenants,
14444
- user,
14445
- onClick: ($event) => handleTagClick(index),
14446
- onClose: ($event) => removeUser(user)
14447
- }, null, 8, ["active", "current-tenant-id", "draggable", "render-tag", "tenants", "user", "onClick", "onClose"]),
14448
- createCommentVNode(" 在当前激活标签后插入输入框 "),
14449
- index === activeTagIndex.value && activeTagIndex.value !== _ctx.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock(
14450
- "input",
14451
- {
14452
- key: 0,
14453
- ref_for: true,
14454
- ref_key: "inlineInputRef",
14455
- ref: inlineInputRef,
14456
- class: "search-input inline",
14457
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
14458
- onFocus: handleInputFocus,
14459
- onInput: handleInput,
14460
- onKeydown: handleKeyDown,
14461
- onPaste: handlePaste
14462
- },
14463
- null,
14464
- 544
14465
- /* NEED_HYDRATION, NEED_PATCH */
14466
- )), [
14467
- [vModelText, unref(searchQuery)]
14468
- ]) : createCommentVNode("v-if", true)
14469
- ], 8, _hoisted_1$1);
14470
- }),
14471
- 128
14472
- /* KEYED_FRAGMENT */
14473
- )),
14474
- createCommentVNode(" 最后一个输入框 "),
14475
- activeTagIndex.value === -1 || activeTagIndex.value === _ctx.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock("input", {
14476
- key: 0,
14477
- ref_key: "lastInputRef",
14478
- ref: lastInputRef,
14479
- class: "search-input last",
14480
- "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
14481
- placeholder: !_ctx.selectedUsers.length ? _ctx.placeholder : "",
14482
- onFocus: handleInputFocus,
14483
- onInput: handleInput,
14484
- onKeydown: handleKeyDown,
14485
- onPaste: handlePaste
14486
- }, null, 40, _hoisted_2$1)), [
14487
- [vModelText, unref(searchQuery)]
14488
- ]) : createCommentVNode("v-if", true),
14489
- createCommentVNode(' ""标签 '),
14490
- createVNode(MeTag, {
14491
- "current-user-id": _ctx.currentUserId,
14492
- "is-disabled": !!_ctx.currentUserId && _ctx.selectedUsers.some((user) => user.id === _ctx.currentUserId),
14493
- onClick: addCurrentUser
14494
- }, null, 8, ["current-user-id", "is-disabled"])
14421
+ createCommentVNode(" 用户标签列表 "),
14422
+ createElementVNode(
14423
+ "div",
14424
+ {
14425
+ ref_key: "sortableContainerRef",
14426
+ ref: sortableContainerRef,
14427
+ class: "tag-list"
14428
+ },
14429
+ [
14430
+ (openBlock(true), createElementBlock(
14431
+ Fragment,
14432
+ null,
14433
+ renderList(_ctx.selectedUsers, (user, index) => {
14434
+ return openBlock(), createElementBlock("div", {
14435
+ class: "tag-wrapper",
14436
+ key: user.id,
14437
+ onClick: withModifiers(($event) => handleTagClick(index), ["stop"])
14438
+ }, [
14439
+ createVNode(UserTag, {
14440
+ active: index === activeTagIndex.value,
14441
+ "current-tenant-id": _ctx.tenantId,
14442
+ draggable: _ctx.draggable,
14443
+ "render-tag": _ctx.renderTag,
14444
+ tenants: _ctx.tenants,
14445
+ user,
14446
+ onClick: ($event) => handleTagClick(index),
14447
+ onClose: ($event) => removeUser(user)
14448
+ }, null, 8, ["active", "current-tenant-id", "draggable", "render-tag", "tenants", "user", "onClick", "onClose"]),
14449
+ createCommentVNode(" 在当前激活标签后插入输入框 "),
14450
+ index === activeTagIndex.value && activeTagIndex.value !== _ctx.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock(
14451
+ "input",
14452
+ {
14453
+ key: 0,
14454
+ ref_for: true,
14455
+ ref_key: "inlineInputRef",
14456
+ ref: inlineInputRef,
14457
+ class: "search-input inline",
14458
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
14459
+ onFocus: handleInputFocus,
14460
+ onInput: handleInput,
14461
+ onKeydown: handleKeyDown,
14462
+ onPaste: handlePaste
14463
+ },
14464
+ null,
14465
+ 544
14466
+ /* NEED_HYDRATION, NEED_PATCH */
14467
+ )), [
14468
+ [vModelText, unref(searchQuery)]
14469
+ ]) : createCommentVNode("v-if", true)
14470
+ ], 8, _hoisted_1$1);
14471
+ }),
14472
+ 128
14473
+ /* KEYED_FRAGMENT */
14474
+ )),
14475
+ createCommentVNode(" 最后一个输入框 "),
14476
+ activeTagIndex.value === -1 || activeTagIndex.value === _ctx.selectedUsers.length - 1 ? withDirectives((openBlock(), createElementBlock("input", {
14477
+ key: 0,
14478
+ ref_key: "lastInputRef",
14479
+ ref: lastInputRef,
14480
+ class: "search-input last",
14481
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
14482
+ placeholder: !_ctx.selectedUsers.length ? _ctx.placeholder : "",
14483
+ onFocus: handleInputFocus,
14484
+ onInput: handleInput,
14485
+ onKeydown: handleKeyDown,
14486
+ onPaste: handlePaste
14487
+ }, null, 40, _hoisted_2$1)), [
14488
+ [vModelText, unref(searchQuery)]
14489
+ ]) : createCommentVNode("v-if", true),
14490
+ createCommentVNode(' "我"标签 '),
14491
+ createVNode(MeTag, {
14492
+ "current-user-id": _ctx.currentUserId,
14493
+ "is-disabled": !!_ctx.currentUserId && _ctx.selectedUsers.some((user) => user.id === _ctx.currentUserId),
14494
+ onClick: addCurrentUser
14495
+ }, null, 8, ["current-user-id", "is-disabled"])
14496
+ ],
14497
+ 512
14498
+ /* NEED_PATCH */
14499
+ )
14495
14500
  ],
14496
14501
  512
14497
14502
  /* NEED_PATCH */
14498
- )
14499
- ],
14500
- 512
14501
- /* NEED_PATCH */
14502
- )) : (openBlock(), createElementBlock(
14503
- Fragment,
14504
- { key: 1 },
14505
- [
14506
- createCommentVNode(" 未聚焦状态 - 只读展示模式 "),
14507
- createElementVNode(
14508
- "div",
14509
- {
14510
- ref_key: "collapsedContainerRef",
14511
- ref: collapsedContainerRef,
14512
- class: "tags-container collapsed",
14513
- onClick: withModifiers(handleFocus, ["stop"])
14514
- },
14503
+ )) : (openBlock(), createElementBlock(
14504
+ Fragment,
14505
+ { key: 1 },
14515
14506
  [
14516
- (openBlock(true), createElementBlock(
14517
- Fragment,
14518
- null,
14519
- renderList(visibleUsers.value, (user) => {
14520
- return openBlock(), createBlock(UserTag, {
14521
- "current-tenant-id": _ctx.tenantId,
14522
- key: user.id,
14523
- "render-tag": _ctx.renderTag,
14524
- "show-tenant": true,
14525
- tenants: _ctx.tenants,
14526
- user,
14527
- onClick: handleFocus,
14528
- onClose: ($event) => removeUser(user)
14529
- }, null, 8, ["current-tenant-id", "render-tag", "tenants", "user", "onClose"]);
14530
- }),
14531
- 128
14532
- /* KEYED_FRAGMENT */
14533
- )),
14534
- createCommentVNode(" 显示折叠标签数量 "),
14535
- hiddenCount.value > 0 ? (openBlock(), createBlock(unref(__webpack_exports__default$1), {
14536
- key: 0,
14537
- placement: "top"
14538
- }, {
14539
- content: withCtx(() => [
14507
+ createCommentVNode(" 未聚焦状态 - 只读展示模式 "),
14508
+ createElementVNode(
14509
+ "div",
14510
+ {
14511
+ ref_key: "collapsedContainerRef",
14512
+ ref: collapsedContainerRef,
14513
+ class: "tags-container collapsed",
14514
+ onClick: withModifiers(handleFocus, ["stop"])
14515
+ },
14516
+ [
14540
14517
  (openBlock(true), createElementBlock(
14541
14518
  Fragment,
14542
14519
  null,
14543
- renderList(_ctx.selectedUsers.slice(visibleUsers.value.length), (user) => {
14544
- return openBlock(), createBlock(unref(UserRender), {
14520
+ renderList(visibleUsers.value, (user) => {
14521
+ return openBlock(), createBlock(UserTag, {
14522
+ "current-tenant-id": _ctx.tenantId,
14545
14523
  key: user.id,
14546
- "tenant-id": _ctx.tenantId,
14524
+ "render-tag": _ctx.renderTag,
14525
+ "show-tenant": true,
14547
14526
  tenants: _ctx.tenants,
14548
- user
14549
- }, null, 8, ["tenant-id", "tenants", "user"]);
14527
+ user,
14528
+ onClick: handleFocus,
14529
+ onClose: ($event) => removeUser(user)
14530
+ }, null, 8, ["current-tenant-id", "render-tag", "tenants", "user", "onClose"]);
14550
14531
  }),
14551
14532
  128
14552
14533
  /* KEYED_FRAGMENT */
14553
- ))
14554
- ]),
14555
- default: withCtx(() => [
14556
- createVNode(unref(__webpack_exports__default), null, {
14534
+ )),
14535
+ createCommentVNode(" 显示折叠标签数量 "),
14536
+ hiddenCount.value > 0 ? (openBlock(), createBlock(unref(__webpack_exports__default$1), {
14537
+ key: 0,
14538
+ placement: "top"
14539
+ }, {
14540
+ content: withCtx(() => [
14541
+ (openBlock(true), createElementBlock(
14542
+ Fragment,
14543
+ null,
14544
+ renderList(_ctx.selectedUsers.slice(visibleUsers.value.length), (user) => {
14545
+ return openBlock(), createBlock(unref(UserRender), {
14546
+ key: user.id,
14547
+ "tenant-id": _ctx.tenantId,
14548
+ tenants: _ctx.tenants,
14549
+ user
14550
+ }, null, 8, ["tenant-id", "tenants", "user"]);
14551
+ }),
14552
+ 128
14553
+ /* KEYED_FRAGMENT */
14554
+ ))
14555
+ ]),
14557
14556
  default: withCtx(() => [
14558
- createTextVNode(
14559
- " +" + toDisplayString(hiddenCount.value),
14560
- 1
14561
- /* TEXT */
14562
- )
14557
+ createVNode(unref(__webpack_exports__default), null, {
14558
+ default: withCtx(() => [
14559
+ createTextVNode(
14560
+ " +" + toDisplayString(hiddenCount.value),
14561
+ 1
14562
+ /* TEXT */
14563
+ )
14564
+ ]),
14565
+ _: 1
14566
+ /* STABLE */
14567
+ })
14563
14568
  ]),
14564
14569
  _: 1
14565
14570
  /* STABLE */
14566
- })
14567
- ]),
14568
- _: 1
14569
- /* STABLE */
14570
- })) : createCommentVNode("v-if", true),
14571
- createCommentVNode(" 搜索输入框 "),
14572
- withDirectives(createElementVNode("input", {
14573
- ref_key: "collapsedInputRef",
14574
- ref: collapsedInputRef,
14575
- class: "search-input collapsed",
14576
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
14577
- placeholder: !_ctx.selectedUsers.length ? _ctx.placeholder : "",
14578
- onFocus: handleFocus
14579
- }, null, 40, _hoisted_3), [
14580
- [vModelText, unref(searchQuery)]
14581
- ]),
14582
- createCommentVNode(' 未聚焦状态下的"我"标签 '),
14583
- createVNode(MeTag, {
14584
- "current-user-id": _ctx.currentUserId,
14585
- "is-disabled": !!_ctx.currentUserId && _ctx.selectedUsers.some((user) => user[props2.exactSearchKey] === _ctx.currentUserId),
14586
- onClick: addCurrentUser
14587
- }, null, 8, ["current-user-id", "is-disabled"])
14571
+ })) : createCommentVNode("v-if", true),
14572
+ createCommentVNode(" 搜索输入框 "),
14573
+ withDirectives(createElementVNode("input", {
14574
+ ref_key: "collapsedInputRef",
14575
+ ref: collapsedInputRef,
14576
+ class: "search-input collapsed",
14577
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
14578
+ placeholder: !_ctx.selectedUsers.length ? _ctx.placeholder : "",
14579
+ onFocus: handleFocus
14580
+ }, null, 40, _hoisted_3), [
14581
+ [vModelText, unref(searchQuery)]
14582
+ ]),
14583
+ createCommentVNode(' 未聚焦状态下的"我"标签 '),
14584
+ createVNode(MeTag, {
14585
+ "current-user-id": _ctx.currentUserId,
14586
+ "is-disabled": !!_ctx.currentUserId && _ctx.selectedUsers.some((user) => user[props2.exactSearchKey] === _ctx.currentUserId),
14587
+ onClick: addCurrentUser
14588
+ }, null, 8, ["current-user-id", "is-disabled"])
14589
+ ],
14590
+ 512
14591
+ /* NEED_PATCH */
14592
+ )
14588
14593
  ],
14589
- 512
14590
- /* NEED_PATCH */
14591
- )
14592
- ],
14593
- 2112
14594
- /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
14595
- )),
14596
- createCommentVNode(" 下拉选项列表 "),
14597
- createVNode(SelectionPopover, {
14598
- "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
14599
- "cross-axis-offset": crossAxisOffset.value,
14600
- "empty-text": _ctx.emptyText,
14601
- "is-show": showDropdown.value,
14602
- loading: unref(searchLoading),
14603
- options: options.value,
14604
- "render-list-item": _ctx.renderListItem,
14605
- "search-query": unref(searchQuery),
14606
- "tenant-id": _ctx.tenantId,
14607
- tenants: _ctx.tenants,
14608
- "user-group": userGroupFilter.value,
14609
- "user-group-name": _ctx.userGroupName,
14610
- onClickOutside: handleClickOutside,
14611
- onSelectUser: addUser
14612
- }, null, 8, ["container-width", "cross-axis-offset", "empty-text", "is-show", "loading", "options", "render-list-item", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
14594
+ 2112
14595
+ /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
14596
+ ))
14597
+ ]),
14598
+ _: 1
14599
+ /* STABLE */
14600
+ }, 8, ["container-width", "cross-axis-offset", "empty-text", "is-show", "loading", "options", "render-list-item", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
14613
14601
  ],
14614
14602
  2
14615
14603
  /* CLASS */
@@ -14617,7 +14605,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
14617
14605
  };
14618
14606
  }
14619
14607
  });
14620
- const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-bebe517d"]]);
14608
+ const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-69acfacb"]]);
14621
14609
  const _hoisted_1 = { class: "input-container" };
14622
14610
  const _hoisted_2 = ["placeholder"];
14623
14611
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
@@ -14654,7 +14642,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14654
14642
  const searchQuery = ref("");
14655
14643
  const showDropdown = ref(false);
14656
14644
  const userGroupFilter = computed(() => {
14657
- return props2.userGroup.filter((group) => group.id !== selectedUser.value && !group.hidden);
14645
+ return props2.userGroup.filter((group) => {
14646
+ var _a, _b;
14647
+ const filtered = group.id !== selectedUser.value && !group.hidden;
14648
+ if (filtered) {
14649
+ return ((_a = group.id) == null ? void 0 : _a.includes(searchQuery.value)) || ((_b = group.name) == null ? void 0 : _b.includes(searchQuery.value));
14650
+ }
14651
+ return false;
14652
+ });
14658
14653
  });
14659
14654
  const selectedUserInfo = computed(() => {
14660
14655
  const userGroup = (props2.userGroup || []).map((group) => ({
@@ -14678,7 +14673,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14678
14673
  usersList: [props2.modelValue],
14679
14674
  enableMultiTenantMode: props2.enableMultiTenantMode
14680
14675
  });
14681
- options.value = formatUsers(result).filter((user) => !props2.excludeUserIds.includes(user.id));
14676
+ options.value = formatUsers(result, props2.enableMultiTenantMode).filter(
14677
+ (user) => !props2.excludeUserIds.includes(user.id)
14678
+ );
14682
14679
  if (props2.userGroup.length > 0) {
14683
14680
  const groupResult = props2.userGroup.filter((group) => group.id == props2.modelValue);
14684
14681
  options.value = groupResult.map((group) => ({
@@ -14709,7 +14706,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14709
14706
  usersList: [props2.currentUserId],
14710
14707
  enableMultiTenantMode: props2.enableMultiTenantMode
14711
14708
  });
14712
- const formattedResults = formatUsers(result);
14709
+ const formattedResults = formatUsers(result, props2.enableMultiTenantMode);
14713
14710
  if (formattedResults.length > 0) {
14714
14711
  options.value = formattedResults.filter((user) => !props2.excludeUserIds.includes(user.id));
14715
14712
  addUser(formattedResults[0]);
@@ -14731,7 +14728,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14731
14728
  keyword,
14732
14729
  enableMultiTenantMode: props2.enableMultiTenantMode
14733
14730
  });
14734
- options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value).filter((user) => !props2.excludeUserIds.includes(user.id));
14731
+ options.value = formatUsers(result, props2.enableMultiTenantMode).filter((user) => !selectedUser.value || user.id !== selectedUser.value).filter((user) => !props2.excludeUserIds.includes(user.id));
14735
14732
  } catch (error3) {
14736
14733
  console.error("获取用户列表失败:", error3);
14737
14734
  options.value = [];
@@ -14778,39 +14775,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14778
14775
  class: normalizeClass(["single-selector", { "is-disabled": _ctx.disabled }])
14779
14776
  },
14780
14777
  [
14781
- createCommentVNode(" 输入框 "),
14782
- createElementVNode("div", _hoisted_1, [
14783
- createCommentVNode(" 用户标签显示 "),
14784
- selectedUserInfo.value ? (openBlock(), createElementBlock("div", {
14785
- key: 0,
14786
- onClick: withModifiers(removeSelectedUser, ["stop"])
14787
- }, [
14788
- createVNode(UserTag, {
14789
- "current-tenant-id": _ctx.tenantId,
14790
- "render-tag": _ctx.renderTag,
14791
- tenants: _ctx.tenants,
14792
- user: selectedUserInfo.value,
14793
- onClose: removeSelectedUser
14794
- }, null, 8, ["current-tenant-id", "render-tag", "tenants", "user"])
14795
- ])) : createCommentVNode("v-if", true),
14796
- withDirectives(createElementVNode("input", {
14797
- ref_key: "inputRef",
14798
- ref: inputRef,
14799
- class: "search-input",
14800
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchQuery.value = $event),
14801
- placeholder: selectedUserInfo.value ? "" : _ctx.placeholder,
14802
- onFocus: handleInputFocus,
14803
- onInput: handleInput
14804
- }, null, 40, _hoisted_2), [
14805
- [vModelText, searchQuery.value]
14806
- ]),
14807
- createCommentVNode(' "我"标签 '),
14808
- createVNode(MeTag, {
14809
- "current-user-id": _ctx.currentUserId,
14810
- "is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey] === _ctx.currentUserId,
14811
- onClick: addCurrentUser
14812
- }, null, 8, ["current-user-id", "is-disabled"])
14813
- ]),
14814
14778
  createCommentVNode(" 使用新的公共下拉选项组件 "),
14815
14779
  createVNode(SelectionPopover, {
14816
14780
  "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
@@ -14825,7 +14789,45 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14825
14789
  "user-group": userGroupFilter.value,
14826
14790
  "user-group-name": _ctx.userGroupName,
14827
14791
  onSelectUser: addUser
14828
- }, null, 8, ["container-width", "empty-text", "is-show", "loading", "options", "render-list-item", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
14792
+ }, {
14793
+ default: withCtx(() => [
14794
+ createCommentVNode(" 输入框 "),
14795
+ createElementVNode("div", _hoisted_1, [
14796
+ createCommentVNode(" 用户标签显示 "),
14797
+ selectedUserInfo.value ? (openBlock(), createElementBlock("div", {
14798
+ key: 0,
14799
+ onClick: withModifiers(removeSelectedUser, ["stop"])
14800
+ }, [
14801
+ createVNode(UserTag, {
14802
+ "current-tenant-id": _ctx.tenantId,
14803
+ "render-tag": _ctx.renderTag,
14804
+ tenants: _ctx.tenants,
14805
+ user: selectedUserInfo.value,
14806
+ onClose: removeSelectedUser
14807
+ }, null, 8, ["current-tenant-id", "render-tag", "tenants", "user"])
14808
+ ])) : createCommentVNode("v-if", true),
14809
+ withDirectives(createElementVNode("input", {
14810
+ ref_key: "inputRef",
14811
+ ref: inputRef,
14812
+ class: "search-input",
14813
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchQuery.value = $event),
14814
+ placeholder: selectedUserInfo.value ? "" : _ctx.placeholder,
14815
+ onFocus: handleInputFocus,
14816
+ onInput: handleInput
14817
+ }, null, 40, _hoisted_2), [
14818
+ [vModelText, searchQuery.value]
14819
+ ]),
14820
+ createCommentVNode(' "我"标签 '),
14821
+ createVNode(MeTag, {
14822
+ "current-user-id": _ctx.currentUserId,
14823
+ "is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey] === _ctx.currentUserId,
14824
+ onClick: addCurrentUser
14825
+ }, null, 8, ["current-user-id", "is-disabled"])
14826
+ ])
14827
+ ]),
14828
+ _: 1
14829
+ /* STABLE */
14830
+ }, 8, ["container-width", "empty-text", "is-show", "loading", "options", "render-list-item", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
14829
14831
  ],
14830
14832
  2
14831
14833
  /* CLASS */
@@ -14835,7 +14837,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
14835
14837
  };
14836
14838
  }
14837
14839
  });
14838
- const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-67f2ee6a"]]);
14840
+ const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-d52d578d"]]);
14839
14841
  const _sfc_main = /* @__PURE__ */ defineComponent({
14840
14842
  ...{
14841
14843
  name: "BkUserSelector"
@@ -14857,7 +14859,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14857
14859
  renderListItem: {},
14858
14860
  renderTag: {},
14859
14861
  excludeUserIds: { default: () => [] },
14860
- enableMultiTenantMode: { type: Boolean, default: false }
14862
+ enableMultiTenantMode: { type: Boolean, default: true }
14861
14863
  },
14862
14864
  emits: ["update:modelValue", "change"],
14863
14865
  setup(__props, { emit: __emit }) {
@@ -14866,7 +14868,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14866
14868
  });
14867
14869
  const props2 = __props;
14868
14870
  const emit = __emit;
14869
- const { tenants = {} } = useTenantData(props2.apiBaseUrl, props2.tenantId);
14871
+ const { tenants = {} } = useTenantData(props2.apiBaseUrl, props2.tenantId, props2.enableMultiTenantMode);
14870
14872
  const selectedUsers = ref([]);
14871
14873
  const selectedUser = ref(props2.multiple ? "" : props2.modelValue);
14872
14874
  const selectedUserIds = computed(() => {
@@ -14893,7 +14895,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
14893
14895
  usersList: ids,
14894
14896
  enableMultiTenantMode: props2.enableMultiTenantMode
14895
14897
  });
14896
- selectedUsers.value = [...selected, ...formatUsers(result)];
14898
+ const selectedList = [...selected, ...formatUsers(result, props2.enableMultiTenantMode)];
14899
+ selectedUsers.value = ids.map((id) => selectedList.find((user) => user.id === id)).filter(Boolean);
14897
14900
  } catch (error3) {
14898
14901
  console.error("获取选中用户信息失败:", error3);
14899
14902
  }
@@ -15000,7 +15003,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
15000
15003
  };
15001
15004
  }
15002
15005
  });
15003
- const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-30b84150"]]);
15006
+ const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-02466e5e"]]);
15004
15007
  const vue2 = {
15005
15008
  model: {
15006
15009
  prop: "modelValue",