cd-personselector 1.1.0 → 1.2.1
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/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +459 -262
- package/dist/src/InputSelect.vue.d.ts +59 -0
- package/dist/src/PersonSelector.vue.d.ts +4 -0
- package/dist/src/types.d.ts +4 -0
- package/dist/style.css +1 -1
- package/package.json +50 -47
- package/src/InputSelect.vue +368 -0
- package/src/PersonSelector.vue +16 -2
- package/src/types.ts +7 -1
package/dist/index.mjs
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as _e, ref as h, computed as A, watch as Q, resolveComponent as S, createBlock as D, openBlock as n, withCtx as U, createElementVNode as i, createElementBlock as c, createCommentVNode as _, createVNode as y, toDisplayString as f, Fragment as j, renderList as F, createTextVNode as X, normalizeClass as te, withModifiers as ue, nextTick as Ne, normalizeStyle as ze } from "vue";
|
|
2
|
+
const we = { class: "cd-ps-container" }, Te = {
|
|
3
3
|
key: 0,
|
|
4
4
|
class: "cd-ps-tips"
|
|
5
|
-
},
|
|
5
|
+
}, Re = {
|
|
6
6
|
key: 1,
|
|
7
7
|
class: "cd-ps-search"
|
|
8
|
-
},
|
|
8
|
+
}, $e = {
|
|
9
9
|
key: 0,
|
|
10
10
|
class: "cd-ps-org-select"
|
|
11
|
-
},
|
|
11
|
+
}, Be = { class: "cd-ps-search-input" }, Oe = { class: "cd-ps-content" }, De = { class: "cd-ps-left" }, Pe = {
|
|
12
12
|
key: 0,
|
|
13
13
|
class: "cd-ps-search-results"
|
|
14
|
-
},
|
|
14
|
+
}, Ae = { class: "cd-ps-search-header" }, Le = {
|
|
15
15
|
key: 0,
|
|
16
16
|
class: "cd-ps-loading"
|
|
17
17
|
}, Me = {
|
|
18
18
|
key: 1,
|
|
19
19
|
class: "cd-ps-empty"
|
|
20
|
-
},
|
|
20
|
+
}, Ee = {
|
|
21
21
|
key: 2,
|
|
22
22
|
class: "cd-ps-result-list"
|
|
23
|
-
},
|
|
23
|
+
}, We = ["onClick"], Je = { class: "cd-ps-avatar" }, je = { class: "cd-ps-info" }, Fe = { class: "cd-ps-name" }, qe = { class: "cd-ps-meta" }, Ge = { key: 0 }, He = { key: 1 }, Qe = { key: 2 }, Xe = { class: "cd-ps-tree" }, Ye = { class: "cd-ps-node-name" }, Ze = {
|
|
24
24
|
key: 0,
|
|
25
25
|
class: "cd-ps-position"
|
|
26
|
-
},
|
|
26
|
+
}, Ke = {
|
|
27
27
|
key: 0,
|
|
28
28
|
class: "cd-ps-count"
|
|
29
|
-
},
|
|
29
|
+
}, et = {
|
|
30
30
|
key: 1,
|
|
31
31
|
class: "cd-ps-empty"
|
|
32
|
-
},
|
|
32
|
+
}, tt = { class: "cd-ps-right" }, lt = { class: "cd-ps-right-header" }, st = { class: "cd-ps-num" }, at = { class: "cd-ps-right-list" }, nt = {
|
|
33
33
|
key: 0,
|
|
34
34
|
class: "cd-ps-empty"
|
|
35
|
-
},
|
|
35
|
+
}, ot = {
|
|
36
36
|
key: 1,
|
|
37
37
|
class: "cd-ps-selected-list"
|
|
38
|
-
},
|
|
38
|
+
}, dt = { class: "cd-ps-item-info" }, it = { class: "cd-ps-info" }, ct = { class: "cd-ps-name" }, ut = { class: "cd-ps-meta" }, rt = { key: 0 }, pt = { key: 1 }, vt = { key: 2 }, mt = { key: 3 }, ft = /* @__PURE__ */ _e({
|
|
39
39
|
__name: "PersonSelector",
|
|
40
40
|
props: {
|
|
41
41
|
visible: { type: Boolean, default: !1 },
|
|
@@ -45,330 +45,332 @@ const Ie = { class: "cd-ps-container" }, Se = {
|
|
|
45
45
|
dialogWidth: { default: "900px" },
|
|
46
46
|
tips: { default: "" },
|
|
47
47
|
showSearch: { type: Boolean, default: !0 },
|
|
48
|
-
showOrg: { type: Boolean, default: !0 }
|
|
48
|
+
showOrg: { type: Boolean, default: !0 },
|
|
49
|
+
multiple: { type: Boolean, default: !0 }
|
|
49
50
|
},
|
|
50
51
|
emits: ["update:visible", "update:modelValue", "confirm", "load-users", "search", "org-change"],
|
|
51
|
-
setup(
|
|
52
|
-
var
|
|
53
|
-
const d =
|
|
54
|
-
|
|
52
|
+
setup(g, { expose: q, emit: k }) {
|
|
53
|
+
var me, fe;
|
|
54
|
+
const d = g, $ = k, x = h(d.visible), N = h(((fe = (me = d.tabs) == null ? void 0 : me[0]) == null ? void 0 : fe.key) || ""), z = h(null), w = h(""), v = h([]), m = h(/* @__PURE__ */ new Map()), M = h({}), G = h(!1), E = h(!1), L = h([]), le = A(() => d.tabs || []), Y = A(() => d.organizations || []), Z = A(() => d.tips || ""), se = A(() => d.showSearch), ae = A(() => d.showOrg), ne = A(() => d.dialogWidth), o = h({});
|
|
55
|
+
Q(() => d.tabs, (t) => {
|
|
55
56
|
if (t && t.length > 0) {
|
|
56
57
|
const e = {};
|
|
57
|
-
t.forEach((
|
|
58
|
-
e[
|
|
59
|
-
}),
|
|
58
|
+
t.forEach((a) => {
|
|
59
|
+
e[a.key] = JSON.parse(JSON.stringify(a.tree));
|
|
60
|
+
}), o.value = e, (!N.value || !t.find((a) => a.key === N.value)) && (N.value = t[0].key);
|
|
60
61
|
}
|
|
61
62
|
}, { immediate: !0, deep: !0 });
|
|
62
|
-
function
|
|
63
|
+
function r() {
|
|
63
64
|
if (d.modelValue && d.modelValue.length > 0) {
|
|
64
65
|
const t = d.modelValue[0];
|
|
65
|
-
typeof t == "object" && t !== null && "id" in t ? (
|
|
66
|
-
|
|
67
|
-
})) :
|
|
66
|
+
typeof t == "object" && t !== null && "id" in t ? (v.value = d.modelValue.map((e) => e.id), m.value.clear(), d.modelValue.forEach((e) => {
|
|
67
|
+
m.value.set(e.id, e);
|
|
68
|
+
})) : v.value = [...d.modelValue];
|
|
68
69
|
} else
|
|
69
|
-
|
|
70
|
+
v.value = [], m.value.clear();
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}, { deep: !0 }),
|
|
74
|
-
|
|
75
|
-
}),
|
|
76
|
-
|
|
72
|
+
Q(() => d.modelValue, (t) => {
|
|
73
|
+
x.value && t && r();
|
|
74
|
+
}, { deep: !0 }), Q(() => d.visible, (t) => {
|
|
75
|
+
x.value = t, t && (r(), d.organizations.length > 0 && !z.value && (z.value = d.organizations[0].id));
|
|
76
|
+
}), Q(x, (t) => {
|
|
77
|
+
$("update:visible", t);
|
|
77
78
|
});
|
|
78
|
-
function
|
|
79
|
-
e && (
|
|
79
|
+
function u(t, e) {
|
|
80
|
+
e && (M.value[t] = e);
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
-
for (const
|
|
83
|
-
if (
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
82
|
+
function b(t, e) {
|
|
83
|
+
for (const a of t) {
|
|
84
|
+
if (a.id === e) return a;
|
|
85
|
+
if (a.children) {
|
|
86
|
+
const p = b(a.children, e);
|
|
87
|
+
if (p) return p;
|
|
87
88
|
}
|
|
88
89
|
}
|
|
89
90
|
return null;
|
|
90
91
|
}
|
|
91
|
-
const
|
|
92
|
-
function
|
|
93
|
-
|
|
92
|
+
const I = A(() => v.value.map((t) => m.value.get(t)).filter(Boolean));
|
|
93
|
+
function s(t, e) {
|
|
94
|
+
v.value.includes(t) || v.value.push(t), m.value.set(t, e);
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
96
|
+
function B(t) {
|
|
97
|
+
v.value = v.value.filter((e) => e !== t), m.value.delete(t);
|
|
97
98
|
}
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
},
|
|
99
|
+
const re = () => {
|
|
100
|
+
w.value = "";
|
|
101
|
+
}, oe = (t) => {
|
|
101
102
|
const e = {};
|
|
102
|
-
d.tabs.forEach((
|
|
103
|
-
e[
|
|
104
|
-
}),
|
|
103
|
+
d.tabs.forEach((a) => {
|
|
104
|
+
e[a.key] = [];
|
|
105
|
+
}), o.value = e, $("org-change", t);
|
|
105
106
|
};
|
|
106
|
-
let
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
|
|
107
|
+
let W = null;
|
|
108
|
+
const ke = () => {
|
|
109
|
+
if (W && clearTimeout(W), !w.value.trim()) {
|
|
110
|
+
de();
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
|
|
113
|
+
G.value = !0, E.value = !0, W = setTimeout(() => be(), 300);
|
|
114
|
+
}, be = () => {
|
|
115
|
+
L.value = [];
|
|
115
116
|
const t = (e) => {
|
|
116
|
-
|
|
117
|
+
L.value = e.map((a) => ({ ...a, isUser: !0 })), E.value = !1;
|
|
117
118
|
};
|
|
118
|
-
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
},
|
|
122
|
-
|
|
119
|
+
$("search", { keyword: w.value, orgId: z.value || void 0, callback: t });
|
|
120
|
+
}, de = () => {
|
|
121
|
+
W && (clearTimeout(W), W = null), G.value = !1, w.value = "", L.value = [], E.value = !1;
|
|
122
|
+
}, Ve = (t) => {
|
|
123
|
+
v.value.indexOf(t.id) > -1 ? B(t.id) : (d.multiple || (v.value = [], m.value.clear()), s(t.id, { ...t, isUser: !0, typeName: "搜索结果", orgId: z.value }), d.multiple || ie());
|
|
123
124
|
};
|
|
124
|
-
function
|
|
125
|
-
const e = [],
|
|
126
|
-
for (const
|
|
127
|
-
e.push(
|
|
125
|
+
function Ce(t) {
|
|
126
|
+
const e = [], a = (p) => {
|
|
127
|
+
for (const O of p)
|
|
128
|
+
e.push(O.id), O.children && a(O.children);
|
|
128
129
|
};
|
|
129
|
-
return
|
|
130
|
+
return a(t), e;
|
|
130
131
|
}
|
|
131
|
-
const
|
|
132
|
-
var
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
const Ue = (t, e) => {
|
|
133
|
+
var V, T;
|
|
134
|
+
const a = e == null ? void 0 : e.node;
|
|
135
|
+
if (a) {
|
|
136
|
+
const R = a.value ?? ((V = a.data) == null ? void 0 : V.id);
|
|
137
|
+
if (R !== void 0) {
|
|
138
|
+
if (a.checked) {
|
|
139
|
+
d.multiple || (v.value = [], m.value.clear());
|
|
140
|
+
const J = d.tabs.find((ce) => ce.key === N.value), H = J ? J.name.replace(/^按/, "") : "";
|
|
141
|
+
s(R, { ...a.data, typeName: H, orgId: z.value }), !d.multiple && ((T = a.data) != null && T.isUser) && ie();
|
|
140
142
|
} else
|
|
141
|
-
|
|
143
|
+
B(R);
|
|
142
144
|
return;
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
+
const p = o.value[N.value] || [], O = Ce(p), P = v.value.filter((R) => !O.includes(R));
|
|
148
|
+
v.value = [...P, ...t];
|
|
147
149
|
};
|
|
148
|
-
function
|
|
149
|
-
for (const
|
|
150
|
-
if (
|
|
151
|
-
return
|
|
152
|
-
if (
|
|
150
|
+
function pe(t, e, a) {
|
|
151
|
+
for (const p of t) {
|
|
152
|
+
if (p.id === e)
|
|
153
|
+
return p.children = p.children || [], p.children.push(...a), p.loaded = !0, !0;
|
|
154
|
+
if (p.children && pe(p.children, e, a))
|
|
153
155
|
return !0;
|
|
154
156
|
}
|
|
155
157
|
return !1;
|
|
156
158
|
}
|
|
157
|
-
async function
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
if (
|
|
161
|
-
const
|
|
162
|
-
const { id:
|
|
163
|
-
return { ...
|
|
164
|
-
}),
|
|
165
|
-
if (
|
|
166
|
-
|
|
159
|
+
async function Se(t, e) {
|
|
160
|
+
const a = t.value, p = M.value[e];
|
|
161
|
+
$("load-users", { tabKey: e, nodeId: a, node: t, callback: async (P) => {
|
|
162
|
+
if (P.length > 0) {
|
|
163
|
+
const V = P.map((R) => {
|
|
164
|
+
const { id: K, name: J, ...H } = R;
|
|
165
|
+
return { ...H, id: K, name: R.displayName || J, isUser: !0 };
|
|
166
|
+
}), T = o.value[e];
|
|
167
|
+
if (T && pe(T, a, V), p) {
|
|
168
|
+
p.appendTo(a, V), t.data.loaded = !0, await Ne();
|
|
167
169
|
try {
|
|
168
|
-
|
|
170
|
+
p.setItem(a, { expanded: !0 });
|
|
169
171
|
} catch {
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
174
|
} else {
|
|
173
175
|
t.data.loaded = !0;
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
const
|
|
177
|
-
|
|
176
|
+
const V = o.value[e];
|
|
177
|
+
if (V) {
|
|
178
|
+
const T = b(V, a);
|
|
179
|
+
T && (T.loaded = !0);
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
} });
|
|
181
183
|
}
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
},
|
|
189
|
-
|
|
184
|
+
const Ie = (t) => {
|
|
185
|
+
B(t);
|
|
186
|
+
}, ve = () => {
|
|
187
|
+
v.value = [], m.value.clear();
|
|
188
|
+
}, ie = () => {
|
|
189
|
+
$("update:modelValue", v.value), $("confirm", I.value), x.value = !1;
|
|
190
|
+
}, xe = () => {
|
|
191
|
+
x.value = !1;
|
|
190
192
|
};
|
|
191
193
|
return q({
|
|
192
|
-
clearSelection:
|
|
193
|
-
appendUsers: (t, e,
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
196
|
-
const
|
|
197
|
-
const { id:
|
|
198
|
-
return { ...
|
|
194
|
+
clearSelection: ve,
|
|
195
|
+
appendUsers: (t, e, a) => {
|
|
196
|
+
const p = M.value[t];
|
|
197
|
+
if (p && a.length > 0) {
|
|
198
|
+
const O = a.map((P) => {
|
|
199
|
+
const { id: V, name: T, ...R } = P;
|
|
200
|
+
return { ...R, id: V, name: P.displayName || T, isUser: !0 };
|
|
199
201
|
});
|
|
200
|
-
|
|
202
|
+
p.appendTo(e, O);
|
|
201
203
|
}
|
|
202
204
|
}
|
|
203
205
|
}), (t, e) => {
|
|
204
|
-
const
|
|
205
|
-
return
|
|
206
|
-
visible:
|
|
207
|
-
"onUpdate:visible": e[4] || (e[4] = (
|
|
206
|
+
const a = S("t-icon"), p = S("t-option"), O = S("t-select"), P = S("t-input"), V = S("t-button"), T = S("t-loading"), R = S("t-checkbox"), K = S("t-tree"), J = S("t-tab-panel"), H = S("t-tabs"), ce = S("t-dialog");
|
|
207
|
+
return n(), D(ce, {
|
|
208
|
+
visible: x.value,
|
|
209
|
+
"onUpdate:visible": e[4] || (e[4] = (l) => x.value = l),
|
|
208
210
|
header: "选择人员",
|
|
209
|
-
width:
|
|
211
|
+
width: ne.value,
|
|
210
212
|
footer: !0,
|
|
211
213
|
placement: "center",
|
|
212
214
|
"destroy-on-close": "",
|
|
213
|
-
onConfirm:
|
|
214
|
-
onClose:
|
|
215
|
+
onConfirm: ie,
|
|
216
|
+
onClose: xe
|
|
215
217
|
}, {
|
|
216
|
-
default:
|
|
217
|
-
|
|
218
|
-
Z.value ? (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
])) :
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
modelValue:
|
|
226
|
-
"onUpdate:modelValue": e[0] || (e[0] = (
|
|
218
|
+
default: U(() => [
|
|
219
|
+
i("div", we, [
|
|
220
|
+
Z.value ? (n(), c("div", Te, [
|
|
221
|
+
y(a, { name: "info-circle" }),
|
|
222
|
+
i("span", null, f(Z.value), 1)
|
|
223
|
+
])) : _("", !0),
|
|
224
|
+
se.value ? (n(), c("div", Re, [
|
|
225
|
+
ae.value && Y.value.length > 0 ? (n(), c("div", $e, [
|
|
226
|
+
y(O, {
|
|
227
|
+
modelValue: z.value,
|
|
228
|
+
"onUpdate:modelValue": e[0] || (e[0] = (l) => z.value = l),
|
|
227
229
|
placeholder: "选择组织",
|
|
228
230
|
style: { width: "200px" },
|
|
229
|
-
onChange:
|
|
231
|
+
onChange: oe
|
|
230
232
|
}, {
|
|
231
|
-
default:
|
|
232
|
-
(
|
|
233
|
-
key:
|
|
234
|
-
value:
|
|
235
|
-
label:
|
|
233
|
+
default: U(() => [
|
|
234
|
+
(n(!0), c(j, null, F(Y.value, (l) => (n(), D(p, {
|
|
235
|
+
key: l.id,
|
|
236
|
+
value: l.id,
|
|
237
|
+
label: l.displayName || l.name
|
|
236
238
|
}, null, 8, ["value", "label"]))), 128))
|
|
237
239
|
]),
|
|
238
240
|
_: 1
|
|
239
241
|
}, 8, ["modelValue"])
|
|
240
|
-
])) :
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
modelValue:
|
|
244
|
-
"onUpdate:modelValue": e[1] || (e[1] = (
|
|
242
|
+
])) : _("", !0),
|
|
243
|
+
i("div", Be, [
|
|
244
|
+
y(P, {
|
|
245
|
+
modelValue: w.value,
|
|
246
|
+
"onUpdate:modelValue": e[1] || (e[1] = (l) => w.value = l),
|
|
245
247
|
placeholder: "输入手机号/工号/姓名/部门/职位搜索",
|
|
246
248
|
clearable: "",
|
|
247
|
-
onInput:
|
|
248
|
-
onClear:
|
|
249
|
+
onInput: ke,
|
|
250
|
+
onClear: de
|
|
249
251
|
}, {
|
|
250
|
-
"prefix-icon":
|
|
251
|
-
|
|
252
|
+
"prefix-icon": U(() => [
|
|
253
|
+
y(a, { name: "search" })
|
|
252
254
|
]),
|
|
253
255
|
_: 1
|
|
254
256
|
}, 8, ["modelValue"])
|
|
255
257
|
])
|
|
256
|
-
])) :
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
e[6] || (e[6] =
|
|
262
|
-
|
|
258
|
+
])) : _("", !0),
|
|
259
|
+
i("div", Oe, [
|
|
260
|
+
i("div", De, [
|
|
261
|
+
G.value ? (n(), c("div", Pe, [
|
|
262
|
+
i("div", Ae, [
|
|
263
|
+
e[6] || (e[6] = i("span", null, "搜索结果", -1)),
|
|
264
|
+
y(V, {
|
|
263
265
|
size: "small",
|
|
264
266
|
variant: "text",
|
|
265
|
-
onClick:
|
|
267
|
+
onClick: de
|
|
266
268
|
}, {
|
|
267
|
-
default:
|
|
268
|
-
|
|
269
|
+
default: U(() => [...e[5] || (e[5] = [
|
|
270
|
+
X("返回", -1)
|
|
269
271
|
])]),
|
|
270
272
|
_: 1
|
|
271
273
|
})
|
|
272
274
|
]),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
e[7] || (e[7] =
|
|
276
|
-
])) :
|
|
277
|
-
|
|
275
|
+
E.value ? (n(), c("div", Le, [
|
|
276
|
+
y(T),
|
|
277
|
+
e[7] || (e[7] = i("span", null, "搜索中...", -1))
|
|
278
|
+
])) : L.value.length === 0 ? (n(), c("div", Me, [
|
|
279
|
+
y(a, {
|
|
278
280
|
name: "search",
|
|
279
281
|
size: "48px",
|
|
280
282
|
style: { color: "#ddd" }
|
|
281
283
|
}),
|
|
282
|
-
e[8] || (e[8] =
|
|
283
|
-
])) : (
|
|
284
|
-
(
|
|
285
|
-
key:
|
|
286
|
-
class:
|
|
287
|
-
onClick: (
|
|
284
|
+
e[8] || (e[8] = i("p", null, "未找到匹配的人员", -1))
|
|
285
|
+
])) : (n(), c("div", Ee, [
|
|
286
|
+
(n(!0), c(j, null, F(L.value, (l) => (n(), c("div", {
|
|
287
|
+
key: l.id,
|
|
288
|
+
class: te(["cd-ps-result-item", { "cd-ps-selected": v.value.includes(l.id) }]),
|
|
289
|
+
onClick: (ee) => Ve(l)
|
|
288
290
|
}, [
|
|
289
|
-
|
|
290
|
-
checked:
|
|
291
|
-
onClick: e[2] || (e[2] =
|
|
291
|
+
y(R, {
|
|
292
|
+
checked: v.value.includes(l.id),
|
|
293
|
+
onClick: e[2] || (e[2] = ue(() => {
|
|
292
294
|
}, ["stop"]))
|
|
293
295
|
}, null, 8, ["checked"]),
|
|
294
|
-
|
|
295
|
-
|
|
296
|
+
i("div", Je, [
|
|
297
|
+
y(a, { name: "user" })
|
|
296
298
|
]),
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
i("div", je, [
|
|
300
|
+
i("div", Fe, f(l.displayName || l.name), 1),
|
|
301
|
+
i("div", qe, [
|
|
302
|
+
l.position ? (n(), c("span", Ge, f(l.position), 1)) : _("", !0),
|
|
303
|
+
l.department ? (n(), c("span", He, f(l.department), 1)) : _("", !0),
|
|
304
|
+
l.phone ? (n(), c("span", Qe, f(l.phone), 1)) : _("", !0)
|
|
303
305
|
])
|
|
304
306
|
])
|
|
305
|
-
], 10,
|
|
307
|
+
], 10, We))), 128))
|
|
306
308
|
]))
|
|
307
|
-
])) : (
|
|
309
|
+
])) : (n(), D(H, {
|
|
308
310
|
key: 1,
|
|
309
|
-
modelValue:
|
|
310
|
-
"onUpdate:modelValue": e[3] || (e[3] = (
|
|
311
|
-
onChange:
|
|
311
|
+
modelValue: N.value,
|
|
312
|
+
"onUpdate:modelValue": e[3] || (e[3] = (l) => N.value = l),
|
|
313
|
+
onChange: re
|
|
312
314
|
}, {
|
|
313
|
-
default:
|
|
314
|
-
(
|
|
315
|
-
key:
|
|
316
|
-
value:
|
|
317
|
-
label:
|
|
315
|
+
default: U(() => [
|
|
316
|
+
(n(!0), c(j, null, F(le.value, (l) => (n(), D(J, {
|
|
317
|
+
key: l.key,
|
|
318
|
+
value: l.key,
|
|
319
|
+
label: l.name
|
|
318
320
|
}, {
|
|
319
|
-
default:
|
|
320
|
-
var
|
|
321
|
+
default: U(() => {
|
|
322
|
+
var ee;
|
|
321
323
|
return [
|
|
322
|
-
|
|
323
|
-
((
|
|
324
|
+
i("div", Xe, [
|
|
325
|
+
((ee = o.value[l.key]) == null ? void 0 : ee.length) > 0 ? (n(), D(K, {
|
|
324
326
|
key: 0,
|
|
325
327
|
ref_for: !0,
|
|
326
|
-
ref: (
|
|
327
|
-
data:
|
|
328
|
+
ref: (C) => u(l.key, C),
|
|
329
|
+
data: o.value[l.key],
|
|
328
330
|
keys: { value: "id", label: "name", children: "children" },
|
|
329
331
|
hover: "",
|
|
330
332
|
checkable: "",
|
|
331
333
|
"expand-all": !1,
|
|
332
|
-
value:
|
|
333
|
-
onChange:
|
|
334
|
+
value: v.value,
|
|
335
|
+
onChange: Ue
|
|
334
336
|
}, {
|
|
335
|
-
label:
|
|
336
|
-
var
|
|
337
|
+
label: U(({ node: C }) => {
|
|
338
|
+
var he;
|
|
337
339
|
return [
|
|
338
|
-
|
|
339
|
-
class:
|
|
340
|
+
i("div", {
|
|
341
|
+
class: te(["cd-ps-node", { "cd-ps-node-user": C.data.isUser }])
|
|
340
342
|
}, [
|
|
341
|
-
|
|
342
|
-
name:
|
|
343
|
+
y(a, {
|
|
344
|
+
name: C.data.isUser ? "user" : l.icon || "folder"
|
|
343
345
|
}, null, 8, ["name"]),
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
346
|
+
i("span", Ye, [
|
|
347
|
+
X(f(C.label) + " ", 1),
|
|
348
|
+
C.data.isUser && C.data.position ? (n(), c("span", Ze, f(C.data.position), 1)) : _("", !0)
|
|
347
349
|
]),
|
|
348
|
-
|
|
349
|
-
!
|
|
350
|
+
C.data.userCount && !C.data.isUser ? (n(), c("span", Ke, "(" + f(C.data.userCount) + ")", 1)) : _("", !0),
|
|
351
|
+
!C.data.isUser && !((he = C.data.children) != null && he.length) && !C.data.loaded ? (n(), D(V, {
|
|
350
352
|
key: 1,
|
|
351
353
|
size: "small",
|
|
352
354
|
variant: "text",
|
|
353
355
|
class: "cd-ps-load-btn",
|
|
354
|
-
onClick:
|
|
356
|
+
onClick: ue((It) => Se(C, l.key), ["stop"])
|
|
355
357
|
}, {
|
|
356
|
-
default:
|
|
357
|
-
|
|
358
|
+
default: U(() => [...e[9] || (e[9] = [
|
|
359
|
+
X("显示人员", -1)
|
|
358
360
|
])]),
|
|
359
361
|
_: 1
|
|
360
|
-
}, 8, ["onClick"])) :
|
|
362
|
+
}, 8, ["onClick"])) : _("", !0)
|
|
361
363
|
], 2)
|
|
362
364
|
];
|
|
363
365
|
}),
|
|
364
366
|
_: 2
|
|
365
|
-
}, 1032, ["data", "value"])) : (
|
|
366
|
-
|
|
367
|
-
name:
|
|
367
|
+
}, 1032, ["data", "value"])) : (n(), c("div", et, [
|
|
368
|
+
y(a, {
|
|
369
|
+
name: l.icon || "folder-open",
|
|
368
370
|
size: "48px",
|
|
369
371
|
style: { color: "#ddd" }
|
|
370
372
|
}, null, 8, ["name"]),
|
|
371
|
-
e[10] || (e[10] =
|
|
373
|
+
e[10] || (e[10] = i("p", null, "暂无数据", -1))
|
|
372
374
|
]))
|
|
373
375
|
])
|
|
374
376
|
];
|
|
@@ -379,61 +381,61 @@ const Ie = { class: "cd-ps-container" }, Se = {
|
|
|
379
381
|
_: 1
|
|
380
382
|
}, 8, ["modelValue"]))
|
|
381
383
|
]),
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
e[12] || (e[12] =
|
|
385
|
-
|
|
386
|
-
|
|
384
|
+
i("div", tt, [
|
|
385
|
+
i("div", lt, [
|
|
386
|
+
e[12] || (e[12] = i("span", { class: "cd-ps-title" }, "已选择", -1)),
|
|
387
|
+
i("span", st, f(I.value.length) + " 项", 1),
|
|
388
|
+
I.value.length > 0 ? (n(), D(V, {
|
|
387
389
|
key: 0,
|
|
388
390
|
size: "small",
|
|
389
391
|
variant: "text",
|
|
390
|
-
onClick:
|
|
392
|
+
onClick: ve
|
|
391
393
|
}, {
|
|
392
|
-
default:
|
|
393
|
-
|
|
394
|
+
default: U(() => [...e[11] || (e[11] = [
|
|
395
|
+
X("清空", -1)
|
|
394
396
|
])]),
|
|
395
397
|
_: 1
|
|
396
|
-
})) :
|
|
398
|
+
})) : _("", !0)
|
|
397
399
|
]),
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
400
|
+
i("div", at, [
|
|
401
|
+
I.value.length === 0 ? (n(), c("div", nt, [
|
|
402
|
+
y(a, {
|
|
401
403
|
name: "user-checked",
|
|
402
404
|
size: "64px",
|
|
403
405
|
style: { color: "#ddd" }
|
|
404
406
|
}),
|
|
405
|
-
e[13] || (e[13] =
|
|
406
|
-
])) : (
|
|
407
|
-
(
|
|
408
|
-
key:
|
|
409
|
-
class:
|
|
407
|
+
e[13] || (e[13] = i("p", null, "暂无选择", -1))
|
|
408
|
+
])) : (n(), c("div", ot, [
|
|
409
|
+
(n(!0), c(j, null, F(I.value, (l) => (n(), c("div", {
|
|
410
|
+
key: l.id,
|
|
411
|
+
class: te(["cd-ps-selected-item", { "cd-ps-dept-item": !l.isUser }])
|
|
410
412
|
}, [
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
class:
|
|
413
|
+
i("div", dt, [
|
|
414
|
+
i("div", {
|
|
415
|
+
class: te(["cd-ps-avatar", { "cd-ps-avatar-dept": !l.isUser }])
|
|
414
416
|
}, [
|
|
415
|
-
|
|
416
|
-
name:
|
|
417
|
+
y(a, {
|
|
418
|
+
name: l.isUser ? "user" : "folder"
|
|
417
419
|
}, null, 8, ["name"])
|
|
418
420
|
], 2),
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
!
|
|
421
|
+
i("div", it, [
|
|
422
|
+
i("div", ct, f(l.displayName || l.name), 1),
|
|
423
|
+
i("div", ut, [
|
|
424
|
+
l.isUser && l.position ? (n(), c("span", rt, f(l.position), 1)) : _("", !0),
|
|
425
|
+
l.isUser && l.department ? (n(), c("span", pt, f(l.department), 1)) : _("", !0),
|
|
426
|
+
l.isUser ? _("", !0) : (n(), c("span", vt, f(l.typeName || "部门"), 1)),
|
|
427
|
+
!l.isUser && l.userCount ? (n(), c("span", mt, f(l.userCount) + "人", 1)) : _("", !0)
|
|
426
428
|
])
|
|
427
429
|
])
|
|
428
430
|
]),
|
|
429
|
-
|
|
431
|
+
y(V, {
|
|
430
432
|
size: "small",
|
|
431
433
|
variant: "text",
|
|
432
434
|
shape: "circle",
|
|
433
|
-
onClick: (
|
|
435
|
+
onClick: (ee) => Ie(l.id)
|
|
434
436
|
}, {
|
|
435
|
-
icon:
|
|
436
|
-
|
|
437
|
+
icon: U(() => [
|
|
438
|
+
y(a, { name: "close" })
|
|
437
439
|
]),
|
|
438
440
|
_: 1
|
|
439
441
|
}, 8, ["onClick"])
|
|
@@ -448,17 +450,212 @@ const Ie = { class: "cd-ps-container" }, Se = {
|
|
|
448
450
|
}, 8, ["visible", "width"]);
|
|
449
451
|
};
|
|
450
452
|
}
|
|
451
|
-
}),
|
|
452
|
-
const
|
|
453
|
-
for (const [d,
|
|
454
|
-
|
|
455
|
-
return
|
|
456
|
-
},
|
|
457
|
-
|
|
458
|
-
|
|
453
|
+
}), ge = (g, q) => {
|
|
454
|
+
const k = g.__vccOpts || g;
|
|
455
|
+
for (const [d, $] of q)
|
|
456
|
+
k[d] = $;
|
|
457
|
+
return k;
|
|
458
|
+
}, ye = /* @__PURE__ */ ge(ft, [["__scopeId", "data-v-1e0585c3"]]), ht = { class: "cd-input-select" }, _t = { class: "cd-input-select__option-content" }, gt = {
|
|
459
|
+
key: 0,
|
|
460
|
+
class: "cd-input-select__option-avatar"
|
|
461
|
+
}, yt = ["src", "alt"], kt = { class: "cd-input-select__option-info" }, bt = { class: "cd-input-select__option-name" }, Vt = {
|
|
462
|
+
key: 0,
|
|
463
|
+
class: "cd-input-select__option-desc"
|
|
464
|
+
}, Ct = {
|
|
465
|
+
key: 2,
|
|
466
|
+
class: "ri-building-line cd-input-select__option-icon"
|
|
467
|
+
}, Ut = /* @__PURE__ */ _e({
|
|
468
|
+
name: "CdInputPersonSelector",
|
|
469
|
+
__name: "InputSelect",
|
|
470
|
+
props: {
|
|
471
|
+
modelValue: {},
|
|
472
|
+
multiple: { type: Boolean, default: !0 },
|
|
473
|
+
placeholder: { default: "搜索用户、部门、职位" },
|
|
474
|
+
tabs: {},
|
|
475
|
+
organizations: {}
|
|
476
|
+
},
|
|
477
|
+
emits: ["update:modelValue", "search", "load-users"],
|
|
478
|
+
setup(g, { emit: q }) {
|
|
479
|
+
const k = g, d = q, $ = h(), x = h(!1), N = h([]), z = h(void 0), w = h(!1), v = h([]), m = h([]), M = A(() => {
|
|
480
|
+
const o = new Set(m.value.map((u) => u.id));
|
|
481
|
+
return [
|
|
482
|
+
...m.value,
|
|
483
|
+
...N.value.filter((u) => !o.has(u.id))
|
|
484
|
+
];
|
|
485
|
+
}), G = (o) => o ? o.substring(0, 2).toUpperCase() : "", E = (o) => {
|
|
486
|
+
const r = [
|
|
487
|
+
"#1890ff",
|
|
488
|
+
"#52c41a",
|
|
489
|
+
"#faad14",
|
|
490
|
+
"#f5222d",
|
|
491
|
+
"#722ed1",
|
|
492
|
+
"#13c2c2",
|
|
493
|
+
"#eb2f96",
|
|
494
|
+
"#fa8c16"
|
|
495
|
+
];
|
|
496
|
+
let u = 0;
|
|
497
|
+
for (let b = 0; b < o.length; b++)
|
|
498
|
+
u = o.charCodeAt(b) + ((u << 5) - u);
|
|
499
|
+
return r[Math.abs(u) % r.length];
|
|
500
|
+
}, L = (o) => {
|
|
501
|
+
o && o.trim() ? (x.value = !0, d("search", {
|
|
502
|
+
keyword: o,
|
|
503
|
+
callback: (r) => {
|
|
504
|
+
N.value = r, x.value = !1;
|
|
505
|
+
}
|
|
506
|
+
})) : (N.value = [], x.value = !1);
|
|
507
|
+
}, le = (o) => {
|
|
508
|
+
const r = Array.isArray(o) ? o : o ? [o] : [], u = k.modelValue.map((s) => s.id), b = r.filter((s) => !u.includes(s)), I = u.filter((s) => !r.includes(s));
|
|
509
|
+
if (b.length > 0) {
|
|
510
|
+
const s = b.map((B) => M.value.find((oe) => oe.id === B)).filter(Boolean);
|
|
511
|
+
if (!k.multiple)
|
|
512
|
+
d("update:modelValue", s), m.value = s, N.value = [];
|
|
513
|
+
else {
|
|
514
|
+
const B = [...k.modelValue, ...s];
|
|
515
|
+
d("update:modelValue", B), m.value = B;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
if (I.length > 0) {
|
|
519
|
+
const s = k.modelValue.filter((B) => !I.includes(B.id));
|
|
520
|
+
d("update:modelValue", s), m.value = s;
|
|
521
|
+
}
|
|
522
|
+
}, Y = (o) => {
|
|
523
|
+
const r = k.modelValue.filter((u) => u.id !== o);
|
|
524
|
+
d("update:modelValue", r), m.value = r;
|
|
525
|
+
}, Z = () => {
|
|
526
|
+
w.value = !0;
|
|
527
|
+
}, se = (o) => {
|
|
528
|
+
const r = o.map((u) => {
|
|
529
|
+
const b = u.displayName || u.name || u.title || String(u.id);
|
|
530
|
+
return {
|
|
531
|
+
id: u.id,
|
|
532
|
+
name: b,
|
|
533
|
+
avatar: u.avatar || "",
|
|
534
|
+
department: u.department || "",
|
|
535
|
+
position: u.position || "",
|
|
536
|
+
phone: u.phone || "",
|
|
537
|
+
isUser: u.isUser !== !1
|
|
538
|
+
};
|
|
539
|
+
});
|
|
540
|
+
if (!k.multiple)
|
|
541
|
+
d("update:modelValue", r.slice(0, 1)), m.value = r.slice(0, 1);
|
|
542
|
+
else {
|
|
543
|
+
const u = new Set(k.modelValue.map((s) => s.id)), b = r.filter((s) => !u.has(s.id)), I = [...k.modelValue, ...b];
|
|
544
|
+
d("update:modelValue", I), m.value = I;
|
|
545
|
+
}
|
|
546
|
+
w.value = !1;
|
|
547
|
+
}, ae = (o) => {
|
|
548
|
+
d("load-users", o);
|
|
549
|
+
}, ne = (o) => {
|
|
550
|
+
d("search", {
|
|
551
|
+
keyword: o.keyword,
|
|
552
|
+
callback: o.callback
|
|
553
|
+
});
|
|
554
|
+
};
|
|
555
|
+
return Q(() => k.modelValue, (o) => {
|
|
556
|
+
k.multiple ? z.value = o.map((r) => r.id) : z.value = o.length > 0 ? o[0].id : void 0, v.value = o.map((r) => r.id), m.value = o;
|
|
557
|
+
}, { immediate: !0, deep: !0 }), (o, r) => {
|
|
558
|
+
const u = S("t-tag"), b = S("t-option"), I = S("t-select");
|
|
559
|
+
return n(), c("div", ht, [
|
|
560
|
+
y(I, {
|
|
561
|
+
ref_key: "selectRef",
|
|
562
|
+
ref: $,
|
|
563
|
+
modelValue: z.value,
|
|
564
|
+
"onUpdate:modelValue": r[0] || (r[0] = (s) => z.value = s),
|
|
565
|
+
multiple: g.multiple,
|
|
566
|
+
placeholder: g.placeholder,
|
|
567
|
+
filterable: !0,
|
|
568
|
+
filter: () => !0,
|
|
569
|
+
loading: x.value,
|
|
570
|
+
"reserve-keyword": !1,
|
|
571
|
+
"allow-input": !0,
|
|
572
|
+
size: "medium",
|
|
573
|
+
class: "cd-input-select__select",
|
|
574
|
+
onSearch: L,
|
|
575
|
+
onChange: le
|
|
576
|
+
}, {
|
|
577
|
+
valueDisplay: U(() => [
|
|
578
|
+
(n(!0), c(j, null, F(m.value, (s) => (n(), D(u, {
|
|
579
|
+
key: s.id,
|
|
580
|
+
closable: "",
|
|
581
|
+
size: "medium",
|
|
582
|
+
variant: s.isUser === !1 ? "outline" : "light",
|
|
583
|
+
theme: s.isUser === !1 ? "primary" : "default",
|
|
584
|
+
onClose: () => Y(s.id),
|
|
585
|
+
class: "cd-input-select__tag"
|
|
586
|
+
}, {
|
|
587
|
+
default: U(() => [
|
|
588
|
+
X(f(s.name), 1)
|
|
589
|
+
]),
|
|
590
|
+
_: 2
|
|
591
|
+
}, 1032, ["variant", "theme", "onClose"]))), 128))
|
|
592
|
+
]),
|
|
593
|
+
suffixIcon: U(() => [
|
|
594
|
+
i("i", {
|
|
595
|
+
class: "ri-add-circle-line cd-input-select__add-icon",
|
|
596
|
+
onClick: ue(Z, ["stop"])
|
|
597
|
+
})
|
|
598
|
+
]),
|
|
599
|
+
default: U(() => [
|
|
600
|
+
(n(!0), c(j, null, F(M.value, (s) => (n(), D(b, {
|
|
601
|
+
key: s.id,
|
|
602
|
+
value: s.id,
|
|
603
|
+
label: s.name,
|
|
604
|
+
class: "cd-input-select__option"
|
|
605
|
+
}, {
|
|
606
|
+
default: U(() => [
|
|
607
|
+
i("div", _t, [
|
|
608
|
+
s.avatar ? (n(), c("div", gt, [
|
|
609
|
+
i("img", {
|
|
610
|
+
src: s.avatar,
|
|
611
|
+
alt: s.name
|
|
612
|
+
}, null, 8, yt)
|
|
613
|
+
])) : (n(), c("div", {
|
|
614
|
+
key: 1,
|
|
615
|
+
class: "cd-input-select__option-avatar cd-input-select__option-avatar--placeholder",
|
|
616
|
+
style: ze({
|
|
617
|
+
backgroundColor: s.isUser === !1 ? "#e6f4ff" : E(s.name),
|
|
618
|
+
color: s.isUser === !1 ? "#0052d9" : "#fff"
|
|
619
|
+
})
|
|
620
|
+
}, f(G(s.name)), 5)),
|
|
621
|
+
i("div", kt, [
|
|
622
|
+
i("div", bt, f(s.name), 1),
|
|
623
|
+
s.department || s.position ? (n(), c("div", Vt, f(s.department) + f(s.department && s.position ? " · " : "") + f(s.position), 1)) : _("", !0)
|
|
624
|
+
]),
|
|
625
|
+
s.isUser === !1 ? (n(), c("i", Ct)) : _("", !0)
|
|
626
|
+
])
|
|
627
|
+
]),
|
|
628
|
+
_: 2
|
|
629
|
+
}, 1032, ["value", "label"]))), 128))
|
|
630
|
+
]),
|
|
631
|
+
_: 1
|
|
632
|
+
}, 8, ["modelValue", "multiple", "placeholder", "loading"]),
|
|
633
|
+
g.tabs && g.tabs.length > 0 && w.value ? (n(), D(ye, {
|
|
634
|
+
key: 0,
|
|
635
|
+
visible: w.value,
|
|
636
|
+
"onUpdate:visible": r[1] || (r[1] = (s) => w.value = s),
|
|
637
|
+
modelValue: v.value,
|
|
638
|
+
"onUpdate:modelValue": r[2] || (r[2] = (s) => v.value = s),
|
|
639
|
+
tabs: g.tabs,
|
|
640
|
+
organizations: g.organizations || [],
|
|
641
|
+
"show-org": !1,
|
|
642
|
+
"show-search": !0,
|
|
643
|
+
multiple: g.multiple,
|
|
644
|
+
tips: "选择要添加的人员",
|
|
645
|
+
onConfirm: se,
|
|
646
|
+
onLoadUsers: ae,
|
|
647
|
+
onSearch: ne
|
|
648
|
+
}, null, 8, ["visible", "modelValue", "tabs", "organizations", "multiple"])) : _("", !0)
|
|
649
|
+
]);
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
}), St = /* @__PURE__ */ ge(Ut, [["__scopeId", "data-v-26709bdb"]]), Nt = {
|
|
653
|
+
install(g) {
|
|
654
|
+
g.component("PersonSelector", ye), g.component("CdInputPersonSelector", St);
|
|
459
655
|
}
|
|
460
656
|
};
|
|
461
657
|
export {
|
|
462
|
-
|
|
463
|
-
|
|
658
|
+
St as InputSelect,
|
|
659
|
+
ye as PersonSelector,
|
|
660
|
+
Nt as default
|
|
464
661
|
};
|