@blueking/bk-user-selector 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/package.json +1 -1
- package/typings/components/me-tag.vue.d.ts +39 -0
- package/typings/components/multiple-selector.vue.d.ts +40 -1
- package/typings/components/selection-popover.vue.d.ts +154 -0
- package/typings/components/user-selector.vue.d.ts +10 -1
- package/typings/types/index.d.ts +36 -39
- package/vue2/index.es.min.js +362 -203
- package/vue2/index.iife.min.js +362 -203
- package/vue2/index.umd.min.js +362 -203
- package/vue2/vue2.css +82 -128
- package/vue3/index.es.min.js +363 -204
- package/vue3/index.iife.min.js +362 -203
- package/vue3/index.umd.min.js +362 -203
- package/vue3/vue3.css +82 -128
package/vue2/index.es.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_vue__ from "@blueking/bkui-library";
|
|
2
|
-
import { ref, onBeforeMount, defineComponent,
|
|
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");
|
|
@@ -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
|
-
|
|
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
|
-
|
|
17101
|
-
"
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
|
|
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 */
|
|
@@ -17166,24 +17429,18 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17166
17429
|
ref_key: "collapsedInputRef",
|
|
17167
17430
|
ref: collapsedInputRef,
|
|
17168
17431
|
class: "search-input collapsed",
|
|
17169
|
-
"onUpdate:modelValue": _cache[
|
|
17432
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
17170
17433
|
placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
|
|
17171
17434
|
onFocus: handleFocus
|
|
17172
17435
|
}, null, 40, _hoisted_3$1), [
|
|
17173
17436
|
[vModelText, unref(searchQuery)]
|
|
17174
17437
|
]),
|
|
17175
17438
|
createCommentVNode(' 未聚焦状态下的"我"标签 '),
|
|
17176
|
-
|
|
17177
|
-
"
|
|
17178
|
-
|
|
17179
|
-
|
|
17180
|
-
|
|
17181
|
-
onClick: _cache[4] || (_cache[4] = withModifiers(($event) => addCurrentUser(), ["stop"]))
|
|
17182
|
-
},
|
|
17183
|
-
" 我 ",
|
|
17184
|
-
2
|
|
17185
|
-
/* CLASS */
|
|
17186
|
-
)) : createCommentVNode("v-if", true)
|
|
17439
|
+
createVNode(MeTag, {
|
|
17440
|
+
"current-user-id": __props.currentUserId,
|
|
17441
|
+
"is-disabled": !!__props.currentUserId && __props.selectedUsers.some((user) => user[props2.exactSearchKey] === __props.currentUserId),
|
|
17442
|
+
onClick: addCurrentUser
|
|
17443
|
+
}, null, 8, ["current-user-id", "is-disabled"])
|
|
17187
17444
|
],
|
|
17188
17445
|
512
|
|
17189
17446
|
/* NEED_PATCH */
|
|
@@ -17193,75 +17450,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17193
17450
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
17194
17451
|
)),
|
|
17195
17452
|
createCommentVNode(" 下拉选项列表 "),
|
|
17196
|
-
createVNode(
|
|
17197
|
-
"
|
|
17198
|
-
arrow: false,
|
|
17453
|
+
createVNode(SelectionPopover, {
|
|
17454
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
17199
17455
|
"is-show": showDropdown.value,
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
|
|
17207
|
-
|
|
17208
|
-
|
|
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"])
|
|
17456
|
+
loading: unref(searchLoading),
|
|
17457
|
+
options: options.value,
|
|
17458
|
+
"search-query": unref(searchQuery),
|
|
17459
|
+
"tenant-id": __props.tenantId,
|
|
17460
|
+
tenants: __props.tenants,
|
|
17461
|
+
"user-group": __props.userGroup,
|
|
17462
|
+
"user-group-name": __props.userGroupName,
|
|
17463
|
+
onSelectUser: addUser
|
|
17464
|
+
}, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
17257
17465
|
])), [
|
|
17258
17466
|
[unref(__webpack_exports__clickoutside), handleClickOutside]
|
|
17259
17467
|
]);
|
|
17260
17468
|
};
|
|
17261
17469
|
}
|
|
17262
17470
|
});
|
|
17263
|
-
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
17264
|
-
const _withScopeId = (n2) => (pushScopeId("data-v-
|
|
17471
|
+
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-a8dc735f"]]);
|
|
17472
|
+
const _withScopeId = (n2) => (pushScopeId("data-v-8b8dd0fd"), n2 = n2(), popScopeId(), n2);
|
|
17265
17473
|
const _hoisted_1$1 = { class: "input-container" };
|
|
17266
17474
|
const _hoisted_2 = {
|
|
17267
17475
|
key: 0,
|
|
@@ -17275,15 +17483,6 @@ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElem
|
|
|
17275
17483
|
/* HOISTED */
|
|
17276
17484
|
));
|
|
17277
17485
|
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
17486
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
17288
17487
|
...{
|
|
17289
17488
|
name: "BkUserSelectorSingle"
|
|
@@ -17291,12 +17490,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17291
17490
|
__name: "single-selector",
|
|
17292
17491
|
props: {
|
|
17293
17492
|
modelValue: {},
|
|
17294
|
-
|
|
17493
|
+
tenants: {},
|
|
17295
17494
|
apiBaseUrl: {},
|
|
17296
17495
|
tenantId: {},
|
|
17297
|
-
|
|
17496
|
+
placeholder: {},
|
|
17298
17497
|
currentUserId: {},
|
|
17299
|
-
exactSearchKey: {}
|
|
17498
|
+
exactSearchKey: {},
|
|
17499
|
+
userGroup: {},
|
|
17500
|
+
userGroupName: {}
|
|
17300
17501
|
},
|
|
17301
17502
|
emits: ["update:modelValue", "change"],
|
|
17302
17503
|
setup(__props, { emit: __emit }) {
|
|
@@ -17310,7 +17511,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17310
17511
|
const searchQuery = ref("");
|
|
17311
17512
|
const showDropdown = ref(false);
|
|
17312
17513
|
const selectedUserInfo = computed(() => {
|
|
17313
|
-
|
|
17514
|
+
const userGroup = (props2.userGroup || []).map((group) => ({
|
|
17515
|
+
id: group.id,
|
|
17516
|
+
name: group.name,
|
|
17517
|
+
tenantId: ""
|
|
17518
|
+
}));
|
|
17519
|
+
const list = [...options.value, ...userGroup];
|
|
17520
|
+
const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
|
|
17521
|
+
emit("change", selectedUserInfo2 || null);
|
|
17522
|
+
return selectedUserInfo2;
|
|
17314
17523
|
});
|
|
17315
17524
|
onBeforeMount(async () => {
|
|
17316
17525
|
if (typeof props2.modelValue === "string" && props2.modelValue) {
|
|
@@ -17334,7 +17543,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17334
17543
|
const formattedResults = formatUsers(result);
|
|
17335
17544
|
if (formattedResults.length > 0) {
|
|
17336
17545
|
options.value = formattedResults;
|
|
17337
|
-
|
|
17546
|
+
addUser(formattedResults[0]);
|
|
17338
17547
|
}
|
|
17339
17548
|
} catch (error3) {
|
|
17340
17549
|
console.error("获取当前用户信息失败:", error3);
|
|
@@ -17348,7 +17557,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17348
17557
|
isLoading.value = true;
|
|
17349
17558
|
try {
|
|
17350
17559
|
const result = await searchUsers(props2.apiBaseUrl, props2.tenantId, keyword);
|
|
17351
|
-
options.value = formatUsers(result);
|
|
17560
|
+
options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
|
|
17352
17561
|
console.log("options.value", options.value);
|
|
17353
17562
|
} catch (error3) {
|
|
17354
17563
|
console.error("获取用户列表失败:", error3);
|
|
@@ -17357,7 +17566,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17357
17566
|
isLoading.value = false;
|
|
17358
17567
|
}
|
|
17359
17568
|
};
|
|
17360
|
-
const
|
|
17569
|
+
const addUser = (user) => {
|
|
17570
|
+
console.log("addUser", user);
|
|
17361
17571
|
selectedUser.value = user.id;
|
|
17362
17572
|
searchQuery.value = "";
|
|
17363
17573
|
showDropdown.value = false;
|
|
@@ -17367,7 +17577,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17367
17577
|
searchQuery.value = "";
|
|
17368
17578
|
};
|
|
17369
17579
|
const handleInputFocus = () => {
|
|
17370
|
-
if (searchQuery.value.length >= 2) {
|
|
17580
|
+
if (searchQuery.value.length >= 2 || Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
|
|
17371
17581
|
showDropdown.value = true;
|
|
17372
17582
|
}
|
|
17373
17583
|
};
|
|
@@ -17380,12 +17590,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17380
17590
|
showDropdown.value = false;
|
|
17381
17591
|
};
|
|
17382
17592
|
watch(selectedUser, (newVal) => {
|
|
17593
|
+
console.log("selectedUser", newVal);
|
|
17383
17594
|
emit("update:modelValue", newVal);
|
|
17384
|
-
const selectedUserInfo2 = options.value.find((user) => user.id === newVal);
|
|
17385
|
-
emit("change", selectedUserInfo2 || null);
|
|
17386
17595
|
});
|
|
17387
17596
|
return (_ctx, _cache) => {
|
|
17388
|
-
var _a;
|
|
17389
17597
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
17390
17598
|
ref_key: "containerRef",
|
|
17391
17599
|
ref: containerRef,
|
|
@@ -17427,87 +17635,32 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17427
17635
|
[vModelText, searchQuery.value]
|
|
17428
17636
|
]),
|
|
17429
17637
|
createCommentVNode(' "我"标签 '),
|
|
17430
|
-
|
|
17431
|
-
"
|
|
17432
|
-
|
|
17433
|
-
|
|
17434
|
-
|
|
17435
|
-
onClick: _cache[1] || (_cache[1] = ($event) => addCurrentUser())
|
|
17436
|
-
},
|
|
17437
|
-
" 我 ",
|
|
17438
|
-
2
|
|
17439
|
-
/* CLASS */
|
|
17440
|
-
)) : createCommentVNode("v-if", true)
|
|
17638
|
+
createVNode(MeTag, {
|
|
17639
|
+
"is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey || "bk_username"] === _ctx.currentUserId,
|
|
17640
|
+
"current-user-id": _ctx.currentUserId,
|
|
17641
|
+
onClick: addCurrentUser
|
|
17642
|
+
}, null, 8, ["is-disabled", "current-user-id"])
|
|
17441
17643
|
]),
|
|
17442
|
-
createCommentVNode("
|
|
17443
|
-
createVNode(
|
|
17444
|
-
"
|
|
17445
|
-
arrow: false,
|
|
17644
|
+
createCommentVNode(" 使用新的公共下拉选项组件 "),
|
|
17645
|
+
createVNode(SelectionPopover, {
|
|
17646
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
17446
17647
|
"is-show": showDropdown.value,
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
|
|
17453
|
-
|
|
17454
|
-
|
|
17455
|
-
|
|
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"])
|
|
17648
|
+
loading: isLoading.value,
|
|
17649
|
+
options: options.value,
|
|
17650
|
+
"search-query": searchQuery.value,
|
|
17651
|
+
"tenant-id": _ctx.tenantId,
|
|
17652
|
+
tenants: _ctx.tenants,
|
|
17653
|
+
"user-group": _ctx.userGroup,
|
|
17654
|
+
"user-group-name": _ctx.userGroupName,
|
|
17655
|
+
onSelectUser: addUser
|
|
17656
|
+
}, null, 8, ["container-width", "is-show", "loading", "options", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
17504
17657
|
])), [
|
|
17505
17658
|
[unref(__webpack_exports__clickoutside), handleClickOutside]
|
|
17506
17659
|
]);
|
|
17507
17660
|
};
|
|
17508
17661
|
}
|
|
17509
17662
|
});
|
|
17510
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
17663
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
|
|
17511
17664
|
const _hoisted_1 = { class: "bk-user-selector" };
|
|
17512
17665
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
17513
17666
|
...{
|
|
@@ -17515,14 +17668,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17515
17668
|
},
|
|
17516
17669
|
__name: "user-selector",
|
|
17517
17670
|
props: {
|
|
17518
|
-
apiBaseUrl: { default: "" },
|
|
17519
|
-
tenantId: { default: "" },
|
|
17520
|
-
placeholder: { default: "请输入人员名称搜索" },
|
|
17521
17671
|
modelValue: { default: "" },
|
|
17522
17672
|
draggable: { type: Boolean, default: false },
|
|
17523
17673
|
multiple: { type: Boolean, default: false },
|
|
17674
|
+
apiBaseUrl: { default: "" },
|
|
17675
|
+
tenantId: { default: "" },
|
|
17676
|
+
placeholder: { default: "请输入人员名称搜索" },
|
|
17524
17677
|
currentUserId: { default: "" },
|
|
17525
|
-
exactSearchKey: { default: "" }
|
|
17678
|
+
exactSearchKey: { default: "bk_username" },
|
|
17679
|
+
userGroup: { default: () => [] },
|
|
17680
|
+
userGroupName: { default: "用户群组" }
|
|
17526
17681
|
},
|
|
17527
17682
|
emits: ["update:modelValue", "change"],
|
|
17528
17683
|
setup(__props, { emit: __emit }) {
|
|
@@ -17582,8 +17737,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17582
17737
|
placeholder: _ctx.placeholder,
|
|
17583
17738
|
"tenant-id": _ctx.tenantId,
|
|
17584
17739
|
tenants: unref(tenants),
|
|
17740
|
+
"user-group": _ctx.userGroup,
|
|
17741
|
+
"user-group-name": _ctx.userGroupName,
|
|
17585
17742
|
onChange: handleUpdateUser
|
|
17586
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants"])) : (openBlock(), createElementBlock(
|
|
17743
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
|
|
17587
17744
|
Fragment,
|
|
17588
17745
|
{ key: 1 },
|
|
17589
17746
|
[
|
|
@@ -17599,8 +17756,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17599
17756
|
"selected-users": selectedUsers.value,
|
|
17600
17757
|
"tenant-id": _ctx.tenantId,
|
|
17601
17758
|
tenants: unref(tenants),
|
|
17759
|
+
"user-group": _ctx.userGroup,
|
|
17760
|
+
"user-group-name": _ctx.userGroupName,
|
|
17602
17761
|
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
17603
|
-
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants"])
|
|
17762
|
+
}, 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
17763
|
],
|
|
17605
17764
|
2112
|
|
17606
17765
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -17609,7 +17768,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17609
17768
|
};
|
|
17610
17769
|
}
|
|
17611
17770
|
});
|
|
17612
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
17771
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
|
|
17613
17772
|
const vue2 = {
|
|
17614
17773
|
beforeDestroy() {
|
|
17615
17774
|
var _a;
|