@blueking/bk-user-selector 0.0.9 → 0.0.11
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/package.json +1 -1
- package/typings/api/user.d.ts +1 -1
- package/typings/vue2.d.ts +4 -0
- package/vue2/index.es.min.js +61 -53
- package/vue2/index.iife.min.js +62 -54
- package/vue2/index.umd.min.js +62 -54
- package/vue2/vue2.css +22 -21
- package/vue3/index.es.min.js +57 -53
- package/vue3/index.iife.min.js +58 -54
- package/vue3/index.umd.min.js +58 -54
- package/vue3/vue3.css +22 -21
package/package.json
CHANGED
package/typings/api/user.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const searchUsers: (apiBaseUrl?: string, tenantId?: string, keywo
|
|
|
26
26
|
* @param exactSearchKey - 精确查找key
|
|
27
27
|
* @returns 查找到的用户列表Promise
|
|
28
28
|
*/
|
|
29
|
-
export declare const lookupUsers: (apiBaseUrl?: string, tenantId?: string, exactSearchKey?: string,
|
|
29
|
+
export declare const lookupUsers: (apiBaseUrl?: string, tenantId?: string, exactSearchKey?: string, usersList?: string[]) => Promise<User[]>;
|
|
30
30
|
/**
|
|
31
31
|
* 将API返回的用户数据格式化为组件所需格式
|
|
32
32
|
* @param users - API返回的用户列表
|
package/typings/vue2.d.ts
CHANGED
package/vue2/index.es.min.js
CHANGED
|
@@ -48,7 +48,8 @@ const searchUsers = async (apiBaseUrl = "", tenantId = "", keyword = "") => {
|
|
|
48
48
|
return [];
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const lookupUsers = async (apiBaseUrl = "", tenantId = "", exactSearchKey = "bk_username",
|
|
51
|
+
const lookupUsers = async (apiBaseUrl = "", tenantId = "", exactSearchKey = "bk_username", usersList = []) => {
|
|
52
|
+
const users = usersList.filter((user) => user).map((user) => user.trim());
|
|
52
53
|
if (users.length === 0 || !apiBaseUrl || !tenantId) {
|
|
53
54
|
console.warn("批量查找用户需要提供有效的apiBaseUrl、租户ID和至少一个用户名");
|
|
54
55
|
return [];
|
|
@@ -16776,7 +16777,6 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16776
16777
|
const emit = __emit;
|
|
16777
16778
|
const groupedUsers = computed(() => {
|
|
16778
16779
|
const groups = {};
|
|
16779
|
-
console.log("props.options", props2.options);
|
|
16780
16780
|
if (Array.isArray(props2.userGroup) && props2.userGroup.length > 0) {
|
|
16781
16781
|
groups[props2.userGroupName] = props2.userGroup.map((group) => ({
|
|
16782
16782
|
id: group.id,
|
|
@@ -16901,7 +16901,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16901
16901
|
};
|
|
16902
16902
|
}
|
|
16903
16903
|
});
|
|
16904
|
-
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-
|
|
16904
|
+
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-01b75e6e"]]);
|
|
16905
16905
|
const _hoisted_1$3 = { class: "tag-content" };
|
|
16906
16906
|
const _hoisted_2$2 = { class: "user-name" };
|
|
16907
16907
|
const _hoisted_3$2 = {
|
|
@@ -16961,7 +16961,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
16961
16961
|
};
|
|
16962
16962
|
}
|
|
16963
16963
|
});
|
|
16964
|
-
const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-
|
|
16964
|
+
const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-87c12feb"]]);
|
|
16965
16965
|
const _hoisted_1$2 = ["onClick"];
|
|
16966
16966
|
const _hoisted_2$1 = ["placeholder"];
|
|
16967
16967
|
const _hoisted_3$1 = ["placeholder"];
|
|
@@ -17409,7 +17409,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
17409
17409
|
}
|
|
17410
17410
|
});
|
|
17411
17411
|
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-1a376d26"]]);
|
|
17412
|
-
const _withScopeId = (n2) => (pushScopeId("data-v-
|
|
17412
|
+
const _withScopeId = (n2) => (pushScopeId("data-v-22d9b76f"), n2 = n2(), popScopeId(), n2);
|
|
17413
17413
|
const _hoisted_1$1 = { class: "input-container" };
|
|
17414
17414
|
const _hoisted_2 = {
|
|
17415
17415
|
key: 0,
|
|
@@ -17498,7 +17498,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17498
17498
|
try {
|
|
17499
17499
|
const result = await searchUsers(props2.apiBaseUrl, props2.tenantId, keyword);
|
|
17500
17500
|
options.value = formatUsers(result).filter((user) => !selectedUser.value || user.id !== selectedUser.value);
|
|
17501
|
-
console.log("options.value", options.value);
|
|
17502
17501
|
} catch (error3) {
|
|
17503
17502
|
console.error("获取用户列表失败:", error3);
|
|
17504
17503
|
options.value = [];
|
|
@@ -17507,7 +17506,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17507
17506
|
}
|
|
17508
17507
|
};
|
|
17509
17508
|
const addUser = (user) => {
|
|
17510
|
-
console.log("addUser", user);
|
|
17511
17509
|
selectedUser.value = user.id;
|
|
17512
17510
|
searchQuery.value = "";
|
|
17513
17511
|
showDropdown.value = false;
|
|
@@ -17522,7 +17520,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17522
17520
|
}
|
|
17523
17521
|
};
|
|
17524
17522
|
const handleInput = () => {
|
|
17525
|
-
console.log("handleInput", searchQuery.value);
|
|
17526
17523
|
fetchUsers(searchQuery.value);
|
|
17527
17524
|
showDropdown.value = searchQuery.value.length >= 2;
|
|
17528
17525
|
};
|
|
@@ -17530,7 +17527,6 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17530
17527
|
showDropdown.value = false;
|
|
17531
17528
|
};
|
|
17532
17529
|
watch(selectedUser, (newVal) => {
|
|
17533
|
-
console.log("selectedUser", newVal);
|
|
17534
17530
|
emit("update:modelValue", newVal);
|
|
17535
17531
|
});
|
|
17536
17532
|
return (_ctx, _cache) => {
|
|
@@ -17600,8 +17596,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
17600
17596
|
};
|
|
17601
17597
|
}
|
|
17602
17598
|
});
|
|
17603
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-
|
|
17604
|
-
const _hoisted_1 = {
|
|
17599
|
+
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-22d9b76f"]]);
|
|
17600
|
+
const _hoisted_1 = {
|
|
17601
|
+
ref: "containerRef",
|
|
17602
|
+
class: "bk-user-selector"
|
|
17603
|
+
};
|
|
17605
17604
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
17606
17605
|
...{
|
|
17607
17606
|
name: "BkUserSelector"
|
|
@@ -17634,7 +17633,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17634
17633
|
const ids = Array.isArray(props2.modelValue) ? props2.modelValue : [];
|
|
17635
17634
|
if (ids.length > 0) {
|
|
17636
17635
|
try {
|
|
17637
|
-
console.log(props2.exactSearchKey);
|
|
17638
17636
|
const result = await lookupUsers(props2.apiBaseUrl, props2.tenantId, props2.exactSearchKey, ids);
|
|
17639
17637
|
selectedUsers.value = formatUsers(result);
|
|
17640
17638
|
} catch (error3) {
|
|
@@ -17665,51 +17663,61 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
17665
17663
|
initSelectedUsers();
|
|
17666
17664
|
});
|
|
17667
17665
|
return (_ctx, _cache) => {
|
|
17668
|
-
return openBlock(), createElementBlock(
|
|
17669
|
-
|
|
17670
|
-
|
|
17671
|
-
|
|
17672
|
-
|
|
17673
|
-
|
|
17674
|
-
|
|
17675
|
-
|
|
17676
|
-
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17680
|
-
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
[
|
|
17687
|
-
|
|
17688
|
-
|
|
17689
|
-
|
|
17690
|
-
"
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
17694
|
-
|
|
17695
|
-
|
|
17696
|
-
|
|
17697
|
-
|
|
17698
|
-
|
|
17699
|
-
|
|
17700
|
-
|
|
17701
|
-
|
|
17702
|
-
|
|
17703
|
-
|
|
17704
|
-
|
|
17705
|
-
|
|
17706
|
-
|
|
17707
|
-
|
|
17666
|
+
return openBlock(), createElementBlock(
|
|
17667
|
+
"section",
|
|
17668
|
+
_hoisted_1,
|
|
17669
|
+
[
|
|
17670
|
+
createCommentVNode(" 单选模式 "),
|
|
17671
|
+
!_ctx.multiple ? (openBlock(), createBlock(SingleSelector, {
|
|
17672
|
+
key: 0,
|
|
17673
|
+
modelValue: selectedUser.value,
|
|
17674
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedUser.value = $event),
|
|
17675
|
+
"api-base-url": _ctx.apiBaseUrl,
|
|
17676
|
+
"current-user-id": _ctx.currentUserId,
|
|
17677
|
+
"exact-search-key": _ctx.exactSearchKey,
|
|
17678
|
+
placeholder: _ctx.placeholder,
|
|
17679
|
+
"tenant-id": _ctx.tenantId,
|
|
17680
|
+
tenants: unref(tenants),
|
|
17681
|
+
"user-group": _ctx.userGroup,
|
|
17682
|
+
"user-group-name": _ctx.userGroupName,
|
|
17683
|
+
onChange: handleUpdateUser
|
|
17684
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "exact-search-key", "placeholder", "tenant-id", "tenants", "user-group", "user-group-name"])) : (openBlock(), createElementBlock(
|
|
17685
|
+
Fragment,
|
|
17686
|
+
{ key: 1 },
|
|
17687
|
+
[
|
|
17688
|
+
createCommentVNode(" 多选模式 "),
|
|
17689
|
+
createVNode(MultipleSelector, {
|
|
17690
|
+
modelValue: selectedUserIds.value,
|
|
17691
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => selectedUserIds.value = $event),
|
|
17692
|
+
"api-base-url": _ctx.apiBaseUrl,
|
|
17693
|
+
"current-user-id": _ctx.currentUserId,
|
|
17694
|
+
draggable: _ctx.draggable,
|
|
17695
|
+
"exact-search-key": _ctx.exactSearchKey,
|
|
17696
|
+
placeholder: _ctx.placeholder,
|
|
17697
|
+
"selected-users": selectedUsers.value,
|
|
17698
|
+
"tenant-id": _ctx.tenantId,
|
|
17699
|
+
tenants: unref(tenants),
|
|
17700
|
+
"user-group": _ctx.userGroup,
|
|
17701
|
+
"user-group-name": _ctx.userGroupName,
|
|
17702
|
+
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
17703
|
+
}, null, 8, ["modelValue", "api-base-url", "current-user-id", "draggable", "exact-search-key", "placeholder", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
17704
|
+
],
|
|
17705
|
+
2112
|
|
17706
|
+
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
17707
|
+
))
|
|
17708
|
+
],
|
|
17709
|
+
512
|
|
17710
|
+
/* NEED_PATCH */
|
|
17711
|
+
);
|
|
17708
17712
|
};
|
|
17709
17713
|
}
|
|
17710
17714
|
});
|
|
17711
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
17715
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-84252deb"]]);
|
|
17712
17716
|
const vue2 = {
|
|
17717
|
+
model: {
|
|
17718
|
+
prop: "modelValue",
|
|
17719
|
+
event: "change"
|
|
17720
|
+
},
|
|
17713
17721
|
beforeDestroy() {
|
|
17714
17722
|
var _a;
|
|
17715
17723
|
this.unWatchStack.forEach((unWatch) => unWatch == null ? void 0 : unWatch());
|