@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.
@@ -1,5 +1,5 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_vue__ from "@blueking/bkui-library";
2
- import { ref, onBeforeMount, defineComponent, createBlock, openBlock, unref, withModifiers, normalizeClass, withCtx, createElementVNode, createElementBlock, createCommentVNode, toDisplayString, watch, nextTick, onMounted, withDirectives, createVNode, Fragment, renderList, isRef, vModelText, createTextVNode, computed, pushScopeId, popScopeId, createApp, h as h$1 } from "@blueking/bkui-library";
2
+ 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, createApp, h as h$1 } from "@blueking/bkui-library";
3
3
  const getTenants = async (apiBaseUrl, tenantId) => {
4
4
  if (!apiBaseUrl || !tenantId) {
5
5
  console.warn("获取租户信息需要提供有效的apiBaseUrl和租户ID");
@@ -13638,7 +13638,7 @@ var __webpack_exports__$1 = {};
13638
13638
  })();
13639
13639
  __webpack_exports__$1.bkEllipsis;
13640
13640
  __webpack_exports__$1.bkEllipsisInstance;
13641
- __webpack_exports__$1.bkTooltips;
13641
+ var __webpack_exports__bkTooltips = __webpack_exports__$1.bkTooltips;
13642
13642
  var __webpack_exports__clickoutside = __webpack_exports__$1.clickoutside;
13643
13643
  __webpack_exports__$1.mousewheel;
13644
13644
  __webpack_exports__$1.overflowTitle;
@@ -16637,6 +16637,270 @@ const useUserSearch = (apiBaseUrl, tenantId) => {
16637
16637
  clearSearch
16638
16638
  };
16639
16639
  };
