@blueking/bk-user-selector 0.0.5 → 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 +41 -2
- package/typings/components/selection-popover.vue.d.ts +154 -0
- package/typings/components/user-selector.vue.d.ts +11 -2
- package/typings/types/index.d.ts +41 -40
- package/vue2/index.es.min.js +366 -203
- package/vue2/index.iife.min.js +366 -203
- package/vue2/index.umd.min.js +366 -203
- package/vue2/vue2.css +82 -128
- package/vue3/index.es.min.js +367 -204
- package/vue3/index.iife.min.js +366 -203
- package/vue3/index.umd.min.js +366 -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");
|
|
@@ -77,7 +77,8 @@ const formatUsers = (users) => {
|
|
|
77
77
|
return users.map((user) => ({
|
|
78
78
|
id: user.bk_username,
|
|
79
79
|
name: user.display_name,
|
|
80
|
-
tenantId: user.owner_tenant_id
|
|
80
|
+
tenantId: user.owner_tenant_id,
|
|
81
|
+
...user
|
|
81
82
|
}));
|
|
82
83
|
};
|
|
83
84
|
const useTenantData = (apiBaseUrl, tenantId) => {
|
|
@@ -16636,6 +16637,270 @@ const useUserSearch = (apiBaseUrl, tenantId) => {
|
|
|
16636
16637
|
clearSearch
|
|
16637
16638
|
};
|
|
16638
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"]]);
|
|
16639
16904
|
const _hoisted_1$3 = { class: "tag-content" };
|
|
16640
16905
|
const _hoisted_2$2 = { class: "user-name" };
|
|
16641
16906
|
const _hoisted_3$2 = {
|
|
@@ -16695,26 +16960,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
16695
16960
|
};
|
|
16696
16961
|
}
|
|
16697
16962
|
});
|
|
16698
|
-
const _export_sfc = (sfc, props2) => {
|
|
16699
|
-
const target = sfc.__vccOpts || sfc;
|
|
16700
|
-
for (const [key, val] of props2) {
|
|
16701
|
-
target[key] = val;
|
|
16702
|
-
}
|
|
16703
|
-
return target;
|
|
16704
|
-
};
|
|
16705
16963
|
const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-203c36cb"]]);
|
|
16706
16964
|
const _hoisted_1$2 = ["onClick"];
|
|
16707
16965
|
const _hoisted_2$1 = ["placeholder"];
|
|
16708
16966
|
const _hoisted_3$1 = ["placeholder"];
|
|
16709
|
-
const _hoisted_4$1 = {
|
|
16710
|
-
key: 0,
|
|
16711
|
-
class: "no-data"
|
|
16712
|
-
};
|
|
16713
|
-
const _hoisted_5$1 = ["onMousedown"];
|
|
16714
|
-
const _hoisted_6$1 = {
|
|
16715
|
-
key: 0,
|
|
16716
|
-
class: "tenant-name"
|
|
16717
|
-
};
|
|
16718
16967
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
16719
16968
|
...{
|
|
16720
16969
|
name: "BkUserSelectorMultiple"
|
|
@@ -16783,6 +17032,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
16783
17032
|
exactSearchKey: {
|
|
16784
17033
|
type: String,
|
|
16785
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: "用户群组"
|
|
16786
17049
|
}
|
|
16787
17050
|
},
|
|
16788
17051
|
emits: ["update:selectedUsers", "add-user", "remove-user"],
|
|
@@ -16808,6 +17071,9 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
16808
17071
|
const sortableInstance = ref(null);
|
|
16809
17072
|
const visibleUsers = ref([]);
|
|
16810
17073
|
const hiddenCount = ref(0);
|
|
17074
|
+
const options = computed(() => {
|
|
17075
|
+
return searchResults.value.filter((user) => !props2.selectedUsers.some((selectedUser) => selectedUser.id === user.id));
|
|
17076
|
+
});
|
|
16811
17077
|
const initSortable = () => {
|
|
16812
17078
|
if (!props2.draggable || !sortableContainerRef.value) return;
|
|
16813
17079
|
if (sortableInstance.value) {
|
|
@@ -16845,7 +17111,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
16845
17111
|
};
|
|
16846
17112
|
const handleFocus = () => {
|
|
16847
17113
|
isFocused.value = true;
|
|
16848
|
-
|
|
17114
|
+
if (props2.userGroup.length > 0) {
|
|
17115
|
+
showDropdown.value = true;
|
|
17116
|
+
} else {
|
|
17117
|
+
showDropdown.value = false;
|
|
17118
|
+
}
|
|
16849
17119
|
activeTagIndex.value = -1;
|
|
16850
17120
|
nextTick(() => {
|
|
16851
17121
|
if (lastInputRef.value) {
|
|
@@ -17096,16 +17366,11 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17096
17366
|
[vModelText, unref(searchQuery)]
|
|
17097
17367
|
]) : createCommentVNode("v-if", true),
|
|
17098
17368
|
createCommentVNode(' "我"标签 '),
|
|
17099
|
-
|
|
17100
|
-
"
|
|
17101
|
-
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
},
|
|
17105
|
-
" 我 ",
|
|
17106
|
-
2
|
|
17107
|
-
/* CLASS */
|
|
17108
|
-
)
|
|
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"])
|
|
17109
17374
|
],
|
|
17110
17375
|
512
|
|
17111
17376
|
/* NEED_PATCH */
|
|
@@ -17164,23 +17429,18 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17164
17429
|
ref_key: "collapsedInputRef",
|
|
17165
17430
|
ref: collapsedInputRef,
|
|
17166
17431
|
class: "search-input collapsed",
|
|
17167
|
-
"onUpdate:modelValue": _cache[
|
|
17432
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
17168
17433
|
placeholder: !__props.selectedUsers.length ? __props.placeholder : "",
|
|
17169
17434
|
onFocus: handleFocus
|
|
17170
17435
|
}, null, 40, _hoisted_3$1), [
|
|
17171
17436
|
[vModelText, unref(searchQuery)]
|
|
17172
17437
|
]),
|
|
17173
17438
|
createCommentVNode(' 未聚焦状态下的"我"标签 '),
|
|
17174
|
-
|
|
17175
|
-
"
|
|
17176
|
-
|
|
17177
|
-
|
|
17178
|
-
|
|
17179
|
-
},
|
|
17180
|
-
" 我 ",
|
|
17181
|
-
2
|
|
17182
|
-
/* CLASS */
|
|
17183
|
-
)
|
|
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"])
|
|
17184
17444
|
],
|
|
17185
17445
|
512
|
|
17186
17446
|
/* NEED_PATCH */
|
|
@@ -17190,75 +17450,26 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17190
17450
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
17191
17451
|
)),
|
|
17192
17452
|
createCommentVNode(" 下拉选项列表 "),
|
|
17193
|
-
createVNode(
|
|
17194
|
-
"
|
|
17195
|
-
arrow: false,
|
|
17453
|
+
createVNode(SelectionPopover, {
|
|
17454
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
17196
17455
|
"is-show": showDropdown.value,
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
|
|
17200
|
-
|
|
17201
|
-
|
|
17202
|
-
|
|
17203
|
-
|
|
17204
|
-
|
|
17205
|
-
|
|
17206
|
-
size: "mini",
|
|
17207
|
-
mode: "spin"
|
|
17208
|
-
}, {
|
|
17209
|
-
default: withCtx(() => [
|
|
17210
|
-
unref(searchResults).length === 0 ? (openBlock(), createElementBlock("div", _hoisted_4$1, [
|
|
17211
|
-
createElementVNode(
|
|
17212
|
-
"span",
|
|
17213
|
-
null,
|
|
17214
|
-
toDisplayString(unref(searchQuery).length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
|
|
17215
|
-
1
|
|
17216
|
-
/* TEXT */
|
|
17217
|
-
)
|
|
17218
|
-
])) : (openBlock(true), createElementBlock(
|
|
17219
|
-
Fragment,
|
|
17220
|
-
{ key: 1 },
|
|
17221
|
-
renderList(unref(searchResults), (user) => {
|
|
17222
|
-
return openBlock(), createElementBlock("div", {
|
|
17223
|
-
class: "user-option",
|
|
17224
|
-
key: user.id,
|
|
17225
|
-
onMousedown: withModifiers(($event) => addUser(user), ["prevent"])
|
|
17226
|
-
}, [
|
|
17227
|
-
createElementVNode(
|
|
17228
|
-
"span",
|
|
17229
|
-
null,
|
|
17230
|
-
toDisplayString(user.name),
|
|
17231
|
-
1
|
|
17232
|
-
/* TEXT */
|
|
17233
|
-
),
|
|
17234
|
-
user.tenantId !== __props.tenantId && user.tenantId && __props.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
17235
|
-
"span",
|
|
17236
|
-
_hoisted_6$1,
|
|
17237
|
-
"@" + toDisplayString(__props.tenants[user.tenantId]),
|
|
17238
|
-
1
|
|
17239
|
-
/* TEXT */
|
|
17240
|
-
)) : createCommentVNode("v-if", true)
|
|
17241
|
-
], 40, _hoisted_5$1);
|
|
17242
|
-
}),
|
|
17243
|
-
128
|
|
17244
|
-
/* KEYED_FRAGMENT */
|
|
17245
|
-
))
|
|
17246
|
-
]),
|
|
17247
|
-
_: 1
|
|
17248
|
-
/* STABLE */
|
|
17249
|
-
}, 8, ["loading"])
|
|
17250
|
-
]),
|
|
17251
|
-
_: 1
|
|
17252
|
-
/* STABLE */
|
|
17253
|
-
}, 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"])
|
|
17254
17465
|
])), [
|
|
17255
17466
|
[unref(__webpack_exports__clickoutside), handleClickOutside]
|
|
17256
17467
|
]);
|
|
17257
17468
|
};
|
|
17258
17469
|
}
|
|
17259
17470
|
});
|
|
17260
|
-
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-
|
|
17261
|
-
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);
|
|
17262
17473
|
const _hoisted_1$1 = { class: "input-container" };
|
|
17263
17474
|
const _hoisted_2 = {
|
|
17264
17475
|
key: 0,
|
|
@@ -17272,15 +17483,6 @@ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElem
|
|
|
17272
17483
|
/* HOISTED */
|
|
17273
17484
|
));
|
|
17274
17485
|
const _hoisted_4 = ["placeholder"];
|
|
17275
|
-
const _hoisted_5 = {
|
|
17276
|
-
key: 0,
|
|
17277
|
-
class: "no-data"
|
|
17278
|
-
};
|
|
17279
|
-
const _hoisted_6 = ["onMousedown"];
|
|
17280
|
-
const _hoisted_7 = {
|
|
17281
|
-
key: 0,
|
|
17282
|
-
class: "tenant-name"
|
|
17283
|
-
};
|
|
17284
17486
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
17285
17487
|
...{
|
|
17286
17488
|
name: "BkUserSelectorSingle"
|
|
@@ -17288,12 +17490,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17288
17490
|
__name: "single-selector",
|
|
17289
17491
|
props: {
|
|
17290
17492
|
modelValue: {},
|
|
17291
|
-
|
|
17493
|
+
tenants: {},
|
|
17292
17494
|
apiBaseUrl: {},
|
|
17293
17495
|
tenantId: {},
|
|
17294
|
-
|
|
17496
|
+
placeholder: {},
|
|
17295
17497
|
currentUserId: {},
|
|
17296
|
-
exactSearchKey: {}
|
|
17498
|
+
exactSearchKey: {},
|
|
17499
|
+
userGroup: {},
|
|
17500
|
+
userGroupName: {}
|
|
17297
17501
|
},
|
|
17298
17502
|
emits: ["update:modelValue", "change"],
|
|
17299
17503
|
setup(__props, { emit: __emit }) {
|
|
@@ -17307,7 +17511,15 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17307
17511
|
const searchQuery = ref("");
|
|
17308
17512
|
const showDropdown = ref(false);
|
|
17309
17513
|
const selectedUserInfo = computed(() => {
|
|
17310
|
-
|
|
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;
|
|
17311
17523
|
});
|
|
17312
17524
|
onBeforeMount(async () => {
|
|
17313
17525
|
if (typeof props2.modelValue === "string" && props2.modelValue) {
|
|
@@ -17331,7 +17543,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17331
17543
|
const formattedResults = formatUsers(result);
|
|
17332
17544
|
if (formattedResults.length > 0) {
|
|
17333
17545
|
options.value = formattedResults;
|
|
17334
|
-
|
|
17546
|
+
addUser(formattedResults[0]);
|
|
17335
17547
|
}
|
|
17336
17548
|
} catch (error3) {
|
|
17337
17549
|
console.error("获取当前用户信息失败:", error3);
|
|
@@ -17345,7 +17557,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17345
17557
|
isLoading.value = true;
|
|
17346
17558
|
try {
|
|
17347
17559
|
const result = await searchUsers(props2.apiBaseUrl, props2.tenantId, keyword);
|
|
17348
|
-
options.value = formatUsers(result);
|
|
17560
|
+
options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
|
|
17349
17561
|
console.log("options.value", options.value);
|
|
17350
17562
|
} catch (error3) {
|
|
17351
17563
|
console.error("获取用户列表失败:", error3);
|
|
@@ -17354,7 +17566,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17354
17566
|
isLoading.value = false;
|
|
17355
17567
|
}
|
|
17356
17568
|
};
|
|
17357
|
-
const
|
|
17569
|
+
const addUser = (user) => {
|
|
17570
|
+
console.log("addUser", user);
|
|
17358
17571
|
selectedUser.value = user.id;
|
|
17359
17572
|
searchQuery.value = "";
|
|
17360
17573
|
showDropdown.value = false;
|
|
@@ -17364,7 +17577,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17364
17577
|
searchQuery.value = "";
|
|
17365
17578
|
};
|
|
17366
17579
|
const handleInputFocus = () => {
|
|
17367
|
-
if (searchQuery.value.length >= 2) {
|
|
17580
|
+
if (searchQuery.value.length >= 2 || Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
|
|
17368
17581
|
showDropdown.value = true;
|
|
17369
17582
|
}
|
|
17370
17583
|
};
|
|
@@ -17377,9 +17590,8 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17377
17590
|
showDropdown.value = false;
|
|
17378
17591
|
};
|
|
17379
17592
|
watch(selectedUser, (newVal) => {
|
|
17593
|
+
console.log("selectedUser", newVal);
|
|
17380
17594
|
emit("update:modelValue", newVal);
|
|
17381
|
-
const selectedUserInfo2 = options.value.find((user) => user.id === newVal);
|
|
17382
|
-
emit("change", selectedUserInfo2 || null);
|
|
17383
17595
|
});
|
|
17384
17596
|
return (_ctx, _cache) => {
|
|
17385
17597
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
@@ -17402,7 +17614,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17402
17614
|
1
|
|
17403
17615
|
/* TEXT */
|
|
17404
17616
|
),
|
|
17405
|
-
selectedUserInfo.value.tenantId !==
|
|
17617
|
+
selectedUserInfo.value.tenantId !== _ctx.tenantId && selectedUserInfo.value.tenantId && _ctx.tenants[selectedUserInfo.value.tenantId] ? (openBlock(), createElementBlock(
|
|
17406
17618
|
"span",
|
|
17407
17619
|
_hoisted_2,
|
|
17408
17620
|
"@" + toDisplayString(_ctx.tenants[selectedUserInfo.value.tenantId]),
|
|
@@ -17416,94 +17628,39 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17416
17628
|
ref: inputRef,
|
|
17417
17629
|
class: "search-input",
|
|
17418
17630
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchQuery.value = $event),
|
|
17419
|
-
placeholder: selectedUserInfo.value ? "" :
|
|
17631
|
+
placeholder: selectedUserInfo.value ? "" : _ctx.placeholder,
|
|
17420
17632
|
onFocus: handleInputFocus,
|
|
17421
17633
|
onInput: handleInput
|
|
17422
17634
|
}, null, 40, _hoisted_4), [
|
|
17423
17635
|
[vModelText, searchQuery.value]
|
|
17424
17636
|
]),
|
|
17425
17637
|
createCommentVNode(' "我"标签 '),
|
|
17426
|
-
|
|
17427
|
-
"
|
|
17428
|
-
|
|
17429
|
-
|
|
17430
|
-
|
|
17431
|
-
onClick: _cache[1] || (_cache[1] = ($event) => addCurrentUser())
|
|
17432
|
-
},
|
|
17433
|
-
" 我 ",
|
|
17434
|
-
2
|
|
17435
|
-
/* CLASS */
|
|
17436
|
-
)) : 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"])
|
|
17437
17643
|
]),
|
|
17438
|
-
createCommentVNode("
|
|
17439
|
-
createVNode(
|
|
17440
|
-
"
|
|
17441
|
-
arrow: false,
|
|
17644
|
+
createCommentVNode(" 使用新的公共下拉选项组件 "),
|
|
17645
|
+
createVNode(SelectionPopover, {
|
|
17646
|
+
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
17442
17647
|
"is-show": showDropdown.value,
|
|
17443
|
-
|
|
17444
|
-
|
|
17445
|
-
|
|
17446
|
-
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
|
|
17451
|
-
|
|
17452
|
-
size: "mini",
|
|
17453
|
-
mode: "spin"
|
|
17454
|
-
}, {
|
|
17455
|
-
default: withCtx(() => [
|
|
17456
|
-
options.value.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_5, [
|
|
17457
|
-
createElementVNode(
|
|
17458
|
-
"span",
|
|
17459
|
-
null,
|
|
17460
|
-
toDisplayString(searchQuery.value.length > 1 ? "未找到匹配用户" : "请输入关键词搜索"),
|
|
17461
|
-
1
|
|
17462
|
-
/* TEXT */
|
|
17463
|
-
)
|
|
17464
|
-
])) : (openBlock(true), createElementBlock(
|
|
17465
|
-
Fragment,
|
|
17466
|
-
{ key: 1 },
|
|
17467
|
-
renderList(options.value, (user) => {
|
|
17468
|
-
return openBlock(), createElementBlock("div", {
|
|
17469
|
-
class: "user-option",
|
|
17470
|
-
key: user.id,
|
|
17471
|
-
onMousedown: withModifiers(($event) => selectUser(user), ["prevent"])
|
|
17472
|
-
}, [
|
|
17473
|
-
createElementVNode(
|
|
17474
|
-
"span",
|
|
17475
|
-
null,
|
|
17476
|
-
toDisplayString(user.name),
|
|
17477
|
-
1
|
|
17478
|
-
/* TEXT */
|
|
17479
|
-
),
|
|
17480
|
-
user.tenantId !== props2.tenantId && user.tenantId && props2.tenants[user.tenantId] ? (openBlock(), createElementBlock(
|
|
17481
|
-
"span",
|
|
17482
|
-
_hoisted_7,
|
|
17483
|
-
"@" + toDisplayString(props2.tenants[user.tenantId]),
|
|
17484
|
-
1
|
|
17485
|
-
/* TEXT */
|
|
17486
|
-
)) : createCommentVNode("v-if", true)
|
|
17487
|
-
], 40, _hoisted_6);
|
|
17488
|
-
}),
|
|
17489
|
-
128
|
|
17490
|
-
/* KEYED_FRAGMENT */
|
|
17491
|
-
))
|
|
17492
|
-
]),
|
|
17493
|
-
_: 1
|
|
17494
|
-
/* STABLE */
|
|
17495
|
-
}, 8, ["loading"])
|
|
17496
|
-
]),
|
|
17497
|
-
_: 1
|
|
17498
|
-
/* STABLE */
|
|
17499
|
-
}, 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"])
|
|
17500
17657
|
])), [
|
|
17501
17658
|
[unref(__webpack_exports__clickoutside), handleClickOutside]
|
|
17502
17659
|
]);
|
|
17503
17660
|
};
|
|
17504
17661
|
}
|
|
17505
17662
|
});
|
|
17506
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
17663
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b8dd0fd"]]);
|
|
17507
17664
|
const _hoisted_1 = { class: "bk-user-selector" };
|
|
17508
17665
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
17509
17666
|
...{
|
|
@@ -17511,14 +17668,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17511
17668
|
},
|
|
17512
17669
|
__name: "user-selector",
|
|
17513
17670
|
props: {
|
|
17514
|
-
apiBaseUrl: { default: "" },
|
|
17515
|
-
tenantId: { default: "" },
|
|
17516
|
-
placeholder: { default: "请输入人员名称搜索" },
|
|
17517
17671
|
modelValue: { default: "" },
|
|
17518
17672
|
draggable: { type: Boolean, default: false },
|
|
17519
17673
|
multiple: { type: Boolean, default: false },
|
|
17674
|
+
apiBaseUrl: { default: "" },
|
|
17675
|
+
tenantId: { default: "" },
|
|
17676
|
+
placeholder: { default: "请输入人员名称搜索" },
|
|
17520
17677
|
currentUserId: { default: "" },
|
|
17521
|
-
exactSearchKey: { default: "" }
|
|
17678
|
+
exactSearchKey: { default: "bk_username" },
|
|
17679
|
+
userGroup: { default: () => [] },
|
|
17680
|
+
userGroupName: { default: "用户群组" }
|
|
17522
17681
|
},
|
|
17523
17682
|
emits: ["update:modelValue", "change"],
|
|
17524
17683
|
setup(__props, { emit: __emit }) {
|
|
@@ -17578,8 +17737,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17578
17737
|
placeholder: _ctx.placeholder,
|
|
17579
17738
|
"tenant-id": _ctx.tenantId,
|
|
17580
17739
|
tenants: unref(tenants),
|
|
17740
|
+
"user-group": _ctx.userGroup,
|
|
17741
|
+
"user-group-name": _ctx.userGroupName,
|
|
17581
17742
|
onChange: handleUpdateUser
|
|
17582
|
-
}, 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(
|
|
17583
17744
|
Fragment,
|
|
17584
17745
|
{ key: 1 },
|
|
17585
17746
|
[
|
|
@@ -17595,8 +17756,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17595
17756
|
"selected-users": selectedUsers.value,
|
|
17596
17757
|
"tenant-id": _ctx.tenantId,
|
|
17597
17758
|
tenants: unref(tenants),
|
|
17759
|
+
"user-group": _ctx.userGroup,
|
|
17760
|
+
"user-group-name": _ctx.userGroupName,
|
|
17598
17761
|
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
17599
|
-
}, 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"])
|
|
17600
17763
|
],
|
|
17601
17764
|
2112
|
|
17602
17765
|
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
@@ -17605,7 +17768,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17605
17768
|
};
|
|
17606
17769
|
}
|
|
17607
17770
|
});
|
|
17608
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
17771
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-bc7b4ccd"]]);
|
|
17609
17772
|
const vue2 = {
|
|
17610
17773
|
beforeDestroy() {
|
|
17611
17774
|
var _a;
|