@mingminghahayu/profession-select-dialog-vue3 1.0.1 → 1.0.2
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as x, openBlock as _, createElementBlock as B, createElementVNode as u, computed as L, ref as w, watch as K, resolveComponent as b, resolveDirective as Q, createBlock as j, withCtx as m, createVNode as c, createTextVNode as I, unref as T, withDirectives as W, toDisplayString as X, createCommentVNode as Y, nextTick as P } from "vue";
|
|
2
2
|
import { ElMessageBox as Z, ElMessage as V } from "element-plus";
|
|
3
3
|
/*! Element Plus Icons Vue v2.3.2 */
|
|
4
|
-
var ee = /* @__PURE__ */
|
|
4
|
+
var ee = /* @__PURE__ */ x({
|
|
5
5
|
name: "Check",
|
|
6
6
|
__name: "check",
|
|
7
7
|
setup(p) {
|
|
@@ -9,13 +9,13 @@ var ee = /* @__PURE__ */ A({
|
|
|
9
9
|
xmlns: "http://www.w3.org/2000/svg",
|
|
10
10
|
viewBox: "0 0 1024 1024"
|
|
11
11
|
}, [
|
|
12
|
-
|
|
12
|
+
u("path", {
|
|
13
13
|
fill: "currentColor",
|
|
14
14
|
d: "M406.656 706.944 195.84 496.256a32 32 0 1 0-45.248 45.248l256 256 512-512a32 32 0 0 0-45.248-45.248L406.592 706.944z"
|
|
15
15
|
})
|
|
16
16
|
]));
|
|
17
17
|
}
|
|
18
|
-
}), te = ee,
|
|
18
|
+
}), te = ee, se = /* @__PURE__ */ x({
|
|
19
19
|
name: "Delete",
|
|
20
20
|
__name: "delete",
|
|
21
21
|
setup(p) {
|
|
@@ -23,19 +23,19 @@ var ee = /* @__PURE__ */ A({
|
|
|
23
23
|
xmlns: "http://www.w3.org/2000/svg",
|
|
24
24
|
viewBox: "0 0 1024 1024"
|
|
25
25
|
}, [
|
|
26
|
-
|
|
26
|
+
u("path", {
|
|
27
27
|
fill: "currentColor",
|
|
28
28
|
d: "M160 256H96a32 32 0 0 1 0-64h256V95.936a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V192h256a32 32 0 1 1 0 64h-64v672a32 32 0 0 1-32 32H192a32 32 0 0 1-32-32zm448-64v-64H416v64zM224 896h576V256H224zm192-128a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32m192 0a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32"
|
|
29
29
|
})
|
|
30
30
|
]));
|
|
31
31
|
}
|
|
32
|
-
}),
|
|
33
|
-
const
|
|
32
|
+
}), A = se;
|
|
33
|
+
const ae = (p, v) => {
|
|
34
34
|
const i = p.__vccOpts || p;
|
|
35
35
|
for (const [h, S] of v)
|
|
36
36
|
i[h] = S;
|
|
37
37
|
return i;
|
|
38
|
-
},
|
|
38
|
+
}, oe = { class: "dialog-body" }, ne = { class: "left-panel" }, le = { class: "select-all-btn-wrap" }, ie = { class: "right-panel" }, re = { class: "selected-header" }, de = {
|
|
39
39
|
__name: "ProfessionSelectDialog",
|
|
40
40
|
props: {
|
|
41
41
|
modelValue: { type: Boolean, default: !1 },
|
|
@@ -48,64 +48,69 @@ const se = (p, v) => {
|
|
|
48
48
|
},
|
|
49
49
|
emits: ["update:modelValue", "confirm"],
|
|
50
50
|
setup(p, { emit: v }) {
|
|
51
|
-
const i = p, h = v, S =
|
|
51
|
+
const i = p, h = v, S = L({
|
|
52
52
|
get: () => i.modelValue,
|
|
53
|
-
set: (
|
|
54
|
-
}), y =
|
|
55
|
-
function
|
|
56
|
-
return
|
|
53
|
+
set: (s) => h("update:modelValue", s)
|
|
54
|
+
}), y = w(!1), f = w([]), l = w([]), g = w(), D = L(() => i.multiple ? i.multipleLimit > 0 && l.value.length > i.multipleLimit ? !1 : l.value.length > 0 : l.value.length === 1);
|
|
55
|
+
function k(s) {
|
|
56
|
+
return l.value.some((e) => String(e.professionId) === String(s));
|
|
57
57
|
}
|
|
58
|
-
function z(
|
|
59
|
-
return i.disabledItems.some((e) => String(e.id) === String(
|
|
58
|
+
function z(s) {
|
|
59
|
+
return i.disabledItems.some((e) => String(e.id) === String(s));
|
|
60
60
|
}
|
|
61
|
-
function $(
|
|
62
|
-
const e =
|
|
63
|
-
var
|
|
61
|
+
function $(s) {
|
|
62
|
+
const e = s.users || s.userList || s.members || s.children || [], o = (Array.isArray(e) ? e : []).map((t) => {
|
|
63
|
+
var n, r;
|
|
64
64
|
return {
|
|
65
|
-
id: (r = (
|
|
66
|
-
|
|
65
|
+
id: (r = (n = t.id) != null ? n : t.userId) != null ? r : t.value,
|
|
66
|
+
userName: t.userName || t.username || "-",
|
|
67
|
+
nickName: t.nickName || t.name || t.label || "-",
|
|
67
68
|
userType: t.userType || "",
|
|
68
69
|
majorCode: t.majorCode || ""
|
|
69
70
|
};
|
|
70
|
-
}),
|
|
71
|
+
}), a = o.map((t) => t.nickName).filter(Boolean).join("\u3001");
|
|
71
72
|
return {
|
|
72
|
-
id:
|
|
73
|
-
profession:
|
|
74
|
-
majorName:
|
|
75
|
-
majorCode:
|
|
76
|
-
users:
|
|
77
|
-
userNames:
|
|
73
|
+
id: s.id,
|
|
74
|
+
profession: s.profession || s.departmentName || s.name || "-",
|
|
75
|
+
majorName: s.majorName || s.profession || s.name || "-",
|
|
76
|
+
majorCode: s.majorCode || "",
|
|
77
|
+
users: o,
|
|
78
|
+
userNames: a
|
|
78
79
|
};
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
-
const e =
|
|
82
|
-
return
|
|
81
|
+
function N(s) {
|
|
82
|
+
const e = s.id, o = s.profession, a = s.majorName || o, t = s.majorCode || "", n = s.users || [];
|
|
83
|
+
return n.length === 0 ? [{
|
|
83
84
|
id: `p_${e}`,
|
|
84
85
|
professionId: e,
|
|
85
|
-
profession:
|
|
86
|
-
majorName:
|
|
86
|
+
profession: o,
|
|
87
|
+
majorName: a,
|
|
87
88
|
majorCode: t,
|
|
88
89
|
userType: "",
|
|
89
90
|
userId: "",
|
|
90
|
-
userName: "-"
|
|
91
|
-
|
|
91
|
+
userName: "-",
|
|
92
|
+
username: "-",
|
|
93
|
+
nickName: "-"
|
|
94
|
+
}] : n.map((r) => ({
|
|
92
95
|
id: `p_${e}_u_${r.id}`,
|
|
93
96
|
professionId: e,
|
|
94
|
-
profession:
|
|
95
|
-
majorName:
|
|
97
|
+
profession: o,
|
|
98
|
+
majorName: a,
|
|
96
99
|
majorCode: r.majorCode || t,
|
|
97
100
|
userType: r.userType || "",
|
|
98
101
|
userId: r.id,
|
|
99
|
-
userName: r.
|
|
102
|
+
userName: r.userName || "-",
|
|
103
|
+
username: r.userName || "-",
|
|
104
|
+
nickName: r.nickName || "-"
|
|
100
105
|
}));
|
|
101
106
|
}
|
|
102
|
-
function H(
|
|
103
|
-
const e =
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
const t = f.value.find((
|
|
108
|
-
t &&
|
|
107
|
+
function H(s) {
|
|
108
|
+
const e = s.professionId;
|
|
109
|
+
if (l.value = l.value.filter((a) => String(a.id) !== String(s.id)), !l.value.some((a) => String(a.professionId) === String(e))) {
|
|
110
|
+
const a = g.value;
|
|
111
|
+
if (a) {
|
|
112
|
+
const t = f.value.find((n) => String(n.id) === String(e));
|
|
113
|
+
t && a.toggleRowSelection(t, !1);
|
|
109
114
|
}
|
|
110
115
|
}
|
|
111
116
|
}
|
|
@@ -115,124 +120,124 @@ const se = (p, v) => {
|
|
|
115
120
|
cancelButtonText: "\u53D6\u6D88",
|
|
116
121
|
type: "warning"
|
|
117
122
|
}).then(() => {
|
|
118
|
-
|
|
123
|
+
l.value = [], g.value && g.value.clearSelection(), V.success("\u5DF2\u6E05\u7A7A\u6240\u6709\u9009\u4E2D\u4E13\u4E1A");
|
|
119
124
|
}).catch(() => {
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
127
|
async function R() {
|
|
123
|
-
const
|
|
124
|
-
if (!!
|
|
128
|
+
const s = i.api.getUserPageList || i.api.getUserList;
|
|
129
|
+
if (!!s) {
|
|
125
130
|
y.value = !0;
|
|
126
131
|
try {
|
|
127
132
|
let e;
|
|
128
133
|
try {
|
|
129
|
-
e = await
|
|
134
|
+
e = await s();
|
|
130
135
|
} catch {
|
|
131
|
-
e = await
|
|
136
|
+
e = await s({ page: 1, pageSize: 99999 }, { page: 1, pageSize: 99999 });
|
|
132
137
|
}
|
|
133
|
-
let
|
|
134
|
-
Array.isArray(
|
|
138
|
+
let o = Array.isArray(e) ? e : e || (e == null ? void 0 : e.data) || (e == null ? void 0 : e.content) || [];
|
|
139
|
+
Array.isArray(o) || (o = []), f.value = o.map((a) => $(a));
|
|
135
140
|
} catch (e) {
|
|
136
141
|
console.error("\u83B7\u53D6\u4E13\u4E1A\u5931\u8D25:", e), V.error("\u83B7\u53D6\u4E13\u4E1A\u5931\u8D25");
|
|
137
142
|
} finally {
|
|
138
|
-
y.value = !1,
|
|
143
|
+
y.value = !1, P(() => {
|
|
139
144
|
U();
|
|
140
145
|
});
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
}
|
|
144
149
|
function U() {
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
150
|
+
const s = g.value;
|
|
151
|
+
if (!s)
|
|
147
152
|
return;
|
|
148
153
|
const e = new Set(
|
|
149
|
-
|
|
154
|
+
l.value.map((o) => String(o.professionId))
|
|
150
155
|
);
|
|
151
|
-
f.value.forEach((
|
|
152
|
-
e.has(String(
|
|
156
|
+
f.value.forEach((o) => {
|
|
157
|
+
e.has(String(o.id)) && s.toggleRowSelection(o, !0);
|
|
153
158
|
});
|
|
154
159
|
}
|
|
155
160
|
function O() {
|
|
156
|
-
const
|
|
157
|
-
const
|
|
158
|
-
return !e.has(
|
|
161
|
+
const s = new Set(i.disabledItems.map((t) => String(t.id))), e = new Set(l.value.map((t) => String(t.professionId))), o = f.value.filter((t) => {
|
|
162
|
+
const n = String(t.id);
|
|
163
|
+
return !e.has(n) && !s.has(n);
|
|
159
164
|
});
|
|
160
|
-
let
|
|
161
|
-
if (
|
|
162
|
-
|
|
165
|
+
let a = [];
|
|
166
|
+
if (o.forEach((t) => {
|
|
167
|
+
a = a.concat(N(t));
|
|
163
168
|
}), i.multiple) {
|
|
164
169
|
if (i.multipleLimit > 0) {
|
|
165
|
-
const t = i.multipleLimit -
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
const t = i.multipleLimit - l.value.length;
|
|
171
|
+
a.slice(0, t).forEach((n) => {
|
|
172
|
+
l.value.push(n);
|
|
168
173
|
});
|
|
169
174
|
} else
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
a.forEach((t) => {
|
|
176
|
+
l.value.push(t);
|
|
172
177
|
});
|
|
173
|
-
V.success(`\u5DF2\u9009\u4E2D ${
|
|
178
|
+
V.success(`\u5DF2\u9009\u4E2D ${o.length} \u4E2A\u4E13\u4E1A\uFF0C\u5171 ${a.length} \u6761\u8BB0\u5F55`);
|
|
174
179
|
}
|
|
175
|
-
|
|
180
|
+
P(() => {
|
|
176
181
|
const t = g.value;
|
|
177
|
-
t &&
|
|
178
|
-
t.toggleRowSelection(
|
|
182
|
+
t && o.forEach((n) => {
|
|
183
|
+
t.toggleRowSelection(n, !0);
|
|
179
184
|
});
|
|
180
185
|
});
|
|
181
186
|
}
|
|
182
|
-
function q(
|
|
183
|
-
if (
|
|
184
|
-
const e = new Set(
|
|
185
|
-
const
|
|
186
|
-
return !e.has(
|
|
187
|
+
function q(s) {
|
|
188
|
+
if (s.length > 0) {
|
|
189
|
+
const e = new Set(l.value.map((t) => String(t.professionId))), o = new Set(i.disabledItems.map((t) => String(t.id))), a = s.filter((t) => {
|
|
190
|
+
const n = String(t.id);
|
|
191
|
+
return !e.has(n) && !o.has(n);
|
|
187
192
|
});
|
|
188
193
|
if (i.multiple) {
|
|
189
194
|
let t = [];
|
|
190
|
-
if (
|
|
191
|
-
t = t.concat(
|
|
195
|
+
if (a.forEach((n) => {
|
|
196
|
+
t = t.concat(N(n));
|
|
192
197
|
}), i.multipleLimit > 0) {
|
|
193
|
-
const
|
|
194
|
-
t.slice(0,
|
|
195
|
-
|
|
198
|
+
const n = i.multipleLimit - l.value.length;
|
|
199
|
+
t.slice(0, n).forEach((r) => {
|
|
200
|
+
l.value.push(r);
|
|
196
201
|
});
|
|
197
202
|
} else
|
|
198
|
-
t.forEach((
|
|
199
|
-
|
|
203
|
+
t.forEach((n) => {
|
|
204
|
+
l.value.push(n);
|
|
200
205
|
});
|
|
201
206
|
}
|
|
202
207
|
}
|
|
203
208
|
}
|
|
204
|
-
function F(
|
|
205
|
-
const e = new Set(
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
209
|
+
function F(s) {
|
|
210
|
+
const e = new Set(s.map((t) => String(t.id))), o = new Set(i.disabledItems.map((t) => String(t.id)));
|
|
211
|
+
s.forEach((t) => {
|
|
212
|
+
const n = String(t.id);
|
|
213
|
+
if (!k(t.id) && !o.has(n))
|
|
209
214
|
if (i.multiple) {
|
|
210
|
-
const r =
|
|
215
|
+
const r = N(t);
|
|
211
216
|
if (i.multipleLimit > 0) {
|
|
212
|
-
const d = i.multipleLimit -
|
|
217
|
+
const d = i.multipleLimit - l.value.length;
|
|
213
218
|
if (d <= 0)
|
|
214
219
|
return;
|
|
215
|
-
r.slice(0, d).forEach((
|
|
216
|
-
|
|
220
|
+
r.slice(0, d).forEach((E) => {
|
|
221
|
+
l.value.push(E);
|
|
217
222
|
});
|
|
218
223
|
} else
|
|
219
224
|
r.forEach((d) => {
|
|
220
|
-
|
|
225
|
+
l.value.push(d);
|
|
221
226
|
});
|
|
222
227
|
} else
|
|
223
|
-
|
|
228
|
+
l.value = N(t);
|
|
224
229
|
});
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
return !(
|
|
230
|
+
const a = new Set(f.value.map((t) => String(t.id)));
|
|
231
|
+
l.value = l.value.filter((t) => {
|
|
232
|
+
const n = String(t.professionId);
|
|
233
|
+
return !(a.has(n) && !e.has(n));
|
|
229
234
|
});
|
|
230
235
|
}
|
|
231
|
-
function G(
|
|
232
|
-
return !i.multiple &&
|
|
236
|
+
function G(s) {
|
|
237
|
+
return !i.multiple && l.value.length >= 1 ? k(s.id) : k(s.id) ? !0 : !z(s.id);
|
|
233
238
|
}
|
|
234
239
|
function J() {
|
|
235
|
-
let
|
|
240
|
+
let s = l.value.map((e) => ({
|
|
236
241
|
id: e.userId || e.id,
|
|
237
242
|
professionId: e.professionId,
|
|
238
243
|
profession: e.profession,
|
|
@@ -240,91 +245,97 @@ const se = (p, v) => {
|
|
|
240
245
|
majorCode: e.majorCode,
|
|
241
246
|
userType: e.userType,
|
|
242
247
|
userId: e.userId,
|
|
243
|
-
userName: e.userName
|
|
248
|
+
userName: e.userName,
|
|
249
|
+
username: e.userName,
|
|
250
|
+
nickName: e.nickName
|
|
244
251
|
}));
|
|
245
|
-
h("confirm",
|
|
252
|
+
h("confirm", s), C();
|
|
246
253
|
}
|
|
247
|
-
function
|
|
254
|
+
function C() {
|
|
248
255
|
f.value = [], h("update:modelValue", !1);
|
|
249
256
|
}
|
|
250
257
|
return K(
|
|
251
258
|
() => i.modelValue,
|
|
252
|
-
(
|
|
253
|
-
|
|
254
|
-
var
|
|
255
|
-
if (e.users && e.users.length > 0) {
|
|
256
|
-
const
|
|
259
|
+
(s) => {
|
|
260
|
+
s && (l.value = i.selectedItems.flatMap((e) => {
|
|
261
|
+
var o;
|
|
262
|
+
if (console.log("nickname", i.selectedItems), e.users && e.users.length > 0) {
|
|
263
|
+
const a = e.id, t = e.profession || e.departmentName, n = e.majorName || t, r = e.majorCode || "";
|
|
257
264
|
return e.users.map((d) => ({
|
|
258
|
-
id: `p_${
|
|
259
|
-
professionId:
|
|
265
|
+
id: `p_${a}_u_${d.id}`,
|
|
266
|
+
professionId: a,
|
|
260
267
|
profession: t,
|
|
261
|
-
majorName:
|
|
268
|
+
majorName: n,
|
|
262
269
|
majorCode: r,
|
|
263
270
|
userType: d.userType || e.userType || "",
|
|
264
271
|
userId: d.id,
|
|
265
|
-
userName: d.
|
|
272
|
+
userName: d.userName || d.username || "-",
|
|
273
|
+
username: d.userName || d.username || "-",
|
|
274
|
+
nickName: d.nickName || d.name || d.label || "-"
|
|
266
275
|
}));
|
|
267
276
|
}
|
|
268
277
|
return [{
|
|
269
278
|
id: e.id,
|
|
270
|
-
professionId: (
|
|
279
|
+
professionId: (o = e.professionId) != null ? o : e.id,
|
|
271
280
|
profession: e.profession || e.departmentName,
|
|
272
281
|
majorName: e.majorName || e.profession || e.departmentName,
|
|
273
282
|
majorCode: e.majorCode || "",
|
|
274
283
|
userType: e.userType || "",
|
|
275
284
|
userId: e.userId || "",
|
|
276
|
-
userName: e.userName || e.
|
|
285
|
+
userName: e.userName || e.username || "-",
|
|
286
|
+
username: e.userName || e.username || "-",
|
|
287
|
+
nickName: e.nickName || e.name || e.userNames || "-"
|
|
277
288
|
}];
|
|
278
289
|
}), R());
|
|
279
290
|
},
|
|
280
291
|
{ immediate: !0 }
|
|
281
|
-
), (
|
|
282
|
-
const
|
|
283
|
-
return _(),
|
|
292
|
+
), (s, e) => {
|
|
293
|
+
const o = b("el-button"), a = b("el-table-column"), t = b("el-table"), n = b("el-dialog"), r = Q("loading");
|
|
294
|
+
return _(), j(n, {
|
|
284
295
|
title: p.dialogTitle,
|
|
285
296
|
modelValue: S.value,
|
|
286
297
|
"onUpdate:modelValue": e[0] || (e[0] = (d) => S.value = d),
|
|
287
298
|
width: "960px",
|
|
288
|
-
"before-close":
|
|
299
|
+
"before-close": C,
|
|
289
300
|
"append-to-body": "",
|
|
290
301
|
class: "profession-select-dialog"
|
|
291
302
|
}, {
|
|
292
|
-
footer:
|
|
293
|
-
c(
|
|
303
|
+
footer: m(() => [
|
|
304
|
+
c(o, {
|
|
294
305
|
type: "primary",
|
|
295
306
|
disabled: !D.value,
|
|
296
307
|
onClick: J
|
|
297
308
|
}, {
|
|
298
|
-
default:
|
|
299
|
-
|
|
309
|
+
default: m(() => [...e[3] || (e[3] = [
|
|
310
|
+
I("\u786E\u5B9A", -1)
|
|
300
311
|
])]),
|
|
301
312
|
_: 1
|
|
302
313
|
}, 8, ["disabled"]),
|
|
303
|
-
c(
|
|
304
|
-
default:
|
|
305
|
-
|
|
314
|
+
c(o, { onClick: C }, {
|
|
315
|
+
default: m(() => [...e[4] || (e[4] = [
|
|
316
|
+
I("\u53D6\u6D88", -1)
|
|
306
317
|
])]),
|
|
307
318
|
_: 1
|
|
308
319
|
})
|
|
309
320
|
]),
|
|
310
|
-
default:
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
c(
|
|
321
|
+
default: m(() => [
|
|
322
|
+
u("div", oe, [
|
|
323
|
+
u("div", ne, [
|
|
324
|
+
u("div", le, [
|
|
325
|
+
c(o, {
|
|
315
326
|
type: "primary",
|
|
316
327
|
size: "default",
|
|
317
|
-
icon:
|
|
328
|
+
icon: T(te),
|
|
318
329
|
disabled: y.value,
|
|
319
330
|
onClick: O
|
|
320
331
|
}, {
|
|
321
|
-
default:
|
|
322
|
-
|
|
332
|
+
default: m(() => [...e[1] || (e[1] = [
|
|
333
|
+
I("\u5168\u90E8\u9009\u4E2D", -1)
|
|
323
334
|
])]),
|
|
324
335
|
_: 1
|
|
325
336
|
}, 8, ["icon", "disabled"])
|
|
326
337
|
]),
|
|
327
|
-
W((_(),
|
|
338
|
+
W((_(), j(t, {
|
|
328
339
|
ref_key: "professionTable",
|
|
329
340
|
ref: g,
|
|
330
341
|
data: f.value,
|
|
@@ -334,14 +345,14 @@ const se = (p, v) => {
|
|
|
334
345
|
onSelectAll: q,
|
|
335
346
|
onSelectionChange: F
|
|
336
347
|
}, {
|
|
337
|
-
default:
|
|
338
|
-
c(
|
|
348
|
+
default: m(() => [
|
|
349
|
+
c(a, {
|
|
339
350
|
type: "selection",
|
|
340
351
|
width: "50",
|
|
341
352
|
align: "center",
|
|
342
353
|
selectable: G
|
|
343
354
|
}),
|
|
344
|
-
c(
|
|
355
|
+
c(a, {
|
|
345
356
|
label: "\u4E13\u4E1A",
|
|
346
357
|
prop: "majorName",
|
|
347
358
|
"show-overflow-tooltip": !0
|
|
@@ -352,60 +363,60 @@ const se = (p, v) => {
|
|
|
352
363
|
[r, y.value]
|
|
353
364
|
])
|
|
354
365
|
]),
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
366
|
+
u("div", ie, [
|
|
367
|
+
u("div", re, [
|
|
368
|
+
u("div", null, "\u5DF2\u9009\u4E2D\u5217\u8868 (" + X(l.value.length) + ")", 1),
|
|
369
|
+
l.value.length > 0 ? (_(), j(o, {
|
|
359
370
|
key: 0,
|
|
360
371
|
type: "text",
|
|
361
372
|
size: "default",
|
|
362
|
-
icon:
|
|
373
|
+
icon: T(A),
|
|
363
374
|
onClick: M,
|
|
364
375
|
class: "clear-btn"
|
|
365
376
|
}, {
|
|
366
|
-
default:
|
|
367
|
-
|
|
377
|
+
default: m(() => [...e[2] || (e[2] = [
|
|
378
|
+
I("\u6E05\u7A7A", -1)
|
|
368
379
|
])]),
|
|
369
380
|
_: 1
|
|
370
381
|
}, 8, ["icon"])) : Y("", !0)
|
|
371
382
|
]),
|
|
372
383
|
c(t, {
|
|
373
|
-
data:
|
|
384
|
+
data: l.value,
|
|
374
385
|
height: "540",
|
|
375
386
|
"row-key": "id",
|
|
376
387
|
class: "selected-table"
|
|
377
388
|
}, {
|
|
378
|
-
default:
|
|
379
|
-
c(
|
|
389
|
+
default: m(() => [
|
|
390
|
+
c(a, {
|
|
380
391
|
align: "center",
|
|
381
392
|
width: "60",
|
|
382
393
|
label: "\u64CD\u4F5C"
|
|
383
394
|
}, {
|
|
384
|
-
default:
|
|
385
|
-
c(
|
|
395
|
+
default: m(({ row: d }) => [
|
|
396
|
+
c(o, {
|
|
386
397
|
type: "primary",
|
|
387
398
|
link: "",
|
|
388
|
-
icon:
|
|
389
|
-
onClick: (
|
|
399
|
+
icon: T(A),
|
|
400
|
+
onClick: (E) => H(d)
|
|
390
401
|
}, null, 8, ["icon", "onClick"])
|
|
391
402
|
]),
|
|
392
403
|
_: 1
|
|
393
404
|
}),
|
|
394
|
-
c(
|
|
405
|
+
c(a, {
|
|
395
406
|
label: "\u4E13\u4E1A",
|
|
396
407
|
prop: "profession",
|
|
397
408
|
"show-overflow-tooltip": !0,
|
|
398
409
|
"min-width": "120"
|
|
399
410
|
}),
|
|
400
|
-
c(
|
|
411
|
+
c(a, {
|
|
401
412
|
label: "\u7528\u6237\u7C7B\u578B",
|
|
402
413
|
prop: "userType",
|
|
403
414
|
width: "100",
|
|
404
415
|
"show-overflow-tooltip": !0
|
|
405
416
|
}),
|
|
406
|
-
c(
|
|
417
|
+
c(a, {
|
|
407
418
|
label: "\u7528\u6237\u540D\u79F0",
|
|
408
|
-
prop: "
|
|
419
|
+
prop: "nickName",
|
|
409
420
|
"min-width": "140",
|
|
410
421
|
"show-overflow-tooltip": !0
|
|
411
422
|
})
|
|
@@ -419,8 +430,8 @@ const se = (p, v) => {
|
|
|
419
430
|
}, 8, ["title", "modelValue"]);
|
|
420
431
|
};
|
|
421
432
|
}
|
|
422
|
-
},
|
|
433
|
+
}, ue = /* @__PURE__ */ ae(de, [["__scopeId", "data-v-144912f0"]]);
|
|
423
434
|
export {
|
|
424
|
-
|
|
425
|
-
|
|
435
|
+
ue as ProfessionSelectDialog,
|
|
436
|
+
ue as default
|
|
426
437
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(m,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],t):(m=typeof globalThis<"u"?globalThis:m||self,t(m.ProfessionSelectVue3={},m.Vue,m.ElementPlus))})(this,function(m,t,_){"use strict";/*! Element Plus Icons Vue v2.3.2 */var
|
|
1
|
+
(function(m,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("element-plus")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus"],t):(m=typeof globalThis<"u"?globalThis:m||self,t(m.ProfessionSelectVue3={},m.Vue,m.ElementPlus))})(this,function(m,t,_){"use strict";/*! Element Plus Icons Vue v2.3.2 */var V=t.defineComponent({name:"Check",__name:"check",setup(p){return(g,r)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"M406.656 706.944 195.84 496.256a32 32 0 1 0-45.248 45.248l256 256 512-512a32 32 0 0 0-45.248-45.248L406.592 706.944z"})]))}}),v=V,j=t.defineComponent({name:"Delete",__name:"delete",setup(p){return(g,r)=>(t.openBlock(),t.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{fill:"currentColor",d:"M160 256H96a32 32 0 0 1 0-64h256V95.936a32 32 0 0 1 32-32h256a32 32 0 0 1 32 32V192h256a32 32 0 1 1 0 64h-64v672a32 32 0 0 1-32 32H192a32 32 0 0 1-32-32zm448-64v-64H416v64zM224 896h576V256H224zm192-128a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32m192 0a32 32 0 0 1-32-32V416a32 32 0 0 1 64 0v320a32 32 0 0 1-32 32"})]))}}),C=j;const J="",K="",T=(p,g)=>{const r=p.__vccOpts||p;for(const[h,N]of g)r[h]=N;return r},E={class:"dialog-body"},x={class:"left-panel"},B={class:"select-all-btn-wrap"},L={class:"right-panel"},P={class:"selected-header"},I=T({__name:"ProfessionSelectDialog",props:{modelValue:{type:Boolean,default:!1},dialogTitle:{type:String,default:"\u9009\u62E9\u4E13\u4E1A"},selectedItems:{type:Array,default:()=>[]},api:{type:Object,required:!0},multiple:{type:Boolean,default:!0},multipleLimit:{type:Number,default:0},disabledItems:{type:Array,default:()=>[]}},emits:["update:modelValue","confirm"],setup(p,{emit:g}){const r=p,h=g,N=t.computed({get:()=>r.modelValue,set:a=>h("update:modelValue",a)}),S=t.ref(!1),f=t.ref([]),i=t.ref([]),u=t.ref(),A=t.computed(()=>r.multiple?r.multipleLimit>0&&i.value.length>r.multipleLimit?!1:i.value.length>0:i.value.length===1);function w(a){return i.value.some(e=>String(e.professionId)===String(a))}function D(a){return r.disabledItems.some(e=>String(e.id)===String(a))}function M(a){const e=a.users||a.userList||a.members||a.children||[],n=(Array.isArray(e)?e:[]).map(o=>{var l,d;return{id:(d=(l=o.id)!=null?l:o.userId)!=null?d:o.value,userName:o.userName||o.username||"-",nickName:o.nickName||o.name||o.label||"-",userType:o.userType||"",majorCode:o.majorCode||""}}),s=n.map(o=>o.nickName).filter(Boolean).join("\u3001");return{id:a.id,profession:a.profession||a.departmentName||a.name||"-",majorName:a.majorName||a.profession||a.name||"-",majorCode:a.majorCode||"",users:n,userNames:s}}function y(a){const e=a.id,n=a.profession,s=a.majorName||n,o=a.majorCode||"",l=a.users||[];return l.length===0?[{id:`p_${e}`,professionId:e,profession:n,majorName:s,majorCode:o,userType:"",userId:"",userName:"-",username:"-",nickName:"-"}]:l.map(d=>({id:`p_${e}_u_${d.id}`,professionId:e,profession:n,majorName:s,majorCode:d.majorCode||o,userType:d.userType||"",userId:d.id,userName:d.userName||"-",username:d.userName||"-",nickName:d.nickName||"-"}))}function z(a){const e=a.professionId;if(i.value=i.value.filter(s=>String(s.id)!==String(a.id)),!i.value.some(s=>String(s.professionId)===String(e))){const s=u.value;if(s){const o=f.value.find(l=>String(l.id)===String(e));o&&s.toggleRowSelection(o,!1)}}}function $(){_.ElMessageBox.confirm("\u786E\u5B9A\u8981\u6E05\u7A7A\u6240\u6709\u5DF2\u9009\u4E2D\u7684\u4E13\u4E1A\u5417\uFF1F","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}).then(()=>{i.value=[],u.value&&u.value.clearSelection(),_.ElMessage.success("\u5DF2\u6E05\u7A7A\u6240\u6709\u9009\u4E2D\u4E13\u4E1A")}).catch(()=>{})}async function H(){const a=r.api.getUserPageList||r.api.getUserList;if(!!a){S.value=!0;try{let e;try{e=await a()}catch{e=await a({page:1,pageSize:99999},{page:1,pageSize:99999})}let n=Array.isArray(e)?e:e||(e==null?void 0:e.data)||(e==null?void 0:e.content)||[];Array.isArray(n)||(n=[]),f.value=n.map(s=>M(s))}catch(e){console.error("\u83B7\u53D6\u4E13\u4E1A\u5931\u8D25:",e),_.ElMessage.error("\u83B7\u53D6\u4E13\u4E1A\u5931\u8D25")}finally{S.value=!1,t.nextTick(()=>{R()})}}}function R(){const a=u.value;if(!a)return;const e=new Set(i.value.map(n=>String(n.professionId)));f.value.forEach(n=>{e.has(String(n.id))&&a.toggleRowSelection(n,!0)})}function U(){const a=new Set(r.disabledItems.map(o=>String(o.id))),e=new Set(i.value.map(o=>String(o.professionId))),n=f.value.filter(o=>{const l=String(o.id);return!e.has(l)&&!a.has(l)});let s=[];if(n.forEach(o=>{s=s.concat(y(o))}),r.multiple){if(r.multipleLimit>0){const o=r.multipleLimit-i.value.length;s.slice(0,o).forEach(l=>{i.value.push(l)})}else s.forEach(o=>{i.value.push(o)});_.ElMessage.success(`\u5DF2\u9009\u4E2D ${n.length} \u4E2A\u4E13\u4E1A\uFF0C\u5171 ${s.length} \u6761\u8BB0\u5F55`)}t.nextTick(()=>{const o=u.value;o&&n.forEach(l=>{o.toggleRowSelection(l,!0)})})}function q(a){if(a.length>0){const e=new Set(i.value.map(o=>String(o.professionId))),n=new Set(r.disabledItems.map(o=>String(o.id))),s=a.filter(o=>{const l=String(o.id);return!e.has(l)&&!n.has(l)});if(r.multiple){let o=[];if(s.forEach(l=>{o=o.concat(y(l))}),r.multipleLimit>0){const l=r.multipleLimit-i.value.length;o.slice(0,l).forEach(d=>{i.value.push(d)})}else o.forEach(l=>{i.value.push(l)})}}}function O(a){const e=new Set(a.map(o=>String(o.id))),n=new Set(r.disabledItems.map(o=>String(o.id)));a.forEach(o=>{const l=String(o.id);if(!w(o.id)&&!n.has(l))if(r.multiple){const d=y(o);if(r.multipleLimit>0){const c=r.multipleLimit-i.value.length;if(c<=0)return;d.slice(0,c).forEach(k=>{i.value.push(k)})}else d.forEach(c=>{i.value.push(c)})}else i.value=y(o)});const s=new Set(f.value.map(o=>String(o.id)));i.value=i.value.filter(o=>{const l=String(o.professionId);return!(s.has(l)&&!e.has(l))})}function F(a){return!r.multiple&&i.value.length>=1?w(a.id):w(a.id)?!0:!D(a.id)}function G(){let a=i.value.map(e=>({id:e.userId||e.id,professionId:e.professionId,profession:e.profession,majorName:e.majorName,majorCode:e.majorCode,userType:e.userType,userId:e.userId,userName:e.userName,username:e.userName,nickName:e.nickName}));h("confirm",a),b()}function b(){f.value=[],h("update:modelValue",!1)}return t.watch(()=>r.modelValue,a=>{a&&(i.value=r.selectedItems.flatMap(e=>{var n;if(console.log("nickname",r.selectedItems),e.users&&e.users.length>0){const s=e.id,o=e.profession||e.departmentName,l=e.majorName||o,d=e.majorCode||"";return e.users.map(c=>({id:`p_${s}_u_${c.id}`,professionId:s,profession:o,majorName:l,majorCode:d,userType:c.userType||e.userType||"",userId:c.id,userName:c.userName||c.username||"-",username:c.userName||c.username||"-",nickName:c.nickName||c.name||c.label||"-"}))}return[{id:e.id,professionId:(n=e.professionId)!=null?n:e.id,profession:e.profession||e.departmentName,majorName:e.majorName||e.profession||e.departmentName,majorCode:e.majorCode||"",userType:e.userType||"",userId:e.userId||"",userName:e.userName||e.username||"-",username:e.userName||e.username||"-",nickName:e.nickName||e.name||e.userNames||"-"}]}),H())},{immediate:!0}),(a,e)=>{const n=t.resolveComponent("el-button"),s=t.resolveComponent("el-table-column"),o=t.resolveComponent("el-table"),l=t.resolveComponent("el-dialog"),d=t.resolveDirective("loading");return t.openBlock(),t.createBlock(l,{title:p.dialogTitle,modelValue:N.value,"onUpdate:modelValue":e[0]||(e[0]=c=>N.value=c),width:"960px","before-close":b,"append-to-body":"",class:"profession-select-dialog"},{footer:t.withCtx(()=>[t.createVNode(n,{type:"primary",disabled:!A.value,onClick:G},{default:t.withCtx(()=>[...e[3]||(e[3]=[t.createTextVNode("\u786E\u5B9A",-1)])]),_:1},8,["disabled"]),t.createVNode(n,{onClick:b},{default:t.withCtx(()=>[...e[4]||(e[4]=[t.createTextVNode("\u53D6\u6D88",-1)])]),_:1})]),default:t.withCtx(()=>[t.createElementVNode("div",E,[t.createElementVNode("div",x,[t.createElementVNode("div",B,[t.createVNode(n,{type:"primary",size:"default",icon:t.unref(v),disabled:S.value,onClick:U},{default:t.withCtx(()=>[...e[1]||(e[1]=[t.createTextVNode("\u5168\u90E8\u9009\u4E2D",-1)])]),_:1},8,["icon","disabled"])]),t.withDirectives((t.openBlock(),t.createBlock(o,{ref_key:"professionTable",ref:u,data:f.value,height:"540","row-key":"id",class:"profession-table",onSelectAll:q,onSelectionChange:O},{default:t.withCtx(()=>[t.createVNode(s,{type:"selection",width:"50",align:"center",selectable:F}),t.createVNode(s,{label:"\u4E13\u4E1A",prop:"majorName","show-overflow-tooltip":!0})]),_:1},8,["data"])),[[d,S.value]])]),t.createElementVNode("div",L,[t.createElementVNode("div",P,[t.createElementVNode("div",null,"\u5DF2\u9009\u4E2D\u5217\u8868 ("+t.toDisplayString(i.value.length)+")",1),i.value.length>0?(t.openBlock(),t.createBlock(n,{key:0,type:"text",size:"default",icon:t.unref(C),onClick:$,class:"clear-btn"},{default:t.withCtx(()=>[...e[2]||(e[2]=[t.createTextVNode("\u6E05\u7A7A",-1)])]),_:1},8,["icon"])):t.createCommentVNode("",!0)]),t.createVNode(o,{data:i.value,height:"540","row-key":"id",class:"selected-table"},{default:t.withCtx(()=>[t.createVNode(s,{align:"center",width:"60",label:"\u64CD\u4F5C"},{default:t.withCtx(({row:c})=>[t.createVNode(n,{type:"primary",link:"",icon:t.unref(C),onClick:k=>z(c)},null,8,["icon","onClick"])]),_:1}),t.createVNode(s,{label:"\u4E13\u4E1A",prop:"profession","show-overflow-tooltip":!0,"min-width":"120"}),t.createVNode(s,{label:"\u7528\u6237\u7C7B\u578B",prop:"userType",width:"100","show-overflow-tooltip":!0}),t.createVNode(s,{label:"\u7528\u6237\u540D\u79F0",prop:"nickName","min-width":"140","show-overflow-tooltip":!0})]),_:1},8,["data"])])])]),_:1},8,["title","modelValue"])}}},[["__scopeId","data-v-144912f0"]]);m.ProfessionSelectDialog=I,m.default=I,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.dialog-body[data-v-
|
|
1
|
+
.dialog-body[data-v-144912f0]{display:flex;gap:16px;min-height:580px}.left-panel[data-v-144912f0]{flex:1;min-width:0;display:flex;flex-direction:column}.select-all-btn-wrap[data-v-144912f0]{margin-bottom:10px}.right-panel[data-v-144912f0]{width:460px;flex-shrink:0;border:1px solid #ebeef5;border-radius:4px;overflow:hidden}.selected-header[data-v-144912f0]{padding:6px 12px;background:#ecf5ff;color:#409eff;font-size:14px;font-weight:500;display:flex;align-items:center;justify-content:space-between;height:40px;box-sizing:border-box;white-space:nowrap}.clear-btn[data-v-144912f0]{color:#f56c6c;padding:0;margin-left:10px}.clear-btn[data-v-144912f0]:hover{color:#ef4444}.profession-table[data-v-144912f0],.selected-table[data-v-144912f0]{flex:1}.selected-table[data-v-144912f0] .el-table__cell{padding:6px 0}.row-type-select[data-v-144912f0]{width:100%}.profession-select-dialog .el-dialog__body{padding:20px}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mingminghahayu/profession-select-dialog-vue3",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Vue 3 Element Plus Profession Select Dialog Component",
|
|
5
5
|
"main": "./dist/profession-select-vue3.umd.js",
|
|
6
6
|
"module": "./dist/profession-select-vue3.es.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
</el-table-column>
|
|
55
55
|
<el-table-column label="专业" prop="profession" :show-overflow-tooltip="true" min-width="120" />
|
|
56
56
|
<el-table-column label="用户类型" prop="userType" width="100" :show-overflow-tooltip="true" />
|
|
57
|
-
<el-table-column label="用户名称" prop="
|
|
57
|
+
<el-table-column label="用户名称" prop="nickName" min-width="140" :show-overflow-tooltip="true" />
|
|
58
58
|
</el-table>
|
|
59
59
|
</div>
|
|
60
60
|
</div>
|
|
@@ -117,11 +117,13 @@ function formatProfessionItem(item) {
|
|
|
117
117
|
const rawUsers = item.users || item.userList || item.members || item.children || []
|
|
118
118
|
const users = (Array.isArray(rawUsers) ? rawUsers : []).map(u => ({
|
|
119
119
|
id: u.id ?? u.userId ?? u.value,
|
|
120
|
-
|
|
120
|
+
// userName / username 都是工号,nickName 才是用户名称
|
|
121
|
+
userName: u.userName || u.username || '-',
|
|
122
|
+
nickName: u.nickName || u.name || u.label || '-',
|
|
121
123
|
userType: u.userType || '',
|
|
122
124
|
majorCode: u.majorCode || ''
|
|
123
125
|
}))
|
|
124
|
-
const userNames = users.map(u => u.
|
|
126
|
+
const userNames = users.map(u => u.nickName).filter(Boolean).join('、')
|
|
125
127
|
return {
|
|
126
128
|
id: item.id,
|
|
127
129
|
profession: item.profession || item.departmentName || item.name || '-',
|
|
@@ -149,7 +151,9 @@ function expandProfessionToRows(prof) {
|
|
|
149
151
|
majorCode,
|
|
150
152
|
userType: '',
|
|
151
153
|
userId: '',
|
|
152
|
-
userName: '-'
|
|
154
|
+
userName: '-',
|
|
155
|
+
username: '-',
|
|
156
|
+
nickName: '-'
|
|
153
157
|
}]
|
|
154
158
|
}
|
|
155
159
|
return users.map(u => ({
|
|
@@ -160,7 +164,9 @@ function expandProfessionToRows(prof) {
|
|
|
160
164
|
majorCode: u.majorCode || majorCode,
|
|
161
165
|
userType: u.userType || '',
|
|
162
166
|
userId: u.id,
|
|
163
|
-
userName: u.
|
|
167
|
+
userName: u.userName || '-',
|
|
168
|
+
username: u.userName || '-',
|
|
169
|
+
nickName: u.nickName || '-'
|
|
164
170
|
}))
|
|
165
171
|
}
|
|
166
172
|
|
|
@@ -371,7 +377,9 @@ function saveDialog() {
|
|
|
371
377
|
majorCode: u.majorCode,
|
|
372
378
|
userType: u.userType,
|
|
373
379
|
userId: u.userId,
|
|
374
|
-
userName: u.userName
|
|
380
|
+
userName: u.userName,
|
|
381
|
+
username: u.userName,
|
|
382
|
+
nickName: u.nickName
|
|
375
383
|
}))
|
|
376
384
|
emit('confirm', list)
|
|
377
385
|
handleClose()
|
|
@@ -388,6 +396,7 @@ watch(
|
|
|
388
396
|
if (visible) {
|
|
389
397
|
// 把外部传入的已选数据按用户展开为多条记录
|
|
390
398
|
multiSelect.value = props.selectedItems.flatMap(u => {
|
|
399
|
+
console.log('nickname',props.selectedItems)
|
|
391
400
|
// 兼容两种数据结构:
|
|
392
401
|
// 1. 已经是按用户展开的记录(含 professionId 和 userName)
|
|
393
402
|
// 2. 按专业展开的记录(含 users 数组)
|
|
@@ -404,7 +413,9 @@ watch(
|
|
|
404
413
|
majorCode,
|
|
405
414
|
userType: x.userType || u.userType || '',
|
|
406
415
|
userId: x.id,
|
|
407
|
-
userName: x.
|
|
416
|
+
userName: x.userName || x.username || '-',
|
|
417
|
+
username: x.userName || x.username || '-',
|
|
418
|
+
nickName: x.nickName || x.name || x.label || '-'
|
|
408
419
|
}))
|
|
409
420
|
}
|
|
410
421
|
// 已是单条用户记录
|
|
@@ -416,7 +427,9 @@ watch(
|
|
|
416
427
|
majorCode: u.majorCode || '',
|
|
417
428
|
userType: u.userType || '',
|
|
418
429
|
userId: u.userId || '',
|
|
419
|
-
userName: u.userName || u.
|
|
430
|
+
userName: u.userName || u.username || '-',
|
|
431
|
+
username: u.userName || u.username || '-',
|
|
432
|
+
nickName: u.nickName || u.name || u.userNames || '-'
|
|
420
433
|
}]
|
|
421
434
|
})
|
|
422
435
|
getPageList()
|