16640
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
16641
+ ...{
16642
+ name: "MeTag"
16643
+ },
16644
+ __name: "me-tag",
16645
+ props: {
16646
+ /**
16647
+ * 当前用户ID
16648
+ */
16649
+ currentUserId: {
16650
+ type: String,
16651
+ default: ""
16652
+ },
16653
+ /**
16654
+ * 是否禁用
16655
+ */
16656
+ isDisabled: {
16657
+ type: Boolean,
16658
+ default: false
16659
+ }
16660
+ },
16661
+ emits: ["click"],
16662
+ setup(__props, { emit: __emit }) {
16663
+ const props2 = __props;
16664
+ const emit = __emit;
16665
+ const handleClick = () => {
16666
+ if (props2.isDisabled) return;
16667
+ emit("click");
16668
+ };
16669
+ return (_ctx, _cache) => {
16670
+ return __props.currentUserId ? (openBlock(), createElementBlock(
16671
+ "div",
16672
+ {
16673
+ key: 0,
16674
+ class: normalizeClass(["me-tag", { disabled: __props.isDisabled }]),
16675
+ onClick: withModifiers(handleClick, ["stop"])
16676
+ },
16677
+ " 我 ",
16678
+ 2
16679
+ /* CLASS */
16680
+ )) : createCommentVNode("v-if", true);
16681
+ };
16682
+ }
16683
+ });
16684
+ const _export_sfc = (sfc, props2) => {
16685
+ const target = sfc.__vccOpts || sfc;
16686
+ for (const [key, val] of props2) {
16687
+ target[key] = val;
16688
+ }
16689
+ return target;
16690
+ };
16691
+ const MeTag = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-887b7c44"]]);
16692
+ const _hoisted_1$4 = {
16693
+ key: 0,
16694
+ class: "no-data"
16695
+ };
16696
+ const _hoisted_2$3 = { class: "group-name" };
16697
+ const _hoisted_3$3 = { class: "group-count" };
16698
+ const _hoisted_4$1 = ["onMousedown"];
16699
+ const _hoisted_5 = {
16700
+ key: 0,
16701
+ class: "tenant-name"
16702
+ };
16703
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
16704
+ ...{
16705
+ name: "SelectionPopover"
16706
+ },
16707
+ __name: "selection-popover",
16708
+ props: {
16709
+ /**
16710
+ * 是否显示下拉菜单
16711
+ */
16712
+ isShow: {
16713
+ type: Boolean,
16714
+ default: false
16715
+ },
16716
+ /**
16717
+ * 容器宽度
16718
+ */
16719
+ containerWidth: {
16720
+ type: [Number, String],
16721
+ default: "auto"
16722
+ },
16723
+ /**
16724
+ * 是否加载中
16725
+ */
16726
+ loading: {
16727
+ type: Boolean,
16728
+ default: false
16729
+ },
16730
+ /**
16731
+ * 搜索结果选项
16732
+ */
16733
+ options: {
16734
+ type: Array,
16735
+ default: () => []
16736
+ },
16737
+ /**
16738
+ * 搜索关键词
16739
+ */
16740
+ searchQuery: {
16741
+ type: String,
16742
+ default: ""
16743
+ },
16744
+ /**
16745
+ * 当前租户ID
16746
+ */
16747
+ tenantId: {
16748
+ type: String,
16749
+ default: ""
16750
+ },
16751
+ /**
16752
+ * 租户信息映射
16753
+ */
16754
+ tenants: {
16755
+ type: Object,
16756
+ default: () => ({})
16757
+ },
16758
+ /**
16759
+ * 用户组
16760
+ */
16761
+ userGroup: {
16762
+ type: Array,
16763
+ default: () => []
16764
+ },
16765
+ /**
16766
+ * 用户组名称
16767
+ */
16768
+ userGroupName: {
16769
+ type: String,
16770
+ default: "用户群组"
16771
+ }
16772
+ },
16773
+ emits: ["select-user"],
16774
+ setup(__props, { emit: __emit }) {
16775
+ const props2 = __props;
16776
+ const emit = __emit;
16777
+ const groupedUsers = computed(() => {
16778
+ const groups = {};
16779
+ console.log("props.options", props2.options);
16780
+ if (Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
16781
+ groups[props2.userGroupName] = props2.userGroup.map((group) => ({
16782
+ id: group.id,
16783
+ name: group.name,
16784
+ tenantId: ""
16785
+ }));
16786
+ }
16787
+ props2.options.forEach((user) => {
16788
+ const groupName = user.data_source_type === "real" ? "用户" : "虚拟账号";
16789
+ if (!groups[groupName]) {
16790
+ groups[groupName] = [];
16791
+ }
16792
+ groups[groupName].push(user);
16793
+ });
16794
+ return groups;
16795
+ });
16796
+ const selectUser = (user) => {
16797
+ emit("select-user", user);
16798
+ };
16799
+ return (_ctx, _cache) => {
16800
+ return openBlock(), createBlock(unref(__webpack_exports__default$1), {
16801
+ "ext-cls": "bk-user-selector-popover",
16802
+ arrow: false,
16803
+ "is-show": __props.isShow,
16804
+ width: __props.containerWidth,
16805
+ placement: "bottom-start",
16806
+ theme: "light",
16807
+ trigger: "manual"
16808
+ }, {
16809
+ content: withCtx(() => [
16810
+ createVNode(unref(__webpack_exports__default$3), {
16811
+ class: "dropdown-content",
16812
+ loading: __props.loading,
16813
+ size: "mini",
16814
+ mode: "spin"
16815
+ }, {
16816
+ default: withCtx(() => [
16817
+ __props.options.length === 0 && __props.userGroup.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
16818
+ createElementVNode(
16819
+ "span",
16820
+ null,
16821
+ toDisplayString(__props.searchQuery.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
16822
+ 1
16823
+ /* TEXT */
16824
+ )
16825
+ ])) : (openBlock(true), createElementBlock(
16826
+ Fragment,
16827
+ { key: 1 },
16828
+ renderList(groupedUsers.value, (group, groupName) => {
16829
+ return openBlock(), createElementBlock("div", {
16830
+ class: "user-group",
16831
+ key: groupName
16832
+ }, [
16833
+ createElementVNode(
16834
+ "div",
16835
+ {
16836
+ class: "group-header",
16837
+ onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {
16838
+ }, ["prevent"]))
16839
+ },
16840
+ [
16841
+ createElementVNode(
16842
+ "span",
16843
+ _hoisted_2$3,
16844
+ toDisplayString(groupName),
16845
+ 1
16846
+ /* TEXT */
16847
+ ),
16848
+ createElementVNode(
16849
+ "span",
16850
+ _hoisted_3$3,
16851
+ "(" + toDisplayString(group.length) + ")",
16852
+ 1
16853
+ /* TEXT */
16854
+ )
16855
+ ],
16856
+ 32
16857
+ /* NEED_HYDRATION */
16858
+ ),
16859
+ (openBlock(true), createElementBlock(
16860
+ Fragment,
16861
+ null,
16862
+ renderList(group, (user) => {
16863
+ return openBlock(), createElementBlock("div", {
16864
+ class: "user-option",
16865
+ key: user.id,
16866
+ onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
16867
+ }, [
16868
+ createElementVNode(
16869
+ "span",
16870
+ null,
16871
+ toDisplayString(user.name),
16872
+ 1
16873
+ /* TEXT */
16874
+ ),
16875
+ user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
16876
+ "span",
16877
+ _hoisted_5,
16878
+ "@" + toDisplayString(__props.tenants[user.tenantId]),
16879
+ 1
16880
+ /* TEXT */
16881
+ )) : createCommentVNode("v-if", true)
16882
+ ], 40, _hoisted_4$1);
16883
+ }),
16884
+ 128
16885
+ /* KEYED_FRAGMENT */
16886
+ ))
16887
+ ]);
16888
+ }),
16889
+ 128
16890
+ /* KEYED_FRAGMENT */
16891
+ ))
16892
+ ]),
16893
+ _: 1
16894
+ /* STABLE */
16895
+ }, 8, ["loading"])
16896
+ ]),
16897
+ _: 1
16898
+ /* STABLE */
16899
+ }, 8, ["is-show", "width"]);
16900
+ };
16901
+ }
16902
+ });
16903
+ const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-c68dfcac"]]);
16640
16904
  const _hoisted_1$3 = { class: "tag-content" };
