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