z-crud-table 0.0.24 → 0.0.26
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/z-crud-table.js +234 -201
- package/dist/z-crud-table.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/z-crud-table.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { ElMessage as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { defineComponent as G, ref as P, resolveComponent as g, createBlock as f, openBlock as n, mergeProps as U, withCtx as u, createElementBlock as h, Fragment as $, renderList as E, createCommentVNode as c, createTextVNode as D, toDisplayString as re, computed as j, reactive as H, onMounted as ne, resolveDirective as ie, normalizeClass as se, renderSlot as w, withDirectives as M, createVNode as S, createElementVNode as I, createSlots as ue } from "vue";
|
|
2
|
+
import { ElMessage as k, ElMessageBox as de } from "element-plus";
|
|
3
|
+
import pe from "axios";
|
|
4
|
+
const fe = /* @__PURE__ */ G({
|
|
5
5
|
__name: "DynamicForm",
|
|
6
6
|
props: {
|
|
7
7
|
modelValue: {},
|
|
8
8
|
formConfig: {},
|
|
9
9
|
rules: {}
|
|
10
10
|
},
|
|
11
|
-
setup(
|
|
12
|
-
const
|
|
13
|
-
return
|
|
11
|
+
setup(y, { expose: b }) {
|
|
12
|
+
const O = P(null);
|
|
13
|
+
return b({
|
|
14
14
|
validate: () => {
|
|
15
15
|
var s;
|
|
16
|
-
return (s =
|
|
16
|
+
return (s = O.value) == null ? void 0 : s.validate();
|
|
17
17
|
}
|
|
18
18
|
}), (s, e) => {
|
|
19
|
-
const
|
|
20
|
-
return n(),
|
|
19
|
+
const z = g("el-input"), x = g("el-option"), v = g("el-select"), q = g("el-radio"), m = g("el-radio-group"), V = g("el-form-item"), A = g("el-form");
|
|
20
|
+
return n(), f(A, U({
|
|
21
21
|
model: s.modelValue,
|
|
22
22
|
rules: s.rules,
|
|
23
23
|
ref_key: "formRef",
|
|
24
|
-
ref:
|
|
24
|
+
ref: O
|
|
25
25
|
}, s.$attrs), {
|
|
26
26
|
default: u(() => [
|
|
27
|
-
(n(!0),
|
|
27
|
+
(n(!0), h($, null, E(s.formConfig, (r) => (n(), f(V, {
|
|
28
28
|
key: r.prop,
|
|
29
29
|
label: r.label,
|
|
30
30
|
prop: r.prop
|
|
31
31
|
}, {
|
|
32
32
|
default: u(() => [
|
|
33
|
-
r.type === "input" ? (n(),
|
|
33
|
+
r.type === "input" ? (n(), f(z, U({
|
|
34
34
|
key: 0,
|
|
35
35
|
modelValue: s.modelValue[r.prop],
|
|
36
36
|
"onUpdate:modelValue": (d) => s.modelValue[r.prop] = d
|
|
37
|
-
}, { ref_for: !0 }, r.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) :
|
|
38
|
-
r.type === "textarea" ? (n(),
|
|
37
|
+
}, { ref_for: !0 }, r.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) : c("", !0),
|
|
38
|
+
r.type === "textarea" ? (n(), f(z, U({
|
|
39
39
|
key: 1,
|
|
40
40
|
type: "textarea",
|
|
41
41
|
modelValue: s.modelValue[r.prop],
|
|
42
42
|
"onUpdate:modelValue": (d) => s.modelValue[r.prop] = d
|
|
43
|
-
}, { ref_for: !0 }, r.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) :
|
|
44
|
-
r.type === "select" ? (n(),
|
|
43
|
+
}, { ref_for: !0 }, r.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) : c("", !0),
|
|
44
|
+
r.type === "select" ? (n(), f(v, U({
|
|
45
45
|
key: 2,
|
|
46
46
|
modelValue: s.modelValue[r.prop],
|
|
47
47
|
"onUpdate:modelValue": (d) => s.modelValue[r.prop] = d
|
|
48
48
|
}, { ref_for: !0 }, r.componentProps), {
|
|
49
49
|
default: u(() => [
|
|
50
|
-
(n(!0),
|
|
50
|
+
(n(!0), h($, null, E(r.options, (d) => (n(), f(x, {
|
|
51
51
|
key: d.value,
|
|
52
52
|
label: d.label,
|
|
53
53
|
value: d.value
|
|
54
54
|
}, null, 8, ["label", "value"]))), 128))
|
|
55
55
|
]),
|
|
56
56
|
_: 2
|
|
57
|
-
}, 1040, ["modelValue", "onUpdate:modelValue"])) :
|
|
58
|
-
r.type === "radio-group" ? (n(),
|
|
57
|
+
}, 1040, ["modelValue", "onUpdate:modelValue"])) : c("", !0),
|
|
58
|
+
r.type === "radio-group" ? (n(), f(m, U({
|
|
59
59
|
key: 3,
|
|
60
60
|
modelValue: s.modelValue[r.prop],
|
|
61
61
|
"onUpdate:modelValue": (d) => s.modelValue[r.prop] = d
|
|
62
62
|
}, { ref_for: !0 }, r.componentProps), {
|
|
63
63
|
default: u(() => [
|
|
64
|
-
(n(!0),
|
|
64
|
+
(n(!0), h($, null, E(r.options, (d) => (n(), f(q, {
|
|
65
65
|
key: d.value,
|
|
66
66
|
label: d.value
|
|
67
67
|
}, {
|
|
68
68
|
default: u(() => [
|
|
69
|
-
|
|
69
|
+
D(re(d.label), 1)
|
|
70
70
|
]),
|
|
71
71
|
_: 2
|
|
72
72
|
}, 1032, ["label"]))), 128))
|
|
73
73
|
]),
|
|
74
74
|
_: 2
|
|
75
|
-
}, 1040, ["modelValue", "onUpdate:modelValue"])) :
|
|
76
|
-
r.type === "input-disabled" ? (n(),
|
|
75
|
+
}, 1040, ["modelValue", "onUpdate:modelValue"])) : c("", !0),
|
|
76
|
+
r.type === "input-disabled" ? (n(), f(z, U({
|
|
77
77
|
key: 4,
|
|
78
78
|
"model-value": s.modelValue[r.prop],
|
|
79
79
|
disabled: ""
|
|
80
|
-
}, { ref_for: !0 }, r.componentProps), null, 16, ["model-value"])) :
|
|
80
|
+
}, { ref_for: !0 }, r.componentProps), null, 16, ["model-value"])) : c("", !0)
|
|
81
81
|
]),
|
|
82
82
|
_: 2
|
|
83
83
|
}, 1032, ["label", "prop"]))), 128))
|
|
@@ -86,39 +86,60 @@ const pe = /* @__PURE__ */ M({
|
|
|
86
86
|
}, 16, ["model", "rules"]);
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
}),
|
|
89
|
+
}), _ = pe.create({
|
|
90
90
|
// VITE_APP_BASE_API 是在 .env 文件中定义的基础 URL
|
|
91
|
-
// 您可以根据您的项目需求进行修改
|
|
92
91
|
baseURL: "",
|
|
93
92
|
timeout: 1e4
|
|
94
93
|
// 请求超时时间
|
|
95
94
|
});
|
|
96
|
-
|
|
97
|
-
(
|
|
98
|
-
const
|
|
99
|
-
return
|
|
95
|
+
_.interceptors.request.use(
|
|
96
|
+
(y) => {
|
|
97
|
+
const b = localStorage.getItem("token");
|
|
98
|
+
return b && (y.headers.Authorization = "Bearer " + b), y;
|
|
100
99
|
},
|
|
101
|
-
(
|
|
100
|
+
(y) => (console.log(y), Promise.reject(y))
|
|
102
101
|
);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
_.interceptors.response.use(
|
|
103
|
+
/**
|
|
104
|
+
* @description 如果您想直接获取诸如 headers 或 status 之类的信息,
|
|
105
|
+
* 请直接返回 response => response
|
|
106
|
+
*/
|
|
107
|
+
(y) => {
|
|
108
|
+
const b = y.data;
|
|
109
|
+
return b.code !== 200 ? (k({
|
|
110
|
+
message: b.msg || "Error",
|
|
111
|
+
// 使用后端返回的 `msg` 作为错误提示
|
|
112
|
+
type: "error",
|
|
113
|
+
duration: 5 * 1e3
|
|
114
|
+
}), (b.code === 401 || b.code === 403) && de.confirm(
|
|
115
|
+
"您的登录状态已失效,请重新登录",
|
|
116
|
+
"确认登出",
|
|
117
|
+
{
|
|
118
|
+
confirmButtonText: "重新登录",
|
|
119
|
+
cancelButtonText: "取消",
|
|
120
|
+
type: "warning"
|
|
121
|
+
}
|
|
122
|
+
).then(() => {
|
|
123
|
+
localStorage.removeItem("token"), location.reload();
|
|
124
|
+
}), Promise.reject(new Error(b.msg || "Error"))) : b;
|
|
125
|
+
},
|
|
126
|
+
(y) => (console.log("HTTP Error: " + y), k({
|
|
127
|
+
message: "网络错误,请检查您的网络连接或联系管理员",
|
|
128
|
+
// 提供更友好的网络错误提示
|
|
108
129
|
type: "error",
|
|
109
130
|
duration: 5 * 1e3
|
|
110
|
-
}), Promise.reject(
|
|
131
|
+
}), Promise.reject(y))
|
|
111
132
|
);
|
|
112
|
-
const
|
|
133
|
+
const me = {
|
|
113
134
|
key: 0,
|
|
114
135
|
class: "flex flex-wrap items-center justify-between gap-4 mb-6"
|
|
115
|
-
},
|
|
136
|
+
}, ce = { class: "flex items-center gap-x-2" }, ge = { class: "flex items-center gap-x-3 action-buttons flex-shrink-0" }, ye = {
|
|
116
137
|
key: 0,
|
|
117
138
|
class: "flex items-center gap-x-2"
|
|
118
|
-
},
|
|
139
|
+
}, be = {
|
|
119
140
|
key: 1,
|
|
120
141
|
class: "flex justify-end"
|
|
121
|
-
},
|
|
142
|
+
}, we = { class: "dialog-footer" }, _e = /* @__PURE__ */ G({
|
|
122
143
|
__name: "CrudTable",
|
|
123
144
|
props: {
|
|
124
145
|
/**
|
|
@@ -180,39 +201,50 @@ const fe = {
|
|
|
180
201
|
submitAsFormData: { type: Boolean, default: !1 }
|
|
181
202
|
},
|
|
182
203
|
emits: ["open-dialog", "submit", "delete"],
|
|
183
|
-
setup(
|
|
184
|
-
const s =
|
|
204
|
+
setup(y, { expose: b, emit: O }) {
|
|
205
|
+
const s = O, e = y, z = j(() => ["crud-table-wrapper", `theme-${e.theme}`, e.customClass]), x = j(() => e.theme === "large-screen" ? "large-screen-dialog" : ""), v = (t, o) => t ? !0 : (k.error(`${o} prop is required.`), !1), q = async (t, o) => {
|
|
185
206
|
try {
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
207
|
+
let a = { ...o };
|
|
208
|
+
e.onBeforeSubmit && (a = await e.onBeforeSubmit(a));
|
|
209
|
+
let p = a;
|
|
210
|
+
if (e.submitAsFormData) {
|
|
211
|
+
const F = new FormData();
|
|
212
|
+
for (const C in a)
|
|
213
|
+
if (Object.prototype.hasOwnProperty.call(a, C)) {
|
|
214
|
+
const T = a[C];
|
|
215
|
+
F.append(C, T ?? "");
|
|
216
|
+
}
|
|
217
|
+
p = F;
|
|
218
|
+
}
|
|
219
|
+
if (l.submitting = !0, t === "add") {
|
|
220
|
+
if (!v(e.apiUrlCreate, "apiUrlCreate")) throw new Error("apiUrlCreate is not configured.");
|
|
221
|
+
await _.post(e.apiUrlCreate, p), k.success("新增成功");
|
|
190
222
|
} else {
|
|
191
|
-
if (!
|
|
192
|
-
await
|
|
223
|
+
if (!v(e.apiUrlUpdate, "apiUrlUpdate")) throw new Error("apiUrlUpdate is not configured.");
|
|
224
|
+
await _.put(e.apiUrlUpdate, p), k.success("更新成功");
|
|
193
225
|
}
|
|
194
|
-
return e.onAfterSubmit && e.onAfterSubmit(t,
|
|
195
|
-
} catch (
|
|
196
|
-
return console.
|
|
226
|
+
return e.onAfterSubmit && e.onAfterSubmit(t, a), s("submit", { mode: t, data: a }), l.visible && (l.visible = !1), B(), Promise.resolve();
|
|
227
|
+
} catch (a) {
|
|
228
|
+
return console.error("Submit failed:", a), Promise.reject(a);
|
|
197
229
|
} finally {
|
|
198
|
-
|
|
230
|
+
l.submitting = !1;
|
|
199
231
|
}
|
|
200
|
-
},
|
|
201
|
-
if (
|
|
232
|
+
}, m = H({ pageNum: 1, pageSize: 10, ...e.initialSearchForm }), V = P([]), A = P(0), r = P(!1), d = P([]), l = H({ visible: !1, loading: !1, submitting: !1, mode: "add", data: {}, formRef: null }), J = j(() => l.mode === "add" ? "新增" : "编辑"), K = j(() => {
|
|
233
|
+
if (l.mode === "add") return e.dialogFormConfig.filter((o) => o.prop !== "id");
|
|
202
234
|
const t = [...e.dialogFormConfig.filter((o) => o.prop !== "id")];
|
|
203
235
|
return t.some((o) => o.prop === "id") || t.unshift({ type: "input-disabled", prop: "id", label: "用户ID" }), t;
|
|
204
|
-
}),
|
|
205
|
-
if (
|
|
236
|
+
}), B = async () => {
|
|
237
|
+
if (v(e.apiUrlQuery, "apiUrlQuery")) {
|
|
206
238
|
r.value = !0;
|
|
207
239
|
try {
|
|
208
|
-
let t = { ...
|
|
240
|
+
let t = { ...m };
|
|
209
241
|
e.onBeforeQuery && (t = await e.onBeforeQuery(t));
|
|
210
|
-
const o = await
|
|
242
|
+
const o = await _.get(e.apiUrlQuery, { params: t });
|
|
211
243
|
if (o && o.data && Array.isArray(o.data.rows) && typeof o.data.total == "number") {
|
|
212
|
-
let
|
|
213
|
-
e.onAfterQuery && (
|
|
244
|
+
let a = o.data.rows;
|
|
245
|
+
e.onAfterQuery && (a = await e.onAfterQuery(a)), V.value = a, A.value = o.data.total;
|
|
214
246
|
} else
|
|
215
|
-
console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),
|
|
247
|
+
console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."), V.value = [], A.value = 0;
|
|
216
248
|
} catch (t) {
|
|
217
249
|
console.error("Fetch data failed:", t);
|
|
218
250
|
} finally {
|
|
@@ -220,124 +252,125 @@ const fe = {
|
|
|
220
252
|
}
|
|
221
253
|
}
|
|
222
254
|
}, N = () => {
|
|
223
|
-
|
|
224
|
-
},
|
|
225
|
-
const { pageNum: t, pageSize: o, ...
|
|
226
|
-
Object.keys(
|
|
227
|
-
|
|
228
|
-
}), Object.assign(
|
|
229
|
-
},
|
|
255
|
+
m.pageNum = 1, B();
|
|
256
|
+
}, X = () => {
|
|
257
|
+
const { pageNum: t, pageSize: o, ...a } = e.initialSearchForm;
|
|
258
|
+
Object.keys(m).forEach((p) => {
|
|
259
|
+
p !== "pageNum" && p !== "pageSize" && delete m[p];
|
|
260
|
+
}), Object.assign(m, a), N();
|
|
261
|
+
}, Y = (t) => {
|
|
230
262
|
d.value = t;
|
|
231
|
-
},
|
|
232
|
-
let
|
|
233
|
-
if (t === "add" ?
|
|
234
|
-
const
|
|
235
|
-
|
|
263
|
+
}, Q = async (t, o) => {
|
|
264
|
+
let a;
|
|
265
|
+
if (t === "add" ? a = o ? { ...o } : { role: "user" } : a = { ...o }, e.onBeforeOpenDialog) {
|
|
266
|
+
const p = await e.onBeforeOpenDialog(t, a);
|
|
267
|
+
p && (a = p);
|
|
236
268
|
}
|
|
237
|
-
if (
|
|
238
|
-
if (!
|
|
239
|
-
|
|
269
|
+
if (l.mode = t, l.visible = !0, t === "edit") {
|
|
270
|
+
if (!v(e.apiUrlDetail, "apiUrlDetail")) return;
|
|
271
|
+
l.loading = !0;
|
|
240
272
|
try {
|
|
241
|
-
const
|
|
242
|
-
|
|
273
|
+
const p = await _.get(e.apiUrlDetail + "/" + a.id.toString());
|
|
274
|
+
l.data = p.data.data;
|
|
243
275
|
} finally {
|
|
244
|
-
|
|
276
|
+
l.loading = !1, e.onAfterOpenDialog && e.onAfterOpenDialog(t, l.data), s("open-dialog", { mode: t, data: l.data });
|
|
245
277
|
}
|
|
246
278
|
} else
|
|
247
|
-
|
|
248
|
-
},
|
|
279
|
+
l.data = a, e.onAfterOpenDialog && e.onAfterOpenDialog(t, l.data), s("open-dialog", { mode: t, data: l.data });
|
|
280
|
+
}, Z = async () => {
|
|
249
281
|
try {
|
|
250
|
-
|
|
251
|
-
let t = { ...
|
|
282
|
+
l.formRef && await l.formRef.validate();
|
|
283
|
+
let t = { ...l.data };
|
|
252
284
|
e.onBeforeSubmit && (t = await e.onBeforeSubmit(t));
|
|
253
285
|
let o = t;
|
|
254
286
|
if (e.submitAsFormData) {
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
if (Object.prototype.hasOwnProperty.call(t,
|
|
258
|
-
const
|
|
259
|
-
|
|
287
|
+
const a = new FormData();
|
|
288
|
+
for (const p in t)
|
|
289
|
+
if (Object.prototype.hasOwnProperty.call(t, p)) {
|
|
290
|
+
const F = t[p];
|
|
291
|
+
a.append(p, F ?? "");
|
|
260
292
|
}
|
|
261
|
-
o =
|
|
293
|
+
o = a;
|
|
294
|
+
debugger;
|
|
262
295
|
}
|
|
263
|
-
if (
|
|
264
|
-
if (!
|
|
265
|
-
await
|
|
296
|
+
if (l.submitting = !0, l.mode === "add") {
|
|
297
|
+
if (!v(e.apiUrlCreate, "apiUrlCreate")) return;
|
|
298
|
+
await _.post(e.apiUrlCreate, o), k.success("新增成功");
|
|
266
299
|
} else {
|
|
267
|
-
if (!
|
|
268
|
-
await
|
|
300
|
+
if (!v(e.apiUrlUpdate, "apiUrlUpdate")) return;
|
|
301
|
+
await _.put(e.apiUrlUpdate, o), k.success("更新成功");
|
|
269
302
|
}
|
|
270
|
-
e.onAfterSubmit && e.onAfterSubmit(
|
|
303
|
+
e.onAfterSubmit && e.onAfterSubmit(l.mode, t), s("submit", { mode: l.mode, data: t }), l.visible = !1, B();
|
|
271
304
|
} catch (t) {
|
|
272
305
|
console.log("Submit error or validation failed:", t);
|
|
273
306
|
} finally {
|
|
274
|
-
|
|
307
|
+
l.submitting = !1;
|
|
275
308
|
}
|
|
276
|
-
},
|
|
277
|
-
if (
|
|
309
|
+
}, L = async (t) => {
|
|
310
|
+
if (v(e.apiUrlDelete, "apiUrlDelete"))
|
|
278
311
|
try {
|
|
279
312
|
if (e.onBeforeDelete && await e.onBeforeDelete(t) === !1)
|
|
280
313
|
return;
|
|
281
314
|
const o = t.join(",");
|
|
282
|
-
await
|
|
315
|
+
await _.delete(e.apiUrlDelete + "/" + o.toString()), k.success("删除成功"), e.onAfterDelete && e.onAfterDelete(t), s("delete", t), V.value.length === t.length && m.pageNum > 1 && m.pageNum--, B();
|
|
283
316
|
} catch (o) {
|
|
284
317
|
console.error("Delete failed", o);
|
|
285
318
|
}
|
|
286
|
-
}, Z = (t) => {
|
|
287
|
-
f.pageSize = t, N();
|
|
288
319
|
}, ee = (t) => {
|
|
289
|
-
|
|
320
|
+
m.pageSize = t, N();
|
|
321
|
+
}, te = (t) => {
|
|
322
|
+
m.pageNum = t, B();
|
|
290
323
|
};
|
|
291
|
-
return ne(
|
|
292
|
-
refresh:
|
|
324
|
+
return ne(B), b({
|
|
325
|
+
refresh: B,
|
|
293
326
|
// 刷新表格
|
|
294
327
|
search: N,
|
|
295
328
|
// 按当前条件搜索
|
|
296
|
-
handleDelete:
|
|
329
|
+
handleDelete: L,
|
|
297
330
|
// 手动触发删除
|
|
298
|
-
openDialog:
|
|
331
|
+
openDialog: Q,
|
|
299
332
|
// 手动打开弹窗
|
|
300
|
-
submit:
|
|
333
|
+
submit: q
|
|
301
334
|
// 手动提交
|
|
302
335
|
}), (t, o) => {
|
|
303
|
-
const
|
|
304
|
-
return n(),
|
|
305
|
-
class: se(
|
|
336
|
+
const a = g("el-button"), p = g("el-form-item"), F = g("el-form"), C = g("el-table-column"), T = g("el-popconfirm"), oe = g("el-table"), ae = g("el-pagination"), le = g("el-dialog"), W = ie("loading");
|
|
337
|
+
return n(), h("div", {
|
|
338
|
+
class: se(z.value)
|
|
306
339
|
}, [
|
|
307
|
-
|
|
308
|
-
e.showSearchSection ? (n(),
|
|
309
|
-
|
|
310
|
-
model:
|
|
340
|
+
w(t.$slots, "header"),
|
|
341
|
+
e.showSearchSection ? (n(), h("div", me, [
|
|
342
|
+
S(F, {
|
|
343
|
+
model: m,
|
|
311
344
|
class: "query-form flex flex-nowrap items-center gap-x-4",
|
|
312
345
|
style: { "overflow-x": "auto", "padding-bottom": "8px" }
|
|
313
346
|
}, {
|
|
314
347
|
default: u(() => [
|
|
315
|
-
|
|
316
|
-
|
|
348
|
+
w(t.$slots, "query-conditions", { searchForm: m }),
|
|
349
|
+
S(p, { class: "!mr-0 flex-shrink-0" }, {
|
|
317
350
|
default: u(() => [
|
|
318
|
-
I("div",
|
|
319
|
-
|
|
320
|
-
e.showSearchActionButtons ? (n(),
|
|
321
|
-
|
|
351
|
+
I("div", ce, [
|
|
352
|
+
w(t.$slots, "query-left"),
|
|
353
|
+
e.showSearchActionButtons ? (n(), h($, { key: 0 }, [
|
|
354
|
+
S(a, {
|
|
322
355
|
type: "primary",
|
|
323
356
|
onClick: N,
|
|
324
357
|
loading: r.value
|
|
325
358
|
}, {
|
|
326
359
|
default: u(() => o[6] || (o[6] = [
|
|
327
|
-
|
|
360
|
+
D("搜索")
|
|
328
361
|
])),
|
|
329
362
|
_: 1,
|
|
330
363
|
__: [6]
|
|
331
364
|
}, 8, ["loading"]),
|
|
332
|
-
|
|
365
|
+
S(a, { onClick: X }, {
|
|
333
366
|
default: u(() => o[7] || (o[7] = [
|
|
334
|
-
|
|
367
|
+
D("清空")
|
|
335
368
|
])),
|
|
336
369
|
_: 1,
|
|
337
370
|
__: [7]
|
|
338
371
|
})
|
|
339
|
-
], 64)) :
|
|
340
|
-
|
|
372
|
+
], 64)) : c("", !0),
|
|
373
|
+
w(t.$slots, "query-right")
|
|
341
374
|
])
|
|
342
375
|
]),
|
|
343
376
|
_: 3
|
|
@@ -345,43 +378,43 @@ const fe = {
|
|
|
345
378
|
]),
|
|
346
379
|
_: 3
|
|
347
380
|
}, 8, ["model"]),
|
|
348
|
-
I("div",
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
e.showNewBtn ? (n(),
|
|
381
|
+
I("div", ge, [
|
|
382
|
+
w(t.$slots, "action-left", { selections: d.value }),
|
|
383
|
+
w(t.$slots, "add-button-content", {}, () => [
|
|
384
|
+
e.showNewBtn ? (n(), f(a, {
|
|
352
385
|
key: 0,
|
|
353
386
|
type: "success",
|
|
354
|
-
onClick: o[0] || (o[0] = (i) =>
|
|
387
|
+
onClick: o[0] || (o[0] = (i) => Q("add"))
|
|
355
388
|
}, {
|
|
356
389
|
default: u(() => o[8] || (o[8] = [
|
|
357
|
-
|
|
390
|
+
D("新增")
|
|
358
391
|
])),
|
|
359
392
|
_: 1,
|
|
360
393
|
__: [8]
|
|
361
|
-
})) :
|
|
394
|
+
})) : c("", !0)
|
|
362
395
|
]),
|
|
363
|
-
|
|
396
|
+
w(t.$slots, "action-right")
|
|
364
397
|
])
|
|
365
|
-
])) :
|
|
366
|
-
|
|
367
|
-
data:
|
|
368
|
-
onSelectionChange:
|
|
398
|
+
])) : c("", !0),
|
|
399
|
+
M((n(), f(oe, U({
|
|
400
|
+
data: V.value,
|
|
401
|
+
onSelectionChange: Y
|
|
369
402
|
}, t.$attrs, { style: { width: "100%", "margin-bottom": "1.5rem" } }), {
|
|
370
403
|
default: u(() => [
|
|
371
|
-
e.showSelectionColumn ? (n(),
|
|
404
|
+
e.showSelectionColumn ? (n(), f(C, {
|
|
372
405
|
key: 0,
|
|
373
406
|
type: "selection",
|
|
374
407
|
width: "55",
|
|
375
408
|
fixed: ""
|
|
376
|
-
})) :
|
|
377
|
-
e.showIndexColumn ? (n(),
|
|
409
|
+
})) : c("", !0),
|
|
410
|
+
e.showIndexColumn ? (n(), f(C, {
|
|
378
411
|
key: 1,
|
|
379
412
|
type: "index",
|
|
380
413
|
label: "序号",
|
|
381
414
|
width: "70",
|
|
382
415
|
fixed: ""
|
|
383
|
-
})) :
|
|
384
|
-
(n(!0),
|
|
416
|
+
})) : c("", !0),
|
|
417
|
+
(n(!0), h($, null, E(e.columns, (i) => (n(), f(C, U({
|
|
385
418
|
key: i.prop,
|
|
386
419
|
prop: i.prop,
|
|
387
420
|
label: i.label,
|
|
@@ -390,119 +423,119 @@ const fe = {
|
|
|
390
423
|
}, { ref_for: !0 }, i.attrs), ue({ _: 2 }, [
|
|
391
424
|
i.slot ? {
|
|
392
425
|
name: "default",
|
|
393
|
-
fn: u((
|
|
394
|
-
|
|
395
|
-
row:
|
|
426
|
+
fn: u((R) => [
|
|
427
|
+
w(t.$slots, i.slot, {
|
|
428
|
+
row: R.row
|
|
396
429
|
})
|
|
397
430
|
]),
|
|
398
431
|
key: "0"
|
|
399
432
|
} : void 0
|
|
400
433
|
]), 1040, ["prop", "label", "width", "sortable"]))), 128)),
|
|
401
|
-
e.showActionsColumn ? (n(),
|
|
434
|
+
e.showActionsColumn ? (n(), f(C, {
|
|
402
435
|
key: 2,
|
|
403
436
|
label: "操作",
|
|
404
|
-
width:
|
|
437
|
+
width: y.actionsColumnWidth
|
|
405
438
|
}, {
|
|
406
439
|
default: u((i) => [
|
|
407
|
-
i.row ? (n(),
|
|
408
|
-
t.$slots.actions ?
|
|
440
|
+
i.row ? (n(), h("div", ye, [
|
|
441
|
+
t.$slots.actions ? w(t.$slots, "actions", {
|
|
409
442
|
key: 0,
|
|
410
443
|
row: i.row
|
|
411
|
-
}) : (n(),
|
|
412
|
-
|
|
444
|
+
}) : (n(), h($, { key: 1 }, [
|
|
445
|
+
w(t.$slots, "action-before-edit", {
|
|
413
446
|
row: i.row
|
|
414
447
|
}),
|
|
415
|
-
e.showEditButton ? (n(),
|
|
448
|
+
e.showEditButton ? (n(), f(a, {
|
|
416
449
|
key: 0,
|
|
417
450
|
size: "small",
|
|
418
451
|
type: "primary",
|
|
419
452
|
link: "",
|
|
420
|
-
onClick: (
|
|
453
|
+
onClick: (R) => Q("edit", i.row)
|
|
421
454
|
}, {
|
|
422
455
|
default: u(() => o[9] || (o[9] = [
|
|
423
|
-
|
|
456
|
+
D("编辑 ")
|
|
424
457
|
])),
|
|
425
458
|
_: 2,
|
|
426
459
|
__: [9]
|
|
427
|
-
}, 1032, ["onClick"])) :
|
|
428
|
-
e.showDeleteButton ? (n(),
|
|
460
|
+
}, 1032, ["onClick"])) : c("", !0),
|
|
461
|
+
e.showDeleteButton ? (n(), f(T, {
|
|
429
462
|
key: 1,
|
|
430
463
|
title: "确定要删除这条数据吗?",
|
|
431
|
-
onConfirm: (
|
|
464
|
+
onConfirm: (R) => L([i.row.id]),
|
|
432
465
|
"confirm-button-text": "确定",
|
|
433
466
|
"cancel-button-text": "取消",
|
|
434
467
|
width: "200"
|
|
435
468
|
}, {
|
|
436
469
|
reference: u(() => [
|
|
437
|
-
|
|
470
|
+
S(a, {
|
|
438
471
|
size: "small",
|
|
439
472
|
type: "danger",
|
|
440
473
|
link: ""
|
|
441
474
|
}, {
|
|
442
475
|
default: u(() => o[10] || (o[10] = [
|
|
443
|
-
|
|
476
|
+
D("删除")
|
|
444
477
|
])),
|
|
445
478
|
_: 1,
|
|
446
479
|
__: [10]
|
|
447
480
|
})
|
|
448
481
|
]),
|
|
449
482
|
_: 2
|
|
450
|
-
}, 1032, ["onConfirm"])) :
|
|
451
|
-
|
|
483
|
+
}, 1032, ["onConfirm"])) : c("", !0),
|
|
484
|
+
w(t.$slots, "action-after-delete", {
|
|
452
485
|
row: i.row
|
|
453
486
|
})
|
|
454
487
|
], 64))
|
|
455
|
-
])) :
|
|
488
|
+
])) : c("", !0)
|
|
456
489
|
]),
|
|
457
490
|
_: 3
|
|
458
|
-
}, 8, ["width"])) :
|
|
491
|
+
}, 8, ["width"])) : c("", !0)
|
|
459
492
|
]),
|
|
460
493
|
_: 3
|
|
461
494
|
}, 16, ["data"])), [
|
|
462
|
-
[
|
|
495
|
+
[W, r.value]
|
|
463
496
|
]),
|
|
464
|
-
e.showPagination &&
|
|
465
|
-
|
|
466
|
-
"current-page":
|
|
467
|
-
"onUpdate:currentPage": o[1] || (o[1] = (i) =>
|
|
468
|
-
"page-size":
|
|
469
|
-
"onUpdate:pageSize": o[2] || (o[2] = (i) =>
|
|
497
|
+
e.showPagination && A.value > 0 ? (n(), h("div", be, [
|
|
498
|
+
S(ae, {
|
|
499
|
+
"current-page": m.pageNum,
|
|
500
|
+
"onUpdate:currentPage": o[1] || (o[1] = (i) => m.pageNum = i),
|
|
501
|
+
"page-size": m.pageSize,
|
|
502
|
+
"onUpdate:pageSize": o[2] || (o[2] = (i) => m.pageSize = i),
|
|
470
503
|
"page-sizes": e.pageSizes,
|
|
471
504
|
layout: e.paginationLayout,
|
|
472
|
-
total:
|
|
505
|
+
total: A.value,
|
|
473
506
|
background: e.paginationBackground,
|
|
474
507
|
small: e.paginationSmall,
|
|
475
508
|
"hide-on-single-page": e.paginationHideOnSinglePage,
|
|
476
|
-
onSizeChange:
|
|
477
|
-
onCurrentChange:
|
|
509
|
+
onSizeChange: ee,
|
|
510
|
+
onCurrentChange: te
|
|
478
511
|
}, null, 8, ["current-page", "page-size", "page-sizes", "layout", "total", "background", "small", "hide-on-single-page"])
|
|
479
|
-
])) :
|
|
480
|
-
|
|
481
|
-
modelValue:
|
|
482
|
-
"onUpdate:modelValue": o[5] || (o[5] = (i) =>
|
|
483
|
-
title:
|
|
512
|
+
])) : c("", !0),
|
|
513
|
+
S(le, {
|
|
514
|
+
modelValue: l.visible,
|
|
515
|
+
"onUpdate:modelValue": o[5] || (o[5] = (i) => l.visible = i),
|
|
516
|
+
title: J.value,
|
|
484
517
|
width: e.dialogWidth,
|
|
485
518
|
"destroy-on-close": !0,
|
|
486
|
-
"custom-class":
|
|
519
|
+
"custom-class": x.value
|
|
487
520
|
}, {
|
|
488
521
|
footer: u(() => [
|
|
489
|
-
I("div",
|
|
490
|
-
|
|
491
|
-
onClick: o[4] || (o[4] = (i) =>
|
|
522
|
+
I("div", we, [
|
|
523
|
+
S(a, {
|
|
524
|
+
onClick: o[4] || (o[4] = (i) => l.visible = !1)
|
|
492
525
|
}, {
|
|
493
526
|
default: u(() => o[11] || (o[11] = [
|
|
494
|
-
|
|
527
|
+
D("取消")
|
|
495
528
|
])),
|
|
496
529
|
_: 1,
|
|
497
530
|
__: [11]
|
|
498
531
|
}),
|
|
499
|
-
|
|
532
|
+
S(a, {
|
|
500
533
|
type: "primary",
|
|
501
|
-
onClick:
|
|
502
|
-
loading:
|
|
534
|
+
onClick: Z,
|
|
535
|
+
loading: l.submitting
|
|
503
536
|
}, {
|
|
504
537
|
default: u(() => o[12] || (o[12] = [
|
|
505
|
-
|
|
538
|
+
D("确定")
|
|
506
539
|
])),
|
|
507
540
|
_: 1,
|
|
508
541
|
__: [12]
|
|
@@ -510,23 +543,23 @@ const fe = {
|
|
|
510
543
|
])
|
|
511
544
|
]),
|
|
512
545
|
default: u(() => [
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
formData:
|
|
516
|
-
mode:
|
|
546
|
+
M((n(), h("div", null, [
|
|
547
|
+
w(t.$slots, "dialog-form-content", {
|
|
548
|
+
formData: l.data,
|
|
549
|
+
mode: l.mode
|
|
517
550
|
}, () => [
|
|
518
|
-
e.dialogFormConfig.length > 0 ? (n(),
|
|
551
|
+
e.dialogFormConfig.length > 0 ? (n(), f(fe, {
|
|
519
552
|
key: 0,
|
|
520
|
-
"form-config":
|
|
521
|
-
modelValue:
|
|
522
|
-
"onUpdate:modelValue": o[3] || (o[3] = (i) =>
|
|
523
|
-
ref: (i) =>
|
|
553
|
+
"form-config": K.value,
|
|
554
|
+
modelValue: l.data,
|
|
555
|
+
"onUpdate:modelValue": o[3] || (o[3] = (i) => l.data = i),
|
|
556
|
+
ref: (i) => l.formRef = i,
|
|
524
557
|
rules: e.dialogFormRules,
|
|
525
558
|
"label-width": "80px"
|
|
526
|
-
}, null, 8, ["form-config", "modelValue", "rules"])) :
|
|
559
|
+
}, null, 8, ["form-config", "modelValue", "rules"])) : c("", !0)
|
|
527
560
|
])
|
|
528
561
|
])), [
|
|
529
|
-
[
|
|
562
|
+
[W, l.loading]
|
|
530
563
|
])
|
|
531
564
|
]),
|
|
532
565
|
_: 3
|
|
@@ -536,5 +569,5 @@ const fe = {
|
|
|
536
569
|
}
|
|
537
570
|
});
|
|
538
571
|
export {
|
|
539
|
-
|
|
572
|
+
_e as CrudTable
|
|
540
573
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(f,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","axios"],e):(f=typeof globalThis<"u"?globalThis:f||self,e(f.ZCrudTable={},f.Vue,f.ElementPlus,f.axios))})(this,function(f,e,y,E){"use strict";const $=e.defineComponent({__name:"DynamicForm",props:{modelValue:{},formConfig:{},rules:{}},setup(c,{expose:k}){const b=e.ref(null);return k({validate:()=>{var s;return(s=b.value)==null?void 0:s.validate()}}),(s,t)=>{const w=e.resolveComponent("el-input"),_=e.resolveComponent("el-option"),u=e.resolveComponent("el-select"),D=e.resolveComponent("el-radio"),p=e.resolveComponent("el-radio-group"),B=e.resolveComponent("el-form-item"),h=e.resolveComponent("el-form");return e.openBlock(),e.createBlock(h,e.mergeProps({model:s.modelValue,rules:s.rules,ref_key:"formRef",ref:b},s.$attrs),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.formConfig,n=>(e.openBlock(),e.createBlock(B,{key:n.prop,label:n.label,prop:n.prop},{default:e.withCtx(()=>[n.type==="input"?(e.openBlock(),e.createBlock(w,e.mergeProps({key:0,modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="textarea"?(e.openBlock(),e.createBlock(w,e.mergeProps({key:1,type:"textarea",modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="select"?(e.openBlock(),e.createBlock(u,e.mergeProps({key:2,modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.options,d=>(e.openBlock(),e.createBlock(_,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="radio-group"?(e.openBlock(),e.createBlock(p,e.mergeProps({key:3,modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.options,d=>(e.openBlock(),e.createBlock(D,{key:d.value,label:d.value},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.label),1)]),_:2},1032,["label"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="input-disabled"?(e.openBlock(),e.createBlock(w,e.mergeProps({key:4,"model-value":s.modelValue[n.prop],disabled:""},{ref_for:!0},n.componentProps),null,16,["model-value"])):e.createCommentVNode("",!0)]),_:2},1032,["label","prop"]))),128))]),_:1},16,["model","rules"])}}}),g=E.create({baseURL:"",timeout:1e4});g.interceptors.request.use(c=>{const k=localStorage.getItem("token");return k&&(c.headers.Authorization="Bearer "+k),c},c=>(console.log(c),Promise.reject(c))),g.interceptors.response.use(c=>c.data,c=>(console.log("err"+c),y.ElMessage({message:"接口错误,请刷新接口",type:"error",duration:5*1e3}),Promise.reject(c)));const z={key:0,class:"flex flex-wrap items-center justify-between gap-4 mb-6"},P={class:"flex items-center gap-x-2"},O={class:"flex items-center gap-x-3 action-buttons flex-shrink-0"},T={key:0,class:"flex items-center gap-x-2"},j={key:1,class:"flex justify-end"},q={class:"dialog-footer"},Q=e.defineComponent({__name:"CrudTable",props:{theme:{type:String,default:"default"},customClass:{type:String,default:""},apiUrlQuery:{type:String,required:!0},apiUrlDetail:{type:String,required:!0},apiUrlCreate:{type:String,required:!0},apiUrlUpdate:{type:String,required:!0},apiUrlDelete:{type:String,required:!0},showSearchSection:{type:Boolean,default:!0},showSearchActionButtons:{type:Boolean,default:!0},showNewBtn:{type:Boolean,default:!0},columns:{type:Array,default:()=>[]},onBeforeQuery:{type:Function},onAfterQuery:{type:Function},onBeforeOpenDialog:{type:Function},onAfterOpenDialog:{type:Function},onBeforeSubmit:{type:Function},onAfterSubmit:{type:Function},onBeforeDelete:{type:Function},onAfterDelete:{type:Function},showSelectionColumn:{type:Boolean,default:!0},showIndexColumn:{type:Boolean,default:!0},showActionsColumn:{type:Boolean,default:!0},showEditButton:{type:Boolean,default:!0},showDeleteButton:{type:Boolean,default:!0},actionsColumnWidth:{type:[String,Number],default:120},dialogWidth:{type:String,default:"50%"},initialSearchForm:{type:Object,default:()=>({pageNum:1,pageSize:10})},showPagination:{type:Boolean,default:!0},pageSizes:{type:Array,default:()=>[10,20,50,100]},paginationLayout:{type:String,default:"total, sizes, prev, pager, next, jumper"},paginationBackground:{type:Boolean,default:!0},paginationSmall:{type:Boolean,default:!1},paginationHideOnSinglePage:{type:Boolean,default:!1},dialogFormConfig:{type:Array,default:()=>[]},dialogFormRules:{type:Object,default:()=>({})},submitAsFormData:{type:Boolean,default:!1}},emits:["open-dialog","submit","delete"],setup(c,{expose:k,emit:b}){const s=b,t=c,w=e.computed(()=>["crud-table-wrapper",`theme-${t.theme}`,t.customClass]),_=e.computed(()=>t.theme==="large-screen"?"large-screen-dialog":""),u=(o,a)=>o?!0:(y.ElMessage.error(`${a} prop is required.`),!1),D=async(o,a)=>{try{let r={...a};if(t.onBeforeSubmit&&(r=await t.onBeforeSubmit(r)),l.submitting=!0,o==="add"){if(!u(t.apiUrlCreate,"apiUrlCreate"))return;await g.post(t.apiUrlCreate,r),y.ElMessage.success("新增成功")}else{if(!u(t.apiUrlUpdate,"apiUrlUpdate"))return;await g.put(t.apiUrlUpdate,r),y.ElMessage.success("更新成功")}return t.onAfterSubmit&&t.onAfterSubmit(o,r),s("submit",{mode:o,data:r}),l.visible&&(l.visible=!1),C(),Promise.resolve()}catch(r){return console.log("Submit error:",r),Promise.reject(r)}finally{l.submitting=!1}},p=e.reactive({pageNum:1,pageSize:10,...t.initialSearchForm}),B=e.ref([]),h=e.ref(0),n=e.ref(!1),d=e.ref([]),l=e.reactive({visible:!1,loading:!1,submitting:!1,mode:"add",data:{},formRef:null}),M=e.computed(()=>l.mode==="add"?"新增":"编辑"),R=e.computed(()=>{if(l.mode==="add")return t.dialogFormConfig.filter(a=>a.prop!=="id");const o=[...t.dialogFormConfig.filter(a=>a.prop!=="id")];return o.some(a=>a.prop==="id")||o.unshift({type:"input-disabled",prop:"id",label:"用户ID"}),o}),C=async()=>{if(u(t.apiUrlQuery,"apiUrlQuery")){n.value=!0;try{let o={...p};t.onBeforeQuery&&(o=await t.onBeforeQuery(o));const a=await g.get(t.apiUrlQuery,{params:o});if(a&&a.data&&Array.isArray(a.data.rows)&&typeof a.data.total=="number"){let r=a.data.rows;t.onAfterQuery&&(r=await t.onAfterQuery(r)),B.value=r,h.value=a.data.total}else console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),B.value=[],h.value=0}catch(o){console.error("Fetch data failed:",o)}finally{n.value=!1}}},S=()=>{p.pageNum=1,C()},L=()=>{const{pageNum:o,pageSize:a,...r}=t.initialSearchForm;Object.keys(p).forEach(m=>{m!=="pageNum"&&m!=="pageSize"&&delete p[m]}),Object.assign(p,r),S()},I=o=>{d.value=o},N=async(o,a)=>{let r;if(o==="add"?r=a?{...a}:{role:"user"}:r={...a},t.onBeforeOpenDialog){const m=await t.onBeforeOpenDialog(o,r);m&&(r=m)}if(l.mode=o,l.visible=!0,o==="edit"){if(!u(t.apiUrlDetail,"apiUrlDetail"))return;l.loading=!0;try{const m=await g.get(t.apiUrlDetail+"/"+r.id.toString());l.data=m.data.data}finally{l.loading=!1,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,l.data),s("open-dialog",{mode:o,data:l.data})}}else l.data=r,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,l.data),s("open-dialog",{mode:o,data:l.data})},W=async()=>{try{l.formRef&&await l.formRef.validate();let o={...l.data};t.onBeforeSubmit&&(o=await t.onBeforeSubmit(o));let a=o;if(t.submitAsFormData){const r=new FormData;for(const m in o)if(Object.prototype.hasOwnProperty.call(o,m)){const U=o[m];r.append(m,U??"")}a=r}if(l.submitting=!0,l.mode==="add"){if(!u(t.apiUrlCreate,"apiUrlCreate"))return;await g.post(t.apiUrlCreate,a),y.ElMessage.success("新增成功")}else{if(!u(t.apiUrlUpdate,"apiUrlUpdate"))return;await g.put(t.apiUrlUpdate,a),y.ElMessage.success("更新成功")}t.onAfterSubmit&&t.onAfterSubmit(l.mode,o),s("submit",{mode:l.mode,data:o}),l.visible=!1,C()}catch(o){console.log("Submit error or validation failed:",o)}finally{l.submitting=!1}},F=async o=>{if(u(t.apiUrlDelete,"apiUrlDelete"))try{if(t.onBeforeDelete&&await t.onBeforeDelete(o)===!1)return;const a=o.join(",");await g.delete(t.apiUrlDelete+"/"+a.toString()),y.ElMessage.success("删除成功"),t.onAfterDelete&&t.onAfterDelete(o),s("delete",o),B.value.length===o.length&&p.pageNum>1&&p.pageNum--,C()}catch(a){console.error("Delete failed",a)}},H=o=>{p.pageSize=o,S()},Z=o=>{p.pageNum=o,C()};return e.onMounted(C),k({refresh:C,search:S,handleDelete:F,openDialog:N,submit:D}),(o,a)=>{const r=e.resolveComponent("el-button"),m=e.resolveComponent("el-form-item"),U=e.resolveComponent("el-form"),V=e.resolveComponent("el-table-column"),G=e.resolveComponent("el-popconfirm"),J=e.resolveComponent("el-table"),K=e.resolveComponent("el-pagination"),X=e.resolveComponent("el-dialog"),A=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(w.value)},[e.renderSlot(o.$slots,"header"),t.showSearchSection?(e.openBlock(),e.createElementBlock("div",z,[e.createVNode(U,{model:p,class:"query-form flex flex-nowrap items-center gap-x-4",style:{"overflow-x":"auto","padding-bottom":"8px"}},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"query-conditions",{searchForm:p}),e.createVNode(m,{class:"!mr-0 flex-shrink-0"},{default:e.withCtx(()=>[e.createElementVNode("div",P,[e.renderSlot(o.$slots,"query-left"),t.showSearchActionButtons?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(r,{type:"primary",onClick:S,loading:n.value},{default:e.withCtx(()=>a[6]||(a[6]=[e.createTextVNode("搜索")])),_:1,__:[6]},8,["loading"]),e.createVNode(r,{onClick:L},{default:e.withCtx(()=>a[7]||(a[7]=[e.createTextVNode("清空")])),_:1,__:[7]})],64)):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"query-right")])]),_:3})]),_:3},8,["model"]),e.createElementVNode("div",O,[e.renderSlot(o.$slots,"action-left",{selections:d.value}),e.renderSlot(o.$slots,"add-button-content",{},()=>[t.showNewBtn?(e.openBlock(),e.createBlock(r,{key:0,type:"success",onClick:a[0]||(a[0]=i=>N("add"))},{default:e.withCtx(()=>a[8]||(a[8]=[e.createTextVNode("新增")])),_:1,__:[8]})):e.createCommentVNode("",!0)]),e.renderSlot(o.$slots,"action-right")])])):e.createCommentVNode("",!0),e.withDirectives((e.openBlock(),e.createBlock(J,e.mergeProps({data:B.value,onSelectionChange:I},o.$attrs,{style:{width:"100%","margin-bottom":"1.5rem"}}),{default:e.withCtx(()=>[t.showSelectionColumn?(e.openBlock(),e.createBlock(V,{key:0,type:"selection",width:"55",fixed:""})):e.createCommentVNode("",!0),t.showIndexColumn?(e.openBlock(),e.createBlock(V,{key:1,type:"index",label:"序号",width:"70",fixed:""})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,i=>(e.openBlock(),e.createBlock(V,e.mergeProps({key:i.prop,prop:i.prop,label:i.label,width:i.width,sortable:i.sortable||!1},{ref_for:!0},i.attrs),e.createSlots({_:2},[i.slot?{name:"default",fn:e.withCtx(x=>[e.renderSlot(o.$slots,i.slot,{row:x.row})]),key:"0"}:void 0]),1040,["prop","label","width","sortable"]))),128)),t.showActionsColumn?(e.openBlock(),e.createBlock(V,{key:2,label:"操作",width:c.actionsColumnWidth},{default:e.withCtx(i=>[i.row?(e.openBlock(),e.createElementBlock("div",T,[o.$slots.actions?e.renderSlot(o.$slots,"actions",{key:0,row:i.row}):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(o.$slots,"action-before-edit",{row:i.row}),t.showEditButton?(e.openBlock(),e.createBlock(r,{key:0,size:"small",type:"primary",link:"",onClick:x=>N("edit",i.row)},{default:e.withCtx(()=>a[9]||(a[9]=[e.createTextVNode("编辑 ")])),_:2,__:[9]},1032,["onClick"])):e.createCommentVNode("",!0),t.showDeleteButton?(e.openBlock(),e.createBlock(G,{key:1,title:"确定要删除这条数据吗?",onConfirm:x=>F([i.row.id]),"confirm-button-text":"确定","cancel-button-text":"取消",width:"200"},{reference:e.withCtx(()=>[e.createVNode(r,{size:"small",type:"danger",link:""},{default:e.withCtx(()=>a[10]||(a[10]=[e.createTextVNode("删除")])),_:1,__:[10]})]),_:2},1032,["onConfirm"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"action-after-delete",{row:i.row})],64))])):e.createCommentVNode("",!0)]),_:3},8,["width"])):e.createCommentVNode("",!0)]),_:3},16,["data"])),[[A,n.value]]),t.showPagination&&h.value>0?(e.openBlock(),e.createElementBlock("div",j,[e.createVNode(K,{"current-page":p.pageNum,"onUpdate:currentPage":a[1]||(a[1]=i=>p.pageNum=i),"page-size":p.pageSize,"onUpdate:pageSize":a[2]||(a[2]=i=>p.pageSize=i),"page-sizes":t.pageSizes,layout:t.paginationLayout,total:h.value,background:t.paginationBackground,small:t.paginationSmall,"hide-on-single-page":t.paginationHideOnSinglePage,onSizeChange:H,onCurrentChange:Z},null,8,["current-page","page-size","page-sizes","layout","total","background","small","hide-on-single-page"])])):e.createCommentVNode("",!0),e.createVNode(X,{modelValue:l.visible,"onUpdate:modelValue":a[5]||(a[5]=i=>l.visible=i),title:M.value,width:t.dialogWidth,"destroy-on-close":!0,"custom-class":_.value},{footer:e.withCtx(()=>[e.createElementVNode("div",q,[e.createVNode(r,{onClick:a[4]||(a[4]=i=>l.visible=!1)},{default:e.withCtx(()=>a[11]||(a[11]=[e.createTextVNode("取消")])),_:1,__:[11]}),e.createVNode(r,{type:"primary",onClick:W,loading:l.submitting},{default:e.withCtx(()=>a[12]||(a[12]=[e.createTextVNode("确定")])),_:1,__:[12]},8,["loading"])])]),default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(o.$slots,"dialog-form-content",{formData:l.data,mode:l.mode},()=>[t.dialogFormConfig.length>0?(e.openBlock(),e.createBlock($,{key:0,"form-config":R.value,modelValue:l.data,"onUpdate:modelValue":a[3]||(a[3]=i=>l.data=i),ref:i=>l.formRef=i,rules:t.dialogFormRules,"label-width":"80px"},null,8,["form-config","modelValue","rules"])):e.createCommentVNode("",!0)])])),[[A,l.loading]])]),_:3},8,["modelValue","title","width","custom-class"])],2)}}});f.CrudTable=Q,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(g,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("element-plus"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","element-plus","axios"],e):(g=typeof globalThis<"u"?globalThis:g||self,e(g.ZCrudTable={},g.Vue,g.ElementPlus,g.axios))})(this,function(g,e,u,$){"use strict";const z=e.defineComponent({__name:"DynamicForm",props:{modelValue:{},formConfig:{},rules:{}},setup(m,{expose:f}){const V=e.ref(null);return f({validate:()=>{var s;return(s=V.value)==null?void 0:s.validate()}}),(s,t)=>{const S=e.resolveComponent("el-input"),D=e.resolveComponent("el-option"),C=e.resolveComponent("el-select"),U=e.resolveComponent("el-radio"),c=e.resolveComponent("el-radio-group"),B=e.resolveComponent("el-form-item"),h=e.resolveComponent("el-form");return e.openBlock(),e.createBlock(h,e.mergeProps({model:s.modelValue,rules:s.rules,ref_key:"formRef",ref:V},s.$attrs),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.formConfig,n=>(e.openBlock(),e.createBlock(B,{key:n.prop,label:n.label,prop:n.prop},{default:e.withCtx(()=>[n.type==="input"?(e.openBlock(),e.createBlock(S,e.mergeProps({key:0,modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="textarea"?(e.openBlock(),e.createBlock(S,e.mergeProps({key:1,type:"textarea",modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="select"?(e.openBlock(),e.createBlock(C,e.mergeProps({key:2,modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.options,d=>(e.openBlock(),e.createBlock(D,{key:d.value,label:d.label,value:d.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="radio-group"?(e.openBlock(),e.createBlock(c,e.mergeProps({key:3,modelValue:s.modelValue[n.prop],"onUpdate:modelValue":d=>s.modelValue[n.prop]=d},{ref_for:!0},n.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.options,d=>(e.openBlock(),e.createBlock(U,{key:d.value,label:d.value},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.label),1)]),_:2},1032,["label"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),n.type==="input-disabled"?(e.openBlock(),e.createBlock(S,e.mergeProps({key:4,"model-value":s.modelValue[n.prop],disabled:""},{ref_for:!0},n.componentProps),null,16,["model-value"])):e.createCommentVNode("",!0)]),_:2},1032,["label","prop"]))),128))]),_:1},16,["model","rules"])}}}),y=$.create({baseURL:"",timeout:1e4});y.interceptors.request.use(m=>{const f=localStorage.getItem("token");return f&&(m.headers.Authorization="Bearer "+f),m},m=>(console.log(m),Promise.reject(m))),y.interceptors.response.use(m=>{const f=m.data;return f.code!==200?(u.ElMessage({message:f.msg||"Error",type:"error",duration:5*1e3}),(f.code===401||f.code===403)&&u.ElMessageBox.confirm("您的登录状态已失效,请重新登录","确认登出",{confirmButtonText:"重新登录",cancelButtonText:"取消",type:"warning"}).then(()=>{localStorage.removeItem("token"),location.reload()}),Promise.reject(new Error(f.msg||"Error"))):f},m=>(console.log("HTTP Error: "+m),u.ElMessage({message:"网络错误,请检查您的网络连接或联系管理员",type:"error",duration:5*1e3}),Promise.reject(m)));const T={key:0,class:"flex flex-wrap items-center justify-between gap-4 mb-6"},P={class:"flex items-center gap-x-2"},O={class:"flex items-center gap-x-3 action-buttons flex-shrink-0"},j={key:0,class:"flex items-center gap-x-2"},q={key:1,class:"flex justify-end"},M={class:"dialog-footer"},Q=e.defineComponent({__name:"CrudTable",props:{theme:{type:String,default:"default"},customClass:{type:String,default:""},apiUrlQuery:{type:String,required:!0},apiUrlDetail:{type:String,required:!0},apiUrlCreate:{type:String,required:!0},apiUrlUpdate:{type:String,required:!0},apiUrlDelete:{type:String,required:!0},showSearchSection:{type:Boolean,default:!0},showSearchActionButtons:{type:Boolean,default:!0},showNewBtn:{type:Boolean,default:!0},columns:{type:Array,default:()=>[]},onBeforeQuery:{type:Function},onAfterQuery:{type:Function},onBeforeOpenDialog:{type:Function},onAfterOpenDialog:{type:Function},onBeforeSubmit:{type:Function},onAfterSubmit:{type:Function},onBeforeDelete:{type:Function},onAfterDelete:{type:Function},showSelectionColumn:{type:Boolean,default:!0},showIndexColumn:{type:Boolean,default:!0},showActionsColumn:{type:Boolean,default:!0},showEditButton:{type:Boolean,default:!0},showDeleteButton:{type:Boolean,default:!0},actionsColumnWidth:{type:[String,Number],default:120},dialogWidth:{type:String,default:"50%"},initialSearchForm:{type:Object,default:()=>({pageNum:1,pageSize:10})},showPagination:{type:Boolean,default:!0},pageSizes:{type:Array,default:()=>[10,20,50,100]},paginationLayout:{type:String,default:"total, sizes, prev, pager, next, jumper"},paginationBackground:{type:Boolean,default:!0},paginationSmall:{type:Boolean,default:!1},paginationHideOnSinglePage:{type:Boolean,default:!1},dialogFormConfig:{type:Array,default:()=>[]},dialogFormRules:{type:Object,default:()=>({})},submitAsFormData:{type:Boolean,default:!1}},emits:["open-dialog","submit","delete"],setup(m,{expose:f,emit:V}){const s=V,t=m,S=e.computed(()=>["crud-table-wrapper",`theme-${t.theme}`,t.customClass]),D=e.computed(()=>t.theme==="large-screen"?"large-screen-dialog":""),C=(o,r)=>o?!0:(u.ElMessage.error(`${r} prop is required.`),!1),U=async(o,r)=>{try{let a={...r};t.onBeforeSubmit&&(a=await t.onBeforeSubmit(a));let p=a;if(t.submitAsFormData){const b=new FormData;for(const k in a)if(Object.prototype.hasOwnProperty.call(a,k)){const x=a[k];b.append(k,x??"")}p=b}if(l.submitting=!0,o==="add"){if(!C(t.apiUrlCreate,"apiUrlCreate"))throw new Error("apiUrlCreate is not configured.");await y.post(t.apiUrlCreate,p),u.ElMessage.success("新增成功")}else{if(!C(t.apiUrlUpdate,"apiUrlUpdate"))throw new Error("apiUrlUpdate is not configured.");await y.put(t.apiUrlUpdate,p),u.ElMessage.success("更新成功")}return t.onAfterSubmit&&t.onAfterSubmit(o,a),s("submit",{mode:o,data:a}),l.visible&&(l.visible=!1),w(),Promise.resolve()}catch(a){return console.error("Submit failed:",a),Promise.reject(a)}finally{l.submitting=!1}},c=e.reactive({pageNum:1,pageSize:10,...t.initialSearchForm}),B=e.ref([]),h=e.ref(0),n=e.ref(!1),d=e.ref([]),l=e.reactive({visible:!1,loading:!1,submitting:!1,mode:"add",data:{},formRef:null}),R=e.computed(()=>l.mode==="add"?"新增":"编辑"),L=e.computed(()=>{if(l.mode==="add")return t.dialogFormConfig.filter(r=>r.prop!=="id");const o=[...t.dialogFormConfig.filter(r=>r.prop!=="id")];return o.some(r=>r.prop==="id")||o.unshift({type:"input-disabled",prop:"id",label:"用户ID"}),o}),w=async()=>{if(C(t.apiUrlQuery,"apiUrlQuery")){n.value=!0;try{let o={...c};t.onBeforeQuery&&(o=await t.onBeforeQuery(o));const r=await y.get(t.apiUrlQuery,{params:o});if(r&&r.data&&Array.isArray(r.data.rows)&&typeof r.data.total=="number"){let a=r.data.rows;t.onAfterQuery&&(a=await t.onAfterQuery(a)),B.value=a,h.value=r.data.total}else console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),B.value=[],h.value=0}catch(o){console.error("Fetch data failed:",o)}finally{n.value=!1}}},_=()=>{c.pageNum=1,w()},I=()=>{const{pageNum:o,pageSize:r,...a}=t.initialSearchForm;Object.keys(c).forEach(p=>{p!=="pageNum"&&p!=="pageSize"&&delete c[p]}),Object.assign(c,a),_()},W=o=>{d.value=o},N=async(o,r)=>{let a;if(o==="add"?a=r?{...r}:{role:"user"}:a={...r},t.onBeforeOpenDialog){const p=await t.onBeforeOpenDialog(o,a);p&&(a=p)}if(l.mode=o,l.visible=!0,o==="edit"){if(!C(t.apiUrlDetail,"apiUrlDetail"))return;l.loading=!0;try{const p=await y.get(t.apiUrlDetail+"/"+a.id.toString());l.data=p.data.data}finally{l.loading=!1,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,l.data),s("open-dialog",{mode:o,data:l.data})}}else l.data=a,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,l.data),s("open-dialog",{mode:o,data:l.data})},H=async()=>{try{l.formRef&&await l.formRef.validate();let o={...l.data};t.onBeforeSubmit&&(o=await t.onBeforeSubmit(o));let r=o;if(t.submitAsFormData){const a=new FormData;for(const p in o)if(Object.prototype.hasOwnProperty.call(o,p)){const b=o[p];a.append(p,b??"")}r=a;debugger}if(l.submitting=!0,l.mode==="add"){if(!C(t.apiUrlCreate,"apiUrlCreate"))return;await y.post(t.apiUrlCreate,r),u.ElMessage.success("新增成功")}else{if(!C(t.apiUrlUpdate,"apiUrlUpdate"))return;await y.put(t.apiUrlUpdate,r),u.ElMessage.success("更新成功")}t.onAfterSubmit&&t.onAfterSubmit(l.mode,o),s("submit",{mode:l.mode,data:o}),l.visible=!1,w()}catch(o){console.log("Submit error or validation failed:",o)}finally{l.submitting=!1}},F=async o=>{if(C(t.apiUrlDelete,"apiUrlDelete"))try{if(t.onBeforeDelete&&await t.onBeforeDelete(o)===!1)return;const r=o.join(",");await y.delete(t.apiUrlDelete+"/"+r.toString()),u.ElMessage.success("删除成功"),t.onAfterDelete&&t.onAfterDelete(o),s("delete",o),B.value.length===o.length&&c.pageNum>1&&c.pageNum--,w()}catch(r){console.error("Delete failed",r)}},Z=o=>{c.pageSize=o,_()},G=o=>{c.pageNum=o,w()};return e.onMounted(w),f({refresh:w,search:_,handleDelete:F,openDialog:N,submit:U}),(o,r)=>{const a=e.resolveComponent("el-button"),p=e.resolveComponent("el-form-item"),b=e.resolveComponent("el-form"),k=e.resolveComponent("el-table-column"),x=e.resolveComponent("el-popconfirm"),J=e.resolveComponent("el-table"),K=e.resolveComponent("el-pagination"),X=e.resolveComponent("el-dialog"),A=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(S.value)},[e.renderSlot(o.$slots,"header"),t.showSearchSection?(e.openBlock(),e.createElementBlock("div",T,[e.createVNode(b,{model:c,class:"query-form flex flex-nowrap items-center gap-x-4",style:{"overflow-x":"auto","padding-bottom":"8px"}},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"query-conditions",{searchForm:c}),e.createVNode(p,{class:"!mr-0 flex-shrink-0"},{default:e.withCtx(()=>[e.createElementVNode("div",P,[e.renderSlot(o.$slots,"query-left"),t.showSearchActionButtons?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(a,{type:"primary",onClick:_,loading:n.value},{default:e.withCtx(()=>r[6]||(r[6]=[e.createTextVNode("搜索")])),_:1,__:[6]},8,["loading"]),e.createVNode(a,{onClick:I},{default:e.withCtx(()=>r[7]||(r[7]=[e.createTextVNode("清空")])),_:1,__:[7]})],64)):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"query-right")])]),_:3})]),_:3},8,["model"]),e.createElementVNode("div",O,[e.renderSlot(o.$slots,"action-left",{selections:d.value}),e.renderSlot(o.$slots,"add-button-content",{},()=>[t.showNewBtn?(e.openBlock(),e.createBlock(a,{key:0,type:"success",onClick:r[0]||(r[0]=i=>N("add"))},{default:e.withCtx(()=>r[8]||(r[8]=[e.createTextVNode("新增")])),_:1,__:[8]})):e.createCommentVNode("",!0)]),e.renderSlot(o.$slots,"action-right")])])):e.createCommentVNode("",!0),e.withDirectives((e.openBlock(),e.createBlock(J,e.mergeProps({data:B.value,onSelectionChange:W},o.$attrs,{style:{width:"100%","margin-bottom":"1.5rem"}}),{default:e.withCtx(()=>[t.showSelectionColumn?(e.openBlock(),e.createBlock(k,{key:0,type:"selection",width:"55",fixed:""})):e.createCommentVNode("",!0),t.showIndexColumn?(e.openBlock(),e.createBlock(k,{key:1,type:"index",label:"序号",width:"70",fixed:""})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,i=>(e.openBlock(),e.createBlock(k,e.mergeProps({key:i.prop,prop:i.prop,label:i.label,width:i.width,sortable:i.sortable||!1},{ref_for:!0},i.attrs),e.createSlots({_:2},[i.slot?{name:"default",fn:e.withCtx(E=>[e.renderSlot(o.$slots,i.slot,{row:E.row})]),key:"0"}:void 0]),1040,["prop","label","width","sortable"]))),128)),t.showActionsColumn?(e.openBlock(),e.createBlock(k,{key:2,label:"操作",width:m.actionsColumnWidth},{default:e.withCtx(i=>[i.row?(e.openBlock(),e.createElementBlock("div",j,[o.$slots.actions?e.renderSlot(o.$slots,"actions",{key:0,row:i.row}):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(o.$slots,"action-before-edit",{row:i.row}),t.showEditButton?(e.openBlock(),e.createBlock(a,{key:0,size:"small",type:"primary",link:"",onClick:E=>N("edit",i.row)},{default:e.withCtx(()=>r[9]||(r[9]=[e.createTextVNode("编辑 ")])),_:2,__:[9]},1032,["onClick"])):e.createCommentVNode("",!0),t.showDeleteButton?(e.openBlock(),e.createBlock(x,{key:1,title:"确定要删除这条数据吗?",onConfirm:E=>F([i.row.id]),"confirm-button-text":"确定","cancel-button-text":"取消",width:"200"},{reference:e.withCtx(()=>[e.createVNode(a,{size:"small",type:"danger",link:""},{default:e.withCtx(()=>r[10]||(r[10]=[e.createTextVNode("删除")])),_:1,__:[10]})]),_:2},1032,["onConfirm"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"action-after-delete",{row:i.row})],64))])):e.createCommentVNode("",!0)]),_:3},8,["width"])):e.createCommentVNode("",!0)]),_:3},16,["data"])),[[A,n.value]]),t.showPagination&&h.value>0?(e.openBlock(),e.createElementBlock("div",q,[e.createVNode(K,{"current-page":c.pageNum,"onUpdate:currentPage":r[1]||(r[1]=i=>c.pageNum=i),"page-size":c.pageSize,"onUpdate:pageSize":r[2]||(r[2]=i=>c.pageSize=i),"page-sizes":t.pageSizes,layout:t.paginationLayout,total:h.value,background:t.paginationBackground,small:t.paginationSmall,"hide-on-single-page":t.paginationHideOnSinglePage,onSizeChange:Z,onCurrentChange:G},null,8,["current-page","page-size","page-sizes","layout","total","background","small","hide-on-single-page"])])):e.createCommentVNode("",!0),e.createVNode(X,{modelValue:l.visible,"onUpdate:modelValue":r[5]||(r[5]=i=>l.visible=i),title:R.value,width:t.dialogWidth,"destroy-on-close":!0,"custom-class":D.value},{footer:e.withCtx(()=>[e.createElementVNode("div",M,[e.createVNode(a,{onClick:r[4]||(r[4]=i=>l.visible=!1)},{default:e.withCtx(()=>r[11]||(r[11]=[e.createTextVNode("取消")])),_:1,__:[11]}),e.createVNode(a,{type:"primary",onClick:H,loading:l.submitting},{default:e.withCtx(()=>r[12]||(r[12]=[e.createTextVNode("确定")])),_:1,__:[12]},8,["loading"])])]),default:e.withCtx(()=>[e.withDirectives((e.openBlock(),e.createElementBlock("div",null,[e.renderSlot(o.$slots,"dialog-form-content",{formData:l.data,mode:l.mode},()=>[t.dialogFormConfig.length>0?(e.openBlock(),e.createBlock(z,{key:0,"form-config":L.value,modelValue:l.data,"onUpdate:modelValue":r[3]||(r[3]=i=>l.data=i),ref:i=>l.formRef=i,rules:t.dialogFormRules,"label-width":"80px"},null,8,["form-config","modelValue","rules"])):e.createCommentVNode("",!0)])])),[[A,l.loading]])]),_:3},8,["modelValue","title","width","custom-class"])],2)}}});g.CrudTable=Q,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
|