16641
16905
  const _hoisted_2$2 = { class: "user-name" };
16642
16906
  const _hoisted_3$2 = {
@@ -16696,26 +16960,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
16696
16960
  };
16697
16961
  }
16698
16962
  });
16699
- const _export_sfc = (sfc, props2) => {
16700
- const target = sfc.__vccOpts || sfc;
16701
- for (const [key, val] of props2) {
16702
- target[key] = val;
16703
- }
16704
- return target;
16705
- };
16706
16963
  const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-203c36cb"]]);
16707
16964
  const _hoisted_1$2 = ["onClick"];
16708
16965
  const _hoisted_2$1 = ["placeholder"];
16709
16966
  const _hoisted_3$1 = ["placeholder"];
16710
- const _hoisted_4$1 = {
16711
- key: 0,
16712
- class: "no-data"
16713
- };
16714
- const _hoisted_5$1 = ["onMousedown"];
16715
- const _hoisted_6$1 = {
16716
- key: 0,
16717
- class: "tenant-name"
16718
- };
16719
16967
  const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16720
16968
  ...{
16721
16969
  name: "BkUserSelectorMultiple"
@@ -16784,6 +17032,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16784
17032
  exactSearchKey: {
16785
17033
  type: String,
16786
17034
  default: "bk_username"
17035
+ },
17036
+ /**
17037
+ * 用户组
17038
+ */
17039
+ userGroup: {
17040
+ type: Array,
17041
+ default: () => []
17042
+ },
17043
+ /**
17044
+ * 用户组名称
17045
+ */
17046
+ userGroupName: {
17047
+ type: String,
17048
+ default: "用户群组"
16787
17049
  }
16788
17050
  },
16789
17051
  emits: ["update:selectedUsers", "add-user", "remove-user"],
