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.mjs CHANGED
@@ -1,41 +1,41 @@
1
- import { defineComponent as Ne, ref as _, computed as S, watch as $, resolveComponent as m, createBlock as w, openBlock as a, withCtx as y, createElementVNode as n, createElementBlock as o, createCommentVNode as h, createVNode as v, toDisplayString as f, Fragment as J, renderList as j, createTextVNode as A, normalizeClass as F, withModifiers as de, nextTick as xe } from "vue";
2
- const Ie = { class: "cd-ps-container" }, Se = {
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
- }, we = {
5
+ }, Re = {
6
6
  key: 1,
7
7
  class: "cd-ps-search"
8
- }, ze = {
8
+ }, $e = {
9
9
  key: 0,
10
10
  class: "cd-ps-org-select"
11
- }, Te = { class: "cd-ps-search-input" }, Oe = { class: "cd-ps-content" }, Be = { class: "cd-ps-left" }, De = {
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
- }, Re = { class: "cd-ps-search-header" }, Ee = {
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
- }, Pe = {
20
+ }, Ee = {
21
21
  key: 2,
22
22
  class: "cd-ps-result-list"
23
- }, Le = ["onClick"], We = { class: "cd-ps-avatar" }, $e = { class: "cd-ps-info" }, Je = { class: "cd-ps-name" }, je = { class: "cd-ps-meta" }, Ae = { key: 0 }, Fe = { key: 1 }, qe = { key: 2 }, Ge = { class: "cd-ps-tree" }, He = { class: "cd-ps-node-name" }, Qe = {
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
- }, Xe = {
26
+ }, Ke = {
27
27
  key: 0,
28
28
  class: "cd-ps-count"
29
- }, Ye = {
29
+ }, et = {
30
30
  key: 1,
31
31
  class: "cd-ps-empty"
32
- }, Ze = { class: "cd-ps-right" }, Ke = { class: "cd-ps-right-header" }, et = { class: "cd-ps-num" }, tt = { class: "cd-ps-right-list" }, st = {
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
- }, lt = {
35
+ }, ot = {
36
36
  key: 1,
37
37
  class: "cd-ps-selected-list"
38
- }, at = { class: "cd-ps-item-info" }, nt = { class: "cd-ps-info" }, ot = { class: "cd-ps-name" }, dt = { class: "cd-ps-meta" }, ct = { key: 0 }, it = { key: 1 }, rt = { key: 2 }, ut = { key: 3 }, pt = /* @__PURE__ */ Ne({
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(z, { expose: q, emit: P }) {
52
- var ae, ne;
53
- const d = z, C = P, b = _(d.visible), V = _(((ne = (ae = d.tabs) == null ? void 0 : ae[0]) == null ? void 0 : ne.key) || ""), U = _(null), T = _(""), i = _([]), N = _(/* @__PURE__ */ new Map()), G = _({}), H = _(!1), L = _(!1), D = _([]), ce = S(() => d.tabs || []), Y = S(() => d.organizations || []), Z = S(() => d.tips || ""), ie = S(() => d.showSearch), re = S(() => d.showOrg), ue = S(() => d.dialogWidth), x = _({});
54
- $(() => d.tabs, (t) => {
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((l) => {
58
- e[l.key] = JSON.parse(JSON.stringify(l.tree));
59
- }), x.value = e, (!V.value || !t.find((l) => l.key === V.value)) && (V.value = t[0].key);
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 K() {
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 ? (i.value = d.modelValue.map((e) => e.id), N.value.clear(), d.modelValue.forEach((e) => {
66
- N.value.set(e.id, e);
67
- })) : i.value = [...d.modelValue];
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
- i.value = [], N.value.clear();
70
+ v.value = [], m.value.clear();
70
71
  }
71
- $(() => d.modelValue, (t) => {
72
- b.value && t && K();
73
- }, { deep: !0 }), $(() => d.visible, (t) => {
74
- b.value = t, t && (K(), d.organizations.length > 0 && !U.value && (U.value = d.organizations[0].id));
75
- }), $(b, (t) => {
76
- C("update:visible", t);
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 pe(t, e) {
79
- e && (G.value[t] = e);
79
+ function u(t, e) {
80
+ e && (M.value[t] = e);
80
81
  }
81
- function ee(t, e) {
82
- for (const l of t) {
83
- if (l.id === e) return l;
84
- if (l.children) {
85
- const c = ee(l.children, e);
86
- if (c) return c;
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 R = S(() => i.value.map((t) => N.value.get(t)).filter(Boolean));
92
- function te(t, e) {
93
- i.value.includes(t) || i.value.push(t), N.value.set(t, e);
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 Q(t) {
96
- i.value = i.value.filter((e) => e !== t), N.value.delete(t);
96
+ function B(t) {
97
+ v.value = v.value.filter((e) => e !== t), m.value.delete(t);
97
98
  }
98
- const ve = () => {
99
- T.value = "";
100
- }, he = (t) => {
99
+ const re = () => {
100
+ w.value = "";
101
+ }, oe = (t) => {
101
102
  const e = {};
102
- d.tabs.forEach((l) => {
103
- e[l.key] = [];
104
- }), x.value = e, C("org-change", t);
103
+ d.tabs.forEach((a) => {
104
+ e[a.key] = [];
105
+ }), o.value = e, $("org-change", t);
105
106
  };
106
- let O = null;
107
- const fe = () => {
108
- if (O && clearTimeout(O), !T.value.trim()) {
109
- X();
107
+ let W = null;
108
+ const ke = () => {
109
+ if (W && clearTimeout(W), !w.value.trim()) {
110
+ de();
110
111
  return;
111
112
  }
112
- H.value = !0, L.value = !0, O = setTimeout(() => _e(), 300);
113
- }, _e = () => {
114
- D.value = [];
113
+ G.value = !0, E.value = !0, W = setTimeout(() => be(), 300);
114
+ }, be = () => {
115
+ L.value = [];
115
116
  const t = (e) => {
116
- D.value = e.map((l) => ({ ...l, isUser: !0 })), L.value = !1;
117
+ L.value = e.map((a) => ({ ...a, isUser: !0 })), E.value = !1;
117
118
  };
118
- C("search", { keyword: T.value, orgId: U.value || void 0, callback: t });
119
- }, X = () => {
120
- O && (clearTimeout(O), O = null), H.value = !1, T.value = "", D.value = [], L.value = !1;
121
- }, me = (t) => {
122
- i.value.indexOf(t.id) > -1 ? Q(t.id) : te(t.id, { ...t, isUser: !0, typeName: "搜索结果", orgId: U.value });
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 ke(t) {
125
- const e = [], l = (c) => {
126
- for (const k of c)
127
- e.push(k.id), k.children && l(k.children);
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 l(t), e;
130
+ return a(t), e;
130
131
  }
131
- const ye = (t, e) => {
132
- var r;
133
- const l = e == null ? void 0 : e.node;
134
- if (l) {
135
- const u = l.value ?? ((r = l.data) == null ? void 0 : r.id);
136
- if (u !== void 0) {
137
- if (l.checked) {
138
- const B = d.tabs.find((M) => M.key === V.value), E = B ? B.name.replace(/^按/, "") : "";
139
- te(u, { ...l.data, typeName: E, orgId: U.value });
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
- Q(u);
143
+ B(R);
142
144
  return;
143
145
  }
144
146
  }
145
- const c = x.value[V.value] || [], k = ke(c), g = i.value.filter((u) => !k.includes(u));
146
- i.value = [...g, ...t];
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 se(t, e, l) {
149
- for (const c of t) {
150
- if (c.id === e)
151
- return c.children = c.children || [], c.children.push(...l), c.loaded = !0, !0;
152
- if (c.children && se(c.children, e, l))
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 ge(t, e) {
158
- const l = t.value, c = G.value[e];
159
- C("load-users", { tabKey: e, nodeId: l, node: t, callback: async (g) => {
160
- if (g.length > 0) {
161
- const r = g.map((I) => {
162
- const { id: B, name: E, ...M } = I;
163
- return { ...M, id: B, name: I.displayName || E, isUser: !0 };
164
- }), u = x.value[e];
165
- if (u && se(u, l, r), c) {
166
- c.appendTo(l, r), t.data.loaded = !0, await xe();
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
- c.setItem(l, { expanded: !0 });
170
+ p.setItem(a, { expanded: !0 });
169
171
  } catch {
170
172
  }
171
173
  }
172
174
  } else {
173
175
  t.data.loaded = !0;
174
- const r = x.value[e];
175
- if (r) {
176
- const u = ee(r, l);
177
- u && (u.loaded = !0);
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 Ce = (t) => {
183
- Q(t);
184
- }, le = () => {
185
- i.value = [], N.value.clear();
186
- }, be = () => {
187
- C("update:modelValue", i.value), C("confirm", R.value), b.value = !1;
188
- }, Ve = () => {
189
- b.value = !1;
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: le,
193
- appendUsers: (t, e, l) => {
194
- const c = G.value[t];
195
- if (c && l.length > 0) {
196
- const k = l.map((g) => {
197
- const { id: r, name: u, ...I } = g;
198
- return { ...I, id: r, name: g.displayName || u, isUser: !0 };
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
- c.appendTo(e, k);
202
+ p.appendTo(e, O);
201
203
  }
202
204
  }
203
205
  }), (t, e) => {
204
- const l = m("t-icon"), c = m("t-option"), k = m("t-select"), g = m("t-input"), r = m("t-button"), u = m("t-loading"), I = m("t-checkbox"), B = m("t-tree"), E = m("t-tab-panel"), M = m("t-tabs"), Ue = m("t-dialog");
205
- return a(), w(Ue, {
206
- visible: b.value,
207
- "onUpdate:visible": e[4] || (e[4] = (s) => b.value = s),
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: ue.value,
211
+ width: ne.value,
210
212
  footer: !0,
211
213
  placement: "center",
212
214
  "destroy-on-close": "",
213
- onConfirm: be,
214
- onClose: Ve
215
+ onConfirm: ie,
216
+ onClose: xe
215
217
  }, {
216
- default: y(() => [
217
- n("div", Ie, [
218
- Z.value ? (a(), o("div", Se, [
219
- v(l, { name: "info-circle" }),
220
- n("span", null, f(Z.value), 1)
221
- ])) : h("", !0),
222
- ie.value ? (a(), o("div", we, [
223
- re.value && Y.value.length > 0 ? (a(), o("div", ze, [
224
- v(k, {
225
- modelValue: U.value,
226
- "onUpdate:modelValue": e[0] || (e[0] = (s) => U.value = s),
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: he
231
+ onChange: oe
230
232
  }, {
231
- default: y(() => [
232
- (a(!0), o(J, null, j(Y.value, (s) => (a(), w(c, {
233
- key: s.id,
234
- value: s.id,
235
- label: s.displayName || s.name
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
- ])) : h("", !0),
241
- n("div", Te, [
242
- v(g, {
243
- modelValue: T.value,
244
- "onUpdate:modelValue": e[1] || (e[1] = (s) => T.value = s),
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: fe,
248
- onClear: X
249
+ onInput: ke,
250
+ onClear: de
249
251
  }, {
250
- "prefix-icon": y(() => [
251
- v(l, { name: "search" })
252
+ "prefix-icon": U(() => [
253
+ y(a, { name: "search" })
252
254
  ]),
253
255
  _: 1
254
256
  }, 8, ["modelValue"])
255
257
  ])
256
- ])) : h("", !0),
257
- n("div", Oe, [
258
- n("div", Be, [
259
- H.value ? (a(), o("div", De, [
260
- n("div", Re, [
261
- e[6] || (e[6] = n("span", null, "搜索结果", -1)),
262
- v(r, {
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: X
267
+ onClick: de
266
268
  }, {
267
- default: y(() => [...e[5] || (e[5] = [
268
- A("返回", -1)
269
+ default: U(() => [...e[5] || (e[5] = [
270
+ X("返回", -1)
269
271
  ])]),
270
272
  _: 1
271
273
  })
272
274
  ]),
273
- L.value ? (a(), o("div", Ee, [
274
- v(u),
275
- e[7] || (e[7] = n("span", null, "搜索中...", -1))
276
- ])) : D.value.length === 0 ? (a(), o("div", Me, [
277
- v(l, {
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] = n("p", null, "未找到匹配的人员", -1))
283
- ])) : (a(), o("div", Pe, [
284
- (a(!0), o(J, null, j(D.value, (s) => (a(), o("div", {
285
- key: s.id,
286
- class: F(["cd-ps-result-item", { "cd-ps-selected": i.value.includes(s.id) }]),
287
- onClick: (W) => me(s)
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
- v(I, {
290
- checked: i.value.includes(s.id),
291
- onClick: e[2] || (e[2] = de(() => {
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
- n("div", We, [
295
- v(l, { name: "user" })
296
+ i("div", Je, [
297
+ y(a, { name: "user" })
296
298
  ]),
297
- n("div", $e, [
298
- n("div", Je, f(s.displayName || s.name), 1),
299
- n("div", je, [
300
- s.position ? (a(), o("span", Ae, f(s.position), 1)) : h("", !0),
301
- s.department ? (a(), o("span", Fe, f(s.department), 1)) : h("", !0),
302
- s.phone ? (a(), o("span", qe, f(s.phone), 1)) : h("", !0)
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, Le))), 128))
307
+ ], 10, We))), 128))
306
308
  ]))
307
- ])) : (a(), w(M, {
309
+ ])) : (n(), D(H, {
308
310
  key: 1,
309
- modelValue: V.value,
310
- "onUpdate:modelValue": e[3] || (e[3] = (s) => V.value = s),
311
- onChange: ve
311
+ modelValue: N.value,
312
+ "onUpdate:modelValue": e[3] || (e[3] = (l) => N.value = l),
313
+ onChange: re
312
314
  }, {
313
- default: y(() => [
314
- (a(!0), o(J, null, j(ce.value, (s) => (a(), w(E, {
315
- key: s.key,
316
- value: s.key,
317
- label: s.name
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: y(() => {
320
- var W;
321
+ default: U(() => {
322
+ var ee;
321
323
  return [
322
- n("div", Ge, [
323
- ((W = x.value[s.key]) == null ? void 0 : W.length) > 0 ? (a(), w(B, {
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: (p) => pe(s.key, p),
327
- data: x.value[s.key],
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: i.value,
333
- onChange: ye
334
+ value: v.value,
335
+ onChange: Ue
334
336
  }, {
335
- label: y(({ node: p }) => {
336
- var oe;
337
+ label: U(({ node: C }) => {
338
+ var he;
337
339
  return [
338
- n("div", {
339
- class: F(["cd-ps-node", { "cd-ps-node-user": p.data.isUser }])
340
+ i("div", {
341
+ class: te(["cd-ps-node", { "cd-ps-node-user": C.data.isUser }])
340
342
  }, [
341
- v(l, {
342
- name: p.data.isUser ? "user" : s.icon || "folder"
343
+ y(a, {
344
+ name: C.data.isUser ? "user" : l.icon || "folder"
343
345
  }, null, 8, ["name"]),
344
- n("span", He, [
345
- A(f(p.label) + " ", 1),
346
- p.data.isUser && p.data.position ? (a(), o("span", Qe, f(p.data.position), 1)) : h("", !0)
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
- p.data.userCount && !p.data.isUser ? (a(), o("span", Xe, "(" + f(p.data.userCount) + ")", 1)) : h("", !0),
349
- !p.data.isUser && !((oe = p.data.children) != null && oe.length) && !p.data.loaded ? (a(), w(r, {
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: de((ft) => ge(p, s.key), ["stop"])
356
+ onClick: ue((It) => Se(C, l.key), ["stop"])
355
357
  }, {
356
- default: y(() => [...e[9] || (e[9] = [
357
- A("显示人员", -1)
358
+ default: U(() => [...e[9] || (e[9] = [
359
+ X("显示人员", -1)
358
360
  ])]),
359
361
  _: 1
360
- }, 8, ["onClick"])) : h("", !0)
362
+ }, 8, ["onClick"])) : _("", !0)
361
363
  ], 2)
362
364
  ];
363
365
  }),
364
366
  _: 2
365
- }, 1032, ["data", "value"])) : (a(), o("div", Ye, [
366
- v(l, {
367
- name: s.icon || "folder-open",
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] = n("p", null, "暂无数据", -1))
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
- n("div", Ze, [
383
- n("div", Ke, [
384
- e[12] || (e[12] = n("span", { class: "cd-ps-title" }, "已选择", -1)),
385
- n("span", et, f(R.value.length) + " 项", 1),
386
- R.value.length > 0 ? (a(), w(r, {
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: le
392
+ onClick: ve
391
393
  }, {
392
- default: y(() => [...e[11] || (e[11] = [
393
- A("清空", -1)
394
+ default: U(() => [...e[11] || (e[11] = [
395
+ X("清空", -1)
394
396
  ])]),
395
397
  _: 1
396
- })) : h("", !0)
398
+ })) : _("", !0)
397
399
  ]),
398
- n("div", tt, [
399
- R.value.length === 0 ? (a(), o("div", st, [
400
- v(l, {
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] = n("p", null, "暂无选择", -1))
406
- ])) : (a(), o("div", lt, [
407
- (a(!0), o(J, null, j(R.value, (s) => (a(), o("div", {
408
- key: s.id,
409
- class: F(["cd-ps-selected-item", { "cd-ps-dept-item": !s.isUser }])
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
- n("div", at, [
412
- n("div", {
413
- class: F(["cd-ps-avatar", { "cd-ps-avatar-dept": !s.isUser }])
413
+ i("div", dt, [
414
+ i("div", {
415
+ class: te(["cd-ps-avatar", { "cd-ps-avatar-dept": !l.isUser }])
414
416
  }, [
415
- v(l, {
416
- name: s.isUser ? "user" : "folder"
417
+ y(a, {
418
+ name: l.isUser ? "user" : "folder"
417
419
  }, null, 8, ["name"])
418
420
  ], 2),
419
- n("div", nt, [
420
- n("div", ot, f(s.displayName || s.name), 1),
421
- n("div", dt, [
422
- s.isUser && s.position ? (a(), o("span", ct, f(s.position), 1)) : h("", !0),
423
- s.isUser && s.department ? (a(), o("span", it, f(s.department), 1)) : h("", !0),
424
- s.isUser ? h("", !0) : (a(), o("span", rt, f(s.typeName || "部门"), 1)),
425
- !s.isUser && s.userCount ? (a(), o("span", ut, f(s.userCount) + "人", 1)) : h("", !0)
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
- v(r, {
431
+ y(V, {
430
432
  size: "small",
431
433
  variant: "text",
432
434
  shape: "circle",
433
- onClick: (W) => Ce(s.id)
435
+ onClick: (ee) => Ie(l.id)
434
436
  }, {
435
- icon: y(() => [
436
- v(l, { name: "close" })
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
- }), vt = (z, q) => {
452
- const P = z.__vccOpts || z;
453
- for (const [d, C] of q)
454
- P[d] = C;
455
- return P;
456
- }, ht = /* @__PURE__ */ vt(pt, [["__scopeId", "data-v-a0450286"]]), mt = {
457
- install(z) {
458
- z.component("PersonSelector", ht);
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
- ht as PersonSelector,
463
- mt as default
658
+ St as InputSelect,
659
+ ye as PersonSelector,
660
+ Nt as default
464
661
  };