@blueking/bk-user-selector 0.0.39-beta.2 → 0.1.0
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 +314 -88
- package/package.json +2 -2
- package/typings/api/user.d.ts +42 -21
- package/typings/components/me-tag.vue.d.ts +14 -35
- package/typings/components/selection-popover.vue.d.ts +42 -197
- package/typings/components/user-selector.vue.d.ts +21 -29
- package/typings/constants/index.d.ts +25 -0
- package/typings/hooks/use-current-user.d.ts +30 -0
- package/typings/hooks/use-focus-state.d.ts +48 -0
- package/typings/hooks/use-input-handler.d.ts +44 -0
- package/typings/hooks/use-resize-observer.d.ts +17 -0
- package/typings/hooks/use-selected-users.d.ts +78 -0
- package/typings/hooks/use-sortable.d.ts +41 -0
- package/typings/hooks/use-tenant-data.d.ts +17 -0
- package/typings/hooks/use-user-search.d.ts +38 -0
- package/typings/hooks/use-user-selection.d.ts +32 -0
- package/typings/hooks/use-visible-tags.d.ts +51 -0
- package/typings/types/index.d.ts +117 -98
- package/typings/utils/logger.d.ts +47 -0
- package/vue2/index.es.min.js +2918 -4553
- package/vue2/index.iife.min.js +2864 -4442
- package/vue2/index.umd.min.js +2910 -4545
- package/vue2/vue2.css +30 -77
- package/vue3/index.es.min.js +1325 -1595
- package/vue3/index.iife.min.js +2908 -4543
- package/vue3/index.umd.min.js +1324 -1594
- package/vue3/vue3.css +30 -63
package/vue3/index.es.min.js
CHANGED
|
@@ -1,586 +1,225 @@
|
|
|
1
|
-
import { unref, ref, onBeforeMount, defineComponent, openBlock, createElementBlock, normalizeClass, withModifiers, toDisplayString, createCommentVNode, h,
|
|
2
|
-
import { Popover, Loading, Tag,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { unref, ref, watch, onUnmounted, onBeforeMount, computed, defineComponent, openBlock, createElementBlock, normalizeClass, withModifiers, toDisplayString, createCommentVNode, h, createBlock, withCtx, createElementVNode, createVNode, Fragment, renderList, renderSlot, toRef, nextTick, onMounted, withDirectives, mergeProps, isRef, normalizeStyle, vModelText, vShow, createTextVNode } from "vue";
|
|
2
|
+
import { Popover, Loading, Tag, provideGlobalConfig } from "bkui-vue";
|
|
3
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
4
|
+
function getDefaultExportFromCjs(x) {
|
|
5
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
6
|
+
}
|
|
7
|
+
var Sortable$1 = { exports: {} };
|
|
8
|
+
/**!
|
|
9
|
+
* Sortable 1.15.6
|
|
10
|
+
* @author RubaXa <trash@rubaxa.org>
|
|
11
|
+
* @author owenm <owen23355@gmail.com>
|
|
12
|
+
* @license MIT
|
|
13
|
+
*/
|
|
14
|
+
(function(module, exports) {
|
|
15
|
+
(function(global2, factory) {
|
|
16
|
+
module.exports = factory();
|
|
17
|
+
})(commonjsGlobal, function() {
|
|
18
|
+
function ownKeys(object, enumerableOnly) {
|
|
19
|
+
var keys = Object.keys(object);
|
|
20
|
+
if (Object.getOwnPropertySymbols) {
|
|
21
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
22
|
+
if (enumerableOnly) {
|
|
23
|
+
symbols = symbols.filter(function(sym) {
|
|
24
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
keys.push.apply(keys, symbols);
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
return keys;
|
|
30
|
+
}
|
|
31
|
+
function _objectSpread2(target) {
|
|
32
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
33
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
34
|
+
if (i % 2) {
|
|
35
|
+
ownKeys(Object(source), true).forEach(function(key) {
|
|
36
|
+
_defineProperty(target, key, source[key]);
|
|
37
|
+
});
|
|
38
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
39
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
40
|
+
} else {
|
|
41
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
42
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
22
45
|
}
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
return target;
|
|
47
|
+
}
|
|
48
|
+
function _typeof(obj) {
|
|
49
|
+
"@babel/helpers - typeof";
|
|
50
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
51
|
+
_typeof = function(obj2) {
|
|
52
|
+
return typeof obj2;
|
|
53
|
+
};
|
|
54
|
+
} else {
|
|
55
|
+
_typeof = function(obj2) {
|
|
56
|
+
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
57
|
+
};
|
|
25
58
|
}
|
|
26
|
-
|
|
27
|
-
window[callbackName] = (data) => {
|
|
28
|
-
cleanup();
|
|
29
|
-
resolve(data.data || data);
|
|
30
|
-
};
|
|
31
|
-
timeoutId = setTimeout(() => {
|
|
32
|
-
cleanup();
|
|
33
|
-
reject(new Error(`JSONP request timeout: ${url}`));
|
|
34
|
-
}, timeout);
|
|
35
|
-
script.onerror = () => {
|
|
36
|
-
cleanup();
|
|
37
|
-
reject(new Error(`JSONP request failed: ${url}`));
|
|
38
|
-
};
|
|
39
|
-
const separator = url.includes("?") ? "&" : "?";
|
|
40
|
-
const paramsStr = params ? `&${Object.entries(params).map(([key, value]) => value ? `${key}=${value}` : "").filter(Boolean).join("&")}` : "";
|
|
41
|
-
script.src = `${url}${separator}callback=${callbackName}${paramsStr}`;
|
|
42
|
-
document.head.appendChild(script);
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
const getTenants = async (apiBaseUrl, tenantId) => {
|
|
46
|
-
if (!apiBaseUrl || !tenantId) {
|
|
47
|
-
console.warn("获取租户信息需要提供有效的apiBaseUrl和租户ID");
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
const url = `${apiBaseUrl}/api/v3/open-web/tenant/data-source-owner-tenants/`;
|
|
52
|
-
const response = await fetch(url, {
|
|
53
|
-
method: "GET",
|
|
54
|
-
headers: {
|
|
55
|
-
"x-bk-tenant-id": tenantId
|
|
56
|
-
},
|
|
57
|
-
credentials: "include"
|
|
58
|
-
});
|
|
59
|
-
if (!response.ok) {
|
|
60
|
-
throw new Error(`获取租户信息失败: ${response.status} ${response.statusText}`);
|
|
59
|
+
return _typeof(obj);
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
pageSize: 100,
|
|
75
|
-
page: 1
|
|
76
|
-
}).catch(() => {
|
|
77
|
-
return [];
|
|
78
|
-
});
|
|
79
|
-
return userList;
|
|
80
|
-
}
|
|
81
|
-
if (!keyword || !apiBaseUrl || !tenantId) {
|
|
82
|
-
console.warn("搜索用户需要提供有效的apiBaseUrl、租户ID和关键词");
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/search/?keyword=${encodeURIComponent(keyword)}`;
|
|
87
|
-
const response = await fetch(url, {
|
|
88
|
-
method: "GET",
|
|
89
|
-
headers: {
|
|
90
|
-
"x-bk-tenant-id": tenantId
|
|
91
|
-
},
|
|
92
|
-
credentials: "include"
|
|
93
|
-
});
|
|
94
|
-
if (!response.ok) {
|
|
95
|
-
throw new Error(`搜索用户失败: ${response.status} ${response.statusText}`);
|
|
61
|
+
function _defineProperty(obj, key, value) {
|
|
62
|
+
if (key in obj) {
|
|
63
|
+
Object.defineProperty(obj, key, {
|
|
64
|
+
value,
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
obj[key] = value;
|
|
71
|
+
}
|
|
72
|
+
return obj;
|
|
96
73
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}).catch(() => {
|
|
111
|
-
return [];
|
|
112
|
-
});
|
|
113
|
-
return users.map((user) => userList.find((u) => u.username === user)).filter(Boolean);
|
|
114
|
-
}
|
|
115
|
-
if (users.length === 0 || !apiBaseUrl || !tenantId) {
|
|
116
|
-
console.warn("批量查找用户需要提供有效的apiBaseUrl、租户ID和至少一个用户名");
|
|
117
|
-
return [];
|
|
118
|
-
}
|
|
119
|
-
try {
|
|
120
|
-
const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/lookup/?lookups=${users.join(",")}&lookup_fields=${exactSearchKey}`;
|
|
121
|
-
const response = await fetch(url, {
|
|
122
|
-
method: "GET",
|
|
123
|
-
headers: {
|
|
124
|
-
"x-bk-tenant-id": tenantId
|
|
125
|
-
},
|
|
126
|
-
credentials: "include"
|
|
127
|
-
});
|
|
128
|
-
if (!response.ok) {
|
|
129
|
-
throw new Error(`批量查找用户失败: ${response.status} ${response.statusText}`);
|
|
74
|
+
function _extends() {
|
|
75
|
+
_extends = Object.assign || function(target) {
|
|
76
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
77
|
+
var source = arguments[i];
|
|
78
|
+
for (var key in source) {
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
80
|
+
target[key] = source[key];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return target;
|
|
85
|
+
};
|
|
86
|
+
return _extends.apply(this, arguments);
|
|
130
87
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
...user,
|
|
143
|
-
id: user.username,
|
|
144
|
-
name: `${user.display_name}(${user.username})`,
|
|
145
|
-
tenantId: user.owner_tenant_id
|
|
146
|
-
}));
|
|
147
|
-
}
|
|
148
|
-
return users.map((user) => ({
|
|
149
|
-
id: user.bk_username,
|
|
150
|
-
name: user.display_name,
|
|
151
|
-
tenantId: user.owner_tenant_id,
|
|
152
|
-
...user
|
|
153
|
-
}));
|
|
154
|
-
};
|
|
155
|
-
const getUserList = async (url, params) => {
|
|
156
|
-
const { userIds, keyword, pageSize = 20, page, appCode } = params;
|
|
157
|
-
const data = await jsonpRequest(url, {
|
|
158
|
-
params: {
|
|
159
|
-
exact_lookups: (userIds == null ? void 0 : userIds.join(",")) || void 0,
|
|
160
|
-
fuzzy_lookups: keyword || void 0,
|
|
161
|
-
page_size: Math.max((userIds == null ? void 0 : userIds.length) || 0, 20, Number(pageSize)).toString(),
|
|
162
|
-
page: (page == null ? void 0 : page.toString()) || "1",
|
|
163
|
-
app_code: appCode || "bk-magicbox"
|
|
88
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
89
|
+
if (source == null) return {};
|
|
90
|
+
var target = {};
|
|
91
|
+
var sourceKeys = Object.keys(source);
|
|
92
|
+
var key, i;
|
|
93
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
94
|
+
key = sourceKeys[i];
|
|
95
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
96
|
+
target[key] = source[key];
|
|
97
|
+
}
|
|
98
|
+
return target;
|
|
164
99
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
100
|
+
function _objectWithoutProperties(source, excluded) {
|
|
101
|
+
if (source == null) return {};
|
|
102
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
103
|
+
var key, i;
|
|
104
|
+
if (Object.getOwnPropertySymbols) {
|
|
105
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
106
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
107
|
+
key = sourceSymbolKeys[i];
|
|
108
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
109
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
110
|
+
target[key] = source[key];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return target;
|
|
174
114
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
var defaultConverter = {
|
|
179
|
-
read: function(value) {
|
|
180
|
-
if (value[0] === '"') {
|
|
181
|
-
value = value.slice(1, -1);
|
|
115
|
+
function _toConsumableArray(arr) {
|
|
116
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
182
117
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
write: function(value) {
|
|
186
|
-
return encodeURIComponent(value).replace(
|
|
187
|
-
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
188
|
-
decodeURIComponent
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
function init(converter, defaultAttributes) {
|
|
193
|
-
function set(name, value, attributes) {
|
|
194
|
-
if (typeof document === "undefined") {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
attributes = assign({}, defaultAttributes, attributes);
|
|
198
|
-
if (typeof attributes.expires === "number") {
|
|
199
|
-
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
118
|
+
function _arrayWithoutHoles(arr) {
|
|
119
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
200
120
|
}
|
|
201
|
-
|
|
202
|
-
|
|
121
|
+
function _iterableToArray(iter) {
|
|
122
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
203
123
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (attributes[attributeName] === true) {
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
|
|
124
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
125
|
+
if (!o) return;
|
|
126
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
127
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
128
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
129
|
+
if (n === "Map" || n === "Set") return Array.from(o);
|
|
130
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
215
131
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
return;
|
|
132
|
+
function _arrayLikeToArray(arr, len) {
|
|
133
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
134
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
135
|
+
return arr2;
|
|
221
136
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
for (var i = 0; i < cookies.length; i++) {
|
|
225
|
-
var parts = cookies[i].split("=");
|
|
226
|
-
var value = parts.slice(1).join("=");
|
|
227
|
-
try {
|
|
228
|
-
var found = decodeURIComponent(parts[0]);
|
|
229
|
-
jar[found] = converter.read(value, found);
|
|
230
|
-
if (name === found) {
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
} catch (e) {
|
|
234
|
-
}
|
|
137
|
+
function _nonIterableSpread() {
|
|
138
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
235
139
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
set,
|
|
241
|
-
get,
|
|
242
|
-
remove: function(name, attributes) {
|
|
243
|
-
set(
|
|
244
|
-
name,
|
|
245
|
-
"",
|
|
246
|
-
assign({}, attributes, {
|
|
247
|
-
expires: -1
|
|
248
|
-
})
|
|
249
|
-
);
|
|
250
|
-
},
|
|
251
|
-
withAttributes: function(attributes) {
|
|
252
|
-
return init(this.converter, assign({}, this.attributes, attributes));
|
|
253
|
-
},
|
|
254
|
-
withConverter: function(converter2) {
|
|
255
|
-
return init(assign({}, this.converter, converter2), this.attributes);
|
|
140
|
+
var version = "1.15.6";
|
|
141
|
+
function userAgent(pattern) {
|
|
142
|
+
if (typeof window !== "undefined" && window.navigator) {
|
|
143
|
+
return !!/* @__PURE__ */ navigator.userAgent.match(pattern);
|
|
256
144
|
}
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
attributes: { value: Object.freeze(defaultAttributes) },
|
|
260
|
-
converter: { value: Object.freeze(converter) }
|
|
261
145
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
我: "我",
|
|
275
|
-
请输入人员名称搜索: "请输入人员名称搜索",
|
|
276
|
-
用户群组: "用户群组",
|
|
277
|
-
无匹配人员: "无匹配人员",
|
|
278
|
-
虚拟账号: "虚拟账号",
|
|
279
|
-
用户: "用户"
|
|
280
|
-
};
|
|
281
|
-
const BLUEKINNG_LANGUAGE = "blueking_language";
|
|
282
|
-
const languageMap = {
|
|
283
|
-
"en-US": enUS,
|
|
284
|
-
"zh-CN": zhCN
|
|
285
|
-
};
|
|
286
|
-
const getPath = (obj, path, variables) => {
|
|
287
|
-
const pathStack = /^\w/.test(path) ? path.split(".") : [path];
|
|
288
|
-
const { length } = pathStack;
|
|
289
|
-
let target = obj;
|
|
290
|
-
let i = 0;
|
|
291
|
-
while (i <= length && target) {
|
|
292
|
-
if (typeof target === "string") {
|
|
293
|
-
return target;
|
|
146
|
+
var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
|
|
147
|
+
var Edge = userAgent(/Edge/i);
|
|
148
|
+
var FireFox = userAgent(/firefox/i);
|
|
149
|
+
var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
|
|
150
|
+
var IOS = userAgent(/iP(ad|od|hone)/i);
|
|
151
|
+
var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
|
|
152
|
+
var captureMode = {
|
|
153
|
+
capture: false,
|
|
154
|
+
passive: false
|
|
155
|
+
};
|
|
156
|
+
function on(el, event, fn) {
|
|
157
|
+
el.addEventListener(event, fn, !IE11OrLess && captureMode);
|
|
294
158
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
Object.keys(variables).forEach((key) => {
|
|
298
|
-
target = target.replace(`{${key}}`, variables[key]);
|
|
299
|
-
});
|
|
300
|
-
} else {
|
|
301
|
-
target = target[pathStack[i]];
|
|
159
|
+
function off(el, event, fn) {
|
|
160
|
+
el.removeEventListener(event, fn, !IE11OrLess && captureMode);
|
|
302
161
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
162
|
+
function matches(el, selector) {
|
|
163
|
+
if (!selector) return;
|
|
164
|
+
selector[0] === ">" && (selector = selector.substring(1));
|
|
165
|
+
if (el) {
|
|
166
|
+
try {
|
|
167
|
+
if (el.matches) {
|
|
168
|
+
return el.matches(selector);
|
|
169
|
+
} else if (el.msMatchesSelector) {
|
|
170
|
+
return el.msMatchesSelector(selector);
|
|
171
|
+
} else if (el.webkitMatchesSelector) {
|
|
172
|
+
return el.webkitMatchesSelector(selector);
|
|
173
|
+
}
|
|
174
|
+
} catch (_) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return false;
|
|
306
179
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
};
|
|
310
|
-
const useI18n = () => {
|
|
311
|
-
let localeLanguage = "zh-CN";
|
|
312
|
-
const bluekingLanguage = api.get(BLUEKINNG_LANGUAGE);
|
|
313
|
-
if (bluekingLanguage && bluekingLanguage.toLowerCase() === "en") {
|
|
314
|
-
localeLanguage = "en-US";
|
|
315
|
-
}
|
|
316
|
-
const languagePackage = languageMap[localeLanguage];
|
|
317
|
-
const t = (path, variable) => {
|
|
318
|
-
const value = getPath(languagePackage, path, variable);
|
|
319
|
-
if (value === void 0) {
|
|
320
|
-
console.warn(`缺少索引 * ${path} *`);
|
|
180
|
+
function getParentOrHost(el) {
|
|
181
|
+
return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
|
|
321
182
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
if (!apiBaseUrl || !tenantId) {
|
|
334
|
-
console.warn("获取租户需要提供有效的API基础URL和租户ID");
|
|
335
|
-
return;
|
|
183
|
+
function closest(el, selector, ctx, includeCTX) {
|
|
184
|
+
if (el) {
|
|
185
|
+
ctx = ctx || document;
|
|
186
|
+
do {
|
|
187
|
+
if (selector != null && (selector[0] === ">" ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
|
|
188
|
+
return el;
|
|
189
|
+
}
|
|
190
|
+
if (el === ctx) break;
|
|
191
|
+
} while (el = getParentOrHost(el));
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
336
194
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
195
|
+
var R_SPACE = /\s+/g;
|
|
196
|
+
function toggleClass(el, name, state) {
|
|
197
|
+
if (el && name) {
|
|
198
|
+
if (el.classList) {
|
|
199
|
+
el.classList[state ? "add" : "remove"](name);
|
|
200
|
+
} else {
|
|
201
|
+
var className = (" " + el.className + " ").replace(R_SPACE, " ").replace(" " + name + " ", " ");
|
|
202
|
+
el.className = (className + (state ? " " + name : "")).replace(R_SPACE, " ");
|
|
344
203
|
}
|
|
345
|
-
}
|
|
346
|
-
tenants.value = tenantMap;
|
|
347
|
-
} catch (error) {
|
|
348
|
-
console.error("获取租户数据失败:", error);
|
|
349
|
-
} finally {
|
|
350
|
-
loading.value = false;
|
|
204
|
+
}
|
|
351
205
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/**!
|
|
370
|
-
* Sortable 1.15.6
|
|
371
|
-
* @author RubaXa <trash@rubaxa.org>
|
|
372
|
-
* @author owenm <owen23355@gmail.com>
|
|
373
|
-
* @license MIT
|
|
374
|
-
*/
|
|
375
|
-
(function(module, exports) {
|
|
376
|
-
(function(global2, factory) {
|
|
377
|
-
module.exports = factory();
|
|
378
|
-
})(commonjsGlobal, function() {
|
|
379
|
-
function ownKeys(object, enumerableOnly) {
|
|
380
|
-
var keys = Object.keys(object);
|
|
381
|
-
if (Object.getOwnPropertySymbols) {
|
|
382
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
383
|
-
if (enumerableOnly) {
|
|
384
|
-
symbols = symbols.filter(function(sym) {
|
|
385
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
keys.push.apply(keys, symbols);
|
|
389
|
-
}
|
|
390
|
-
return keys;
|
|
391
|
-
}
|
|
392
|
-
function _objectSpread2(target) {
|
|
393
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
394
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
395
|
-
if (i % 2) {
|
|
396
|
-
ownKeys(Object(source), true).forEach(function(key) {
|
|
397
|
-
_defineProperty(target, key, source[key]);
|
|
398
|
-
});
|
|
399
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
400
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
401
|
-
} else {
|
|
402
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
403
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return target;
|
|
408
|
-
}
|
|
409
|
-
function _typeof(obj) {
|
|
410
|
-
"@babel/helpers - typeof";
|
|
411
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
412
|
-
_typeof = function(obj2) {
|
|
413
|
-
return typeof obj2;
|
|
414
|
-
};
|
|
415
|
-
} else {
|
|
416
|
-
_typeof = function(obj2) {
|
|
417
|
-
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
return _typeof(obj);
|
|
421
|
-
}
|
|
422
|
-
function _defineProperty(obj, key, value) {
|
|
423
|
-
if (key in obj) {
|
|
424
|
-
Object.defineProperty(obj, key, {
|
|
425
|
-
value,
|
|
426
|
-
enumerable: true,
|
|
427
|
-
configurable: true,
|
|
428
|
-
writable: true
|
|
429
|
-
});
|
|
430
|
-
} else {
|
|
431
|
-
obj[key] = value;
|
|
432
|
-
}
|
|
433
|
-
return obj;
|
|
434
|
-
}
|
|
435
|
-
function _extends() {
|
|
436
|
-
_extends = Object.assign || function(target) {
|
|
437
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
438
|
-
var source = arguments[i];
|
|
439
|
-
for (var key in source) {
|
|
440
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
441
|
-
target[key] = source[key];
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
return target;
|
|
446
|
-
};
|
|
447
|
-
return _extends.apply(this, arguments);
|
|
448
|
-
}
|
|
449
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
450
|
-
if (source == null) return {};
|
|
451
|
-
var target = {};
|
|
452
|
-
var sourceKeys = Object.keys(source);
|
|
453
|
-
var key, i;
|
|
454
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
455
|
-
key = sourceKeys[i];
|
|
456
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
457
|
-
target[key] = source[key];
|
|
458
|
-
}
|
|
459
|
-
return target;
|
|
460
|
-
}
|
|
461
|
-
function _objectWithoutProperties(source, excluded) {
|
|
462
|
-
if (source == null) return {};
|
|
463
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
464
|
-
var key, i;
|
|
465
|
-
if (Object.getOwnPropertySymbols) {
|
|
466
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
467
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
468
|
-
key = sourceSymbolKeys[i];
|
|
469
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
470
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
471
|
-
target[key] = source[key];
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
return target;
|
|
475
|
-
}
|
|
476
|
-
function _toConsumableArray(arr) {
|
|
477
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
478
|
-
}
|
|
479
|
-
function _arrayWithoutHoles(arr) {
|
|
480
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
481
|
-
}
|
|
482
|
-
function _iterableToArray(iter) {
|
|
483
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
484
|
-
}
|
|
485
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
486
|
-
if (!o) return;
|
|
487
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
488
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
489
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
490
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
491
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
492
|
-
}
|
|
493
|
-
function _arrayLikeToArray(arr, len) {
|
|
494
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
495
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
496
|
-
return arr2;
|
|
497
|
-
}
|
|
498
|
-
function _nonIterableSpread() {
|
|
499
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
500
|
-
}
|
|
501
|
-
var version = "1.15.6";
|
|
502
|
-
function userAgent(pattern) {
|
|
503
|
-
if (typeof window !== "undefined" && window.navigator) {
|
|
504
|
-
return !!/* @__PURE__ */ navigator.userAgent.match(pattern);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
|
|
508
|
-
var Edge = userAgent(/Edge/i);
|
|
509
|
-
var FireFox = userAgent(/firefox/i);
|
|
510
|
-
var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
|
|
511
|
-
var IOS = userAgent(/iP(ad|od|hone)/i);
|
|
512
|
-
var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
|
|
513
|
-
var captureMode = {
|
|
514
|
-
capture: false,
|
|
515
|
-
passive: false
|
|
516
|
-
};
|
|
517
|
-
function on(el, event, fn) {
|
|
518
|
-
el.addEventListener(event, fn, !IE11OrLess && captureMode);
|
|
519
|
-
}
|
|
520
|
-
function off(el, event, fn) {
|
|
521
|
-
el.removeEventListener(event, fn, !IE11OrLess && captureMode);
|
|
522
|
-
}
|
|
523
|
-
function matches(el, selector) {
|
|
524
|
-
if (!selector) return;
|
|
525
|
-
selector[0] === ">" && (selector = selector.substring(1));
|
|
526
|
-
if (el) {
|
|
527
|
-
try {
|
|
528
|
-
if (el.matches) {
|
|
529
|
-
return el.matches(selector);
|
|
530
|
-
} else if (el.msMatchesSelector) {
|
|
531
|
-
return el.msMatchesSelector(selector);
|
|
532
|
-
} else if (el.webkitMatchesSelector) {
|
|
533
|
-
return el.webkitMatchesSelector(selector);
|
|
534
|
-
}
|
|
535
|
-
} catch (_) {
|
|
536
|
-
return false;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
return false;
|
|
540
|
-
}
|
|
541
|
-
function getParentOrHost(el) {
|
|
542
|
-
return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
|
|
543
|
-
}
|
|
544
|
-
function closest(el, selector, ctx, includeCTX) {
|
|
545
|
-
if (el) {
|
|
546
|
-
ctx = ctx || document;
|
|
547
|
-
do {
|
|
548
|
-
if (selector != null && (selector[0] === ">" ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
|
|
549
|
-
return el;
|
|
550
|
-
}
|
|
551
|
-
if (el === ctx) break;
|
|
552
|
-
} while (el = getParentOrHost(el));
|
|
553
|
-
}
|
|
554
|
-
return null;
|
|
555
|
-
}
|
|
556
|
-
var R_SPACE = /\s+/g;
|
|
557
|
-
function toggleClass(el, name, state) {
|
|
558
|
-
if (el && name) {
|
|
559
|
-
if (el.classList) {
|
|
560
|
-
el.classList[state ? "add" : "remove"](name);
|
|
561
|
-
} else {
|
|
562
|
-
var className = (" " + el.className + " ").replace(R_SPACE, " ").replace(" " + name + " ", " ");
|
|
563
|
-
el.className = (className + (state ? " " + name : "")).replace(R_SPACE, " ");
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
function css(el, prop, val) {
|
|
568
|
-
var style = el && el.style;
|
|
569
|
-
if (style) {
|
|
570
|
-
if (val === void 0) {
|
|
571
|
-
if (document.defaultView && document.defaultView.getComputedStyle) {
|
|
572
|
-
val = document.defaultView.getComputedStyle(el, "");
|
|
573
|
-
} else if (el.currentStyle) {
|
|
574
|
-
val = el.currentStyle;
|
|
575
|
-
}
|
|
576
|
-
return prop === void 0 ? val : val[prop];
|
|
577
|
-
} else {
|
|
578
|
-
if (!(prop in style) && prop.indexOf("webkit") === -1) {
|
|
579
|
-
prop = "-webkit-" + prop;
|
|
580
|
-
}
|
|
581
|
-
style[prop] = val + (typeof val === "string" ? "" : "px");
|
|
582
|
-
}
|
|
583
|
-
}
|
|
206
|
+
function css(el, prop, val) {
|
|
207
|
+
var style = el && el.style;
|
|
208
|
+
if (style) {
|
|
209
|
+
if (val === void 0) {
|
|
210
|
+
if (document.defaultView && document.defaultView.getComputedStyle) {
|
|
211
|
+
val = document.defaultView.getComputedStyle(el, "");
|
|
212
|
+
} else if (el.currentStyle) {
|
|
213
|
+
val = el.currentStyle;
|
|
214
|
+
}
|
|
215
|
+
return prop === void 0 ? val : val[prop];
|
|
216
|
+
} else {
|
|
217
|
+
if (!(prop in style) && prop.indexOf("webkit") === -1) {
|
|
218
|
+
prop = "-webkit-" + prop;
|
|
219
|
+
}
|
|
220
|
+
style[prop] = val + (typeof val === "string" ? "" : "px");
|
|
221
|
+
}
|
|
222
|
+
}
|
|
584
223
|
}
|
|
585
224
|
function matrix(el, selfOnly) {
|
|
586
225
|
var appliedTransforms = "";
|
|
@@ -3103,31 +2742,594 @@ var Sortable$1 = { exports: {} };
|
|
|
3103
2742
|
}
|
|
3104
2743
|
});
|
|
3105
2744
|
}
|
|
3106
|
-
function insertMultiDragClones(elementsInserted, rootEl2) {
|
|
3107
|
-
multiDragClones.forEach(function(clone2, i) {
|
|
3108
|
-
var target = rootEl2.children[clone2.sortableIndex + (elementsInserted ? Number(i) : 0)];
|
|
3109
|
-
if (target) {
|
|
3110
|
-
rootEl2.insertBefore(clone2, target);
|
|
3111
|
-
} else {
|
|
3112
|
-
rootEl2.appendChild(clone2);
|
|
2745
|
+
function insertMultiDragClones(elementsInserted, rootEl2) {
|
|
2746
|
+
multiDragClones.forEach(function(clone2, i) {
|
|
2747
|
+
var target = rootEl2.children[clone2.sortableIndex + (elementsInserted ? Number(i) : 0)];
|
|
2748
|
+
if (target) {
|
|
2749
|
+
rootEl2.insertBefore(clone2, target);
|
|
2750
|
+
} else {
|
|
2751
|
+
rootEl2.appendChild(clone2);
|
|
2752
|
+
}
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2755
|
+
function removeMultiDragElements() {
|
|
2756
|
+
multiDragElements.forEach(function(multiDragElement) {
|
|
2757
|
+
if (multiDragElement === dragEl$1) return;
|
|
2758
|
+
multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
Sortable2.mount(new AutoScrollPlugin());
|
|
2762
|
+
Sortable2.mount(Remove, Revert);
|
|
2763
|
+
Sortable2.mount(new SwapPlugin());
|
|
2764
|
+
Sortable2.mount(new MultiDragPlugin());
|
|
2765
|
+
return Sortable2;
|
|
2766
|
+
});
|
|
2767
|
+
})(Sortable$1);
|
|
2768
|
+
var SortableExports = Sortable$1.exports;
|
|
2769
|
+
const Sortable = /* @__PURE__ */ getDefaultExportFromCjs(SortableExports);
|
|
2770
|
+
const RESERVED_SPACE_FOR_INPUT = 100;
|
|
2771
|
+
const SEARCH_DEBOUNCE_DELAY = 300;
|
|
2772
|
+
const DEFAULT_EXACT_SEARCH_KEY = "bk_username";
|
|
2773
|
+
const USER_TYPE = {
|
|
2774
|
+
/** 普通用户 */
|
|
2775
|
+
USER: "user",
|
|
2776
|
+
/** 虚拟账号 */
|
|
2777
|
+
VIRTUAL: "virtual",
|
|
2778
|
+
/** 自定义用户 */
|
|
2779
|
+
CUSTOM: "custom",
|
|
2780
|
+
/** 用户群组 */
|
|
2781
|
+
USER_GROUP: "userGroup"
|
|
2782
|
+
};
|
|
2783
|
+
const DEFAULT_PAGE_SIZE = 100;
|
|
2784
|
+
const generateCallbackName = () => {
|
|
2785
|
+
const timestamp = Date.now();
|
|
2786
|
+
const random = Math.random().toString(36).slice(2, 9);
|
|
2787
|
+
return `__jsonp_callback_${timestamp}_${random}`;
|
|
2788
|
+
};
|
|
2789
|
+
const jsonpRequest = (requestUrl, options = {}) => {
|
|
2790
|
+
return new Promise((resolve, reject) => {
|
|
2791
|
+
const url = unref(requestUrl);
|
|
2792
|
+
const { timeout = 1e3 * 60 * 2, params } = options;
|
|
2793
|
+
const callbackName = generateCallbackName();
|
|
2794
|
+
const script = document.createElement("script");
|
|
2795
|
+
let timeoutId = null;
|
|
2796
|
+
script.setAttribute("type", "text/javascript");
|
|
2797
|
+
const cleanup = () => {
|
|
2798
|
+
if (timeoutId) {
|
|
2799
|
+
clearTimeout(timeoutId);
|
|
2800
|
+
}
|
|
2801
|
+
if (script.parentNode) {
|
|
2802
|
+
script.parentNode.removeChild(script);
|
|
2803
|
+
}
|
|
2804
|
+
if (window[callbackName]) {
|
|
2805
|
+
delete window[callbackName];
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
window[callbackName] = (data) => {
|
|
2809
|
+
cleanup();
|
|
2810
|
+
resolve(data.data || data);
|
|
2811
|
+
};
|
|
2812
|
+
timeoutId = setTimeout(() => {
|
|
2813
|
+
cleanup();
|
|
2814
|
+
reject(new Error(`JSONP request timeout: ${url}`));
|
|
2815
|
+
}, timeout);
|
|
2816
|
+
script.onerror = () => {
|
|
2817
|
+
cleanup();
|
|
2818
|
+
reject(new Error(`JSONP request failed: ${url}`));
|
|
2819
|
+
};
|
|
2820
|
+
const separator = url.includes("?") ? "&" : "?";
|
|
2821
|
+
const paramsStr = params ? `&${Object.entries(params).map(([key, value]) => value ? `${key}=${value}` : "").filter(Boolean).join("&")}` : "";
|
|
2822
|
+
script.src = `${url}${separator}callback=${callbackName}${paramsStr}`;
|
|
2823
|
+
document.head.appendChild(script);
|
|
2824
|
+
});
|
|
2825
|
+
};
|
|
2826
|
+
const logger = {
|
|
2827
|
+
/**
|
|
2828
|
+
* 调试日志
|
|
2829
|
+
*/
|
|
2830
|
+
debug: (message, ...args) => {
|
|
2831
|
+
},
|
|
2832
|
+
/**
|
|
2833
|
+
* 信息日志
|
|
2834
|
+
*/
|
|
2835
|
+
info: (message, ...args) => {
|
|
2836
|
+
},
|
|
2837
|
+
/**
|
|
2838
|
+
* 警告日志
|
|
2839
|
+
*/
|
|
2840
|
+
warn: (message, ...args) => {
|
|
2841
|
+
},
|
|
2842
|
+
/**
|
|
2843
|
+
* 错误日志
|
|
2844
|
+
*/
|
|
2845
|
+
error: (message, error) => {
|
|
2846
|
+
}
|
|
2847
|
+
};
|
|
2848
|
+
const warnMissingParams = (operation, params) => {
|
|
2849
|
+
logger.warn(`${operation}需要提供有效的参数: ${params.join(", ")}`);
|
|
2850
|
+
};
|
|
2851
|
+
const getTenants = async (apiBaseUrl, tenantId) => {
|
|
2852
|
+
if (!apiBaseUrl || !tenantId) {
|
|
2853
|
+
warnMissingParams("获取租户信息", ["apiBaseUrl", "tenantId"]);
|
|
2854
|
+
return [];
|
|
2855
|
+
}
|
|
2856
|
+
try {
|
|
2857
|
+
const url = `${apiBaseUrl}/api/v3/open-web/tenant/data-source-owner-tenants/`;
|
|
2858
|
+
const response = await fetch(url, {
|
|
2859
|
+
method: "GET",
|
|
2860
|
+
headers: {
|
|
2861
|
+
"x-bk-tenant-id": tenantId
|
|
2862
|
+
},
|
|
2863
|
+
credentials: "include"
|
|
2864
|
+
});
|
|
2865
|
+
if (!response.ok) {
|
|
2866
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
2867
|
+
}
|
|
2868
|
+
const data = await response.json();
|
|
2869
|
+
return data.data || [];
|
|
2870
|
+
} catch (error) {
|
|
2871
|
+
return [];
|
|
2872
|
+
}
|
|
2873
|
+
};
|
|
2874
|
+
const searchUsers = async (params) => {
|
|
2875
|
+
const { apiBaseUrl, tenantId, keyword, enableMultiTenantMode = true } = params;
|
|
2876
|
+
if (!enableMultiTenantMode) {
|
|
2877
|
+
try {
|
|
2878
|
+
return await getUserList(apiBaseUrl, {
|
|
2879
|
+
keyword,
|
|
2880
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
2881
|
+
page: 1
|
|
2882
|
+
});
|
|
2883
|
+
} catch {
|
|
2884
|
+
return [];
|
|
2885
|
+
}
|
|
2886
|
+
}
|
|
2887
|
+
if (!keyword || !apiBaseUrl || !tenantId) {
|
|
2888
|
+
warnMissingParams("搜索用户", ["apiBaseUrl", "tenantId", "keyword"]);
|
|
2889
|
+
return [];
|
|
2890
|
+
}
|
|
2891
|
+
try {
|
|
2892
|
+
const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/search/?keyword=${encodeURIComponent(keyword)}`;
|
|
2893
|
+
const response = await fetch(url, {
|
|
2894
|
+
method: "GET",
|
|
2895
|
+
headers: {
|
|
2896
|
+
"x-bk-tenant-id": tenantId
|
|
2897
|
+
},
|
|
2898
|
+
credentials: "include"
|
|
2899
|
+
});
|
|
2900
|
+
if (!response.ok) {
|
|
2901
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
2902
|
+
}
|
|
2903
|
+
const data = await response.json();
|
|
2904
|
+
return data.data || [];
|
|
2905
|
+
} catch (error) {
|
|
2906
|
+
return [];
|
|
2907
|
+
}
|
|
2908
|
+
};
|
|
2909
|
+
const lookupUsers = async (params) => {
|
|
2910
|
+
const { apiBaseUrl, tenantId, exactSearchKey = "bk_username", usersList = [], enableMultiTenantMode = true } = params;
|
|
2911
|
+
const users = usersList.filter(Boolean).map((user) => user.trim());
|
|
2912
|
+
if (!enableMultiTenantMode) {
|
|
2913
|
+
try {
|
|
2914
|
+
const userList = await getUserList(apiBaseUrl, { userIds: users });
|
|
2915
|
+
return users.map((user) => userList.find((u) => u.username === user)).filter(Boolean);
|
|
2916
|
+
} catch {
|
|
2917
|
+
return [];
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
if (users.length === 0 || !apiBaseUrl || !tenantId) {
|
|
2921
|
+
warnMissingParams("批量查找用户", ["apiBaseUrl", "tenantId", "usersList"]);
|
|
2922
|
+
return [];
|
|
2923
|
+
}
|
|
2924
|
+
try {
|
|
2925
|
+
const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/lookup/?lookups=${users.join(",")}&lookup_fields=${exactSearchKey}`;
|
|
2926
|
+
const response = await fetch(url, {
|
|
2927
|
+
method: "GET",
|
|
2928
|
+
headers: {
|
|
2929
|
+
"x-bk-tenant-id": tenantId
|
|
2930
|
+
},
|
|
2931
|
+
credentials: "include"
|
|
2932
|
+
});
|
|
2933
|
+
if (!response.ok) {
|
|
2934
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
2935
|
+
}
|
|
2936
|
+
const data = await response.json();
|
|
2937
|
+
return data.data || [];
|
|
2938
|
+
} catch (error) {
|
|
2939
|
+
return [];
|
|
2940
|
+
}
|
|
2941
|
+
};
|
|
2942
|
+
const formatUsers = (users, enableMultiTenantMode = true) => {
|
|
2943
|
+
if (!users || !Array.isArray(users)) return [];
|
|
2944
|
+
if (!enableMultiTenantMode) {
|
|
2945
|
+
return users.map((user) => ({
|
|
2946
|
+
...user,
|
|
2947
|
+
id: user.username,
|
|
2948
|
+
name: `${user.display_name}(${user.username})`,
|
|
2949
|
+
tenantId: user.owner_tenant_id
|
|
2950
|
+
}));
|
|
2951
|
+
}
|
|
2952
|
+
return users.map((user) => ({
|
|
2953
|
+
id: user.bk_username,
|
|
2954
|
+
name: user.display_name,
|
|
2955
|
+
tenantId: user.owner_tenant_id,
|
|
2956
|
+
...user
|
|
2957
|
+
}));
|
|
2958
|
+
};
|
|
2959
|
+
const getUserList = async (url, params) => {
|
|
2960
|
+
const { userIds, keyword, pageSize = 20, page = 1, appCode = "bk-magicbox" } = params;
|
|
2961
|
+
const data = await jsonpRequest(url, {
|
|
2962
|
+
params: {
|
|
2963
|
+
exact_lookups: (userIds == null ? void 0 : userIds.join(",")) || void 0,
|
|
2964
|
+
fuzzy_lookups: keyword || void 0,
|
|
2965
|
+
page_size: Math.max((userIds == null ? void 0 : userIds.length) || 0, 20, Number(pageSize)).toString(),
|
|
2966
|
+
page: page.toString(),
|
|
2967
|
+
app_code: appCode
|
|
2968
|
+
}
|
|
2969
|
+
});
|
|
2970
|
+
return (data == null ? void 0 : data.results) || [];
|
|
2971
|
+
};
|
|
2972
|
+
const useCurrentUser = (options) => {
|
|
2973
|
+
const {
|
|
2974
|
+
apiBaseUrl,
|
|
2975
|
+
tenantId,
|
|
2976
|
+
currentUserId,
|
|
2977
|
+
exactSearchKey = DEFAULT_EXACT_SEARCH_KEY,
|
|
2978
|
+
enableMultiTenantMode = true
|
|
2979
|
+
} = options;
|
|
2980
|
+
const loading = ref(false);
|
|
2981
|
+
const fetchCurrentUser = async () => {
|
|
2982
|
+
if (!currentUserId) {
|
|
2983
|
+
return null;
|
|
2984
|
+
}
|
|
2985
|
+
loading.value = true;
|
|
2986
|
+
try {
|
|
2987
|
+
const result = await lookupUsers({
|
|
2988
|
+
apiBaseUrl,
|
|
2989
|
+
tenantId,
|
|
2990
|
+
exactSearchKey,
|
|
2991
|
+
usersList: [currentUserId],
|
|
2992
|
+
enableMultiTenantMode
|
|
2993
|
+
});
|
|
2994
|
+
const formattedUsers = formatUsers(result, enableMultiTenantMode);
|
|
2995
|
+
return formattedUsers.length > 0 ? formattedUsers[0] : null;
|
|
2996
|
+
} catch (error) {
|
|
2997
|
+
console.error("获取当前用户信息失败:", error);
|
|
2998
|
+
return null;
|
|
2999
|
+
} finally {
|
|
3000
|
+
loading.value = false;
|
|
3001
|
+
}
|
|
3002
|
+
};
|
|
3003
|
+
return {
|
|
3004
|
+
loading,
|
|
3005
|
+
fetchCurrentUser
|
|
3006
|
+
};
|
|
3007
|
+
};
|
|
3008
|
+
/*! js-cookie v3.0.5 | MIT */
|
|
3009
|
+
function assign(target) {
|
|
3010
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
3011
|
+
var source = arguments[i];
|
|
3012
|
+
for (var key in source) {
|
|
3013
|
+
target[key] = source[key];
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
return target;
|
|
3017
|
+
}
|
|
3018
|
+
var defaultConverter = {
|
|
3019
|
+
read: function(value) {
|
|
3020
|
+
if (value[0] === '"') {
|
|
3021
|
+
value = value.slice(1, -1);
|
|
3022
|
+
}
|
|
3023
|
+
return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
3024
|
+
},
|
|
3025
|
+
write: function(value) {
|
|
3026
|
+
return encodeURIComponent(value).replace(
|
|
3027
|
+
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
3028
|
+
decodeURIComponent
|
|
3029
|
+
);
|
|
3030
|
+
}
|
|
3031
|
+
};
|
|
3032
|
+
function init(converter, defaultAttributes) {
|
|
3033
|
+
function set(name, value, attributes) {
|
|
3034
|
+
if (typeof document === "undefined") {
|
|
3035
|
+
return;
|
|
3036
|
+
}
|
|
3037
|
+
attributes = assign({}, defaultAttributes, attributes);
|
|
3038
|
+
if (typeof attributes.expires === "number") {
|
|
3039
|
+
attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
|
|
3040
|
+
}
|
|
3041
|
+
if (attributes.expires) {
|
|
3042
|
+
attributes.expires = attributes.expires.toUTCString();
|
|
3043
|
+
}
|
|
3044
|
+
name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
3045
|
+
var stringifiedAttributes = "";
|
|
3046
|
+
for (var attributeName in attributes) {
|
|
3047
|
+
if (!attributes[attributeName]) {
|
|
3048
|
+
continue;
|
|
3049
|
+
}
|
|
3050
|
+
stringifiedAttributes += "; " + attributeName;
|
|
3051
|
+
if (attributes[attributeName] === true) {
|
|
3052
|
+
continue;
|
|
3053
|
+
}
|
|
3054
|
+
stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
|
|
3055
|
+
}
|
|
3056
|
+
return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes;
|
|
3057
|
+
}
|
|
3058
|
+
function get(name) {
|
|
3059
|
+
if (typeof document === "undefined" || arguments.length && !name) {
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3062
|
+
var cookies = document.cookie ? document.cookie.split("; ") : [];
|
|
3063
|
+
var jar = {};
|
|
3064
|
+
for (var i = 0; i < cookies.length; i++) {
|
|
3065
|
+
var parts = cookies[i].split("=");
|
|
3066
|
+
var value = parts.slice(1).join("=");
|
|
3067
|
+
try {
|
|
3068
|
+
var found = decodeURIComponent(parts[0]);
|
|
3069
|
+
jar[found] = converter.read(value, found);
|
|
3070
|
+
if (name === found) {
|
|
3071
|
+
break;
|
|
3072
|
+
}
|
|
3073
|
+
} catch (e) {
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
return name ? jar[name] : jar;
|
|
3077
|
+
}
|
|
3078
|
+
return Object.create(
|
|
3079
|
+
{
|
|
3080
|
+
set,
|
|
3081
|
+
get,
|
|
3082
|
+
remove: function(name, attributes) {
|
|
3083
|
+
set(
|
|
3084
|
+
name,
|
|
3085
|
+
"",
|
|
3086
|
+
assign({}, attributes, {
|
|
3087
|
+
expires: -1
|
|
3088
|
+
})
|
|
3089
|
+
);
|
|
3090
|
+
},
|
|
3091
|
+
withAttributes: function(attributes) {
|
|
3092
|
+
return init(this.converter, assign({}, this.attributes, attributes));
|
|
3093
|
+
},
|
|
3094
|
+
withConverter: function(converter2) {
|
|
3095
|
+
return init(assign({}, this.converter, converter2), this.attributes);
|
|
3096
|
+
}
|
|
3097
|
+
},
|
|
3098
|
+
{
|
|
3099
|
+
attributes: { value: Object.freeze(defaultAttributes) },
|
|
3100
|
+
converter: { value: Object.freeze(converter) }
|
|
3101
|
+
}
|
|
3102
|
+
);
|
|
3103
|
+
}
|
|
3104
|
+
var api = init(defaultConverter, { path: "/" });
|
|
3105
|
+
const enUS = {
|
|
3106
|
+
我: "Me",
|
|
3107
|
+
请输入人员名称搜索: "Please enter the name of the user to search",
|
|
3108
|
+
用户群组: "User Group",
|
|
3109
|
+
无匹配人员: "No matching users",
|
|
3110
|
+
虚拟账号: "Virtual Account",
|
|
3111
|
+
用户: "User"
|
|
3112
|
+
};
|
|
3113
|
+
const zhCN = {
|
|
3114
|
+
我: "我",
|
|
3115
|
+
请输入人员名称搜索: "请输入人员名称搜索",
|
|
3116
|
+
用户群组: "用户群组",
|
|
3117
|
+
无匹配人员: "无匹配人员",
|
|
3118
|
+
虚拟账号: "虚拟账号",
|
|
3119
|
+
用户: "用户"
|
|
3120
|
+
};
|
|
3121
|
+
const BLUEKINNG_LANGUAGE = "blueking_language";
|
|
3122
|
+
const languageMap = {
|
|
3123
|
+
"en-US": enUS,
|
|
3124
|
+
"zh-CN": zhCN
|
|
3125
|
+
};
|
|
3126
|
+
const getPath = (obj, path, variables) => {
|
|
3127
|
+
const pathStack = /^\w/.test(path) ? path.split(".") : [path];
|
|
3128
|
+
const { length } = pathStack;
|
|
3129
|
+
let target = obj;
|
|
3130
|
+
let i = 0;
|
|
3131
|
+
while (i <= length && target) {
|
|
3132
|
+
if (typeof target === "string") {
|
|
3133
|
+
return target;
|
|
3134
|
+
}
|
|
3135
|
+
if (variables) {
|
|
3136
|
+
target = target[pathStack[i]];
|
|
3137
|
+
Object.keys(variables).forEach((key) => {
|
|
3138
|
+
target = target.replace(`{${key}}`, variables[key]);
|
|
3139
|
+
});
|
|
3140
|
+
} else {
|
|
3141
|
+
target = target[pathStack[i]];
|
|
3142
|
+
}
|
|
3143
|
+
i = i + 1;
|
|
3144
|
+
if (!target) {
|
|
3145
|
+
return target;
|
|
3146
|
+
}
|
|
3147
|
+
}
|
|
3148
|
+
return target;
|
|
3149
|
+
};
|
|
3150
|
+
const useI18n = () => {
|
|
3151
|
+
let localeLanguage = "zh-CN";
|
|
3152
|
+
const bluekingLanguage = api.get(BLUEKINNG_LANGUAGE);
|
|
3153
|
+
if (bluekingLanguage && bluekingLanguage.toLowerCase() === "en") {
|
|
3154
|
+
localeLanguage = "en-US";
|
|
3155
|
+
}
|
|
3156
|
+
const languagePackage = languageMap[localeLanguage];
|
|
3157
|
+
const t = (path, variable) => {
|
|
3158
|
+
const value = getPath(languagePackage, path, variable);
|
|
3159
|
+
if (value === void 0) {
|
|
3160
|
+
console.warn(`缺少索引 * ${path} *`);
|
|
3161
|
+
}
|
|
3162
|
+
return value;
|
|
3163
|
+
};
|
|
3164
|
+
return {
|
|
3165
|
+
local: localeLanguage,
|
|
3166
|
+
t
|
|
3167
|
+
};
|
|
3168
|
+
};
|
|
3169
|
+
const useInputHandler = (options) => {
|
|
3170
|
+
const {
|
|
3171
|
+
apiBaseUrl,
|
|
3172
|
+
tenantId,
|
|
3173
|
+
searchQuery,
|
|
3174
|
+
selectedUsers,
|
|
3175
|
+
allowCreate = false,
|
|
3176
|
+
freePaste = false,
|
|
3177
|
+
enableMultiTenantMode = true,
|
|
3178
|
+
maxCount = 0,
|
|
3179
|
+
onAddUser,
|
|
3180
|
+
onBatchAddUsers
|
|
3181
|
+
} = options;
|
|
3182
|
+
const isPasting = ref(false);
|
|
3183
|
+
const createCustomUser = (loginName) => ({
|
|
3184
|
+
id: loginName,
|
|
3185
|
+
name: loginName,
|
|
3186
|
+
type: USER_TYPE.CUSTOM,
|
|
3187
|
+
tenantId: "",
|
|
3188
|
+
login_name: loginName
|
|
3189
|
+
});
|
|
3190
|
+
const parsePastedText = (text) => {
|
|
3191
|
+
const usersList = text.split(/[,,;\n\s]+/).filter(Boolean);
|
|
3192
|
+
return usersList.map((user) => user.trim().replace(/\s*\(.*?\)\s*/, "")).filter(Boolean);
|
|
3193
|
+
};
|
|
3194
|
+
const mergeUsers = (existingUsers, newUsers) => {
|
|
3195
|
+
const userMap = /* @__PURE__ */ new Map();
|
|
3196
|
+
for (const user of [...existingUsers, ...newUsers]) {
|
|
3197
|
+
if (!userMap.has(user.id)) {
|
|
3198
|
+
userMap.set(user.id, user);
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3201
|
+
return Array.from(userMap.values());
|
|
3202
|
+
};
|
|
3203
|
+
const handleEnterCreate = (event) => {
|
|
3204
|
+
if (event.key !== "Enter" || !allowCreate || !searchQuery.value.trim()) {
|
|
3205
|
+
return;
|
|
3206
|
+
}
|
|
3207
|
+
const customUser = createCustomUser(searchQuery.value.trim());
|
|
3208
|
+
const isDuplicate = selectedUsers.value.some((user) => user.id === customUser.id);
|
|
3209
|
+
if (!isDuplicate) {
|
|
3210
|
+
onAddUser(customUser);
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
const handlePaste = async (event) => {
|
|
3214
|
+
var _a, _b;
|
|
3215
|
+
event.preventDefault();
|
|
3216
|
+
const pastedText = (_b = (_a = event.clipboardData) == null ? void 0 : _a.getData("text")) == null ? void 0 : _b.trim();
|
|
3217
|
+
if (!pastedText) return;
|
|
3218
|
+
isPasting.value = true;
|
|
3219
|
+
try {
|
|
3220
|
+
const usersList = parsePastedText(pastedText);
|
|
3221
|
+
if (usersList.length === 0) return;
|
|
3222
|
+
const result = await lookupUsers({
|
|
3223
|
+
apiBaseUrl,
|
|
3224
|
+
tenantId,
|
|
3225
|
+
exactSearchKey: "login_name",
|
|
3226
|
+
usersList,
|
|
3227
|
+
enableMultiTenantMode
|
|
3228
|
+
});
|
|
3229
|
+
const formattedUsers = formatUsers(result, enableMultiTenantMode);
|
|
3230
|
+
if (onBatchAddUsers) {
|
|
3231
|
+
let mergedUsers = mergeUsers(selectedUsers.value, formattedUsers);
|
|
3232
|
+
if (freePaste) {
|
|
3233
|
+
for (const loginName of usersList) {
|
|
3234
|
+
const isDuplicate = mergedUsers.some((item) => item.login_name === loginName || item.id === loginName);
|
|
3235
|
+
if (!isDuplicate) {
|
|
3236
|
+
mergedUsers.push(createCustomUser(loginName));
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
if (maxCount > 0 && mergedUsers.length > maxCount) {
|
|
3241
|
+
mergedUsers = mergedUsers.slice(0, maxCount);
|
|
3242
|
+
}
|
|
3243
|
+
onBatchAddUsers(mergedUsers);
|
|
3244
|
+
} else {
|
|
3245
|
+
if (formattedUsers.length > 0) {
|
|
3246
|
+
onAddUser(formattedUsers[0]);
|
|
3247
|
+
} else if (freePaste && usersList.length > 0) {
|
|
3248
|
+
onAddUser(createCustomUser(usersList[0]));
|
|
3249
|
+
}
|
|
3250
|
+
}
|
|
3251
|
+
} catch (error) {
|
|
3252
|
+
console.error("精准查找用户失败:", error);
|
|
3253
|
+
} finally {
|
|
3254
|
+
isPasting.value = false;
|
|
3255
|
+
}
|
|
3256
|
+
};
|
|
3257
|
+
return {
|
|
3258
|
+
isPasting,
|
|
3259
|
+
parsePastedText,
|
|
3260
|
+
handleEnterCreate,
|
|
3261
|
+
handlePaste
|
|
3262
|
+
};
|
|
3263
|
+
};
|
|
3264
|
+
const useResizeObserver = (target, callback, options = {}) => {
|
|
3265
|
+
const { immediate = true } = options;
|
|
3266
|
+
let observer = null;
|
|
3267
|
+
const cleanup = () => {
|
|
3268
|
+
if (observer) {
|
|
3269
|
+
observer.disconnect();
|
|
3270
|
+
observer = null;
|
|
3271
|
+
}
|
|
3272
|
+
};
|
|
3273
|
+
const observe = () => {
|
|
3274
|
+
cleanup();
|
|
3275
|
+
if (!target.value) return;
|
|
3276
|
+
observer = new ResizeObserver((entries) => {
|
|
3277
|
+
for (const entry of entries) {
|
|
3278
|
+
callback(entry);
|
|
3279
|
+
}
|
|
3280
|
+
});
|
|
3281
|
+
observer.observe(target.value);
|
|
3282
|
+
if (immediate && target.value) {
|
|
3283
|
+
const rect = target.value.getBoundingClientRect();
|
|
3284
|
+
const entry = {
|
|
3285
|
+
target: target.value,
|
|
3286
|
+
contentRect: rect,
|
|
3287
|
+
borderBoxSize: [{ blockSize: rect.height, inlineSize: rect.width }],
|
|
3288
|
+
contentBoxSize: [{ blockSize: rect.height, inlineSize: rect.width }],
|
|
3289
|
+
devicePixelContentBoxSize: [{ blockSize: rect.height, inlineSize: rect.width }]
|
|
3290
|
+
};
|
|
3291
|
+
callback(entry);
|
|
3292
|
+
}
|
|
3293
|
+
};
|
|
3294
|
+
watch(target, observe, { immediate: true });
|
|
3295
|
+
onUnmounted(cleanup);
|
|
3296
|
+
return cleanup;
|
|
3297
|
+
};
|
|
3298
|
+
const useTenantData = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
3299
|
+
const tenants = ref({});
|
|
3300
|
+
const loading = ref(false);
|
|
3301
|
+
const fetchTenants = async () => {
|
|
3302
|
+
if (!apiBaseUrl || !tenantId) {
|
|
3303
|
+
console.warn("获取租户需要提供有效的API基础URL和租户ID");
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
loading.value = true;
|
|
3307
|
+
try {
|
|
3308
|
+
const result = await getTenants(apiBaseUrl, tenantId);
|
|
3309
|
+
const tenantMap = {};
|
|
3310
|
+
result.forEach((item) => {
|
|
3311
|
+
if (item.id && item.name) {
|
|
3312
|
+
tenantMap[item.id] = item.name;
|
|
3113
3313
|
}
|
|
3114
3314
|
});
|
|
3315
|
+
tenants.value = tenantMap;
|
|
3316
|
+
} catch (error) {
|
|
3317
|
+
console.error("获取租户数据失败:", error);
|
|
3318
|
+
} finally {
|
|
3319
|
+
loading.value = false;
|
|
3115
3320
|
}
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
});
|
|
3321
|
+
};
|
|
3322
|
+
onBeforeMount(() => {
|
|
3323
|
+
if (enableMultiTenantMode) {
|
|
3324
|
+
fetchTenants();
|
|
3121
3325
|
}
|
|
3122
|
-
Sortable2.mount(new AutoScrollPlugin());
|
|
3123
|
-
Sortable2.mount(Remove, Revert);
|
|
3124
|
-
Sortable2.mount(new SwapPlugin());
|
|
3125
|
-
Sortable2.mount(new MultiDragPlugin());
|
|
3126
|
-
return Sortable2;
|
|
3127
3326
|
});
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3327
|
+
return {
|
|
3328
|
+
tenants,
|
|
3329
|
+
loading,
|
|
3330
|
+
fetchTenants
|
|
3331
|
+
};
|
|
3332
|
+
};
|
|
3131
3333
|
const debounce = (fn, delay) => {
|
|
3132
3334
|
let timer = null;
|
|
3133
3335
|
return function(...args) {
|
|
@@ -3188,14 +3390,16 @@ const useUserSearch = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
|
3188
3390
|
loading.value = false;
|
|
3189
3391
|
}
|
|
3190
3392
|
};
|
|
3191
|
-
const debouncedSearch = debounce(performSearch,
|
|
3393
|
+
const debouncedSearch = debounce(performSearch, SEARCH_DEBOUNCE_DELAY);
|
|
3192
3394
|
const handleSearchInput = (value) => {
|
|
3193
|
-
|
|
3194
|
-
|
|
3395
|
+
loading.value = true;
|
|
3396
|
+
searchQuery.value = value.trim();
|
|
3397
|
+
debouncedSearch(searchQuery.value);
|
|
3195
3398
|
};
|
|
3196
3399
|
const clearSearch = () => {
|
|
3197
3400
|
searchQuery.value = "";
|
|
3198
3401
|
searchResults.value = [];
|
|
3402
|
+
loading.value = false;
|
|
3199
3403
|
};
|
|
3200
3404
|
return {
|
|
3201
3405
|
searchResults,
|
|
@@ -3206,26 +3410,57 @@ const useUserSearch = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
|
3206
3410
|
clearSearch
|
|
3207
3411
|
};
|
|
3208
3412
|
};
|
|
3209
|
-
const
|
|
3413
|
+
const useUserSelection = (options) => {
|
|
3414
|
+
const { selectedUserIds, excludeUserIds, userGroup, searchQuery } = options;
|
|
3415
|
+
const createCustomUser = (loginName) => ({
|
|
3416
|
+
id: loginName,
|
|
3417
|
+
name: loginName,
|
|
3418
|
+
type: USER_TYPE.CUSTOM,
|
|
3419
|
+
tenantId: "",
|
|
3420
|
+
login_name: loginName
|
|
3421
|
+
});
|
|
3422
|
+
const isUserSelected = (userId) => {
|
|
3423
|
+
return selectedUserIds.value.includes(userId);
|
|
3424
|
+
};
|
|
3425
|
+
const filterOptions = (options2) => {
|
|
3426
|
+
return options2.filter((user) => !isUserSelected(user.id)).filter((user) => {
|
|
3427
|
+
var _a;
|
|
3428
|
+
return !((_a = excludeUserIds == null ? void 0 : excludeUserIds.value) == null ? void 0 : _a.includes(user.id));
|
|
3429
|
+
});
|
|
3430
|
+
};
|
|
3431
|
+
const filteredUserGroup = computed(() => {
|
|
3432
|
+
var _a;
|
|
3433
|
+
if (!((_a = userGroup == null ? void 0 : userGroup.value) == null ? void 0 : _a.length)) {
|
|
3434
|
+
return [];
|
|
3435
|
+
}
|
|
3436
|
+
return userGroup.value.filter((group) => {
|
|
3437
|
+
var _a2, _b;
|
|
3438
|
+
const isNotSelectedAndVisible = !isUserSelected(group.id) && !group.hidden;
|
|
3439
|
+
if (!isNotSelectedAndVisible) {
|
|
3440
|
+
return false;
|
|
3441
|
+
}
|
|
3442
|
+
const query = searchQuery.value.trim();
|
|
3443
|
+
if (!query) {
|
|
3444
|
+
return true;
|
|
3445
|
+
}
|
|
3446
|
+
return ((_a2 = group.id) == null ? void 0 : _a2.includes(query)) || ((_b = group.name) == null ? void 0 : _b.includes(query));
|
|
3447
|
+
});
|
|
3448
|
+
});
|
|
3449
|
+
return {
|
|
3450
|
+
createCustomUser,
|
|
3451
|
+
isUserSelected,
|
|
3452
|
+
filterOptions,
|
|
3453
|
+
filteredUserGroup
|
|
3454
|
+
};
|
|
3455
|
+
};
|
|
3456
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
3210
3457
|
...{
|
|
3211
3458
|
name: "MeTag"
|
|
3212
3459
|
},
|
|
3213
3460
|
__name: "me-tag",
|
|
3214
3461
|
props: {
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
*/
|
|
3218
|
-
currentUserId: {
|
|
3219
|
-
type: String,
|
|
3220
|
-
default: ""
|
|
3221
|
-
},
|
|
3222
|
-
/**
|
|
3223
|
-
* 是否禁用
|
|
3224
|
-
*/
|
|
3225
|
-
isDisabled: {
|
|
3226
|
-
type: Boolean,
|
|
3227
|
-
default: false
|
|
3228
|
-
}
|
|
3462
|
+
currentUserId: { default: "" },
|
|
3463
|
+
isDisabled: { type: Boolean, default: false }
|
|
3229
3464
|
},
|
|
3230
3465
|
emits: ["click"],
|
|
3231
3466
|
setup(__props, { emit: __emit }) {
|
|
@@ -3237,11 +3472,11 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
3237
3472
|
emit("click");
|
|
3238
3473
|
};
|
|
3239
3474
|
return (_ctx, _cache) => {
|
|
3240
|
-
return
|
|
3475
|
+
return _ctx.currentUserId ? (openBlock(), createElementBlock(
|
|
3241
3476
|
"div",
|
|
3242
3477
|
{
|
|
3243
3478
|
key: 0,
|
|
3244
|
-
class: normalizeClass(["me-tag", { disabled:
|
|
3479
|
+
class: normalizeClass(["me-tag", { disabled: _ctx.isDisabled }]),
|
|
3245
3480
|
onClick: withModifiers(handleClick, ["stop"])
|
|
3246
3481
|
},
|
|
3247
3482
|
toDisplayString(unref(t)("我")),
|
|
@@ -3258,7 +3493,7 @@ const _export_sfc = (sfc, props) => {
|
|
|
3258
3493
|
}
|
|
3259
3494
|
return target;
|
|
3260
3495
|
};
|
|
3261
|
-
const MeTag = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3496
|
+
const MeTag = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-4f251ce1"]]);
|
|
3262
3497
|
const UserRender = defineComponent({
|
|
3263
3498
|
name: "UserRender",
|
|
3264
3499
|
props: {
|
|
@@ -3305,106 +3540,36 @@ const UserRender = defineComponent({
|
|
|
3305
3540
|
};
|
|
3306
3541
|
}
|
|
3307
3542
|
});
|
|
3308
|
-
const _hoisted_1$
|
|
3543
|
+
const _hoisted_1$1 = {
|
|
3309
3544
|
key: 0,
|
|
3310
3545
|
class: "no-data"
|
|
3311
3546
|
};
|
|
3312
|
-
const _hoisted_2$
|
|
3547
|
+
const _hoisted_2$1 = { class: "group-name" };
|
|
3313
3548
|
const _hoisted_3$1 = { class: "group-count" };
|
|
3314
|
-
const _hoisted_4
|
|
3315
|
-
const _sfc_main$
|
|
3549
|
+
const _hoisted_4 = ["onClick"];
|
|
3550
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3316
3551
|
...{
|
|
3317
3552
|
name: "SelectionPopover"
|
|
3318
3553
|
},
|
|
3319
3554
|
__name: "selection-popover",
|
|
3320
3555
|
props: {
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
},
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
type: [Number, String],
|
|
3333
|
-
default: "auto"
|
|
3334
|
-
},
|
|
3335
|
-
/**
|
|
3336
|
-
* popover crossAxis 偏移量
|
|
3337
|
-
*/
|
|
3338
|
-
crossAxisOffset: {
|
|
3339
|
-
type: Number,
|
|
3340
|
-
default: 0
|
|
3341
|
-
},
|
|
3342
|
-
/**
|
|
3343
|
-
* 是否加载中
|
|
3344
|
-
*/
|
|
3345
|
-
loading: {
|
|
3346
|
-
type: Boolean,
|
|
3347
|
-
default: false
|
|
3348
|
-
},
|
|
3349
|
-
/**
|
|
3350
|
-
* 搜索结果选项
|
|
3351
|
-
*/
|
|
3352
|
-
options: {
|
|
3353
|
-
type: Array,
|
|
3354
|
-
default: () => []
|
|
3355
|
-
},
|
|
3356
|
-
/**
|
|
3357
|
-
* 搜索关键词
|
|
3358
|
-
*/
|
|
3359
|
-
searchQuery: {
|
|
3360
|
-
type: String,
|
|
3361
|
-
default: ""
|
|
3362
|
-
},
|
|
3363
|
-
/**
|
|
3364
|
-
* 当前租户ID
|
|
3365
|
-
*/
|
|
3366
|
-
tenantId: {
|
|
3367
|
-
type: String,
|
|
3368
|
-
default: ""
|
|
3369
|
-
},
|
|
3370
|
-
/**
|
|
3371
|
-
* 租户信息映射
|
|
3372
|
-
*/
|
|
3373
|
-
tenants: {
|
|
3374
|
-
type: Object,
|
|
3375
|
-
default: () => ({})
|
|
3376
|
-
},
|
|
3377
|
-
/**
|
|
3378
|
-
* 用户组
|
|
3379
|
-
*/
|
|
3380
|
-
userGroup: {
|
|
3381
|
-
type: Array,
|
|
3382
|
-
default: () => []
|
|
3383
|
-
},
|
|
3384
|
-
/**
|
|
3385
|
-
* 用户组名称
|
|
3386
|
-
*/
|
|
3387
|
-
userGroupName: {
|
|
3388
|
-
type: String,
|
|
3389
|
-
default: ""
|
|
3390
|
-
},
|
|
3391
|
-
/**
|
|
3392
|
-
* 无匹配人员时的提示文本
|
|
3393
|
-
*/
|
|
3394
|
-
emptyText: {
|
|
3395
|
-
type: String,
|
|
3396
|
-
default: ""
|
|
3397
|
-
},
|
|
3398
|
-
/**
|
|
3399
|
-
* 渲染列表项
|
|
3400
|
-
*/
|
|
3401
|
-
renderListItem: {
|
|
3402
|
-
type: Function
|
|
3403
|
-
}
|
|
3556
|
+
containerWidth: { default: "auto" },
|
|
3557
|
+
emptyText: { default: "" },
|
|
3558
|
+
isShow: { type: Boolean, default: false },
|
|
3559
|
+
loading: { type: Boolean, default: false },
|
|
3560
|
+
options: { default: () => [] },
|
|
3561
|
+
renderListItem: {},
|
|
3562
|
+
searchQuery: { default: "" },
|
|
3563
|
+
tenantId: { default: "" },
|
|
3564
|
+
tenants: { default: () => ({}) },
|
|
3565
|
+
userGroup: { default: () => [] },
|
|
3566
|
+
userGroupName: { default: "" }
|
|
3404
3567
|
},
|
|
3405
|
-
emits: ["
|
|
3568
|
+
emits: ["click-outside", "select-user"],
|
|
3406
3569
|
setup(__props, { emit: __emit }) {
|
|
3407
3570
|
const { t } = useI18n();
|
|
3571
|
+
const slotContainerRef = ref(null);
|
|
3572
|
+
const contentContainerRef = ref(null);
|
|
3408
3573
|
const props = __props;
|
|
3409
3574
|
const emit = __emit;
|
|
3410
3575
|
const groupedUsers = computed(() => {
|
|
@@ -3413,11 +3578,11 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3413
3578
|
groups[props.userGroupName] = props.userGroup.map((group) => ({
|
|
3414
3579
|
...group,
|
|
3415
3580
|
tenantId: "",
|
|
3416
|
-
type:
|
|
3581
|
+
type: USER_TYPE.USER_GROUP
|
|
3417
3582
|
}));
|
|
3418
3583
|
}
|
|
3419
3584
|
props.options.forEach((user) => {
|
|
3420
|
-
const groupName = user.data_source_type ===
|
|
3585
|
+
const groupName = user.data_source_type === USER_TYPE.VIRTUAL ? t("虚拟账号") : t("用户");
|
|
3421
3586
|
if (!groups[groupName]) {
|
|
3422
3587
|
groups[groupName] = [];
|
|
3423
3588
|
}
|
|
@@ -3429,106 +3594,138 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
3429
3594
|
emit("select-user", user);
|
|
3430
3595
|
};
|
|
3431
3596
|
const handleClickOutside = ({ event }) => {
|
|
3597
|
+
var _a, _b;
|
|
3598
|
+
const target = event.target;
|
|
3599
|
+
if ((_a = slotContainerRef.value) == null ? void 0 : _a.contains(target)) {
|
|
3600
|
+
return;
|
|
3601
|
+
}
|
|
3602
|
+
if ((_b = contentContainerRef.value) == null ? void 0 : _b.contains(target)) {
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3432
3605
|
emit("click-outside", event);
|
|
3433
3606
|
};
|
|
3434
3607
|
return (_ctx, _cache) => {
|
|
3435
3608
|
return openBlock(), createBlock(unref(Popover), {
|
|
3436
3609
|
arrow: false,
|
|
3437
3610
|
"ext-cls": "bk-user-selector-popover",
|
|
3438
|
-
"is-show":
|
|
3439
|
-
offset: { mainAxis: 4
|
|
3611
|
+
"is-show": _ctx.isShow,
|
|
3612
|
+
offset: { mainAxis: 4 },
|
|
3440
3613
|
placement: "bottom-start",
|
|
3441
3614
|
theme: "light",
|
|
3442
3615
|
trigger: "manual",
|
|
3443
|
-
width:
|
|
3616
|
+
width: _ctx.containerWidth,
|
|
3444
3617
|
onClickoutside: handleClickOutside
|
|
3445
3618
|
}, {
|
|
3446
3619
|
content: withCtx(() => [
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
{ key: 1 },
|
|
3465
|
-
renderList(groupedUsers.value, (group, groupName) => {
|
|
3466
|
-
return openBlock(), createElementBlock("div", {
|
|
3467
|
-
key: groupName,
|
|
3468
|
-
class: "user-group"
|
|
3469
|
-
}, [
|
|
3470
|
-
Object.keys(groupedUsers.value).length > 1 || group.some((user) => user.type === "userGroup") ? (openBlock(), createElementBlock("div", {
|
|
3471
|
-
key: 0,
|
|
3472
|
-
class: "group-header",
|
|
3473
|
-
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
3474
|
-
}, ["prevent"]))
|
|
3475
|
-
}, [
|
|
3476
|
-
createElementVNode(
|
|
3477
|
-
"span",
|
|
3478
|
-
_hoisted_2$2,
|
|
3479
|
-
toDisplayString(groupName),
|
|
3480
|
-
1
|
|
3481
|
-
/* TEXT */
|
|
3482
|
-
),
|
|
3483
|
-
createElementVNode(
|
|
3484
|
-
"span",
|
|
3485
|
-
_hoisted_3$1,
|
|
3486
|
-
"(" + toDisplayString(group.length) + ")",
|
|
3487
|
-
1
|
|
3488
|
-
/* TEXT */
|
|
3489
|
-
)
|
|
3490
|
-
])) : createCommentVNode("v-if", true),
|
|
3491
|
-
(openBlock(true), createElementBlock(
|
|
3492
|
-
Fragment,
|
|
3620
|
+
createElementVNode(
|
|
3621
|
+
"div",
|
|
3622
|
+
{
|
|
3623
|
+
ref_key: "contentContainerRef",
|
|
3624
|
+
ref: contentContainerRef
|
|
3625
|
+
},
|
|
3626
|
+
[
|
|
3627
|
+
createVNode(unref(Loading), {
|
|
3628
|
+
class: "dropdown-content",
|
|
3629
|
+
loading: _ctx.loading,
|
|
3630
|
+
mode: "spin",
|
|
3631
|
+
size: "mini"
|
|
3632
|
+
}, {
|
|
3633
|
+
default: withCtx(() => [
|
|
3634
|
+
_ctx.options.length === 0 && _ctx.userGroup.length === 0 ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
3635
|
+
createElementVNode(
|
|
3636
|
+
"span",
|
|
3493
3637
|
null,
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3638
|
+
toDisplayString(_ctx.emptyText),
|
|
3639
|
+
1
|
|
3640
|
+
/* TEXT */
|
|
3641
|
+
)
|
|
3642
|
+
])) : (openBlock(true), createElementBlock(
|
|
3643
|
+
Fragment,
|
|
3644
|
+
{ key: 1 },
|
|
3645
|
+
renderList(groupedUsers.value, (group, groupName) => {
|
|
3646
|
+
return openBlock(), createElementBlock("div", {
|
|
3647
|
+
key: groupName,
|
|
3648
|
+
class: "user-group"
|
|
3649
|
+
}, [
|
|
3650
|
+
Object.keys(groupedUsers.value).length > 1 || group.some((user) => user.type === "userGroup") ? (openBlock(), createElementBlock("div", {
|
|
3651
|
+
key: 0,
|
|
3652
|
+
class: "group-header",
|
|
3653
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
3654
|
+
}, ["prevent"]))
|
|
3499
3655
|
}, [
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3656
|
+
createElementVNode(
|
|
3657
|
+
"span",
|
|
3658
|
+
_hoisted_2$1,
|
|
3659
|
+
toDisplayString(groupName),
|
|
3660
|
+
1
|
|
3661
|
+
/* TEXT */
|
|
3662
|
+
),
|
|
3663
|
+
createElementVNode(
|
|
3664
|
+
"span",
|
|
3665
|
+
_hoisted_3$1,
|
|
3666
|
+
"(" + toDisplayString(group.length) + ")",
|
|
3667
|
+
1
|
|
3668
|
+
/* TEXT */
|
|
3669
|
+
)
|
|
3670
|
+
])) : createCommentVNode("v-if", true),
|
|
3671
|
+
(openBlock(true), createElementBlock(
|
|
3672
|
+
Fragment,
|
|
3673
|
+
null,
|
|
3674
|
+
renderList(group, (user) => {
|
|
3675
|
+
return openBlock(), createElementBlock("div", {
|
|
3676
|
+
key: user.id,
|
|
3677
|
+
class: "user-option",
|
|
3678
|
+
onClick: withModifiers(($event) => selectUser(user), ["prevent"]),
|
|
3679
|
+
onMousedown: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
3680
|
+
}, ["prevent"]))
|
|
3681
|
+
}, [
|
|
3682
|
+
createVNode(unref(UserRender), {
|
|
3683
|
+
render: _ctx.renderListItem,
|
|
3684
|
+
"tenant-id": _ctx.tenantId,
|
|
3685
|
+
tenants: _ctx.tenants,
|
|
3686
|
+
user
|
|
3687
|
+
}, null, 8, ["render", "tenant-id", "tenants", "user"])
|
|
3688
|
+
], 40, _hoisted_4);
|
|
3689
|
+
}),
|
|
3690
|
+
128
|
|
3691
|
+
/* KEYED_FRAGMENT */
|
|
3692
|
+
))
|
|
3693
|
+
]);
|
|
3694
|
+
}),
|
|
3695
|
+
128
|
|
3696
|
+
/* KEYED_FRAGMENT */
|
|
3697
|
+
))
|
|
3698
|
+
]),
|
|
3699
|
+
_: 1
|
|
3700
|
+
/* STABLE */
|
|
3701
|
+
}, 8, ["loading"])
|
|
3702
|
+
],
|
|
3703
|
+
512
|
|
3704
|
+
/* NEED_PATCH */
|
|
3705
|
+
)
|
|
3520
3706
|
]),
|
|
3521
3707
|
default: withCtx(() => [
|
|
3522
|
-
|
|
3708
|
+
createElementVNode(
|
|
3709
|
+
"div",
|
|
3710
|
+
{
|
|
3711
|
+
ref_key: "slotContainerRef",
|
|
3712
|
+
ref: slotContainerRef
|
|
3713
|
+
},
|
|
3714
|
+
[
|
|
3715
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
3716
|
+
],
|
|
3717
|
+
512
|
|
3718
|
+
/* NEED_PATCH */
|
|
3719
|
+
)
|
|
3523
3720
|
]),
|
|
3524
3721
|
_: 3
|
|
3525
3722
|
/* FORWARDED */
|
|
3526
|
-
}, 8, ["is-show", "
|
|
3723
|
+
}, 8, ["is-show", "width"]);
|
|
3527
3724
|
};
|
|
3528
3725
|
}
|
|
3529
3726
|
});
|
|
3530
|
-
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3531
|
-
const _sfc_main$
|
|
3727
|
+
const SelectionPopover = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-024fc663"]]);
|
|
3728
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
3532
3729
|
...{
|
|
3533
3730
|
name: "UserTag"
|
|
3534
3731
|
},
|
|
@@ -3573,84 +3770,172 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
3573
3770
|
};
|
|
3574
3771
|
}
|
|
3575
3772
|
});
|
|
3576
|
-
const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$
|
|
3577
|
-
const _hoisted_1
|
|
3578
|
-
const _hoisted_2
|
|
3579
|
-
const _hoisted_3 =
|
|
3580
|
-
const
|
|
3581
|
-
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3773
|
+
const UserTag = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-48ac8fc1"]]);
|
|
3774
|
+
const _hoisted_1 = ["placeholder"];
|
|
3775
|
+
const _hoisted_2 = { class: "hidden-users" };
|
|
3776
|
+
const _hoisted_3 = ["placeholder"];
|
|
3777
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3582
3778
|
...{
|
|
3583
|
-
name: "
|
|
3779
|
+
name: "BkUserSelector"
|
|
3584
3780
|
},
|
|
3585
|
-
__name: "
|
|
3781
|
+
__name: "user-selector",
|
|
3586
3782
|
props: {
|
|
3587
3783
|
draggable: { type: Boolean, default: false },
|
|
3588
|
-
|
|
3589
|
-
modelValue: { default:
|
|
3590
|
-
|
|
3591
|
-
tenants: { default: () => ({}) },
|
|
3784
|
+
maxCount: { default: 0 },
|
|
3785
|
+
modelValue: { default: "" },
|
|
3786
|
+
multiple: { type: Boolean, default: false },
|
|
3592
3787
|
allowCreate: { type: Boolean, default: false },
|
|
3593
3788
|
apiBaseUrl: { default: "" },
|
|
3594
3789
|
currentUserId: { default: "" },
|
|
3595
|
-
disabled: { type: Boolean },
|
|
3790
|
+
disabled: { type: Boolean, default: false },
|
|
3596
3791
|
emptyText: { default: "" },
|
|
3597
|
-
enableMultiTenantMode: { type: Boolean },
|
|
3598
|
-
exactSearchKey: { default:
|
|
3792
|
+
enableMultiTenantMode: { type: Boolean, default: true },
|
|
3793
|
+
exactSearchKey: { default: DEFAULT_EXACT_SEARCH_KEY },
|
|
3599
3794
|
excludeUserIds: { default: () => [] },
|
|
3795
|
+
freePaste: { type: Boolean, default: false },
|
|
3600
3796
|
placeholder: { default: "" },
|
|
3601
|
-
tenantId: { default: "" },
|
|
3602
|
-
userGroupName: { default: "" },
|
|
3603
3797
|
renderListItem: {},
|
|
3604
3798
|
renderTag: {},
|
|
3605
|
-
|
|
3799
|
+
tenantId: { default: "" },
|
|
3800
|
+
userGroup: { default: () => [] },
|
|
3801
|
+
userGroupName: { default: "" }
|
|
3606
3802
|
},
|
|
3607
|
-
emits: [
|
|
3608
|
-
"update:selectedUsers",
|
|
3609
|
-
"add-user",
|
|
3610
|
-
"remove-user",
|
|
3611
|
-
"dragStart",
|
|
3612
|
-
"dragEnd",
|
|
3613
|
-
"focus",
|
|
3614
|
-
"blur"
|
|
3615
|
-
],
|
|
3803
|
+
emits: ["blur", "change", "dragEnd", "dragStart", "focus", "update:modelValue"],
|
|
3616
3804
|
setup(__props, { emit: __emit }) {
|
|
3805
|
+
const { t } = useI18n();
|
|
3806
|
+
provideGlobalConfig({
|
|
3807
|
+
prefix: "bk"
|
|
3808
|
+
});
|
|
3617
3809
|
const props = __props;
|
|
3618
3810
|
const emit = __emit;
|
|
3811
|
+
const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
|
|
3619
3812
|
const {
|
|
3620
3813
|
searchResults,
|
|
3621
3814
|
loading: searchLoading,
|
|
3622
3815
|
searchQuery,
|
|
3623
|
-
|
|
3816
|
+
clearSearch,
|
|
3624
3817
|
handleSearchInput
|
|
3625
3818
|
} = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
|
|
3819
|
+
const { fetchCurrentUser } = useCurrentUser({
|
|
3820
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
3821
|
+
tenantId: props.tenantId,
|
|
3822
|
+
currentUserId: props.currentUserId || "",
|
|
3823
|
+
exactSearchKey: props.exactSearchKey,
|
|
3824
|
+
enableMultiTenantMode: props.enableMultiTenantMode
|
|
3825
|
+
});
|
|
3626
3826
|
const containerRef = ref(null);
|
|
3627
|
-
const tagsContainerRef = ref(null);
|
|
3628
3827
|
const sortableContainerRef = ref(null);
|
|
3629
3828
|
const collapsedContainerRef = ref(null);
|
|
3630
3829
|
const inlineInputRef = ref(null);
|
|
3631
3830
|
const lastInputRef = ref(null);
|
|
3632
|
-
const collapsedInputRef = ref(null);
|
|
3633
3831
|
const isFocused = ref(false);
|
|
3634
|
-
const showDropdown = ref(false);
|
|
3635
3832
|
const activeTagIndex = ref(-1);
|
|
3636
3833
|
const sortableInstance = ref(null);
|
|
3637
3834
|
const visibleUsers = ref([]);
|
|
3638
3835
|
const hiddenCount = ref(0);
|
|
3639
|
-
const
|
|
3640
|
-
|
|
3836
|
+
const selectedUsers = ref([]);
|
|
3837
|
+
const showDropdown = computed(() => {
|
|
3838
|
+
return isFocused.value && (props.userGroup.length > 0 || searchQuery.value.trim() !== "");
|
|
3641
3839
|
});
|
|
3642
|
-
const
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3840
|
+
const modelValueIds = computed(() => {
|
|
3841
|
+
if (props.multiple) {
|
|
3842
|
+
return Array.isArray(props.modelValue) ? props.modelValue : [];
|
|
3843
|
+
}
|
|
3844
|
+
return props.modelValue ? [props.modelValue] : [];
|
|
3845
|
+
});
|
|
3846
|
+
const computedPlaceholder = computed(() => props.placeholder || t("请输入人员名称搜索"));
|
|
3847
|
+
const computedUserGroupName = computed(() => props.userGroupName || t("用户群组"));
|
|
3848
|
+
const computedEmptyText = computed(() => props.emptyText || t("无匹配人员"));
|
|
3849
|
+
const selectedUserIds = computed(() => selectedUsers.value.map((user) => user.id));
|
|
3850
|
+
const isMaxCountReached = computed(() => {
|
|
3851
|
+
if (!props.maxCount || props.maxCount <= 0) return false;
|
|
3852
|
+
return selectedUsers.value.length >= props.maxCount;
|
|
3853
|
+
});
|
|
3854
|
+
const isMeTagDisabled = computed(
|
|
3855
|
+
() => isMaxCountReached.value || !!props.currentUserId && selectedUsers.value.some((user) => user[props.exactSearchKey] === props.currentUserId)
|
|
3856
|
+
);
|
|
3857
|
+
const userTagCommonProps = computed(() => ({
|
|
3858
|
+
currentTenantId: props.tenantId,
|
|
3859
|
+
renderTag: props.renderTag,
|
|
3860
|
+
tenants
|
|
3861
|
+
}));
|
|
3862
|
+
const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
|
|
3863
|
+
selectedUserIds,
|
|
3864
|
+
excludeUserIds: toRef(props, "excludeUserIds"),
|
|
3865
|
+
userGroup: toRef(props, "userGroup"),
|
|
3866
|
+
searchQuery
|
|
3867
|
+
});
|
|
3868
|
+
const { handlePaste } = useInputHandler({
|
|
3869
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
3870
|
+
tenantId: props.tenantId,
|
|
3871
|
+
searchQuery,
|
|
3872
|
+
selectedUsers,
|
|
3873
|
+
allowCreate: props.allowCreate,
|
|
3874
|
+
freePaste: props.freePaste,
|
|
3875
|
+
enableMultiTenantMode: props.enableMultiTenantMode,
|
|
3876
|
+
maxCount: props.maxCount,
|
|
3877
|
+
onAddUser: addUser,
|
|
3878
|
+
onBatchAddUsers: props.multiple ? updateSelectedUsers : void 0
|
|
3651
3879
|
});
|
|
3880
|
+
const displayOptions = computed(() => filterOptions(searchResults.value));
|
|
3881
|
+
const inputWidth = computed(() => {
|
|
3882
|
+
const query = searchQuery.value;
|
|
3883
|
+
if (!query) return "20px";
|
|
3884
|
+
const charWidth = query.split("").reduce((acc, char) => {
|
|
3885
|
+
return acc + (/[\u4e00-\u9fa5]/.test(char) ? 12 : 8);
|
|
3886
|
+
}, 0);
|
|
3887
|
+
return `${Math.max(20, charWidth + 4)}px`;
|
|
3888
|
+
});
|
|
3889
|
+
const initSelectedUsers = async () => {
|
|
3890
|
+
const ids = modelValueIds.value;
|
|
3891
|
+
if (ids.length === 0) {
|
|
3892
|
+
selectedUsers.value = [];
|
|
3893
|
+
return;
|
|
3894
|
+
}
|
|
3895
|
+
let userGroupSelected = [];
|
|
3896
|
+
if (props.userGroup.length > 0) {
|
|
3897
|
+
const result = props.userGroup.filter((group) => ids.includes(group.id));
|
|
3898
|
+
userGroupSelected = result.map((group) => ({
|
|
3899
|
+
...group,
|
|
3900
|
+
tenantId: "",
|
|
3901
|
+
type: USER_TYPE.USER_GROUP
|
|
3902
|
+
}));
|
|
3903
|
+
}
|
|
3904
|
+
try {
|
|
3905
|
+
const result = await lookupUsers({
|
|
3906
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
3907
|
+
tenantId: props.tenantId,
|
|
3908
|
+
exactSearchKey: "bk_username",
|
|
3909
|
+
usersList: ids,
|
|
3910
|
+
enableMultiTenantMode: props.enableMultiTenantMode
|
|
3911
|
+
});
|
|
3912
|
+
const selectedList = [...userGroupSelected, ...formatUsers(result, props.enableMultiTenantMode)];
|
|
3913
|
+
if (props.allowCreate) {
|
|
3914
|
+
selectedList.push(
|
|
3915
|
+
...ids.filter((id) => !selectedList.some((user) => user.id === id)).map((id) => ({ id, name: id, type: USER_TYPE.CUSTOM, tenantId: "" }))
|
|
3916
|
+
);
|
|
3917
|
+
}
|
|
3918
|
+
selectedUsers.value = ids.map((id) => selectedList.find((user) => user.id === id)).filter(Boolean);
|
|
3919
|
+
} catch (error) {
|
|
3920
|
+
console.error("获取选中用户信息失败:", error);
|
|
3921
|
+
selectedUsers.value = [];
|
|
3922
|
+
}
|
|
3923
|
+
};
|
|
3924
|
+
function updateSelectedUsers(users) {
|
|
3925
|
+
selectedUsers.value = users;
|
|
3926
|
+
if (props.multiple) {
|
|
3927
|
+
const ids = users.map((user) => user.id);
|
|
3928
|
+
emit("update:modelValue", ids);
|
|
3929
|
+
emit("change", users);
|
|
3930
|
+
} else {
|
|
3931
|
+
const user = users.length > 0 ? users[0] : null;
|
|
3932
|
+
const id = user ? user.id : "";
|
|
3933
|
+
emit("update:modelValue", id);
|
|
3934
|
+
emit("change", user);
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3652
3937
|
const initSortable = () => {
|
|
3653
|
-
if (!props.draggable || !sortableContainerRef.value) return;
|
|
3938
|
+
if (!props.draggable || !props.multiple || !sortableContainerRef.value) return;
|
|
3654
3939
|
if (sortableInstance.value) {
|
|
3655
3940
|
sortableInstance.value.destroy();
|
|
3656
3941
|
}
|
|
@@ -3663,276 +3948,206 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3663
3948
|
onEnd: (evt) => {
|
|
3664
3949
|
const { oldIndex, newIndex } = evt;
|
|
3665
3950
|
if (oldIndex === newIndex || oldIndex === void 0 || newIndex === void 0) return;
|
|
3666
|
-
const updatedUsers = [...
|
|
3951
|
+
const updatedUsers = [...selectedUsers.value];
|
|
3667
3952
|
const [movedUser] = updatedUsers.splice(oldIndex, 1);
|
|
3668
3953
|
updatedUsers.splice(newIndex, 0, movedUser);
|
|
3669
|
-
|
|
3954
|
+
updateSelectedUsers(updatedUsers);
|
|
3670
3955
|
emit("dragEnd", evt);
|
|
3671
3956
|
}
|
|
3672
3957
|
});
|
|
3673
3958
|
};
|
|
3674
3959
|
const calculateVisibleUsers = () => {
|
|
3675
|
-
if (!
|
|
3960
|
+
if (!selectedUsers.value.length) {
|
|
3676
3961
|
visibleUsers.value = [];
|
|
3677
3962
|
hiddenCount.value = 0;
|
|
3678
3963
|
return;
|
|
3679
3964
|
}
|
|
3965
|
+
if (!collapsedContainerRef.value) {
|
|
3966
|
+
visibleUsers.value = [...selectedUsers.value];
|
|
3967
|
+
hiddenCount.value = 0;
|
|
3968
|
+
return;
|
|
3969
|
+
}
|
|
3680
3970
|
const containerWidth = collapsedContainerRef.value.offsetWidth;
|
|
3681
3971
|
const tagElements = collapsedContainerRef.value.querySelectorAll(".user-tag");
|
|
3972
|
+
if (tagElements.length !== selectedUsers.value.length) {
|
|
3973
|
+
visibleUsers.value = [...selectedUsers.value];
|
|
3974
|
+
hiddenCount.value = 0;
|
|
3975
|
+
nextTick(calculateVisibleUsers);
|
|
3976
|
+
return;
|
|
3977
|
+
}
|
|
3682
3978
|
const visibleCount = calculateVisibleTags(
|
|
3683
3979
|
collapsedContainerRef.value,
|
|
3684
3980
|
tagElements,
|
|
3685
|
-
containerWidth -
|
|
3686
|
-
// 为输入框和更多标签预留空间
|
|
3981
|
+
containerWidth - RESERVED_SPACE_FOR_INPUT
|
|
3687
3982
|
);
|
|
3688
|
-
visibleUsers.value =
|
|
3689
|
-
hiddenCount.value = Math.max(0,
|
|
3983
|
+
visibleUsers.value = selectedUsers.value.slice(0, visibleCount);
|
|
3984
|
+
hiddenCount.value = Math.max(0, selectedUsers.value.length - visibleCount);
|
|
3690
3985
|
};
|
|
3691
3986
|
const handleFocus = () => {
|
|
3692
3987
|
isFocused.value = true;
|
|
3693
|
-
if (props.userGroup.length > 0) {
|
|
3694
|
-
showDropdown.value = true;
|
|
3695
|
-
} else {
|
|
3696
|
-
showDropdown.value = false;
|
|
3697
|
-
}
|
|
3698
3988
|
activeTagIndex.value = -1;
|
|
3699
3989
|
nextTick(() => {
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
}
|
|
3990
|
+
var _a;
|
|
3991
|
+
return (_a = lastInputRef.value) == null ? void 0 : _a.focus();
|
|
3703
3992
|
});
|
|
3704
3993
|
};
|
|
3994
|
+
const scheduleVisibleUsersCalculation = () => {
|
|
3995
|
+
if (!isFocused.value) {
|
|
3996
|
+
nextTick(calculateVisibleUsers);
|
|
3997
|
+
}
|
|
3998
|
+
};
|
|
3705
3999
|
const handleClickOutside = (event) => {
|
|
3706
4000
|
const target = event.target;
|
|
3707
4001
|
const container = containerRef.value;
|
|
3708
|
-
if ((container == null ? void 0 : container.contains(target)) || container === target)
|
|
3709
|
-
|
|
3710
|
-
}
|
|
3711
|
-
if (isFocused.value) {
|
|
3712
|
-
emit("blur");
|
|
3713
|
-
}
|
|
4002
|
+
if ((container == null ? void 0 : container.contains(target)) || container === target) return;
|
|
4003
|
+
if (isFocused.value) emit("blur");
|
|
3714
4004
|
isFocused.value = false;
|
|
3715
|
-
showDropdown.value = false;
|
|
3716
4005
|
activeTagIndex.value = -1;
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
calculateVisibleUsers();
|
|
3720
|
-
});
|
|
4006
|
+
clearSearch();
|
|
4007
|
+
scheduleVisibleUsersCalculation();
|
|
3721
4008
|
};
|
|
3722
4009
|
const handleContainerClick = () => {
|
|
3723
4010
|
activeTagIndex.value = -1;
|
|
3724
4011
|
nextTick(() => {
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
}
|
|
4012
|
+
var _a;
|
|
4013
|
+
return (_a = lastInputRef.value) == null ? void 0 : _a.focus();
|
|
3728
4014
|
});
|
|
3729
4015
|
};
|
|
3730
4016
|
const handleTagClick = (index) => {
|
|
3731
4017
|
activeTagIndex.value = index;
|
|
3732
4018
|
nextTick(() => {
|
|
3733
4019
|
var _a;
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
}
|
|
3738
|
-
} else if ((_a = inlineInputRef.value) == null ? void 0 : _a[0]) {
|
|
3739
|
-
inlineInputRef.value[0].focus();
|
|
3740
|
-
}
|
|
4020
|
+
const isLastTag = index === selectedUsers.value.length - 1;
|
|
4021
|
+
const targetInput = isLastTag ? lastInputRef.value : (_a = inlineInputRef.value) == null ? void 0 : _a[0];
|
|
4022
|
+
targetInput == null ? void 0 : targetInput.focus();
|
|
3741
4023
|
});
|
|
3742
4024
|
};
|
|
3743
4025
|
const handleInputFocus = () => {
|
|
3744
4026
|
emit("focus");
|
|
3745
|
-
|
|
3746
|
-
isFocused.value = true;
|
|
3747
|
-
}
|
|
3748
|
-
if (searchQuery.value.length >= 1) {
|
|
3749
|
-
showDropdown.value = true;
|
|
3750
|
-
}
|
|
4027
|
+
isFocused.value = true;
|
|
3751
4028
|
};
|
|
3752
4029
|
const handleInput = () => {
|
|
3753
4030
|
handleSearchInput(searchQuery.value);
|
|
3754
|
-
if (searchQuery.value.length >= 1) {
|
|
3755
|
-
showDropdown.value = true;
|
|
3756
|
-
} else {
|
|
3757
|
-
showDropdown.value = false;
|
|
3758
|
-
}
|
|
3759
4031
|
};
|
|
3760
4032
|
const addCurrentUser = async () => {
|
|
3761
|
-
if (!props.currentUserId ||
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
tenantId: props.tenantId,
|
|
3766
|
-
exactSearchKey: props.exactSearchKey,
|
|
3767
|
-
usersList: [props.currentUserId],
|
|
3768
|
-
enableMultiTenantMode: props.enableMultiTenantMode
|
|
3769
|
-
});
|
|
3770
|
-
const formattedUsers = formatUsers(result, props.enableMultiTenantMode);
|
|
3771
|
-
if (formattedUsers.length > 0) {
|
|
3772
|
-
if (!props.selectedUsers.some((item) => item.id === formattedUsers[0].id)) {
|
|
3773
|
-
emit("update:selectedUsers", [...props.selectedUsers, formattedUsers[0]]);
|
|
3774
|
-
emit("add-user", formattedUsers[0]);
|
|
3775
|
-
}
|
|
3776
|
-
searchQuery.value = "";
|
|
3777
|
-
showDropdown.value = false;
|
|
3778
|
-
}
|
|
3779
|
-
} catch (error) {
|
|
3780
|
-
console.error("获取当前用户信息失败:", error);
|
|
4033
|
+
if (!props.currentUserId || selectedUsers.value.some((user) => user[props.exactSearchKey] === props.currentUserId))
|
|
4034
|
+
return;
|
|
4035
|
+
if (props.multiple && isMaxCountReached.value) {
|
|
4036
|
+
return;
|
|
3781
4037
|
}
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
try {
|
|
3789
|
-
const usersList = pastedText.trim().split(/[,,;\n\s]+/).filter(Boolean);
|
|
3790
|
-
const users = usersList.map((user) => user.trim().replace(/\s*\(.*?\)\s*/, "")).filter((user) => user);
|
|
3791
|
-
const result = await lookupUsers({
|
|
3792
|
-
apiBaseUrl: props.apiBaseUrl,
|
|
3793
|
-
tenantId: props.tenantId,
|
|
3794
|
-
exactSearchKey: "login_name",
|
|
3795
|
-
usersList: users,
|
|
3796
|
-
enableMultiTenantMode: props.enableMultiTenantMode
|
|
3797
|
-
});
|
|
3798
|
-
const formattedUsers = formatUsers(result, props.enableMultiTenantMode);
|
|
3799
|
-
if (formattedUsers.length > 0) {
|
|
3800
|
-
const userMap = /* @__PURE__ */ new Map();
|
|
3801
|
-
[...props.selectedUsers, ...formattedUsers].forEach((user) => {
|
|
3802
|
-
if (!userMap.has(user.id)) {
|
|
3803
|
-
userMap.set(user.id, user);
|
|
3804
|
-
}
|
|
3805
|
-
});
|
|
3806
|
-
const updatedUsers = Array.from(userMap.values());
|
|
3807
|
-
if (props.freePaste) {
|
|
3808
|
-
const pastedUsers = usersList.map((user) => ({
|
|
3809
|
-
id: user,
|
|
3810
|
-
name: user,
|
|
3811
|
-
type: "custom",
|
|
3812
|
-
tenantId: "",
|
|
3813
|
-
login_name: user
|
|
3814
|
-
}));
|
|
3815
|
-
pastedUsers.forEach((user) => {
|
|
3816
|
-
if (!updatedUsers.some((item) => item.login_name === user.login_name)) {
|
|
3817
|
-
addUser(user);
|
|
3818
|
-
}
|
|
3819
|
-
});
|
|
3820
|
-
} else {
|
|
3821
|
-
emit("update:selectedUsers", updatedUsers);
|
|
3822
|
-
}
|
|
3823
|
-
} else {
|
|
3824
|
-
if (props.freePaste) {
|
|
3825
|
-
const pastedUsers = usersList.map((user) => ({
|
|
3826
|
-
id: user,
|
|
3827
|
-
name: user,
|
|
3828
|
-
type: "custom",
|
|
3829
|
-
tenantId: "",
|
|
3830
|
-
login_name: user
|
|
3831
|
-
}));
|
|
3832
|
-
pastedUsers.forEach((user) => {
|
|
3833
|
-
if (!props.selectedUsers.some((item) => item.login_name === user.login_name)) {
|
|
3834
|
-
addUser(user);
|
|
3835
|
-
}
|
|
3836
|
-
});
|
|
3837
|
-
}
|
|
3838
|
-
}
|
|
3839
|
-
} catch (error) {
|
|
3840
|
-
console.error("精准查找用户失败:", error);
|
|
4038
|
+
const currentUser = await fetchCurrentUser();
|
|
4039
|
+
if (currentUser) {
|
|
4040
|
+
if (!props.multiple) {
|
|
4041
|
+
updateSelectedUsers([currentUser]);
|
|
4042
|
+
} else if (!selectedUsers.value.some((item) => item.id === currentUser.id)) {
|
|
4043
|
+
updateSelectedUsers([...selectedUsers.value, currentUser]);
|
|
3841
4044
|
}
|
|
4045
|
+
clearSearch();
|
|
4046
|
+
isFocused.value = true;
|
|
4047
|
+
nextTick(() => {
|
|
4048
|
+
var _a;
|
|
4049
|
+
return (_a = lastInputRef.value) == null ? void 0 : _a.focus();
|
|
4050
|
+
});
|
|
3842
4051
|
}
|
|
3843
4052
|
};
|
|
4053
|
+
const onPaste = (event) => {
|
|
4054
|
+
handlePaste(event);
|
|
4055
|
+
};
|
|
3844
4056
|
const handleKeyDown = (event) => {
|
|
3845
|
-
if (event.key === "Backspace" && !searchQuery.value &&
|
|
4057
|
+
if (event.key === "Backspace" && !searchQuery.value && selectedUsers.value.length > 0) {
|
|
3846
4058
|
if (activeTagIndex.value >= 0) {
|
|
3847
|
-
const userToRemove =
|
|
4059
|
+
const userToRemove = selectedUsers.value[activeTagIndex.value];
|
|
3848
4060
|
removeUser(userToRemove);
|
|
3849
|
-
|
|
3850
|
-
activeTagIndex.value = activeTagIndex.value - 1;
|
|
3851
|
-
} else {
|
|
3852
|
-
activeTagIndex.value = -1;
|
|
3853
|
-
}
|
|
4061
|
+
activeTagIndex.value = activeTagIndex.value > 0 ? activeTagIndex.value - 1 : -1;
|
|
3854
4062
|
} else {
|
|
3855
|
-
const lastUser =
|
|
4063
|
+
const lastUser = selectedUsers.value[selectedUsers.value.length - 1];
|
|
3856
4064
|
removeUser(lastUser);
|
|
3857
4065
|
}
|
|
3858
|
-
} else if (event.key === "Enter" && props.allowCreate) {
|
|
3859
|
-
addUser(
|
|
3860
|
-
id: searchQuery.value,
|
|
3861
|
-
name: searchQuery.value,
|
|
3862
|
-
type: "custom",
|
|
3863
|
-
tenantId: "",
|
|
3864
|
-
login_name: searchQuery.value
|
|
3865
|
-
});
|
|
4066
|
+
} else if (event.key === "Enter" && props.allowCreate && searchQuery.value) {
|
|
4067
|
+
addUser(createCustomUser(searchQuery.value));
|
|
3866
4068
|
}
|
|
3867
4069
|
};
|
|
3868
|
-
|
|
4070
|
+
function addUser(user) {
|
|
3869
4071
|
if (!(user == null ? void 0 : user.id)) return;
|
|
3870
|
-
if (
|
|
4072
|
+
if (props.multiple && isMaxCountReached.value) {
|
|
4073
|
+
clearSearch();
|
|
4074
|
+
return;
|
|
4075
|
+
}
|
|
4076
|
+
if (!props.multiple) {
|
|
4077
|
+
updateSelectedUsers([user]);
|
|
4078
|
+
} else if (!selectedUsers.value.some((item) => item.id === user.id)) {
|
|
4079
|
+
const updatedUsers = activeTagIndex.value !== -1 ? [
|
|
4080
|
+
...selectedUsers.value.slice(0, activeTagIndex.value + 1),
|
|
4081
|
+
user,
|
|
4082
|
+
...selectedUsers.value.slice(activeTagIndex.value + 1)
|
|
4083
|
+
] : [...selectedUsers.value, user];
|
|
4084
|
+
updateSelectedUsers(updatedUsers);
|
|
4085
|
+
}
|
|
4086
|
+
if (activeTagIndex.value !== -1) {
|
|
4087
|
+
activeTagIndex.value = activeTagIndex.value + 1;
|
|
4088
|
+
}
|
|
4089
|
+
clearSearch();
|
|
4090
|
+
isFocused.value = true;
|
|
4091
|
+
nextTick(() => {
|
|
4092
|
+
var _a, _b, _c;
|
|
3871
4093
|
if (activeTagIndex.value !== -1) {
|
|
3872
|
-
|
|
3873
|
-
...props.selectedUsers.slice(0, activeTagIndex.value + 1),
|
|
3874
|
-
user,
|
|
3875
|
-
...props.selectedUsers.slice(activeTagIndex.value + 1)
|
|
3876
|
-
];
|
|
3877
|
-
emit("update:selectedUsers", updatedUsers);
|
|
4094
|
+
(_b = (_a = inlineInputRef.value) == null ? void 0 : _a[0]) == null ? void 0 : _b.focus();
|
|
3878
4095
|
} else {
|
|
3879
|
-
|
|
4096
|
+
(_c = lastInputRef.value) == null ? void 0 : _c.focus();
|
|
3880
4097
|
}
|
|
3881
|
-
emit("add-user", user);
|
|
3882
|
-
}
|
|
3883
|
-
searchQuery.value = "";
|
|
3884
|
-
showDropdown.value = false;
|
|
3885
|
-
nextTick(() => {
|
|
3886
|
-
var _a;
|
|
3887
|
-
(_a = lastInputRef.value) == null ? void 0 : _a.focus();
|
|
3888
4098
|
});
|
|
3889
|
-
}
|
|
4099
|
+
}
|
|
3890
4100
|
const removeUser = (user) => {
|
|
3891
4101
|
if (!(user == null ? void 0 : user.id)) return;
|
|
3892
|
-
const updatedUsers =
|
|
3893
|
-
|
|
3894
|
-
emit("remove-user", user);
|
|
4102
|
+
const updatedUsers = selectedUsers.value.filter((item) => item.id !== user.id);
|
|
4103
|
+
updateSelectedUsers(updatedUsers);
|
|
3895
4104
|
if (activeTagIndex.value >= updatedUsers.length) {
|
|
3896
4105
|
activeTagIndex.value = updatedUsers.length - 1;
|
|
3897
4106
|
}
|
|
3898
|
-
|
|
3899
|
-
nextTick(() => {
|
|
3900
|
-
calculateVisibleUsers();
|
|
3901
|
-
});
|
|
3902
|
-
}
|
|
4107
|
+
scheduleVisibleUsersCalculation();
|
|
3903
4108
|
};
|
|
3904
|
-
const crossAxisOffset = ref(0);
|
|
3905
4109
|
watch(
|
|
3906
|
-
|
|
4110
|
+
selectedUsers,
|
|
3907
4111
|
() => {
|
|
3908
|
-
|
|
3909
|
-
if (!isFocused.value) {
|
|
3910
|
-
nextTick(() => {
|
|
3911
|
-
calculateVisibleUsers();
|
|
3912
|
-
});
|
|
3913
|
-
}
|
|
4112
|
+
scheduleVisibleUsersCalculation();
|
|
3914
4113
|
},
|
|
3915
4114
|
{ deep: true }
|
|
3916
4115
|
);
|
|
3917
4116
|
watch(isFocused, (newVal) => {
|
|
3918
4117
|
if (newVal) {
|
|
3919
|
-
nextTick(() =>
|
|
3920
|
-
initSortable();
|
|
3921
|
-
});
|
|
4118
|
+
nextTick(() => initSortable());
|
|
3922
4119
|
}
|
|
3923
4120
|
});
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
4121
|
+
watch(
|
|
4122
|
+
() => props.userGroup,
|
|
4123
|
+
() => {
|
|
4124
|
+
initSelectedUsers();
|
|
3927
4125
|
}
|
|
3928
|
-
|
|
4126
|
+
);
|
|
4127
|
+
watch(
|
|
4128
|
+
() => props.modelValue,
|
|
4129
|
+
() => {
|
|
4130
|
+
const currentIds = selectedUsers.value.map((u) => u.id);
|
|
4131
|
+
const newIds = modelValueIds.value;
|
|
4132
|
+
if (currentIds.length !== newIds.length || !currentIds.every((id, index) => id === newIds[index])) {
|
|
4133
|
+
initSelectedUsers();
|
|
4134
|
+
}
|
|
4135
|
+
},
|
|
4136
|
+
{ deep: true }
|
|
4137
|
+
);
|
|
4138
|
+
useResizeObserver(containerRef, () => {
|
|
4139
|
+
scheduleVisibleUsersCalculation();
|
|
4140
|
+
});
|
|
4141
|
+
onBeforeMount(() => {
|
|
4142
|
+
initSelectedUsers();
|
|
4143
|
+
});
|
|
3929
4144
|
onMounted(() => {
|
|
3930
4145
|
initSortable();
|
|
3931
|
-
calculateVisibleUsers
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
4146
|
+
nextTick(calculateVisibleUsers);
|
|
4147
|
+
});
|
|
4148
|
+
onUnmounted(() => {
|
|
4149
|
+
var _a;
|
|
4150
|
+
(_a = sortableInstance.value) == null ? void 0 : _a.destroy();
|
|
3936
4151
|
});
|
|
3937
4152
|
return (_ctx, _cache) => {
|
|
3938
4153
|
return openBlock(), createElementBlock(
|
|
@@ -3940,34 +4155,30 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3940
4155
|
{
|
|
3941
4156
|
ref_key: "containerRef",
|
|
3942
4157
|
ref: containerRef,
|
|
3943
|
-
class: normalizeClass(["
|
|
4158
|
+
class: normalizeClass(["bk-user-selector", { "is-disabled": _ctx.disabled }])
|
|
3944
4159
|
},
|
|
3945
4160
|
[
|
|
3946
4161
|
createCommentVNode(" 下拉选项列表 "),
|
|
3947
4162
|
createVNode(SelectionPopover, {
|
|
3948
4163
|
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
3949
|
-
"
|
|
3950
|
-
"empty-text": _ctx.emptyText,
|
|
4164
|
+
"empty-text": computedEmptyText.value,
|
|
3951
4165
|
"is-show": showDropdown.value,
|
|
3952
4166
|
loading: unref(searchLoading),
|
|
3953
|
-
options:
|
|
4167
|
+
options: displayOptions.value,
|
|
3954
4168
|
"render-list-item": _ctx.renderListItem,
|
|
3955
4169
|
"search-query": unref(searchQuery),
|
|
3956
4170
|
"tenant-id": _ctx.tenantId,
|
|
3957
|
-
tenants:
|
|
3958
|
-
"user-group":
|
|
3959
|
-
"user-group-name":
|
|
4171
|
+
tenants: unref(tenants),
|
|
4172
|
+
"user-group": unref(filteredUserGroup),
|
|
4173
|
+
"user-group-name": computedUserGroupName.value,
|
|
3960
4174
|
onClickOutside: handleClickOutside,
|
|
3961
4175
|
onSelectUser: addUser
|
|
3962
4176
|
}, {
|
|
3963
4177
|
default: withCtx(() => [
|
|
3964
4178
|
createCommentVNode(" 聚焦状态 - 可编辑模式 "),
|
|
3965
|
-
|
|
4179
|
+
withDirectives(createElementVNode(
|
|
3966
4180
|
"div",
|
|
3967
4181
|
{
|
|
3968
|
-
key: 0,
|
|
3969
|
-
ref_key: "tagsContainerRef",
|
|
3970
|
-
ref: tagsContainerRef,
|
|
3971
4182
|
class: "tags-container focused",
|
|
3972
4183
|
onClick: withModifiers(handleContainerClick, ["stop"])
|
|
3973
4184
|
},
|
|
@@ -3984,24 +4195,20 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3984
4195
|
(openBlock(true), createElementBlock(
|
|
3985
4196
|
Fragment,
|
|
3986
4197
|
null,
|
|
3987
|
-
renderList(
|
|
4198
|
+
renderList(selectedUsers.value, (user, index) => {
|
|
3988
4199
|
return openBlock(), createElementBlock("div", {
|
|
3989
4200
|
key: user.id,
|
|
3990
|
-
class: "tag-wrapper"
|
|
3991
|
-
onClick: withModifiers(($event) => handleTagClick(index), ["stop"])
|
|
4201
|
+
class: "tag-wrapper"
|
|
3992
4202
|
}, [
|
|
3993
|
-
createVNode(UserTag, {
|
|
4203
|
+
createVNode(UserTag, mergeProps({ ref_for: true }, userTagCommonProps.value, {
|
|
3994
4204
|
active: index === activeTagIndex.value,
|
|
3995
|
-
|
|
3996
|
-
draggable: _ctx.draggable,
|
|
3997
|
-
"render-tag": _ctx.renderTag,
|
|
3998
|
-
tenants: _ctx.tenants,
|
|
4205
|
+
draggable: _ctx.draggable && _ctx.multiple,
|
|
3999
4206
|
user,
|
|
4000
4207
|
onClick: ($event) => handleTagClick(index),
|
|
4001
4208
|
onClose: ($event) => removeUser(user)
|
|
4002
|
-
}, null,
|
|
4209
|
+
}), null, 16, ["active", "draggable", "user", "onClick", "onClose"]),
|
|
4003
4210
|
createCommentVNode(" 在当前激活标签后插入输入框 "),
|
|
4004
|
-
index === activeTagIndex.value && activeTagIndex.value !==
|
|
4211
|
+
index === activeTagIndex.value && activeTagIndex.value !== selectedUsers.value.length - 1 ? withDirectives((openBlock(), createElementBlock(
|
|
4005
4212
|
"input",
|
|
4006
4213
|
{
|
|
4007
4214
|
key: 0,
|
|
@@ -4009,42 +4216,45 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
4009
4216
|
ref_key: "inlineInputRef",
|
|
4010
4217
|
ref: inlineInputRef,
|
|
4011
4218
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
4012
|
-
|
|
4219
|
+
autofocus: "",
|
|
4220
|
+
class: "search-input input-inline",
|
|
4221
|
+
style: normalizeStyle({ width: inputWidth.value }),
|
|
4013
4222
|
onFocus: handleInputFocus,
|
|
4014
4223
|
onInput: handleInput,
|
|
4015
4224
|
onKeydown: handleKeyDown,
|
|
4016
|
-
onPaste
|
|
4225
|
+
onPaste
|
|
4017
4226
|
},
|
|
4018
4227
|
null,
|
|
4019
|
-
|
|
4020
|
-
/*
|
|
4228
|
+
36
|
|
4229
|
+
/* STYLE, NEED_HYDRATION */
|
|
4021
4230
|
)), [
|
|
4022
4231
|
[vModelText, unref(searchQuery)]
|
|
4023
4232
|
]) : createCommentVNode("v-if", true)
|
|
4024
|
-
]
|
|
4233
|
+
]);
|
|
4025
4234
|
}),
|
|
4026
4235
|
128
|
|
4027
4236
|
/* KEYED_FRAGMENT */
|
|
4028
4237
|
)),
|
|
4029
4238
|
createCommentVNode(" 最后一个输入框 "),
|
|
4030
|
-
activeTagIndex.value === -1 || activeTagIndex.value ===
|
|
4239
|
+
activeTagIndex.value === -1 || activeTagIndex.value === selectedUsers.value.length - 1 ? withDirectives((openBlock(), createElementBlock("input", {
|
|
4031
4240
|
key: 0,
|
|
4032
4241
|
ref_key: "lastInputRef",
|
|
4033
4242
|
ref: lastInputRef,
|
|
4034
4243
|
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
4035
|
-
|
|
4036
|
-
|
|
4244
|
+
autofocus: "",
|
|
4245
|
+
class: "search-input input-last",
|
|
4246
|
+
placeholder: !selectedUsers.value.length ? computedPlaceholder.value : "",
|
|
4037
4247
|
onFocus: handleInputFocus,
|
|
4038
4248
|
onInput: handleInput,
|
|
4039
4249
|
onKeydown: handleKeyDown,
|
|
4040
|
-
onPaste
|
|
4041
|
-
}, null, 40,
|
|
4250
|
+
onPaste
|
|
4251
|
+
}, null, 40, _hoisted_1)), [
|
|
4042
4252
|
[vModelText, unref(searchQuery)]
|
|
4043
4253
|
]) : createCommentVNode("v-if", true),
|
|
4044
4254
|
createCommentVNode(' "我"标签 '),
|
|
4045
4255
|
createVNode(MeTag, {
|
|
4046
4256
|
"current-user-id": _ctx.currentUserId,
|
|
4047
|
-
"is-disabled":
|
|
4257
|
+
"is-disabled": isMeTagDisabled.value,
|
|
4048
4258
|
onClick: addCurrentUser
|
|
4049
4259
|
}, null, 8, ["current-user-id", "is-disabled"])
|
|
4050
4260
|
],
|
|
@@ -4054,379 +4264,95 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
4054
4264
|
],
|
|
4055
4265
|
512
|
|
4056
4266
|
/* NEED_PATCH */
|
|
4057
|
-
)
|
|
4058
|
-
|
|
4059
|
-
|
|
4267
|
+
), [
|
|
4268
|
+
[vShow, isFocused.value]
|
|
4269
|
+
]),
|
|
4270
|
+
createCommentVNode(" 未聚焦状态 - 只读展示模式 "),
|
|
4271
|
+
withDirectives(createElementVNode(
|
|
4272
|
+
"div",
|
|
4273
|
+
{
|
|
4274
|
+
ref_key: "collapsedContainerRef",
|
|
4275
|
+
ref: collapsedContainerRef,
|
|
4276
|
+
class: "tags-container tags-container-collapsed",
|
|
4277
|
+
onClick: withModifiers(handleFocus, ["stop"])
|
|
4278
|
+
},
|
|
4060
4279
|
[
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
{
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4103
|
-
tenants: _ctx.tenants,
|
|
4104
|
-
user
|
|
4105
|
-
}, null, 8, ["tenant-id", "tenants", "user"]);
|
|
4106
|
-
}),
|
|
4107
|
-
128
|
|
4108
|
-
/* KEYED_FRAGMENT */
|
|
4109
|
-
))
|
|
4110
|
-
])
|
|
4111
|
-
]),
|
|
4280
|
+
(openBlock(true), createElementBlock(
|
|
4281
|
+
Fragment,
|
|
4282
|
+
null,
|
|
4283
|
+
renderList(visibleUsers.value, (user) => {
|
|
4284
|
+
return openBlock(), createBlock(UserTag, mergeProps({
|
|
4285
|
+
key: user.id,
|
|
4286
|
+
ref_for: true
|
|
4287
|
+
}, userTagCommonProps.value, {
|
|
4288
|
+
"show-tenant": true,
|
|
4289
|
+
user,
|
|
4290
|
+
onClick: handleFocus,
|
|
4291
|
+
onClose: ($event) => removeUser(user)
|
|
4292
|
+
}), null, 16, ["user", "onClose"]);
|
|
4293
|
+
}),
|
|
4294
|
+
128
|
|
4295
|
+
/* KEYED_FRAGMENT */
|
|
4296
|
+
)),
|
|
4297
|
+
createCommentVNode(" 显示折叠标签数量 "),
|
|
4298
|
+
hiddenCount.value > 0 ? (openBlock(), createBlock(unref(Popover), {
|
|
4299
|
+
key: 0,
|
|
4300
|
+
placement: "top"
|
|
4301
|
+
}, {
|
|
4302
|
+
content: withCtx(() => [
|
|
4303
|
+
createElementVNode("div", _hoisted_2, [
|
|
4304
|
+
(openBlock(true), createElementBlock(
|
|
4305
|
+
Fragment,
|
|
4306
|
+
null,
|
|
4307
|
+
renderList(selectedUsers.value.slice(visibleUsers.value.length), (user) => {
|
|
4308
|
+
return openBlock(), createBlock(unref(UserRender), {
|
|
4309
|
+
key: user.id,
|
|
4310
|
+
"tenant-id": _ctx.tenantId,
|
|
4311
|
+
tenants: unref(tenants),
|
|
4312
|
+
user
|
|
4313
|
+
}, null, 8, ["tenant-id", "tenants", "user"]);
|
|
4314
|
+
}),
|
|
4315
|
+
128
|
|
4316
|
+
/* KEYED_FRAGMENT */
|
|
4317
|
+
))
|
|
4318
|
+
])
|
|
4319
|
+
]),
|
|
4320
|
+
default: withCtx(() => [
|
|
4321
|
+
createVNode(unref(Tag), null, {
|
|
4112
4322
|
default: withCtx(() => [
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
/* TEXT */
|
|
4119
|
-
)
|
|
4120
|
-
]),
|
|
4121
|
-
_: 1
|
|
4122
|
-
/* STABLE */
|
|
4123
|
-
})
|
|
4323
|
+
createTextVNode(
|
|
4324
|
+
" +" + toDisplayString(hiddenCount.value),
|
|
4325
|
+
1
|
|
4326
|
+
/* TEXT */
|
|
4327
|
+
)
|
|
4124
4328
|
]),
|
|
4125
4329
|
_: 1
|
|
4126
4330
|
/* STABLE */
|
|
4127
|
-
})
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
/* NEED_PATCH */
|
|
4148
|
-
)
|
|
4331
|
+
})
|
|
4332
|
+
]),
|
|
4333
|
+
_: 1
|
|
4334
|
+
/* STABLE */
|
|
4335
|
+
})) : createCommentVNode("v-if", true),
|
|
4336
|
+
createCommentVNode(" 搜索输入框 "),
|
|
4337
|
+
withDirectives(createElementVNode("input", {
|
|
4338
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(searchQuery) ? searchQuery.value = $event : null),
|
|
4339
|
+
class: "search-input search-input-collapsed",
|
|
4340
|
+
placeholder: !selectedUsers.value.length ? computedPlaceholder.value : "",
|
|
4341
|
+
onFocus: handleFocus
|
|
4342
|
+
}, null, 40, _hoisted_3), [
|
|
4343
|
+
[vModelText, unref(searchQuery)]
|
|
4344
|
+
]),
|
|
4345
|
+
createCommentVNode(' 未聚焦状态下的"我"标签 '),
|
|
4346
|
+
createVNode(MeTag, {
|
|
4347
|
+
"current-user-id": _ctx.currentUserId,
|
|
4348
|
+
"is-disabled": isMeTagDisabled.value,
|
|
4349
|
+
onClick: addCurrentUser
|
|
4350
|
+
}, null, 8, ["current-user-id", "is-disabled"])
|
|
4149
4351
|
],
|
|
4150
|
-
|
|
4151
|
-
/*
|
|
4152
|
-
)
|
|
4153
|
-
|
|
4154
|
-
_: 1
|
|
4155
|
-
/* STABLE */
|
|
4156
|
-
}, 8, ["container-width", "cross-axis-offset", "empty-text", "is-show", "loading", "options", "render-list-item", "search-query", "tenant-id", "tenants", "user-group", "user-group-name"])
|
|
4157
|
-
],
|
|
4158
|
-
2
|
|
4159
|
-
/* CLASS */
|
|
4160
|
-
);
|
|
4161
|
-
};
|
|
4162
|
-
}
|
|
4163
|
-
});
|
|
4164
|
-
const MultipleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-2a532f24"]]);
|
|
4165
|
-
const _hoisted_1 = { class: "input-container" };
|
|
4166
|
-
const _hoisted_2 = ["placeholder"];
|
|
4167
|
-
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
4168
|
-
...{
|
|
4169
|
-
name: "BkUserSelectorSingle"
|
|
4170
|
-
},
|
|
4171
|
-
__name: "single-selector",
|
|
4172
|
-
props: {
|
|
4173
|
-
modelValue: { default: "" },
|
|
4174
|
-
tenants: {},
|
|
4175
|
-
allowCreate: { type: Boolean },
|
|
4176
|
-
apiBaseUrl: { default: "" },
|
|
4177
|
-
currentUserId: { default: "" },
|
|
4178
|
-
disabled: { type: Boolean },
|
|
4179
|
-
emptyText: { default: "" },
|
|
4180
|
-
enableMultiTenantMode: { type: Boolean },
|
|
4181
|
-
exactSearchKey: { default: "bk_username" },
|
|
4182
|
-
excludeUserIds: { default: () => [] },
|
|
4183
|
-
freePaste: { type: Boolean },
|
|
4184
|
-
placeholder: { default: "" },
|
|
4185
|
-
tenantId: { default: "" },
|
|
4186
|
-
userGroupName: { default: "" },
|
|
4187
|
-
renderListItem: {},
|
|
4188
|
-
renderTag: {},
|
|
4189
|
-
userGroup: { default: () => [] }
|
|
4190
|
-
},
|
|
4191
|
-
emits: ["update:modelValue", "change", "focus", "blur"],
|
|
4192
|
-
setup(__props, { emit: __emit }) {
|
|
4193
|
-
const props = __props;
|
|
4194
|
-
const emit = __emit;
|
|
4195
|
-
const containerRef = ref(null);
|
|
4196
|
-
const inputRef = ref(null);
|
|
4197
|
-
const options = ref([]);
|
|
4198
|
-
const isLoading = ref(false);
|
|
4199
|
-
const selectedUser = ref(props.modelValue || "");
|
|
4200
|
-
const searchQuery = ref("");
|
|
4201
|
-
const showDropdown = ref(false);
|
|
4202
|
-
const userGroupFilter = computed(() => {
|
|
4203
|
-
return props.userGroup.filter((group) => {
|
|
4204
|
-
var _a, _b;
|
|
4205
|
-
const filtered = group.id !== selectedUser.value && !group.hidden;
|
|
4206
|
-
if (filtered) {
|
|
4207
|
-
return ((_a = group.id) == null ? void 0 : _a.includes(searchQuery.value)) || ((_b = group.name) == null ? void 0 : _b.includes(searchQuery.value));
|
|
4208
|
-
}
|
|
4209
|
-
return false;
|
|
4210
|
-
});
|
|
4211
|
-
});
|
|
4212
|
-
const selectedUserInfo = computed(() => {
|
|
4213
|
-
const userGroup = (props.userGroup || []).map((group) => ({
|
|
4214
|
-
...group,
|
|
4215
|
-
tenantId: "",
|
|
4216
|
-
type: "userGroup"
|
|
4217
|
-
}));
|
|
4218
|
-
const list = [...options.value, ...userGroup];
|
|
4219
|
-
const selectedUserInfo2 = list.find((user) => user.id === selectedUser.value);
|
|
4220
|
-
emit("change", selectedUserInfo2 || null);
|
|
4221
|
-
return selectedUserInfo2;
|
|
4222
|
-
});
|
|
4223
|
-
const initSelectedUser = async () => {
|
|
4224
|
-
if (typeof props.modelValue === "string" && props.modelValue) {
|
|
4225
|
-
try {
|
|
4226
|
-
isLoading.value = true;
|
|
4227
|
-
const result = await lookupUsers({
|
|
4228
|
-
apiBaseUrl: props.apiBaseUrl,
|
|
4229
|
-
tenantId: props.tenantId,
|
|
4230
|
-
exactSearchKey: props.exactSearchKey,
|
|
4231
|
-
usersList: [props.modelValue],
|
|
4232
|
-
enableMultiTenantMode: props.enableMultiTenantMode
|
|
4233
|
-
});
|
|
4234
|
-
options.value = formatUsers(result, props.enableMultiTenantMode).filter(
|
|
4235
|
-
(user) => !props.excludeUserIds.includes(user.id)
|
|
4236
|
-
);
|
|
4237
|
-
if (props.userGroup.length > 0) {
|
|
4238
|
-
const groupResult = props.userGroup.filter((group) => group.id == props.modelValue);
|
|
4239
|
-
options.value = groupResult.map((group) => ({
|
|
4240
|
-
...group,
|
|
4241
|
-
tenantId: "",
|
|
4242
|
-
type: "userGroup"
|
|
4243
|
-
}));
|
|
4244
|
-
}
|
|
4245
|
-
if (props.allowCreate && options.value.length === 0) {
|
|
4246
|
-
options.value.push({
|
|
4247
|
-
id: props.modelValue,
|
|
4248
|
-
name: props.modelValue,
|
|
4249
|
-
type: "custom",
|
|
4250
|
-
tenantId: ""
|
|
4251
|
-
});
|
|
4252
|
-
}
|
|
4253
|
-
} catch (error) {
|
|
4254
|
-
console.error("获取用户信息失败:", error);
|
|
4255
|
-
} finally {
|
|
4256
|
-
isLoading.value = false;
|
|
4257
|
-
}
|
|
4258
|
-
} else {
|
|
4259
|
-
options.value = [];
|
|
4260
|
-
}
|
|
4261
|
-
};
|
|
4262
|
-
onBeforeMount(async () => {
|
|
4263
|
-
initSelectedUser();
|
|
4264
|
-
});
|
|
4265
|
-
const addCurrentUser = async () => {
|
|
4266
|
-
if (!props.currentUserId || selectedUser.value === props.currentUserId) return;
|
|
4267
|
-
try {
|
|
4268
|
-
const result = await lookupUsers({
|
|
4269
|
-
apiBaseUrl: props.apiBaseUrl,
|
|
4270
|
-
tenantId: props.tenantId,
|
|
4271
|
-
exactSearchKey: props.exactSearchKey,
|
|
4272
|
-
usersList: [props.currentUserId],
|
|
4273
|
-
enableMultiTenantMode: props.enableMultiTenantMode
|
|
4274
|
-
});
|
|
4275
|
-
const formattedResults = formatUsers(result, props.enableMultiTenantMode);
|
|
4276
|
-
if (formattedResults.length > 0) {
|
|
4277
|
-
options.value = formattedResults.filter((user) => !props.excludeUserIds.includes(user.id));
|
|
4278
|
-
addUser(formattedResults[0]);
|
|
4279
|
-
}
|
|
4280
|
-
} catch (error) {
|
|
4281
|
-
console.error("获取当前用户信息失败:", error);
|
|
4282
|
-
}
|
|
4283
|
-
};
|
|
4284
|
-
const fetchUsers = async (keyword = "") => {
|
|
4285
|
-
if (!(keyword == null ? void 0 : keyword.length)) {
|
|
4286
|
-
options.value = [];
|
|
4287
|
-
isLoading.value = false;
|
|
4288
|
-
return;
|
|
4289
|
-
}
|
|
4290
|
-
isLoading.value = true;
|
|
4291
|
-
try {
|
|
4292
|
-
const result = await searchUsers({
|
|
4293
|
-
apiBaseUrl: props.apiBaseUrl,
|
|
4294
|
-
tenantId: props.tenantId,
|
|
4295
|
-
keyword,
|
|
4296
|
-
enableMultiTenantMode: props.enableMultiTenantMode
|
|
4297
|
-
});
|
|
4298
|
-
options.value = formatUsers(result, props.enableMultiTenantMode).filter((user) => !selectedUser.value || user.id !== selectedUser.value).filter((user) => !props.excludeUserIds.includes(user.id));
|
|
4299
|
-
} catch (error) {
|
|
4300
|
-
console.error("获取用户列表失败:", error);
|
|
4301
|
-
options.value = [];
|
|
4302
|
-
} finally {
|
|
4303
|
-
isLoading.value = false;
|
|
4304
|
-
}
|
|
4305
|
-
};
|
|
4306
|
-
const handleKeyDown = (event) => {
|
|
4307
|
-
if (event.key === "Enter") {
|
|
4308
|
-
if (props.allowCreate) {
|
|
4309
|
-
const customUser = {
|
|
4310
|
-
id: searchQuery.value,
|
|
4311
|
-
name: searchQuery.value,
|
|
4312
|
-
tenantId: "",
|
|
4313
|
-
type: "custom"
|
|
4314
|
-
};
|
|
4315
|
-
options.value.push(customUser);
|
|
4316
|
-
addUser(customUser);
|
|
4317
|
-
}
|
|
4318
|
-
}
|
|
4319
|
-
};
|
|
4320
|
-
const handlePaste = (event) => {
|
|
4321
|
-
var _a;
|
|
4322
|
-
event.preventDefault();
|
|
4323
|
-
const pastedText = ((_a = event.clipboardData) == null ? void 0 : _a.getData("text").trim()) || "";
|
|
4324
|
-
if (props.freePaste) {
|
|
4325
|
-
const customUser = { id: pastedText, name: pastedText, type: "custom", tenantId: "", login_name: pastedText };
|
|
4326
|
-
if (!options.value.some((item) => item.login_name === customUser.login_name)) {
|
|
4327
|
-
options.value.push(customUser);
|
|
4328
|
-
}
|
|
4329
|
-
addUser(customUser);
|
|
4330
|
-
}
|
|
4331
|
-
};
|
|
4332
|
-
const addUser = (user) => {
|
|
4333
|
-
selectedUser.value = user.id;
|
|
4334
|
-
searchQuery.value = "";
|
|
4335
|
-
showDropdown.value = false;
|
|
4336
|
-
};
|
|
4337
|
-
const removeSelectedUser = () => {
|
|
4338
|
-
selectedUser.value = "";
|
|
4339
|
-
searchQuery.value = "";
|
|
4340
|
-
};
|
|
4341
|
-
const handleInputFocus = () => {
|
|
4342
|
-
if (searchQuery.value.length >= 1 || Array.isArray(props.userGroup) && props.userGroup.length > 0) {
|
|
4343
|
-
showDropdown.value = true;
|
|
4344
|
-
}
|
|
4345
|
-
emit("focus");
|
|
4346
|
-
};
|
|
4347
|
-
let timer = null;
|
|
4348
|
-
const handleInput = () => {
|
|
4349
|
-
showDropdown.value = searchQuery.value.length >= 1;
|
|
4350
|
-
isLoading.value = true;
|
|
4351
|
-
clearTimeout(timer);
|
|
4352
|
-
timer = setTimeout(() => {
|
|
4353
|
-
fetchUsers(searchQuery.value);
|
|
4354
|
-
}, 300);
|
|
4355
|
-
};
|
|
4356
|
-
const handleClickOutside = () => {
|
|
4357
|
-
setTimeout(() => {
|
|
4358
|
-
showDropdown.value = false;
|
|
4359
|
-
}, 0);
|
|
4360
|
-
};
|
|
4361
|
-
watch(
|
|
4362
|
-
() => props.modelValue,
|
|
4363
|
-
(newVal) => {
|
|
4364
|
-
selectedUser.value = newVal;
|
|
4365
|
-
}
|
|
4366
|
-
);
|
|
4367
|
-
watch(selectedUser, (newVal) => {
|
|
4368
|
-
emit("update:modelValue", newVal);
|
|
4369
|
-
});
|
|
4370
|
-
return (_ctx, _cache) => {
|
|
4371
|
-
return withDirectives((openBlock(), createElementBlock(
|
|
4372
|
-
"div",
|
|
4373
|
-
{
|
|
4374
|
-
ref_key: "containerRef",
|
|
4375
|
-
ref: containerRef,
|
|
4376
|
-
class: normalizeClass(["single-selector", { "is-disabled": _ctx.disabled }])
|
|
4377
|
-
},
|
|
4378
|
-
[
|
|
4379
|
-
createCommentVNode(" 使用新的公共下拉选项组件 "),
|
|
4380
|
-
createVNode(SelectionPopover, {
|
|
4381
|
-
"container-width": containerRef.value ? containerRef.value.offsetWidth : "auto",
|
|
4382
|
-
"empty-text": _ctx.emptyText,
|
|
4383
|
-
"is-show": showDropdown.value,
|
|
4384
|
-
loading: isLoading.value,
|
|
4385
|
-
options: options.value,
|
|
4386
|
-
"render-list-item": _ctx.renderListItem,
|
|
4387
|
-
"search-query": searchQuery.value,
|
|
4388
|
-
"tenant-id": _ctx.tenantId,
|
|
4389
|
-
tenants: _ctx.tenants,
|
|
4390
|
-
"user-group": userGroupFilter.value,
|
|
4391
|
-
"user-group-name": _ctx.userGroupName,
|
|
4392
|
-
onSelectUser: addUser
|
|
4393
|
-
}, {
|
|
4394
|
-
default: withCtx(() => [
|
|
4395
|
-
createCommentVNode(" 输入框 "),
|
|
4396
|
-
createElementVNode("div", _hoisted_1, [
|
|
4397
|
-
createCommentVNode(" 用户标签显示 "),
|
|
4398
|
-
selectedUserInfo.value ? (openBlock(), createElementBlock("div", {
|
|
4399
|
-
key: 0,
|
|
4400
|
-
onClick: withModifiers(removeSelectedUser, ["stop"])
|
|
4401
|
-
}, [
|
|
4402
|
-
createVNode(UserTag, {
|
|
4403
|
-
"current-tenant-id": _ctx.tenantId,
|
|
4404
|
-
"render-tag": _ctx.renderTag,
|
|
4405
|
-
tenants: _ctx.tenants,
|
|
4406
|
-
user: selectedUserInfo.value,
|
|
4407
|
-
onClose: removeSelectedUser
|
|
4408
|
-
}, null, 8, ["current-tenant-id", "render-tag", "tenants", "user"])
|
|
4409
|
-
])) : createCommentVNode("v-if", true),
|
|
4410
|
-
withDirectives(createElementVNode("input", {
|
|
4411
|
-
ref_key: "inputRef",
|
|
4412
|
-
ref: inputRef,
|
|
4413
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => searchQuery.value = $event),
|
|
4414
|
-
class: "search-input",
|
|
4415
|
-
placeholder: selectedUserInfo.value ? "" : _ctx.placeholder,
|
|
4416
|
-
onBlur: _cache[1] || (_cache[1] = ($event) => emit("blur")),
|
|
4417
|
-
onFocus: handleInputFocus,
|
|
4418
|
-
onInput: handleInput,
|
|
4419
|
-
onKeydown: handleKeyDown,
|
|
4420
|
-
onPaste: handlePaste
|
|
4421
|
-
}, null, 40, _hoisted_2), [
|
|
4422
|
-
[vModelText, searchQuery.value]
|
|
4423
|
-
]),
|
|
4424
|
-
createCommentVNode(' "我"标签 '),
|
|
4425
|
-
createVNode(MeTag, {
|
|
4426
|
-
"current-user-id": _ctx.currentUserId,
|
|
4427
|
-
"is-disabled": !!_ctx.currentUserId && !!selectedUserInfo.value && selectedUserInfo.value[_ctx.exactSearchKey] === _ctx.currentUserId,
|
|
4428
|
-
onClick: addCurrentUser
|
|
4429
|
-
}, null, 8, ["current-user-id", "is-disabled"])
|
|
4352
|
+
512
|
|
4353
|
+
/* NEED_PATCH */
|
|
4354
|
+
), [
|
|
4355
|
+
[vShow, !isFocused.value]
|
|
4430
4356
|
])
|
|
4431
4357
|
]),
|
|
4432
4358
|
_: 1
|
|
@@ -4435,207 +4361,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
4435
4361
|
],
|
|
4436
4362
|
2
|
|
4437
4363
|
/* CLASS */
|
|
4438
|
-
)), [
|
|
4439
|
-
[unref(clickoutside), handleClickOutside]
|
|
4440
|
-
]);
|
|
4441
|
-
};
|
|
4442
|
-
}
|
|
4443
|
-
});
|
|
4444
|
-
const SingleSelector = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-cbe352a6"]]);
|
|
4445
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4446
|
-
...{
|
|
4447
|
-
name: "BkUserSelector"
|
|
4448
|
-
},
|
|
4449
|
-
__name: "user-selector",
|
|
4450
|
-
props: {
|
|
4451
|
-
draggable: { type: Boolean, default: false },
|
|
4452
|
-
modelValue: { default: "" },
|
|
4453
|
-
multiple: { type: Boolean, default: false },
|
|
4454
|
-
allowCreate: { type: Boolean, default: false },
|
|
4455
|
-
apiBaseUrl: { default: "" },
|
|
4456
|
-
currentUserId: { default: "" },
|
|
4457
|
-
disabled: { type: Boolean, default: false },
|
|
4458
|
-
emptyText: { default: "" },
|
|
4459
|
-
enableMultiTenantMode: { type: Boolean, default: true },
|
|
4460
|
-
exactSearchKey: { default: "bk_username" },
|
|
4461
|
-
excludeUserIds: { default: () => [] },
|
|
4462
|
-
freePaste: { type: Boolean, default: false },
|
|
4463
|
-
placeholder: { default: "" },
|
|
4464
|
-
tenantId: { default: "" },
|
|
4465
|
-
userGroupName: { default: "" },
|
|
4466
|
-
renderListItem: {},
|
|
4467
|
-
renderTag: {},
|
|
4468
|
-
userGroup: { default: () => [] }
|
|
4469
|
-
},
|
|
4470
|
-
emits: ["update:modelValue", "change", "dragStart", "dragEnd", "focus", "blur"],
|
|
4471
|
-
setup(__props, { emit: __emit }) {
|
|
4472
|
-
const { t } = useI18n();
|
|
4473
|
-
provideGlobalConfig({
|
|
4474
|
-
prefix: "bk"
|
|
4475
|
-
});
|
|
4476
|
-
const props = __props;
|
|
4477
|
-
const emit = __emit;
|
|
4478
|
-
const { tenants = {} } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
|
|
4479
|
-
const selectedUsers = ref([]);
|
|
4480
|
-
const selectedUser = ref(props.multiple ? "" : props.modelValue);
|
|
4481
|
-
const selectedUserIds = computed(() => {
|
|
4482
|
-
return props.multiple ? selectedUsers.value.map((user) => user.id) : [];
|
|
4483
|
-
});
|
|
4484
|
-
const placeholder = computed(() => props.placeholder || t("请输入人员名称搜索"));
|
|
4485
|
-
const userGroupName = computed(() => props.userGroupName || t("用户群组"));
|
|
4486
|
-
const emptyText = computed(() => props.emptyText || t("无匹配人员"));
|
|
4487
|
-
const initSelectedUsers = async () => {
|
|
4488
|
-
if (props.multiple) {
|
|
4489
|
-
const ids = Array.isArray(props.modelValue) ? props.modelValue : [];
|
|
4490
|
-
let userGroupSelected = [];
|
|
4491
|
-
if (props.userGroup.length > 0) {
|
|
4492
|
-
const result = props.userGroup.filter((group) => ids.includes(group.id));
|
|
4493
|
-
userGroupSelected = result.map((group) => ({
|
|
4494
|
-
...group,
|
|
4495
|
-
tenantId: "",
|
|
4496
|
-
type: "userGroup"
|
|
4497
|
-
}));
|
|
4498
|
-
}
|
|
4499
|
-
if (ids.length > 0) {
|
|
4500
|
-
try {
|
|
4501
|
-
const result = await lookupUsers({
|
|
4502
|
-
apiBaseUrl: props.apiBaseUrl,
|
|
4503
|
-
tenantId: props.tenantId,
|
|
4504
|
-
exactSearchKey: "bk_username",
|
|
4505
|
-
usersList: ids,
|
|
4506
|
-
enableMultiTenantMode: props.enableMultiTenantMode
|
|
4507
|
-
});
|
|
4508
|
-
const selectedList = [...userGroupSelected, ...formatUsers(result, props.enableMultiTenantMode)];
|
|
4509
|
-
if (props.allowCreate) {
|
|
4510
|
-
selectedList.push(
|
|
4511
|
-
...ids.filter((id) => !selectedList.some((user) => user.id === id)).map((id) => ({ id, name: id, type: "custom", tenantId: "" }))
|
|
4512
|
-
);
|
|
4513
|
-
}
|
|
4514
|
-
selectedUsers.value = ids.map((id) => selectedList.find((user) => user.id === id)).filter(Boolean);
|
|
4515
|
-
} catch (error) {
|
|
4516
|
-
console.error("获取选中用户信息失败:", error);
|
|
4517
|
-
}
|
|
4518
|
-
} else {
|
|
4519
|
-
selectedUsers.value = [];
|
|
4520
|
-
}
|
|
4521
|
-
} else {
|
|
4522
|
-
selectedUser.value = props.modelValue;
|
|
4523
|
-
}
|
|
4524
|
-
};
|
|
4525
|
-
const handleUpdateUser = (user) => {
|
|
4526
|
-
emit("change", user);
|
|
4527
|
-
};
|
|
4528
|
-
const handleUpdateSelectedUsers = (users) => {
|
|
4529
|
-
selectedUsers.value = users;
|
|
4530
|
-
emit(
|
|
4531
|
-
"update:modelValue",
|
|
4532
|
-
users.map((user) => user.id)
|
|
4533
|
-
);
|
|
4534
|
-
emit("change", users);
|
|
4535
|
-
};
|
|
4536
|
-
const handleFocus = () => {
|
|
4537
|
-
emit("focus");
|
|
4538
|
-
};
|
|
4539
|
-
const handleBlur = () => {
|
|
4540
|
-
emit("blur");
|
|
4541
|
-
};
|
|
4542
|
-
watch(selectedUser, (newVal) => {
|
|
4543
|
-
if (!props.multiple) {
|
|
4544
|
-
emit("update:modelValue", newVal);
|
|
4545
|
-
}
|
|
4546
|
-
});
|
|
4547
|
-
watch(
|
|
4548
|
-
() => props.userGroup,
|
|
4549
|
-
() => {
|
|
4550
|
-
initSelectedUsers();
|
|
4551
|
-
}
|
|
4552
|
-
);
|
|
4553
|
-
watch(
|
|
4554
|
-
() => props.modelValue,
|
|
4555
|
-
() => {
|
|
4556
|
-
initSelectedUsers();
|
|
4557
|
-
},
|
|
4558
|
-
{ deep: true }
|
|
4559
|
-
);
|
|
4560
|
-
onBeforeMount(() => {
|
|
4561
|
-
initSelectedUsers();
|
|
4562
|
-
});
|
|
4563
|
-
return (_ctx, _cache) => {
|
|
4564
|
-
return openBlock(), createElementBlock(
|
|
4565
|
-
"section",
|
|
4566
|
-
{
|
|
4567
|
-
ref: "containerRef",
|
|
4568
|
-
class: normalizeClass(["bk-user-selector", { "is-disabled": _ctx.disabled }])
|
|
4569
|
-
},
|
|
4570
|
-
[
|
|
4571
|
-
createCommentVNode(" 单选模式 "),
|
|
4572
|
-
!_ctx.multiple ? (openBlock(), createBlock(SingleSelector, {
|
|
4573
|
-
key: 0,
|
|
4574
|
-
modelValue: selectedUser.value,
|
|
4575
|
-
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => selectedUser.value = $event),
|
|
4576
|
-
"allow-create": _ctx.allowCreate,
|
|
4577
|
-
"api-base-url": _ctx.apiBaseUrl,
|
|
4578
|
-
"current-user-id": _ctx.currentUserId,
|
|
4579
|
-
disabled: _ctx.disabled,
|
|
4580
|
-
"empty-text": emptyText.value,
|
|
4581
|
-
"enable-multi-tenant-mode": _ctx.enableMultiTenantMode,
|
|
4582
|
-
"exact-search-key": _ctx.exactSearchKey,
|
|
4583
|
-
"exclude-user-ids": _ctx.excludeUserIds,
|
|
4584
|
-
placeholder: placeholder.value,
|
|
4585
|
-
"render-list-item": _ctx.renderListItem,
|
|
4586
|
-
"render-tag": _ctx.renderTag,
|
|
4587
|
-
"tenant-id": _ctx.tenantId,
|
|
4588
|
-
tenants: unref(tenants),
|
|
4589
|
-
"user-group": _ctx.userGroup,
|
|
4590
|
-
"user-group-name": userGroupName.value,
|
|
4591
|
-
"free-paste": _ctx.freePaste,
|
|
4592
|
-
onBlur: handleBlur,
|
|
4593
|
-
onChange: handleUpdateUser,
|
|
4594
|
-
onFocus: handleFocus
|
|
4595
|
-
}, null, 8, ["modelValue", "allow-create", "api-base-url", "current-user-id", "disabled", "empty-text", "enable-multi-tenant-mode", "exact-search-key", "exclude-user-ids", "placeholder", "render-list-item", "render-tag", "tenant-id", "tenants", "user-group", "user-group-name", "free-paste"])) : (openBlock(), createElementBlock(
|
|
4596
|
-
Fragment,
|
|
4597
|
-
{ key: 1 },
|
|
4598
|
-
[
|
|
4599
|
-
createCommentVNode(" 多选模式 "),
|
|
4600
|
-
createVNode(MultipleSelector, {
|
|
4601
|
-
modelValue: selectedUserIds.value,
|
|
4602
|
-
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => selectedUserIds.value = $event),
|
|
4603
|
-
"allow-create": _ctx.allowCreate,
|
|
4604
|
-
"api-base-url": _ctx.apiBaseUrl,
|
|
4605
|
-
"current-user-id": _ctx.currentUserId,
|
|
4606
|
-
disabled: _ctx.disabled,
|
|
4607
|
-
draggable: _ctx.draggable,
|
|
4608
|
-
"empty-text": emptyText.value,
|
|
4609
|
-
"enable-multi-tenant-mode": _ctx.enableMultiTenantMode,
|
|
4610
|
-
"exact-search-key": _ctx.exactSearchKey,
|
|
4611
|
-
"exclude-user-ids": _ctx.excludeUserIds,
|
|
4612
|
-
placeholder: placeholder.value,
|
|
4613
|
-
"render-list-item": _ctx.renderListItem,
|
|
4614
|
-
"render-tag": _ctx.renderTag,
|
|
4615
|
-
"selected-users": selectedUsers.value,
|
|
4616
|
-
"tenant-id": _ctx.tenantId,
|
|
4617
|
-
tenants: unref(tenants),
|
|
4618
|
-
"user-group": _ctx.userGroup,
|
|
4619
|
-
"user-group-name": userGroupName.value,
|
|
4620
|
-
"free-paste": _ctx.freePaste,
|
|
4621
|
-
onBlur: handleBlur,
|
|
4622
|
-
onDragEnd: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("dragEnd", $event)),
|
|
4623
|
-
onDragStart: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("dragStart", $event)),
|
|
4624
|
-
onFocus: handleFocus,
|
|
4625
|
-
"onUpdate:selectedUsers": handleUpdateSelectedUsers
|
|
4626
|
-
}, null, 8, ["modelValue", "allow-create", "api-base-url", "current-user-id", "disabled", "draggable", "empty-text", "enable-multi-tenant-mode", "exact-search-key", "exclude-user-ids", "placeholder", "render-list-item", "render-tag", "selected-users", "tenant-id", "tenants", "user-group", "user-group-name", "free-paste"])
|
|
4627
|
-
],
|
|
4628
|
-
2112
|
|
4629
|
-
/* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
|
|
4630
|
-
))
|
|
4631
|
-
],
|
|
4632
|
-
2
|
|
4633
|
-
/* CLASS */
|
|
4634
4364
|
);
|
|
4635
4365
|
};
|
|
4636
4366
|
}
|
|
4637
4367
|
});
|
|
4638
|
-
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4368
|
+
const BkUserSelector = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-65e61c1c"]]);
|
|
4639
4369
|
export {
|
|
4640
4370
|
BkUserSelector,
|
|
4641
4371
|
BkUserSelector as default
|