@@ -16809,6 +17071,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16809
17071
  const sortableInstance = ref(null);
16810
17072
  const visibleUsers = ref([]);
16811
17073
  const hiddenCount = ref(0);
17074
+ const options = computed(() => {
17075
+ return searchResults.value.filter((user) => !props2.selectedUsers.some((selectedUser) => selectedUser.id === user.id));
17076
+ });
16812
17077
  const initSortable = () => {
16813
17078
  if (!props2.draggable || !sortableContainerRef.value) return;
16814
17079
  if (sortableInstance.value) {
@@ -16846,7 +17111,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
16846
17111
  };
16847
17112
  const handleFocus = () => {
16848
17113
  isFocused.value = true;
16849
- showDropdown.value = false;
17114
+ if (props2.userGroup.length > 0) {
17115
+ showDropdown.value = true;
17116
+ } else {
17117
+ showDropdown.value = false;
17118
+ }
16850
17119
  activeTagIndex.value = -1;
16851
17120
  nextTick(() => {
16852
17121
  if (lastInputRef.value) {
@@ -17097,17 +17366,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17097
17366
  [vModelText, unref(searchQuery)]
17098
17367
  ]) : createCommentVNode("v-if", true),
17099
17368
  createCommentVNode(' "我"标签 '),
17100
- __props.currentUserId ? (openBlock(), createElementBlock(
17101
- "div",
17102
- {
17103
- key: 1,
17104
- class: normalizeClass(["me-tag", { disabled: __props.currentUserId && __props.selectedUsers.some((user) => user.id === __props.currentUserId) }]),
17105
- onClick: _cache[2] || (_cache[2] = withModifiers(($event) => addCurrentUser(), ["stop"]))
17106
- },
17107
- " 我 ",
17108
- 2
17109
- /* CLASS */
17110
- )) : createCommentVNode("v-if", true)
17369
+ createVNode(MeTag, {
17370
+ "current-user-id": __props.currentUserId,
17371
+ "is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user.id === __props.currentUserId),
17372
+ onClick: addCurrentUser
17373
+ }, null, 8, ["current-user-id", "is-disabled"])
17111
17374
  ],
17112
17375
  512
17113
17376
  /* NEED_PATCH */
@@ -17147,7 +17410,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17147
17410
  /* KEYED_FRAGMENT */
17148
17411
  )),
17149
17412
  createCommentVNode(" 显示折叠标签数量 "),
17150
- hiddenCount.value > 0 ? (openBlock(), createBlock(unref(__webpack_exports__default), {
17413
+ hiddenCount.value > 0 ? withDirectives((openBlock(), createBlock(unref(__webpack_exports__default), {
17151
17414
  key: 0,
17152
17415
  onClick: withModifiers(handleFocus, ["stop"])
17153
17416
  }, {
@@ -17160,30 +17423,29 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17160
17423
  ]),
17161
17424
  _: 1
17162
17425
  /* STABLE */
17163
- })) : createCommentVNode("v-if", true),
17426
+ })), [
17427
+ [unref(__webpack_exports__bkTooltips), {
17428
+ content: __props.selectedUsers.slice(visibleUsers.value.length).map((user) => user.display_name).join(","),
17429
+ placement: "top"
17430
+ }]
17431
+ ]) : createCommentVNode("v-if", true),
17164
17432
  createCommentVNode(" 搜索输入框 "),
17165
17433
  withDirectives(createElementVNode("input", {
17166
17434
  ref_key: "collapsedInputRef",
17167
17435
  ref: collapsedInputRef,
17168
17436
  class: "search-input collapsed",
17169
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
17437
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
17170
17438
  placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
17171
17439
  onFocus: handleFocus
17172
17440
  }, null, 40, _hoisted_3$1), [
17173
17441
  [vModelText, unref(searchQuery)]
17174
17442
  ]),
17175
17443
  createCommentVNode(' 未聚焦状态下的"我"标签 '),
17176
- __props.currentUserId ? (openBlock(), createElementBlock(
17177
- "div",
17178
- {
17179
- key: 1,
17180
- class: normalizeClass(["me-tag", { disabled: __props.currentUserId && __props.selectedUsers.some((user) => user[props2.exactSearchKey] === __props.currentUserId) }]),
17181
- onClick: _cache[4] || (_cache[4] = withModifiers(($event) => addCurrentUser(), ["stop"]))
17182
- },
17183
- " 我 ",
17184
- 2
17185
- /* CLASS */
17186
- )) : createCommentVNode("v-if", true)
17444
+ createVNode(MeTag, {
17445
+ "current-user-id": __props.currentUserId,
17446
+ "is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user[props2.exactSearchKey] === __props.currentUserId),
17447
+ onClick: addCurrentUser
17448
+ }, null, 8, ["current-user-id", "is-disabled"])
17187
17449
  ],
17188
17450
  512
17189
17451
  /* NEED_PATCH */
@@ -17193,75 +17455,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
17193
17455
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
17194
17456
  )),
17195
17457
  createCommentVNode(" 下拉选项列表 "),
17196
- createVNode(unref(__webpack_exports__default$1), {
17197
- "ext-cls": "bk-user-selector-popover",
17198
- arrow: false,
17458
+ createVNode(SelectionPopover, {
17459
+ "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
17199
17460
  "is-show": showDropdown.value,
17200
- width: containerRef.value ? containerRef.value.offsetWidth : "auto",
17201
- placement: "bottom-start",
17202
- theme: "light",
17203
- trigger: "manual"
17204
- }, {
17205
- content: withCtx(() => [
17206
- createVNode(unref(__webpack_exports__default$3), {
17207
- class: "dropdown-content",
17208
- loading: unref(searchLoading),
17209
- size: "mini",
17210
- mode: "spin"
17211
- }, {
17212
- default: withCtx(() => [
17213
- unref(searchResults).length === 0 ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
17214
- createElementVNode(
17215
- "span",
17216
- null,
17217
- toDisplayString(unref(searchQuery).length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
17218
- 1
17219
- /* TEXT */
17220
- )
17221
- ])) : (openBlock(true), createElementBlock(
17222
- Fragment,
17223
- { key: 1 },
17224
- renderList(unref(searchResults), (user) => {
17225
- return openBlock(), createElementBlock("div", {
17226
- class: "user-option",
17227
- key: user.id,
17228
- onMousedown: withModifiers(($event) => addUser(user), ["prevent"])
17229
- }, [
17230
- createElementVNode(
17231
- "span",
17232
- null,
17233
- toDisplayString(user.name),
17234
- 1
17235
- /* TEXT */
17236
- ),
17237
- user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
17238
- "span",
17239
- _hoisted_6$1,
17240
- "@" + toDisplayString(__props.tenants[user.tenantId]),
17241
- 1
17242
- /* TEXT */
17243
- )) : createCommentVNode("v-if", true)
17244
- ], 40, _hoisted_5$1);
17245
- }),
17246
- 128
17247
- /* KEYED_FRAGMENT */
17248
- ))
17249
- ]),
17250
- _: 1
17251
- /* STABLE */
17252
- }, 8, ["loading"])
17253
- ]),
17254
- _: 1
17255
- /* STABLE */
17256
- }, 8, ["is-show", "width"])
17461
+ loading: unref(searchLoading),
17462
+ options: options.value,
17463
+ "search-query": unref(searchQuery),
17464
+ "tenant-id": __props.tenantId,
17465
+ tenants: __props.tenants,
17466
+ "user-group": __props.userGroup,
17467
+ "user-group-name": __props.userGroupName,
17468
+ onSelectUser: addUser
17469
+ }, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
17257
17470
  ])), [
17258
17471
  [unref(__webpack_exports__clickoutside), handleClickOutside]
17259
17472
  ]);
17260
17473
  };
17261
17474
  }
17262
17475
  });
17263
- const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-50540b99"]]);
17264
- const _withScopeId = (n2) => (pushScopeId("data-v-308925e9"), n2 = n2(), popScopeId(), n2);
17476
+ const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a09f11c3"]]);
17477
+ const _withScopeId = (n2) => (pushScopeId("data-v-8b8dd0fd"), n2 = n2(), popScopeId(), n2);
17265
17478
  const _hoisted_1$1 = { class: "input-container" };
17266
17479
  const _hoisted_2 = {
17267
17480
  key: 0,
@@ -17275,15 +17488,6 @@ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElem
17275
17488
  /* HOISTED */
17276
17489
  ));
17277
17490
  const _hoisted_4 = ["placeholder"];
17278
- const _hoisted_5 = {
17279
- key: 0,
17280
- class: "no-data"
17281
- };
17282
- const _hoisted_6 = ["onMousedown"];
17283
- const _hoisted_7 = {
17284
- key: 0,
17285
- class: "tenant-name"
17286
- };
17287
17491
  const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17288
17492
  ...{
17289
17493
  name: "BkUserSelectorSingle"
@@ -17291,12 +17495,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17291
17495
  __name: "single-selector",
17292
17496
  props: {
17293
17497
  modelValue: {},
17294
- placeholder: {},
17498
+ tenants: {},
17295
17499
  apiBaseUrl: {},
17296
17500
  tenantId: {},
17297
- tenants: {},
17501
+ placeholder: {},
17298
17502
  currentUserId: {},
17299
- exactSearchKey: {}
17503
+ exactSearchKey: {},
17504
+ userGroup: {},
17505
+ userGroupName: {}
17300
17506
  },
17301
17507
  emits: ["update:modelValue", "change"],
17302
17508
  setup(__props, { emit: __emit }) {
@@ -17310,7 +17516,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17310
17516
  const searchQuery = ref("");
17311
17517
  const showDropdown = ref(false);
17312
17518
  const selectedUserInfo = computed(() => {
17313
- return options.value.find((user) => user.id === selectedUser.value);
17519
+ const userGroup = (props2.userGroup || []).map((group) => ({
17520
+ id: group.id,
17521
+ name: group.name,
17522
+ tenantId: ""
17523
+ }));
17524
+ const list = [...options.value, ...userGroup];
17525
+ const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
17526
+ emit("change", selectedUserInfo2 || null);
17527
+ return selectedUserInfo2;
17314
17528
  });
17315
17529
  onBeforeMount(async () => {
17316
17530
  if (typeof props2.modelValue === "string" && props2.modelValue) {
@@ -17334,7 +17548,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17334
17548
  const formattedResults = formatUsers(result);
17335
17549
  if (formattedResults.length > 0) {
17336
17550
  options.value = formattedResults;
17337
- selectUser(formattedResults[0]);
17551
+ addUser(formattedResults[0]);
17338
17552
  }
17339
17553
  } catch (error3) {
17340
17554
  console.error("获取当前用户信息失败:", error3);
@@ -17348,7 +17562,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17348
17562
  isLoading.value = true;
17349
17563
  try {
17350
17564
  const result = await searchUsers(props2.apiBaseUrl, props2.tenantId, keyword);
17351
- options.value = formatUsers(result);
17565
+ options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
17352
17566
  console.log("options.value", options.value);
17353
17567
  } catch (error3) {
17354
17568
  console.error("获取用户列表失败:", error3);
@@ -17357,7 +17571,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17357
17571
  isLoading.value = false;
17358
17572
  }
17359
17573
  };
17360
- const selectUser = (user) => {
17574
+ const addUser = (user) => {
17575
+ console.log("addUser", user);
17361
17576
  selectedUser.value = user.id;
17362
17577
  searchQuery.value = "";
17363
17578
  showDropdown.value = false;
@@ -17367,7 +17582,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17367
17582
  searchQuery.value = "";
17368
17583
  };
17369
17584
  const handleInputFocus = () => {
17370
- if (searchQuery.value.length >= 2) {
17585
+ if (searchQuery.value.length >= 2 || Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
17371
17586
  showDropdown.value = true;
17372
17587
  }
17373
17588
  };
@@ -17380,12 +17595,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17380
17595
  showDropdown.value = false;
17381
17596
  };
17382
17597
  watch(selectedUser, (newVal) => {
17598
+ console.log("selectedUser", newVal);
17383
17599
  emit("update:modelValue", newVal);
17384
- const selectedUserInfo2 = options.value.find((user) => user.id === newVal);
17385
- emit("change", selectedUserInfo2 || null);
17386
17600
  });
17387
17601
  return (_ctx, _cache) => {
17388
- var _a;
17389
17602
  return withDirectives((openBlock(), createElementBlock("div", {
17390
17603
  ref_key: "containerRef",
17391
17604
  ref: containerRef,
@@ -17427,87 +17640,32 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
17427
17640
  [vModelText, searchQuery.value]
17428
17641
  ]),
17429
17642
  createCommentVNode(' "我"标签 '),
17430
- _ctx.currentUserId ? (openBlock(), createElementBlock(
17431
- "div",
17432
- {
17433
- key: 1,
17434
- class: normalizeClass(["me-tag", { disabled: _ctx.currentUserId && ((_a = selectedUserInfo.value) == null ? void 0 : _a[_ctx.exactSearchKey]) === _ctx.currentUserId }]),
17435
- onClick: _cache[1] || (_cache[1] = ($event) => addCurrentUser())
17436
- },
17437
- " 我 ",
17438
- 2
17439
- /* CLASS */
17440
- )) : createCommentVNode("v-if", true)
17643
+ createVNode(MeTag, {
17644
+ "is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey || "bk_username"] === _ctx.currentUserId,
17645
+ "current-user-id": _ctx.currentUserId,
17646
+ onClick: addCurrentUser
17647
+ }, null, 8, ["is-disabled", "current-user-id"])
17441
17648
  ]),
17442
- createCommentVNode(" 下拉选项列表 "),
17443
- createVNode(unref(__webpack_exports__default$1), {
17444
- "ext-cls": "bk-user-selector-popover",
17445
- arrow: false,
17649
+ createCommentVNode(" 使用新的公共下拉选项组件 "),
17650
+ createVNode(SelectionPopover, {
17651
+ "container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
17446
17652
  "is-show": showDropdown.value,
17447
- width: containerRef.value ? containerRef.value.offsetWidth : "auto",
17448
- placement: "bottom-start",
17449
- theme: "light",
17450
- trigger: "manual"
17451
- }, {
17452
- content: withCtx(() => [
17453
- createVNode(unref(__webpack_exports__default$3), {
17454
- class: "dropdown-content",
17455
- loading: isLoading.value,
17456
- size: "mini",
17457
- mode: "spin"
17458
- }, {
17459
- default: withCtx(() => [
17460
- options.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_5, [
17461
- createElementVNode(
17462
- "span",
17463
- null,
17464
- toDisplayString(searchQuery.value.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
17465
- 1
17466
- /* TEXT */
17467
- )
17468
- ])) : (openBlock(true), createElementBlock(
17469
- Fragment,
17470
- { key: 1 },
17471
- renderList(options.value, (user) => {
17472
- return openBlock(), createElementBlock("div", {
17473
- class: "user-option",
17474
- key: user.id,
17475
- onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
17476
- }, [
17477
- createElementVNode(
17478
- "span",
17479
- null,
17480
- toDisplayString(user.name),
17481
- 1
17482
- /* TEXT */
17483
- ),
17484
- user.tenantId !== _ctx.tenantId && user.tenantId && _ctx.tenants[user.tenantId] ? (openBlock(), createElementBlock(
17485
- "span",
17486
- _hoisted_7,
17487
- "@" + toDisplayString(_ctx.tenants[user.tenantId]),
17488
- 1
17489
- /* TEXT */
17490
- )) : createCommentVNode("v-if", true)
17491
- ], 40, _hoisted_6);
17492
- }),
17493
- 128
17494
- /* KEYED_FRAGMENT */
17495
- ))
17496
- ]),
17497
- _: 1
17498
- /* STABLE */
17499
- }, 8, ["loading"])
17500
- ]),
17501
- _: 1
17502
- /* STABLE */
17503
- }, 8, ["is-show", "width"])
17653
+ loading: isLoading.value,
17654
+ options: options.value,
17655
+ "search-query": searchQuery.value,
17656
+ "tenant-id": _ctx.tenantId,
17657
+ tenants: _ctx.tenants,
17658
+ "user-group": _ctx.userGroup,
17659
+ "user-group-name": _ctx.userGroupName,
17660
+ onSelectUser: addUser
17661
+ }, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
17504
17662
  ])), [
17505
17663
  [unref(__webpack_exports__clickoutside), handleClickOutside]
17506
17664
  ]);
17507
17665
  };
17508
17666
  }
17509
17667
  });
17510
- const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-308925e9"]]);
17668
+ const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
17511
17669
  const _hoisted_1 = { class: "bk-user-selector" };
17512
17670
  const _sfc_main = /* @__PURE__ */ defineComponent({
17513
17671
  ...{
@@ -17515,14 +17673,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17515
17673
  },
17516
17674
  __name: "user-selector",
17517
17675
  props: {
17518
- apiBaseUrl: { default: "" },
17519
- tenantId: { default: "" },
17520
- placeholder: { default: "请输入人员名称搜索" },
17521
17676
  modelValue: { default: "" },
17522
17677
  draggable: { type: Boolean, default: false },
17523
17678
  multiple: { type: Boolean, default: false },
17679
+ apiBaseUrl: { default: "" },
17680
+ tenantId: { default: "" },
17681
+ placeholder: { default: "请输入人员名称搜索" },
17524
17682
  currentUserId: { default: "" },
17525
- exactSearchKey: { default: "" }
17683
+ exactSearchKey: { default: "bk_username" },
17684
+ userGroup: { default: () => [] },
17685
+ userGroupName: { default: "用户群组" }
17526
17686
  },
17527
17687
  emits: ["update:modelValue", "change"],
17528
17688
  setup(__props, { emit: __emit }) {
@@ -17582,8 +17742,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17582
17742
  placeholder: _ctx.placeholder,
17583
17743
  "tenant-id": _ctx.tenantId,
17584
17744
  tenants: unref(tenants),
17745
+ "user-group": _ctx.userGroup,
17746
+ "user-group-name": _ctx.userGroupName,
17585
17747
  onChange: handleUpdateUser
17586
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants"])) : (openBlock(), createElementBlock(
17748
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
17587
17749
  Fragment,
17588
17750
  { key: 1 },
17589
17751
  [
@@ -17599,8 +17761,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17599
17761
  "selected-users": selectedUsers.value,
17600
17762
  "tenant-id": _ctx.tenantId,
17601
17763
  tenants: unref(tenants),
17764
+ "user-group": _ctx.userGroup,
17765
+ "user-group-name": _ctx.userGroupName,
17602
17766
  "onUpdate:selectedUsers": handleUpdateSelectedUsers
17603
- }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants"])
17767
+ }, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
17604
17768
  ],
17605
17769
  2112
17606
17770
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
@@ -17609,7 +17773,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
17609
17773
  };
17610
17774
  }
17611
17775
  });
17612
- const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-fe084750"]]);
17776
+ const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
17613
17777
  const vue2 = {
17614
17778
  beforeDestroy() {
17615
17779
  var _a;
@@ -17625,6 +17789,7 @@ const vue2 = {
17625
17789
  userSelectorInstance = this;
17626
17790
  return h$1(BkUserSelector, {
17627
17791
  ...props2,
17792
+ modelValue: this.modelValue || props2.modelValue,
17628
17793
  "onUpdate:modelValue"() {
17629
17794
  emit("update:modelValue", ...arguments);
17630
17795
  emit("change", ...arguments);