z-crud-table 0.0.49 → 0.0.51
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/components/CrudTable.vue.d.ts +2 -0
- package/dist/z-crud-table.js +199 -185
- package/dist/z-crud-table.umd.cjs +2 -2
- package/package.json +1 -1
|
@@ -226,6 +226,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
|
|
|
226
226
|
submit: (...args: any[]) => void;
|
|
227
227
|
delete: (...args: any[]) => void;
|
|
228
228
|
"open-dialog": (...args: any[]) => void;
|
|
229
|
+
"update:initialSearchForm": (...args: any[]) => void;
|
|
229
230
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
230
231
|
/**
|
|
231
232
|
* @description 组件的主题风格
|
|
@@ -445,6 +446,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<im
|
|
|
445
446
|
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
446
447
|
onDelete?: ((...args: any[]) => any) | undefined;
|
|
447
448
|
"onOpen-dialog"?: ((...args: any[]) => any) | undefined;
|
|
449
|
+
"onUpdate:initialSearchForm"?: ((...args: any[]) => any) | undefined;
|
|
448
450
|
}>, {
|
|
449
451
|
customClass: string;
|
|
450
452
|
theme: "default" | "large-screen";
|
package/dist/z-crud-table.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.header-cell-content[data-v-d23c8660]{display:inline-block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.crud-table-container[data-v-
|
|
2
|
-
import { defineComponent as L, createElementBlock as w, openBlock as r, createElementVNode as
|
|
3
|
-
import { ElMessage as T, ElMessageBox as
|
|
4
|
-
import
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.header-cell-content[data-v-d23c8660]{display:inline-block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.crud-table-container[data-v-96732da5]{display:flex;flex-direction:column;height:100%;width:100%;min-width:0;min-height:0;overflow:hidden}.search-section-wrapper[data-v-96732da5]{flex-shrink:0}.table-content-wrapper[data-v-96732da5]{flex:1;min-height:0;overflow:hidden}.pagination-wrapper[data-v-96732da5]{flex-shrink:0;padding-top:1rem;display:flex;justify-content:flex-end}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.visible{visibility:visible}.relative{position:relative}.\\!mr-0{margin-right:0!important}.mt-2{margin-top:.5rem}.flex{display:flex}.hidden{display:none}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.flex-wrap{flex-wrap:wrap}.flex-nowrap{flex-wrap:nowrap}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-between{justify-content:space-between}.gap-4{gap:1rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.px-8{padding-left:2rem;padding-right:2rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}body{background-color:#f0f2f5;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;margin:0}#app{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#2c3e50}.crud-container{transition:box-shadow .3s ease-in-out}.crud-container:hover{box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.query-form .el-form-item{margin-bottom:0!important}.el-table__expanded-cell{padding:1rem 3.5rem!important;background-color:#f8fafc}.action-buttons>*+*{margin-left:.75rem}.el-dialog__header{border-bottom:none;padding:24px 24px 10px}.el-dialog__title{font-size:1.25rem;font-weight:600}.el-dialog__footer{border-top:none;padding:10px 24px 24px}.el-dialog__body{padding:10px 24px}:root{--large-screen-border-color: rgba(120, 153, 199, 1);--large-screen-text-color: rgba(227, 246, 255, 1);--large-screen-search-bg: rgba(210, 224, 243, .1);--large-screen-button-bg: rgba(38, 120, 255, 1);--large-screen-action-link-color: rgba(39, 233, 255, 1);--large-screen-dialog-bg: #1e293b;--large-screen-hover-bg: rgba(120, 153, 199, .15)}.theme-large-screen{color:var(--large-screen-text-color)}.el-modal-dialog,.el-overlay-dialog{position:absolute!important}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import { defineComponent as L, createElementBlock as w, openBlock as r, createElementVNode as k, ref as x, resolveComponent as y, createBlock as f, mergeProps as $, withCtx as p, Fragment as P, renderList as q, createCommentVNode as g, createTextVNode as B, toDisplayString as N, getCurrentScope as me, onScopeDispose as ge, computed as R, toValue as oe, watch as H, shallowRef as ye, getCurrentInstance as ve, onMounted as G, reactive as Z, toRaw as he, resolveDirective as be, normalizeClass as we, renderSlot as b, createVNode as C, withDirectives as _e, createSlots as Se, unref as ke } from "vue";
|
|
3
|
+
import { ElMessage as T, ElMessageBox as Ce } from "element-plus";
|
|
4
|
+
import De from "axios";
|
|
5
5
|
/*! Element Plus Icons Vue v2.3.2 */
|
|
6
|
-
var
|
|
6
|
+
var Fe = /* @__PURE__ */ L({
|
|
7
7
|
name: "ArrowLeftBold",
|
|
8
8
|
__name: "arrow-left-bold",
|
|
9
|
-
setup(
|
|
9
|
+
setup(d) {
|
|
10
10
|
return (s, v) => (r(), w("svg", {
|
|
11
11
|
xmlns: "http://www.w3.org/2000/svg",
|
|
12
12
|
viewBox: "0 0 1024 1024"
|
|
13
13
|
}, [
|
|
14
|
-
|
|
14
|
+
k("path", {
|
|
15
15
|
fill: "currentColor",
|
|
16
16
|
d: "M685.248 104.704a64 64 0 0 1 0 90.496L368.448 512l316.8 316.8a64 64 0 0 1-90.496 90.496L232.704 557.248a64 64 0 0 1 0-90.496l362.048-362.048a64 64 0 0 1 90.496 0"
|
|
17
17
|
})
|
|
18
18
|
]));
|
|
19
19
|
}
|
|
20
|
-
}),
|
|
21
|
-
const
|
|
20
|
+
}), Be = Fe;
|
|
21
|
+
const ee = /* @__PURE__ */ L({
|
|
22
22
|
__name: "DynamicForm",
|
|
23
23
|
props: {
|
|
24
24
|
modelValue: {},
|
|
25
25
|
formConfig: {},
|
|
26
26
|
rules: {}
|
|
27
27
|
},
|
|
28
|
-
setup(
|
|
28
|
+
setup(d, { expose: s }) {
|
|
29
29
|
const v = x(null);
|
|
30
30
|
return s({
|
|
31
31
|
validate: () => {
|
|
32
|
-
var
|
|
33
|
-
return (
|
|
32
|
+
var u;
|
|
33
|
+
return (u = v.value) == null ? void 0 : u.validate();
|
|
34
34
|
}
|
|
35
|
-
}), (
|
|
36
|
-
const _ = y("el-input"), U = y("el-option"), D = y("el-select"), z = y("el-radio"), c = y("el-radio-group"),
|
|
37
|
-
return r(), f(
|
|
38
|
-
model:
|
|
39
|
-
rules:
|
|
35
|
+
}), (u, e) => {
|
|
36
|
+
const _ = y("el-input"), U = y("el-option"), D = y("el-select"), z = y("el-radio"), c = y("el-radio-group"), F = y("el-form-item"), S = y("el-form");
|
|
37
|
+
return r(), f(S, $({
|
|
38
|
+
model: u.modelValue,
|
|
39
|
+
rules: u.rules,
|
|
40
40
|
ref_key: "formRef",
|
|
41
41
|
ref: v
|
|
42
|
-
},
|
|
42
|
+
}, u.$attrs), {
|
|
43
43
|
default: p(() => [
|
|
44
|
-
(r(!0), w(P, null, q(
|
|
44
|
+
(r(!0), w(P, null, q(u.formConfig, (i) => (r(), f(F, {
|
|
45
45
|
key: i.prop,
|
|
46
46
|
label: i.label,
|
|
47
47
|
prop: i.prop
|
|
@@ -49,19 +49,19 @@ const Z = /* @__PURE__ */ L({
|
|
|
49
49
|
default: p(() => [
|
|
50
50
|
i.type === "input" ? (r(), f(_, $({
|
|
51
51
|
key: 0,
|
|
52
|
-
modelValue:
|
|
53
|
-
"onUpdate:modelValue": (m) =>
|
|
52
|
+
modelValue: u.modelValue[i.prop],
|
|
53
|
+
"onUpdate:modelValue": (m) => u.modelValue[i.prop] = m
|
|
54
54
|
}, { ref_for: !0 }, i.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) : g("", !0),
|
|
55
55
|
i.type === "textarea" ? (r(), f(_, $({
|
|
56
56
|
key: 1,
|
|
57
57
|
type: "textarea",
|
|
58
|
-
modelValue:
|
|
59
|
-
"onUpdate:modelValue": (m) =>
|
|
58
|
+
modelValue: u.modelValue[i.prop],
|
|
59
|
+
"onUpdate:modelValue": (m) => u.modelValue[i.prop] = m
|
|
60
60
|
}, { ref_for: !0 }, i.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) : g("", !0),
|
|
61
61
|
i.type === "select" ? (r(), f(D, $({
|
|
62
62
|
key: 2,
|
|
63
|
-
modelValue:
|
|
64
|
-
"onUpdate:modelValue": (m) =>
|
|
63
|
+
modelValue: u.modelValue[i.prop],
|
|
64
|
+
"onUpdate:modelValue": (m) => u.modelValue[i.prop] = m
|
|
65
65
|
}, { ref_for: !0 }, i.componentProps), {
|
|
66
66
|
default: p(() => [
|
|
67
67
|
(r(!0), w(P, null, q(i.options, (m) => (r(), f(U, {
|
|
@@ -74,8 +74,8 @@ const Z = /* @__PURE__ */ L({
|
|
|
74
74
|
}, 1040, ["modelValue", "onUpdate:modelValue"])) : g("", !0),
|
|
75
75
|
i.type === "radio-group" ? (r(), f(c, $({
|
|
76
76
|
key: 3,
|
|
77
|
-
modelValue:
|
|
78
|
-
"onUpdate:modelValue": (m) =>
|
|
77
|
+
modelValue: u.modelValue[i.prop],
|
|
78
|
+
"onUpdate:modelValue": (m) => u.modelValue[i.prop] = m
|
|
79
79
|
}, { ref_for: !0 }, i.componentProps), {
|
|
80
80
|
default: p(() => [
|
|
81
81
|
(r(!0), w(P, null, q(i.options, (m) => (r(), f(z, {
|
|
@@ -83,7 +83,7 @@ const Z = /* @__PURE__ */ L({
|
|
|
83
83
|
label: m.value
|
|
84
84
|
}, {
|
|
85
85
|
default: p(() => [
|
|
86
|
-
|
|
86
|
+
B(N(m.label), 1)
|
|
87
87
|
]),
|
|
88
88
|
_: 2
|
|
89
89
|
}, 1032, ["label"]))), 128))
|
|
@@ -92,7 +92,7 @@ const Z = /* @__PURE__ */ L({
|
|
|
92
92
|
}, 1040, ["modelValue", "onUpdate:modelValue"])) : g("", !0),
|
|
93
93
|
i.type === "input-disabled" ? (r(), f(_, $({
|
|
94
94
|
key: 4,
|
|
95
|
-
"model-value":
|
|
95
|
+
"model-value": u.modelValue[i.prop],
|
|
96
96
|
disabled: ""
|
|
97
97
|
}, { ref_for: !0 }, i.componentProps), null, 16, ["model-value"])) : g("", !0)
|
|
98
98
|
]),
|
|
@@ -103,32 +103,32 @@ const Z = /* @__PURE__ */ L({
|
|
|
103
103
|
}, 16, ["model", "rules"]);
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
}), A =
|
|
106
|
+
}), A = De.create({
|
|
107
107
|
// VITE_APP_BASE_API 是在 .env 文件中定义的基础 URL
|
|
108
108
|
baseURL: "",
|
|
109
109
|
timeout: 1e4
|
|
110
110
|
// 请求超时时间
|
|
111
111
|
});
|
|
112
112
|
A.interceptors.request.use(
|
|
113
|
-
(
|
|
113
|
+
(d) => {
|
|
114
114
|
const s = localStorage.getItem("token");
|
|
115
|
-
return s && (
|
|
115
|
+
return s && (d.headers.Authorization = "Bearer " + s), d;
|
|
116
116
|
},
|
|
117
|
-
(
|
|
117
|
+
(d) => (console.log(d), Promise.reject(d))
|
|
118
118
|
);
|
|
119
119
|
A.interceptors.response.use(
|
|
120
120
|
/**
|
|
121
121
|
* @description 如果您想直接获取诸如 headers 或 status 之类的信息,
|
|
122
122
|
* 请直接返回 response => response
|
|
123
123
|
*/
|
|
124
|
-
(
|
|
125
|
-
const s =
|
|
124
|
+
(d) => {
|
|
125
|
+
const s = d.data;
|
|
126
126
|
return s.code !== 200 ? (T({
|
|
127
127
|
message: s.msg || "Error",
|
|
128
128
|
// 使用后端返回的 `msg` 作为错误提示
|
|
129
129
|
type: "error",
|
|
130
130
|
duration: 5 * 1e3
|
|
131
|
-
}), (s.code === 401 || s.code === 403) &&
|
|
131
|
+
}), (s.code === 401 || s.code === 403) && Ce.confirm(
|
|
132
132
|
"您的登录状态已失效,请重新登录",
|
|
133
133
|
"确认登出",
|
|
134
134
|
{
|
|
@@ -140,76 +140,76 @@ A.interceptors.response.use(
|
|
|
140
140
|
localStorage.removeItem("token"), location.reload();
|
|
141
141
|
}), Promise.reject(new Error(s.msg || "Error"))) : s;
|
|
142
142
|
},
|
|
143
|
-
(
|
|
143
|
+
(d) => (console.log("HTTP Error: " + d), T({
|
|
144
144
|
message: "网络错误,请检查您的网络连接或联系管理员",
|
|
145
145
|
// 提供更友好的网络错误提示
|
|
146
146
|
type: "error",
|
|
147
147
|
duration: 5 * 1e3
|
|
148
|
-
}), Promise.reject(
|
|
148
|
+
}), Promise.reject(d))
|
|
149
149
|
);
|
|
150
|
-
function
|
|
151
|
-
return
|
|
150
|
+
function Ue(d) {
|
|
151
|
+
return me() ? (ge(d), !0) : !1;
|
|
152
152
|
}
|
|
153
|
-
const
|
|
153
|
+
const Ve = typeof window < "u" && typeof document < "u";
|
|
154
154
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
155
|
-
const
|
|
156
|
-
function
|
|
155
|
+
const $e = Ve ? window : void 0;
|
|
156
|
+
function te(d) {
|
|
157
157
|
var s;
|
|
158
|
-
const v =
|
|
158
|
+
const v = oe(d);
|
|
159
159
|
return (s = v == null ? void 0 : v.$el) != null ? s : v;
|
|
160
160
|
}
|
|
161
161
|
// @__NO_SIDE_EFFECTS__
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
return s &&
|
|
165
|
-
|
|
166
|
-
}, s),
|
|
162
|
+
function Ae() {
|
|
163
|
+
const d = ye(!1), s = ve();
|
|
164
|
+
return s && G(() => {
|
|
165
|
+
d.value = !0;
|
|
166
|
+
}, s), d;
|
|
167
167
|
}
|
|
168
168
|
// @__NO_SIDE_EFFECTS__
|
|
169
|
-
function
|
|
170
|
-
const s = /* @__PURE__ */
|
|
171
|
-
return R(() => (s.value, !!
|
|
169
|
+
function xe(d) {
|
|
170
|
+
const s = /* @__PURE__ */ Ae();
|
|
171
|
+
return R(() => (s.value, !!d()));
|
|
172
172
|
}
|
|
173
|
-
function
|
|
174
|
-
const { window:
|
|
173
|
+
function ze(d, s, v = {}) {
|
|
174
|
+
const { window: u = $e, ...e } = v;
|
|
175
175
|
let _;
|
|
176
|
-
const U = /* @__PURE__ */
|
|
176
|
+
const U = /* @__PURE__ */ xe(() => u && "ResizeObserver" in u), D = () => {
|
|
177
177
|
_ && (_.disconnect(), _ = void 0);
|
|
178
178
|
}, z = R(() => {
|
|
179
|
-
const
|
|
180
|
-
return Array.isArray(
|
|
181
|
-
}), c =
|
|
179
|
+
const S = oe(d);
|
|
180
|
+
return Array.isArray(S) ? S.map((i) => te(i)) : [te(S)];
|
|
181
|
+
}), c = H(
|
|
182
182
|
z,
|
|
183
|
-
(
|
|
184
|
-
if (D(), U.value &&
|
|
183
|
+
(S) => {
|
|
184
|
+
if (D(), U.value && u) {
|
|
185
185
|
_ = new ResizeObserver(s);
|
|
186
|
-
for (const i of
|
|
186
|
+
for (const i of S)
|
|
187
187
|
i && _.observe(i, e);
|
|
188
188
|
}
|
|
189
189
|
},
|
|
190
190
|
{ immediate: !0, flush: "post" }
|
|
191
|
-
),
|
|
191
|
+
), F = () => {
|
|
192
192
|
D(), c();
|
|
193
193
|
};
|
|
194
|
-
return
|
|
194
|
+
return Ue(F), {
|
|
195
195
|
isSupported: U,
|
|
196
|
-
stop:
|
|
196
|
+
stop: F
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
-
const
|
|
199
|
+
const Oe = /* @__PURE__ */ L({
|
|
200
200
|
__name: "TableHeaderWithTooltip",
|
|
201
201
|
props: {
|
|
202
202
|
label: {},
|
|
203
203
|
placement: {}
|
|
204
204
|
},
|
|
205
|
-
setup(
|
|
206
|
-
const s = x(null), v = x(!1),
|
|
205
|
+
setup(d) {
|
|
206
|
+
const s = x(null), v = x(!1), u = () => {
|
|
207
207
|
s.value && (v.value = s.value.scrollWidth > s.value.clientWidth);
|
|
208
208
|
};
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
}),
|
|
212
|
-
|
|
209
|
+
return G(() => {
|
|
210
|
+
u();
|
|
211
|
+
}), ze(s, () => {
|
|
212
|
+
u();
|
|
213
213
|
}), (e, _) => {
|
|
214
214
|
const U = y("el-tooltip");
|
|
215
215
|
return v.value ? (r(), f(U, {
|
|
@@ -218,7 +218,7 @@ const xe = /* @__PURE__ */ L({
|
|
|
218
218
|
placement: e.placement || "top"
|
|
219
219
|
}, {
|
|
220
220
|
default: p(() => [
|
|
221
|
-
|
|
221
|
+
k("span", {
|
|
222
222
|
ref_key: "textRef",
|
|
223
223
|
ref: s,
|
|
224
224
|
class: "header-cell-content"
|
|
@@ -233,21 +233,21 @@ const xe = /* @__PURE__ */ L({
|
|
|
233
233
|
}, N(e.label), 513));
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
-
}),
|
|
237
|
-
const v =
|
|
238
|
-
for (const [
|
|
239
|
-
v[
|
|
236
|
+
}), le = (d, s) => {
|
|
237
|
+
const v = d.__vccOpts || d;
|
|
238
|
+
for (const [u, e] of s)
|
|
239
|
+
v[u] = e;
|
|
240
240
|
return v;
|
|
241
|
-
},
|
|
241
|
+
}, Re = /* @__PURE__ */ le(Oe, [["__scopeId", "data-v-d23c8660"]]), Te = {
|
|
242
242
|
key: 0,
|
|
243
243
|
class: "search-section-wrapper"
|
|
244
|
-
},
|
|
244
|
+
}, Pe = { class: "flex flex-wrap items-center justify-between gap-4" }, Ne = { class: "flex items-center gap-x-2" }, We = { class: "flex items-center gap-x-3 action-buttons flex-shrink-0" }, je = { class: "table-content-wrapper" }, Ee = { key: 1 }, qe = {
|
|
245
245
|
key: 0,
|
|
246
246
|
class: "flex items-center gap-x-2"
|
|
247
|
-
},
|
|
247
|
+
}, Le = {
|
|
248
248
|
key: 1,
|
|
249
249
|
class: "pagination-wrapper flex justify-end mt-2"
|
|
250
|
-
},
|
|
250
|
+
}, Qe = { style: { "overflow-y": "auto", flex: "1" } }, Ie = { class: "dialog-footer" }, Me = { class: "flex items-center" }, He = { class: "el-dialog__title" }, Ge = { style: { "overflow-y": "auto", flex: "1" } }, Je = { class: "dialog-footer" }, Ke = /* @__PURE__ */ L({
|
|
251
251
|
__name: "CrudTable",
|
|
252
252
|
props: {
|
|
253
253
|
/**
|
|
@@ -367,36 +367,36 @@ const xe = /* @__PURE__ */ L({
|
|
|
367
367
|
*/
|
|
368
368
|
editDialogTitle: { type: String, default: "编辑" }
|
|
369
369
|
},
|
|
370
|
-
emits: ["open-dialog", "submit", "delete"],
|
|
371
|
-
setup(
|
|
372
|
-
const
|
|
370
|
+
emits: ["open-dialog", "submit", "delete", "update:initialSearchForm"],
|
|
371
|
+
setup(d, { expose: s, emit: v }) {
|
|
372
|
+
const u = v, e = d, _ = R(() => ["crud-table-wrapper", `theme-${e.theme}`, e.customClass]), U = R(() => e.theme === "large-screen" ? "large-screen-dialog" : ""), D = (t, o) => t ? !0 : (T.error(`${o} prop is required.`), !1), z = async (t, o) => {
|
|
373
373
|
try {
|
|
374
374
|
let n = { ...o };
|
|
375
375
|
e.onBeforeSubmit && (n = await e.onBeforeSubmit(n, t));
|
|
376
|
-
let
|
|
376
|
+
let h = n;
|
|
377
377
|
if (e.submitAsFormData) {
|
|
378
|
-
const
|
|
378
|
+
const E = new FormData();
|
|
379
379
|
for (const V in n)
|
|
380
380
|
if (Object.prototype.hasOwnProperty.call(n, V)) {
|
|
381
381
|
const I = n[V];
|
|
382
|
-
|
|
382
|
+
E.append(V, I ?? "");
|
|
383
383
|
}
|
|
384
|
-
|
|
384
|
+
h = E;
|
|
385
385
|
}
|
|
386
386
|
if (l.submitting = !0, t === "add") {
|
|
387
387
|
if (!D(e.apiUrlCreate, "apiUrlCreate")) throw new Error("apiUrlCreate is not configured.");
|
|
388
|
-
await A.post(e.apiUrlCreate,
|
|
388
|
+
await A.post(e.apiUrlCreate, h), T.success("新增成功");
|
|
389
389
|
} else {
|
|
390
390
|
if (!D(e.apiUrlUpdate, "apiUrlUpdate")) throw new Error("apiUrlUpdate is not configured.");
|
|
391
|
-
await A.put(e.apiUrlUpdate,
|
|
391
|
+
await A.put(e.apiUrlUpdate, h), T.success("更新成功");
|
|
392
392
|
}
|
|
393
|
-
return e.onAfterSubmit && e.onAfterSubmit(t, n),
|
|
393
|
+
return e.onAfterSubmit && e.onAfterSubmit(t, n), u("submit", { mode: t, data: n }), l.visible && (l.visible = !1), O(), Promise.resolve();
|
|
394
394
|
} catch (n) {
|
|
395
395
|
return console.error("Submit failed:", n), Promise.reject(n);
|
|
396
396
|
} finally {
|
|
397
397
|
l.submitting = !1;
|
|
398
398
|
}
|
|
399
|
-
}, c =
|
|
399
|
+
}, c = Z({ pageNum: 1, pageSize: 10, ...e.initialSearchForm }), F = x([]), S = x(0), i = x(!1), m = x([]), l = Z({ visible: !1, loading: !1, submitting: !1, mode: "add", data: {}, formRef: null }), J = R(() => l.mode === "add" ? e.addDialogTitle : e.editDialogTitle), K = R(() => {
|
|
400
400
|
if (l.mode === "add") return e.dialogFormConfig.filter((o) => o.prop !== "id");
|
|
401
401
|
const t = [...e.dialogFormConfig.filter((o) => o.prop !== "id")];
|
|
402
402
|
return t.some((o) => o.prop === "id") || t.unshift({ type: "input-disabled", prop: "id", label: "用户ID" }), t;
|
|
@@ -409,9 +409,9 @@ const xe = /* @__PURE__ */ L({
|
|
|
409
409
|
const o = await A.get(e.apiUrlQuery, { params: t });
|
|
410
410
|
if (o && o.data && Array.isArray(o.data.rows) && typeof o.data.total == "number") {
|
|
411
411
|
let n = o.data.rows;
|
|
412
|
-
e.onAfterQuery && (n = await e.onAfterQuery(n, t)),
|
|
412
|
+
e.onAfterQuery && (n = await e.onAfterQuery(n, t)), F.value = n, S.value = o.data.total;
|
|
413
413
|
} else
|
|
414
|
-
console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),
|
|
414
|
+
console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."), F.value = [], S.value = 0;
|
|
415
415
|
} catch (t) {
|
|
416
416
|
console.error("Fetch data failed:", t);
|
|
417
417
|
} finally {
|
|
@@ -420,86 +420,100 @@ const xe = /* @__PURE__ */ L({
|
|
|
420
420
|
}
|
|
421
421
|
}, W = () => {
|
|
422
422
|
c.pageNum = 1, O();
|
|
423
|
-
},
|
|
423
|
+
}, ae = () => {
|
|
424
424
|
const { pageNum: t, pageSize: o, ...n } = e.initialSearchForm;
|
|
425
|
-
Object.keys(c).forEach((
|
|
426
|
-
|
|
425
|
+
Object.keys(c).forEach((h) => {
|
|
426
|
+
h !== "pageNum" && h !== "pageSize" && delete c[h];
|
|
427
427
|
}), Object.assign(c, n), W();
|
|
428
|
-
},
|
|
428
|
+
}, re = (t) => {
|
|
429
429
|
m.value = t;
|
|
430
430
|
}, Q = async (t, o) => {
|
|
431
431
|
let n;
|
|
432
432
|
if (t === "add" ? n = o ? { ...o } : { role: "user" } : n = { ...o }, e.onBeforeOpenDialog) {
|
|
433
|
-
const
|
|
434
|
-
|
|
433
|
+
const h = await e.onBeforeOpenDialog(t, n);
|
|
434
|
+
h && (n = h);
|
|
435
435
|
}
|
|
436
436
|
if (l.mode = t, l.visible = !0, t === "edit") {
|
|
437
437
|
if (!D(e.apiUrlDetail, "apiUrlDetail")) return;
|
|
438
438
|
l.loading = !0;
|
|
439
439
|
try {
|
|
440
|
-
const
|
|
441
|
-
l.data =
|
|
440
|
+
const h = await A.get(e.apiUrlDetail + "/" + n.id.toString());
|
|
441
|
+
l.data = h.data.data;
|
|
442
442
|
} finally {
|
|
443
|
-
l.loading = !1, e.onAfterOpenDialog && e.onAfterOpenDialog(t, l.data),
|
|
443
|
+
l.loading = !1, e.onAfterOpenDialog && e.onAfterOpenDialog(t, l.data), u("open-dialog", { mode: t, data: l.data });
|
|
444
444
|
}
|
|
445
445
|
} else
|
|
446
|
-
l.data = n, e.onAfterOpenDialog && e.onAfterOpenDialog(t, l.data),
|
|
447
|
-
},
|
|
446
|
+
l.data = n, e.onAfterOpenDialog && e.onAfterOpenDialog(t, l.data), u("open-dialog", { mode: t, data: l.data });
|
|
447
|
+
}, j = async () => {
|
|
448
448
|
try {
|
|
449
449
|
l.formRef ? await l.formRef.validate() : console.warn("Dialog form ref is not available for validation."), await z(l.mode, l.data);
|
|
450
450
|
} catch (t) {
|
|
451
451
|
console.log("Validation or submit error:", t);
|
|
452
452
|
}
|
|
453
|
-
},
|
|
453
|
+
}, X = async (t) => {
|
|
454
454
|
if (D(e.apiUrlDelete, "apiUrlDelete"))
|
|
455
455
|
try {
|
|
456
|
-
const o =
|
|
456
|
+
const o = F.value.filter((h) => t.includes(h.id));
|
|
457
457
|
if (e.onBeforeDelete && await e.onBeforeDelete(t, o) === !1)
|
|
458
458
|
return;
|
|
459
459
|
const n = t.join(",");
|
|
460
|
-
await A.delete(e.apiUrlDelete + "/" + n.toString()), T.success("删除成功"), e.onAfterDelete && e.onAfterDelete(t, o),
|
|
460
|
+
await A.delete(e.apiUrlDelete + "/" + n.toString()), T.success("删除成功"), e.onAfterDelete && e.onAfterDelete(t, o), u("delete", t), F.value.length === t.length && c.pageNum > 1 && c.pageNum--, O();
|
|
461
461
|
} catch (o) {
|
|
462
462
|
console.error("Delete failed", o);
|
|
463
463
|
}
|
|
464
|
-
}, re = (t) => {
|
|
465
|
-
c.pageSize = t, W();
|
|
466
464
|
}, ne = (t) => {
|
|
465
|
+
c.pageSize = t, W();
|
|
466
|
+
}, ie = (t) => {
|
|
467
467
|
c.pageNum = t, O();
|
|
468
468
|
};
|
|
469
|
-
|
|
469
|
+
G(O);
|
|
470
|
+
const se = () => {
|
|
471
|
+
l.visible = !1;
|
|
472
|
+
};
|
|
473
|
+
return H(
|
|
474
|
+
c,
|
|
475
|
+
(t) => {
|
|
476
|
+
u("update:initialSearchForm", { ...he(t) });
|
|
477
|
+
},
|
|
478
|
+
{ deep: !0 }
|
|
479
|
+
), H(
|
|
480
|
+
() => e.initialSearchForm,
|
|
481
|
+
(t) => {
|
|
482
|
+
Object.assign(c, t);
|
|
483
|
+
},
|
|
484
|
+
{ deep: !0 }
|
|
485
|
+
), s({
|
|
470
486
|
refresh: O,
|
|
471
487
|
// 刷新表格
|
|
472
488
|
search: W,
|
|
473
489
|
// 按当前条件搜索
|
|
474
|
-
handleDelete:
|
|
490
|
+
handleDelete: X,
|
|
475
491
|
// 手动触发删除
|
|
476
492
|
openDialog: Q,
|
|
477
493
|
// 手动打开弹窗
|
|
478
494
|
submit: z,
|
|
479
495
|
// 手动提交
|
|
480
|
-
closeDialog:
|
|
481
|
-
l.visible = !1;
|
|
482
|
-
}
|
|
496
|
+
closeDialog: se
|
|
483
497
|
//关闭弹窗
|
|
484
498
|
}), (t, o) => {
|
|
485
|
-
const n = y("el-button"),
|
|
499
|
+
const n = y("el-button"), h = y("el-form-item"), E = y("el-form"), V = y("el-table-column"), I = y("el-popconfirm"), ue = y("el-table"), de = y("el-pagination"), pe = y("el-skeleton"), Y = y("el-dialog"), fe = y("el-icon"), ce = be("loading");
|
|
486
500
|
return r(), w("div", {
|
|
487
|
-
class:
|
|
501
|
+
class: we([_.value, "crud-table-container"])
|
|
488
502
|
}, [
|
|
489
|
-
e.showSearchSection ? (r(), w("div",
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
C(
|
|
503
|
+
e.showSearchSection ? (r(), w("div", Te, [
|
|
504
|
+
b(t.$slots, "header", {}, void 0, !0),
|
|
505
|
+
k("div", Pe, [
|
|
506
|
+
C(E, {
|
|
493
507
|
model: c,
|
|
494
508
|
class: "query-form flex flex-nowrap items-center gap-x-4",
|
|
495
509
|
style: { "overflow-x": "auto", "padding-bottom": "8px" }
|
|
496
510
|
}, {
|
|
497
511
|
default: p(() => [
|
|
498
|
-
|
|
499
|
-
C(
|
|
512
|
+
b(t.$slots, "query-conditions", { searchForm: c }, void 0, !0),
|
|
513
|
+
C(h, { class: "!mr-0 flex-shrink-0" }, {
|
|
500
514
|
default: p(() => [
|
|
501
|
-
|
|
502
|
-
|
|
515
|
+
k("div", Ne, [
|
|
516
|
+
b(t.$slots, "query-left", { searchForm: c }, void 0, !0),
|
|
503
517
|
e.showSearchActionButtons ? (r(), w(P, { key: 0 }, [
|
|
504
518
|
e.showSearchButton ? (r(), f(n, {
|
|
505
519
|
key: 0,
|
|
@@ -508,7 +522,7 @@ const xe = /* @__PURE__ */ L({
|
|
|
508
522
|
loading: i.value
|
|
509
523
|
}, {
|
|
510
524
|
default: p(() => [...o[8] || (o[8] = [
|
|
511
|
-
|
|
525
|
+
B("搜索", -1)
|
|
512
526
|
])]),
|
|
513
527
|
_: 1
|
|
514
528
|
}, 8, ["loading"])) : g("", !0),
|
|
@@ -516,15 +530,15 @@ const xe = /* @__PURE__ */ L({
|
|
|
516
530
|
key: 1,
|
|
517
531
|
color: "#336FFF",
|
|
518
532
|
plain: "",
|
|
519
|
-
onClick:
|
|
533
|
+
onClick: ae
|
|
520
534
|
}, {
|
|
521
535
|
default: p(() => [...o[9] || (o[9] = [
|
|
522
|
-
|
|
536
|
+
B("清空", -1)
|
|
523
537
|
])]),
|
|
524
538
|
_: 1
|
|
525
539
|
})) : g("", !0)
|
|
526
540
|
], 64)) : g("", !0),
|
|
527
|
-
|
|
541
|
+
b(t.$slots, "query-right", { searchForm: c }, void 0, !0)
|
|
528
542
|
])
|
|
529
543
|
]),
|
|
530
544
|
_: 3
|
|
@@ -532,30 +546,30 @@ const xe = /* @__PURE__ */ L({
|
|
|
532
546
|
]),
|
|
533
547
|
_: 3
|
|
534
548
|
}, 8, ["model"]),
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
549
|
+
k("div", We, [
|
|
550
|
+
b(t.$slots, "action-left", { selections: m.value }, void 0, !0),
|
|
551
|
+
b(t.$slots, "add-button-content", { selections: m.value }, () => [
|
|
538
552
|
e.showNewBtn ? (r(), f(n, {
|
|
539
553
|
key: 0,
|
|
540
554
|
color: "#336FFF",
|
|
541
555
|
onClick: o[0] || (o[0] = (a) => Q("add"))
|
|
542
556
|
}, {
|
|
543
557
|
default: p(() => [...o[10] || (o[10] = [
|
|
544
|
-
|
|
558
|
+
B("新增", -1)
|
|
545
559
|
])]),
|
|
546
560
|
_: 1
|
|
547
561
|
})) : g("", !0)
|
|
548
562
|
], !0),
|
|
549
|
-
|
|
563
|
+
b(t.$slots, "action-right", { selections: m.value }, void 0, !0)
|
|
550
564
|
])
|
|
551
565
|
])
|
|
552
566
|
])) : g("", !0),
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
data:
|
|
567
|
+
k("div", je, [
|
|
568
|
+
_e((r(), f(ue, $({
|
|
569
|
+
data: F.value,
|
|
556
570
|
"element-loading-text": e.loadingText,
|
|
557
571
|
"element-loading-background": e.loadingBackground,
|
|
558
|
-
onSelectionChange:
|
|
572
|
+
onSelectionChange: re
|
|
559
573
|
}, t.$attrs, {
|
|
560
574
|
height: "100%",
|
|
561
575
|
style: { width: "100%" }
|
|
@@ -580,20 +594,20 @@ const xe = /* @__PURE__ */ L({
|
|
|
580
594
|
label: a.label,
|
|
581
595
|
width: a.width,
|
|
582
596
|
sortable: a.sortable || !1
|
|
583
|
-
}, { ref_for: !0 }, a.attrs),
|
|
597
|
+
}, { ref_for: !0 }, a.attrs), Se({
|
|
584
598
|
header: p(() => [
|
|
585
|
-
a.headerTooltip ? (r(), f(
|
|
599
|
+
a.headerTooltip ? (r(), f(Re, {
|
|
586
600
|
key: 0,
|
|
587
601
|
label: a.label,
|
|
588
602
|
placement: a.placement
|
|
589
|
-
}, null, 8, ["label", "placement"])) : (r(), w("span",
|
|
603
|
+
}, null, 8, ["label", "placement"])) : (r(), w("span", Ee, N(a.label), 1))
|
|
590
604
|
]),
|
|
591
605
|
_: 2
|
|
592
606
|
}, [
|
|
593
607
|
a.slot ? {
|
|
594
608
|
name: "default",
|
|
595
609
|
fn: p((M) => [
|
|
596
|
-
|
|
610
|
+
b(t.$slots, a.slot, {
|
|
597
611
|
row: M.row
|
|
598
612
|
}, void 0, !0)
|
|
599
613
|
]),
|
|
@@ -603,15 +617,15 @@ const xe = /* @__PURE__ */ L({
|
|
|
603
617
|
e.showActionsColumn ? (r(), f(V, {
|
|
604
618
|
key: 2,
|
|
605
619
|
label: "操作",
|
|
606
|
-
width:
|
|
620
|
+
width: d.actionsColumnWidth
|
|
607
621
|
}, {
|
|
608
622
|
default: p((a) => [
|
|
609
|
-
a.row ? (r(), w("div",
|
|
610
|
-
t.$slots.actions ?
|
|
623
|
+
a.row ? (r(), w("div", qe, [
|
|
624
|
+
t.$slots.actions ? b(t.$slots, "actions", {
|
|
611
625
|
key: 0,
|
|
612
626
|
row: a.row
|
|
613
627
|
}, void 0, !0) : (r(), w(P, { key: 1 }, [
|
|
614
|
-
|
|
628
|
+
b(t.$slots, "action-before-edit", {
|
|
615
629
|
row: a.row
|
|
616
630
|
}, void 0, !0),
|
|
617
631
|
e.showEditButton ? (r(), f(n, {
|
|
@@ -622,14 +636,14 @@ const xe = /* @__PURE__ */ L({
|
|
|
622
636
|
onClick: (M) => Q("edit", a.row)
|
|
623
637
|
}, {
|
|
624
638
|
default: p(() => [...o[11] || (o[11] = [
|
|
625
|
-
|
|
639
|
+
B("编辑 ", -1)
|
|
626
640
|
])]),
|
|
627
641
|
_: 1
|
|
628
642
|
}, 8, ["onClick"])) : g("", !0),
|
|
629
643
|
e.showDeleteButton ? (r(), f(I, {
|
|
630
644
|
key: 1,
|
|
631
645
|
title: "确定要删除这条数据吗?",
|
|
632
|
-
onConfirm: (M) =>
|
|
646
|
+
onConfirm: (M) => X([a.row.id]),
|
|
633
647
|
"confirm-button-text": "确定",
|
|
634
648
|
"cancel-button-text": "取消",
|
|
635
649
|
width: "200"
|
|
@@ -641,14 +655,14 @@ const xe = /* @__PURE__ */ L({
|
|
|
641
655
|
link: ""
|
|
642
656
|
}, {
|
|
643
657
|
default: p(() => [...o[12] || (o[12] = [
|
|
644
|
-
|
|
658
|
+
B("删除", -1)
|
|
645
659
|
])]),
|
|
646
660
|
_: 1
|
|
647
661
|
})
|
|
648
662
|
]),
|
|
649
663
|
_: 1
|
|
650
664
|
}, 8, ["onConfirm"])) : g("", !0),
|
|
651
|
-
|
|
665
|
+
b(t.$slots, "action-after-delete", {
|
|
652
666
|
row: a.row
|
|
653
667
|
}, void 0, !0)
|
|
654
668
|
], 64))
|
|
@@ -659,26 +673,26 @@ const xe = /* @__PURE__ */ L({
|
|
|
659
673
|
]),
|
|
660
674
|
_: 3
|
|
661
675
|
}, 16, ["data", "element-loading-text", "element-loading-background"])), [
|
|
662
|
-
[
|
|
676
|
+
[ce, i.value]
|
|
663
677
|
])
|
|
664
678
|
]),
|
|
665
|
-
e.showPagination &&
|
|
666
|
-
C(
|
|
679
|
+
e.showPagination && S.value > 0 ? (r(), w("div", Le, [
|
|
680
|
+
C(de, {
|
|
667
681
|
"current-page": c.pageNum,
|
|
668
682
|
"onUpdate:currentPage": o[1] || (o[1] = (a) => c.pageNum = a),
|
|
669
683
|
"page-size": c.pageSize,
|
|
670
684
|
"onUpdate:pageSize": o[2] || (o[2] = (a) => c.pageSize = a),
|
|
671
685
|
"page-sizes": e.pageSizes,
|
|
672
686
|
layout: e.paginationLayout,
|
|
673
|
-
total:
|
|
687
|
+
total: S.value,
|
|
674
688
|
background: e.paginationBackground,
|
|
675
689
|
small: e.paginationSmall,
|
|
676
690
|
"hide-on-single-page": e.paginationHideOnSinglePage,
|
|
677
|
-
onSizeChange:
|
|
678
|
-
onCurrentChange:
|
|
691
|
+
onSizeChange: ne,
|
|
692
|
+
onCurrentChange: ie
|
|
679
693
|
}, null, 8, ["current-page", "page-size", "page-sizes", "layout", "total", "background", "small", "hide-on-single-page"])
|
|
680
694
|
])) : g("", !0),
|
|
681
|
-
e.dialogFullscreen ? (r(), f(
|
|
695
|
+
e.dialogFullscreen ? (r(), f(Y, {
|
|
682
696
|
key: 3,
|
|
683
697
|
modelValue: l.visible,
|
|
684
698
|
"onUpdate:modelValue": o[7] || (o[7] = (a) => l.visible = a),
|
|
@@ -691,7 +705,7 @@ const xe = /* @__PURE__ */ L({
|
|
|
691
705
|
style: { display: "flex", "flex-direction": "column", "max-height": "100vh" }
|
|
692
706
|
}, {
|
|
693
707
|
header: p(() => [
|
|
694
|
-
|
|
708
|
+
k("div", Me, [
|
|
695
709
|
C(n, {
|
|
696
710
|
type: "info",
|
|
697
711
|
text: "",
|
|
@@ -699,42 +713,42 @@ const xe = /* @__PURE__ */ L({
|
|
|
699
713
|
style: { "margin-right": "12px" }
|
|
700
714
|
}, {
|
|
701
715
|
default: p(() => [
|
|
702
|
-
C(
|
|
716
|
+
C(fe, { size: "20" }, {
|
|
703
717
|
default: p(() => [
|
|
704
|
-
C(
|
|
718
|
+
C(ke(Be))
|
|
705
719
|
]),
|
|
706
720
|
_: 1
|
|
707
721
|
})
|
|
708
722
|
]),
|
|
709
723
|
_: 1
|
|
710
724
|
}),
|
|
711
|
-
|
|
725
|
+
k("span", He, N(J.value), 1)
|
|
712
726
|
])
|
|
713
727
|
]),
|
|
714
728
|
footer: p(() => [
|
|
715
|
-
|
|
729
|
+
b(t.$slots, "dialog-footer", {
|
|
716
730
|
dialog: l,
|
|
717
|
-
submit:
|
|
731
|
+
submit: j,
|
|
718
732
|
cancel: () => l.visible = !1
|
|
719
733
|
}, () => [
|
|
720
|
-
|
|
734
|
+
k("span", Je, [
|
|
721
735
|
C(n, {
|
|
722
736
|
color: "#336FFF",
|
|
723
737
|
plain: "",
|
|
724
738
|
onClick: o[6] || (o[6] = (a) => l.visible = !1)
|
|
725
739
|
}, {
|
|
726
740
|
default: p(() => [...o[15] || (o[15] = [
|
|
727
|
-
|
|
741
|
+
B("取消", -1)
|
|
728
742
|
])]),
|
|
729
743
|
_: 1
|
|
730
744
|
}),
|
|
731
745
|
C(n, {
|
|
732
746
|
color: "#336FFF",
|
|
733
|
-
onClick:
|
|
747
|
+
onClick: j,
|
|
734
748
|
loading: l.submitting
|
|
735
749
|
}, {
|
|
736
750
|
default: p(() => [...o[16] || (o[16] = [
|
|
737
|
-
|
|
751
|
+
B(" 确定 ", -1)
|
|
738
752
|
])]),
|
|
739
753
|
_: 1
|
|
740
754
|
}, 8, ["loading"])
|
|
@@ -742,60 +756,60 @@ const xe = /* @__PURE__ */ L({
|
|
|
742
756
|
], !0)
|
|
743
757
|
]),
|
|
744
758
|
default: p(() => [
|
|
745
|
-
|
|
746
|
-
t.$slots["dialog-form"] ?
|
|
759
|
+
k("div", Ge, [
|
|
760
|
+
t.$slots["dialog-form"] ? b(t.$slots, "dialog-form", {
|
|
747
761
|
key: 0,
|
|
748
762
|
formData: l.data,
|
|
749
763
|
mode: l.mode,
|
|
750
764
|
formRef: (a) => {
|
|
751
765
|
l.formRef = a;
|
|
752
766
|
}
|
|
753
|
-
}, void 0, !0) : l.loading ? g("", !0) : (r(), f(
|
|
767
|
+
}, void 0, !0) : l.loading ? g("", !0) : (r(), f(ee, {
|
|
754
768
|
key: 1,
|
|
755
769
|
ref: (a) => {
|
|
756
770
|
l.formRef = a;
|
|
757
771
|
},
|
|
758
772
|
"model-value": l.data,
|
|
759
|
-
"form-config":
|
|
773
|
+
"form-config": K.value,
|
|
760
774
|
rules: e.dialogFormRules,
|
|
761
775
|
"label-width": e.dialogFormLabelWidth
|
|
762
776
|
}, null, 8, ["model-value", "form-config", "rules", "label-width"]))
|
|
763
777
|
])
|
|
764
778
|
]),
|
|
765
779
|
_: 3
|
|
766
|
-
}, 8, ["modelValue", "width", "modal", "custom-class"])) : (r(), f(
|
|
780
|
+
}, 8, ["modelValue", "width", "modal", "custom-class"])) : (r(), f(Y, {
|
|
767
781
|
key: 2,
|
|
768
782
|
modelValue: l.visible,
|
|
769
783
|
"onUpdate:modelValue": o[4] || (o[4] = (a) => l.visible = a),
|
|
770
|
-
title:
|
|
784
|
+
title: J.value,
|
|
771
785
|
width: e.dialogWidth,
|
|
772
786
|
"destroy-on-close": !0,
|
|
773
787
|
"custom-class": U.value,
|
|
774
788
|
style: { display: "flex", "flex-direction": "column", "max-height": "80vh" }
|
|
775
789
|
}, {
|
|
776
790
|
footer: p(() => [
|
|
777
|
-
|
|
791
|
+
b(t.$slots, "dialog-footer", {
|
|
778
792
|
dialog: l,
|
|
779
|
-
submit:
|
|
793
|
+
submit: j,
|
|
780
794
|
cancel: () => l.visible = !1
|
|
781
795
|
}, () => [
|
|
782
|
-
|
|
796
|
+
k("span", Ie, [
|
|
783
797
|
C(n, {
|
|
784
798
|
color: "#336FFF",
|
|
785
799
|
onClick: o[3] || (o[3] = (a) => l.visible = !1)
|
|
786
800
|
}, {
|
|
787
801
|
default: p(() => [...o[13] || (o[13] = [
|
|
788
|
-
|
|
802
|
+
B("取消", -1)
|
|
789
803
|
])]),
|
|
790
804
|
_: 1
|
|
791
805
|
}),
|
|
792
806
|
C(n, {
|
|
793
807
|
color: "#336FFF",
|
|
794
|
-
onClick:
|
|
808
|
+
onClick: j,
|
|
795
809
|
loading: l.submitting
|
|
796
810
|
}, {
|
|
797
811
|
default: p(() => [...o[14] || (o[14] = [
|
|
798
|
-
|
|
812
|
+
B(" 确定 ", -1)
|
|
799
813
|
])]),
|
|
800
814
|
_: 1
|
|
801
815
|
}, 8, ["loading"])
|
|
@@ -803,25 +817,25 @@ const xe = /* @__PURE__ */ L({
|
|
|
803
817
|
], !0)
|
|
804
818
|
]),
|
|
805
819
|
default: p(() => [
|
|
806
|
-
|
|
807
|
-
t.$slots["dialog-form"] ?
|
|
820
|
+
k("div", Qe, [
|
|
821
|
+
t.$slots["dialog-form"] ? b(t.$slots, "dialog-form", {
|
|
808
822
|
key: 0,
|
|
809
823
|
formData: l.data,
|
|
810
824
|
mode: l.mode,
|
|
811
825
|
formRef: (a) => {
|
|
812
826
|
l.formRef = a;
|
|
813
827
|
}
|
|
814
|
-
}, void 0, !0) : l.loading ? (r(), f(
|
|
828
|
+
}, void 0, !0) : l.loading ? (r(), f(pe, {
|
|
815
829
|
key: 1,
|
|
816
830
|
rows: 5,
|
|
817
831
|
animated: ""
|
|
818
|
-
})) : l.loading ? g("", !0) : (r(), f(
|
|
832
|
+
})) : l.loading ? g("", !0) : (r(), f(ee, {
|
|
819
833
|
key: 2,
|
|
820
834
|
ref: (a) => {
|
|
821
835
|
l.formRef = a;
|
|
822
836
|
},
|
|
823
837
|
"model-value": l.data,
|
|
824
|
-
"form-config":
|
|
838
|
+
"form-config": K.value,
|
|
825
839
|
rules: e.dialogFormRules,
|
|
826
840
|
"label-width": e.dialogFormLabelWidth
|
|
827
841
|
}, null, 8, ["model-value", "form-config", "rules", "label-width"]))
|
|
@@ -832,7 +846,7 @@ const xe = /* @__PURE__ */ L({
|
|
|
832
846
|
], 2);
|
|
833
847
|
};
|
|
834
848
|
}
|
|
835
|
-
}),
|
|
849
|
+
}), et = /* @__PURE__ */ le(Ke, [["__scopeId", "data-v-96732da5"]]);
|
|
836
850
|
export {
|
|
837
|
-
|
|
851
|
+
et as CrudTable
|
|
838
852
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.header-cell-content[data-v-d23c8660]{display:inline-block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.crud-table-container[data-v-
|
|
2
|
-
(function(w,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):(w=typeof globalThis<"u"?globalThis:w||self,e(w.ZCrudTable={},w.Vue,w.ElementPlus,w.axios))})(this,(function(w,e,b,W){"use strict";/*! Element Plus Icons Vue v2.3.2 */var j=e.defineComponent({name:"ArrowLeftBold",__name:"arrow-left-bold",setup(d){return(s,m)=>(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[e.createElementVNode("path",{fill:"currentColor",d:"M685.248 104.704a64 64 0 0 1 0 90.496L368.448 512l316.8 316.8a64 64 0 0 1-90.496 90.496L232.704 557.248a64 64 0 0 1 0-90.496l362.048-362.048a64 64 0 0 1 90.496 0"})]))}}),M=j;const T=e.defineComponent({__name:"DynamicForm",props:{modelValue:{},formConfig:{},rules:{}},setup(d,{expose:s}){const m=e.ref(null);return s({validate:()=>{var c;return(c=m.value)==null?void 0:c.validate()}}),(c,t)=>{const u=e.resolveComponent("el-input"),B=e.resolveComponent("el-option"),h=e.resolveComponent("el-select"),S=e.resolveComponent("el-radio"),p=e.resolveComponent("el-radio-group"),k=e.resolveComponent("el-form-item"),y=e.resolveComponent("el-form");return e.openBlock(),e.createBlock(y,e.mergeProps({model:c.modelValue,rules:c.rules,ref_key:"formRef",ref:m},c.$attrs),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.formConfig,i=>(e.openBlock(),e.createBlock(k,{key:i.prop,label:i.label,prop:i.prop},{default:e.withCtx(()=>[i.type==="input"?(e.openBlock(),e.createBlock(u,e.mergeProps({key:0,modelValue:c.modelValue[i.prop],"onUpdate:modelValue":f=>c.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="textarea"?(e.openBlock(),e.createBlock(u,e.mergeProps({key:1,type:"textarea",modelValue:c.modelValue[i.prop],"onUpdate:modelValue":f=>c.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="select"?(e.openBlock(),e.createBlock(h,e.mergeProps({key:2,modelValue:c.modelValue[i.prop],"onUpdate:modelValue":f=>c.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.options,f=>(e.openBlock(),e.createBlock(B,{key:f.value,label:f.label,value:f.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="radio-group"?(e.openBlock(),e.createBlock(p,e.mergeProps({key:3,modelValue:c.modelValue[i.prop],"onUpdate:modelValue":f=>c.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.options,f=>(e.openBlock(),e.createBlock(S,{key:f.value,label:f.value},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(f.label),1)]),_:2},1032,["label"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="input-disabled"?(e.openBlock(),e.createBlock(u,e.mergeProps({key:4,"model-value":c.modelValue[i.prop],disabled:""},{ref_for:!0},i.componentProps),null,16,["model-value"])):e.createCommentVNode("",!0)]),_:2},1032,["label","prop"]))),128))]),_:1},16,["model","rules"])}}}),_=W.create({baseURL:"",timeout:1e4});_.interceptors.request.use(d=>{const s=localStorage.getItem("token");return s&&(d.headers.Authorization="Bearer "+s),d},d=>(console.log(d),Promise.reject(d))),_.interceptors.response.use(d=>{const s=d.data;return s.code!==200?(b.ElMessage({message:s.msg||"Error",type:"error",duration:5*1e3}),(s.code===401||s.code===403)&&b.ElMessageBox.confirm("您的登录状态已失效,请重新登录","确认登出",{confirmButtonText:"重新登录",cancelButtonText:"取消",type:"warning"}).then(()=>{localStorage.removeItem("token"),location.reload()}),Promise.reject(new Error(s.msg||"Error"))):s},d=>(console.log("HTTP Error: "+d),b.ElMessage({message:"网络错误,请检查您的网络连接或联系管理员",type:"error",duration:5*1e3}),Promise.reject(d)));function q(d){return e.getCurrentScope()?(e.onScopeDispose(d),!0):!1}const L=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Q=L?window:void 0;function $(d){var s;const m=e.toValue(d);return(s=m==null?void 0:m.$el)!=null?s:m}function I(){const d=e.shallowRef(!1),s=e.getCurrentInstance();return s&&e.onMounted(()=>{d.value=!0},s),d}function H(d){const s=I();return e.computed(()=>(s.value,!!d()))}function G(d,s,m={}){const{window:c=Q,...t}=m;let u;const B=H(()=>c&&"ResizeObserver"in c),h=()=>{u&&(u.disconnect(),u=void 0)},S=e.computed(()=>{const y=e.toValue(d);return Array.isArray(y)?y.map(i=>$(i)):[$(y)]}),p=e.watch(S,y=>{if(h(),B.value&&c){u=new ResizeObserver(s);for(const i of y)i&&u.observe(i,t)}},{immediate:!0,flush:"post"}),k=()=>{h(),p()};return q(k),{isSupported:B,stop:k}}const Z=e.defineComponent({__name:"TableHeaderWithTooltip",props:{label:{},placement:{}},setup(d){const s=e.ref(null),m=e.ref(!1),c=()=>{s.value&&(m.value=s.value.scrollWidth>s.value.clientWidth)};return e.onMounted(()=>{c()}),G(s,()=>{c()}),(t,u)=>{const B=e.resolveComponent("el-tooltip");return m.value?(e.openBlock(),e.createBlock(B,{key:1,content:t.label,placement:t.placement||"top"},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"textRef",ref:s,class:"header-cell-content"},e.toDisplayString(t.label),513)]),_:1},8,["content","placement"])):(e.openBlock(),e.createElementBlock("span",{key:0,ref_key:"textRef",ref:s,class:"header-cell-content"},e.toDisplayString(t.label),513))}}}),A=(d,s)=>{const m=d.__vccOpts||d;for(const[c,t]of s)m[c]=t;return m},J=A(Z,[["__scopeId","data-v-d23c8660"]]),K={key:0,class:"search-section-wrapper"},X={class:"flex flex-wrap items-center justify-between gap-4"},Y={class:"flex items-center gap-x-2"},v={class:"flex items-center gap-x-3 action-buttons flex-shrink-0"},ee={class:"table-content-wrapper"},te={key:1},oe={key:0,class:"flex items-center gap-x-2"},le={key:1,class:"pagination-wrapper flex justify-end mt-2"},ae={style:{"overflow-y":"auto",flex:"1"}},re={class:"dialog-footer"},ne={class:"flex items-center"},ie={class:"el-dialog__title"},se={style:{"overflow-y":"auto",flex:"1"}},de={class:"dialog-footer"},ce=A(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},loadingText:{type:String,default:"加载中…"},loadingBackground:{type:String,default:"rgba(0, 0, 0, 0.3)"},showSearchSection:{type:Boolean,default:!0},showSearchActionButtons:{type:Boolean,default:!0},showSearchButton:{type:Boolean,default:!0},showClearButton:{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:()=>({})},dialogFormLabelWidth:{type:String,default:120},submitAsFormData:{type:Boolean,default:!1},dialogFullscreen:{type:Boolean,default:!1},addDialogTitle:{type:String,default:"新增"},editDialogTitle:{type:String,default:"编辑"}},emits:["open-dialog","submit","delete"],setup(d,{expose:s,emit:m}){const c=m,t=d,u=e.computed(()=>["crud-table-wrapper",`theme-${t.theme}`,t.customClass]),B=e.computed(()=>t.theme==="large-screen"?"large-screen-dialog":""),h=(o,l)=>o?!0:(b.ElMessage.error(`${l} prop is required.`),!1),S=async(o,l)=>{try{let n={...l};t.onBeforeSubmit&&(n=await t.onBeforeSubmit(n,o));let g=n;if(t.submitAsFormData){const D=new FormData;for(const C in n)if(Object.prototype.hasOwnProperty.call(n,C)){const E=n[C];D.append(C,E??"")}g=D}if(a.submitting=!0,o==="add"){if(!h(t.apiUrlCreate,"apiUrlCreate"))throw new Error("apiUrlCreate is not configured.");await _.post(t.apiUrlCreate,g),b.ElMessage.success("新增成功")}else{if(!h(t.apiUrlUpdate,"apiUrlUpdate"))throw new Error("apiUrlUpdate is not configured.");await _.put(t.apiUrlUpdate,g),b.ElMessage.success("更新成功")}return t.onAfterSubmit&&t.onAfterSubmit(o,n),c("submit",{mode:o,data:n}),a.visible&&(a.visible=!1),V(),Promise.resolve()}catch(n){return console.error("Submit failed:",n),Promise.reject(n)}finally{a.submitting=!1}},p=e.reactive({pageNum:1,pageSize:10,...t.initialSearchForm}),k=e.ref([]),y=e.ref(0),i=e.ref(!1),f=e.ref([]),a=e.reactive({visible:!1,loading:!1,submitting:!1,mode:"add",data:{},formRef:null}),z=e.computed(()=>a.mode==="add"?t.addDialogTitle:t.editDialogTitle),O=e.computed(()=>{if(a.mode==="add")return t.dialogFormConfig.filter(l=>l.prop!=="id");const o=[...t.dialogFormConfig.filter(l=>l.prop!=="id")];return o.some(l=>l.prop==="id")||o.unshift({type:"input-disabled",prop:"id",label:"用户ID"}),o}),V=async()=>{if(h(t.apiUrlQuery,"apiUrlQuery")){i.value=!0;try{let o={...p};t.onBeforeQuery&&(o=await t.onBeforeQuery(o));const l=await _.get(t.apiUrlQuery,{params:o});if(l&&l.data&&Array.isArray(l.data.rows)&&typeof l.data.total=="number"){let n=l.data.rows;t.onAfterQuery&&(n=await t.onAfterQuery(n,o)),k.value=n,y.value=l.data.total}else console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),k.value=[],y.value=0}catch(o){console.error("Fetch data failed:",o)}finally{i.value=!1}}},x=()=>{p.pageNum=1,V()},pe=()=>{const{pageNum:o,pageSize:l,...n}=t.initialSearchForm;Object.keys(p).forEach(g=>{g!=="pageNum"&&g!=="pageSize"&&delete p[g]}),Object.assign(p,n),x()},fe=o=>{f.value=o},F=async(o,l)=>{let n;if(o==="add"?n=l?{...l}:{role:"user"}:n={...l},t.onBeforeOpenDialog){const g=await t.onBeforeOpenDialog(o,n);g&&(n=g)}if(a.mode=o,a.visible=!0,o==="edit"){if(!h(t.apiUrlDetail,"apiUrlDetail"))return;a.loading=!0;try{const g=await _.get(t.apiUrlDetail+"/"+n.id.toString());a.data=g.data.data}finally{a.loading=!1,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,a.data),c("open-dialog",{mode:o,data:a.data})}}else a.data=n,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,a.data),c("open-dialog",{mode:o,data:a.data})},N=async()=>{try{a.formRef?await a.formRef.validate():console.warn("Dialog form ref is not available for validation."),await S(a.mode,a.data)}catch(o){console.log("Validation or submit error:",o)}},R=async o=>{if(h(t.apiUrlDelete,"apiUrlDelete"))try{const l=k.value.filter(g=>o.includes(g.id));if(t.onBeforeDelete&&await t.onBeforeDelete(o,l)===!1)return;const n=o.join(",");await _.delete(t.apiUrlDelete+"/"+n.toString()),b.ElMessage.success("删除成功"),t.onAfterDelete&&t.onAfterDelete(o,l),c("delete",o),k.value.length===o.length&&p.pageNum>1&&p.pageNum--,V()}catch(l){console.error("Delete failed",l)}},me=o=>{p.pageSize=o,x()},ge=o=>{p.pageNum=o,V()};return e.onMounted(V),s({refresh:V,search:x,handleDelete:R,openDialog:F,submit:S,closeDialog:()=>{a.visible=!1}}),(o,l)=>{const n=e.resolveComponent("el-button"),g=e.resolveComponent("el-form-item"),D=e.resolveComponent("el-form"),C=e.resolveComponent("el-table-column"),E=e.resolveComponent("el-popconfirm"),ue=e.resolveComponent("el-table"),ye=e.resolveComponent("el-pagination"),he=e.resolveComponent("el-skeleton"),P=e.resolveComponent("el-dialog"),ke=e.resolveComponent("el-icon"),we=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([u.value,"crud-table-container"])},[t.showSearchSection?(e.openBlock(),e.createElementBlock("div",K,[e.renderSlot(o.$slots,"header",{},void 0,!0),e.createElementVNode("div",X,[e.createVNode(D,{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},void 0,!0),e.createVNode(g,{class:"!mr-0 flex-shrink-0"},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.renderSlot(o.$slots,"query-left",{searchForm:p},void 0,!0),t.showSearchActionButtons?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t.showSearchButton?(e.openBlock(),e.createBlock(n,{key:0,color:"#336FFF",onClick:x,loading:i.value},{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode("搜索",-1)])]),_:1},8,["loading"])):e.createCommentVNode("",!0),t.showClearButton?(e.openBlock(),e.createBlock(n,{key:1,color:"#336FFF",plain:"",onClick:pe},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("清空",-1)])]),_:1})):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"query-right",{searchForm:p},void 0,!0)])]),_:3})]),_:3},8,["model"]),e.createElementVNode("div",v,[e.renderSlot(o.$slots,"action-left",{selections:f.value},void 0,!0),e.renderSlot(o.$slots,"add-button-content",{selections:f.value},()=>[t.showNewBtn?(e.openBlock(),e.createBlock(n,{key:0,color:"#336FFF",onClick:l[0]||(l[0]=r=>F("add"))},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("新增",-1)])]),_:1})):e.createCommentVNode("",!0)],!0),e.renderSlot(o.$slots,"action-right",{selections:f.value},void 0,!0)])])])):e.createCommentVNode("",!0),e.createElementVNode("div",ee,[e.withDirectives((e.openBlock(),e.createBlock(ue,e.mergeProps({data:k.value,"element-loading-text":t.loadingText,"element-loading-background":t.loadingBackground,onSelectionChange:fe},o.$attrs,{height:"100%",style:{width:"100%"}}),{default:e.withCtx(()=>[t.showSelectionColumn?(e.openBlock(),e.createBlock(C,{key:0,type:"selection",width:"55",fixed:""})):e.createCommentVNode("",!0),t.showIndexColumn?(e.openBlock(),e.createBlock(C,{key:1,type:"index",label:"序号",width:"70",fixed:""})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,r=>(e.openBlock(),e.createBlock(C,e.mergeProps({key:r.prop,prop:r.prop,label:r.label,width:r.width,sortable:r.sortable||!1},{ref_for:!0},r.attrs),e.createSlots({header:e.withCtx(()=>[r.headerTooltip?(e.openBlock(),e.createBlock(J,{key:0,label:r.label,placement:r.placement},null,8,["label","placement"])):(e.openBlock(),e.createElementBlock("span",te,e.toDisplayString(r.label),1))]),_:2},[r.slot?{name:"default",fn:e.withCtx(U=>[e.renderSlot(o.$slots,r.slot,{row:U.row},void 0,!0)]),key:"0"}:void 0]),1040,["prop","label","width","sortable"]))),128)),t.showActionsColumn?(e.openBlock(),e.createBlock(C,{key:2,label:"操作",width:d.actionsColumnWidth},{default:e.withCtx(r=>[r.row?(e.openBlock(),e.createElementBlock("div",oe,[o.$slots.actions?e.renderSlot(o.$slots,"actions",{key:0,row:r.row},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(o.$slots,"action-before-edit",{row:r.row},void 0,!0),t.showEditButton?(e.openBlock(),e.createBlock(n,{key:0,size:"small",type:"primary",link:"",onClick:U=>F("edit",r.row)},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode("编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),t.showDeleteButton?(e.openBlock(),e.createBlock(E,{key:1,title:"确定要删除这条数据吗?",onConfirm:U=>R([r.row.id]),"confirm-button-text":"确定","cancel-button-text":"取消",width:"200"},{reference:e.withCtx(()=>[e.createVNode(n,{size:"small",type:"danger",link:""},{default:e.withCtx(()=>[...l[12]||(l[12]=[e.createTextVNode("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"action-after-delete",{row:r.row},void 0,!0)],64))])):e.createCommentVNode("",!0)]),_:3},8,["width"])):e.createCommentVNode("",!0)]),_:3},16,["data","element-loading-text","element-loading-background"])),[[we,i.value]])]),t.showPagination&&y.value>0?(e.openBlock(),e.createElementBlock("div",le,[e.createVNode(ye,{"current-page":p.pageNum,"onUpdate:currentPage":l[1]||(l[1]=r=>p.pageNum=r),"page-size":p.pageSize,"onUpdate:pageSize":l[2]||(l[2]=r=>p.pageSize=r),"page-sizes":t.pageSizes,layout:t.paginationLayout,total:y.value,background:t.paginationBackground,small:t.paginationSmall,"hide-on-single-page":t.paginationHideOnSinglePage,onSizeChange:me,onCurrentChange:ge},null,8,["current-page","page-size","page-sizes","layout","total","background","small","hide-on-single-page"])])):e.createCommentVNode("",!0),t.dialogFullscreen?(e.openBlock(),e.createBlock(P,{key:3,modelValue:a.visible,"onUpdate:modelValue":l[7]||(l[7]=r=>a.visible=r),fullscreen:!0,width:t.dialogWidth,"destroy-on-close":!0,modal:!t.dialogFullscreen,"custom-class":B.value,"show-close":!1,style:{display:"flex","flex-direction":"column","max-height":"100vh"}},{header:e.withCtx(()=>[e.createElementVNode("div",ne,[e.createVNode(n,{type:"info",text:"",onClick:l[5]||(l[5]=r=>a.visible=!1),style:{"margin-right":"12px"}},{default:e.withCtx(()=>[e.createVNode(ke,{size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(M))]),_:1})]),_:1}),e.createElementVNode("span",ie,e.toDisplayString(z.value),1)])]),footer:e.withCtx(()=>[e.renderSlot(o.$slots,"dialog-footer",{dialog:a,submit:N,cancel:()=>a.visible=!1},()=>[e.createElementVNode("span",de,[e.createVNode(n,{color:"#336FFF",plain:"",onClick:l[6]||(l[6]=r=>a.visible=!1)},{default:e.withCtx(()=>[...l[15]||(l[15]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(n,{color:"#336FFF",onClick:N,loading:a.submitting},{default:e.withCtx(()=>[...l[16]||(l[16]=[e.createTextVNode(" 确定 ",-1)])]),_:1},8,["loading"])])],!0)]),default:e.withCtx(()=>[e.createElementVNode("div",se,[o.$slots["dialog-form"]?e.renderSlot(o.$slots,"dialog-form",{key:0,formData:a.data,mode:a.mode,formRef:r=>{a.formRef=r}},void 0,!0):a.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(T,{key:1,ref:r=>{a.formRef=r},"model-value":a.data,"form-config":O.value,rules:t.dialogFormRules,"label-width":t.dialogFormLabelWidth},null,8,["model-value","form-config","rules","label-width"]))])]),_:3},8,["modelValue","width","modal","custom-class"])):(e.openBlock(),e.createBlock(P,{key:2,modelValue:a.visible,"onUpdate:modelValue":l[4]||(l[4]=r=>a.visible=r),title:z.value,width:t.dialogWidth,"destroy-on-close":!0,"custom-class":B.value,style:{display:"flex","flex-direction":"column","max-height":"80vh"}},{footer:e.withCtx(()=>[e.renderSlot(o.$slots,"dialog-footer",{dialog:a,submit:N,cancel:()=>a.visible=!1},()=>[e.createElementVNode("span",re,[e.createVNode(n,{color:"#336FFF",onClick:l[3]||(l[3]=r=>a.visible=!1)},{default:e.withCtx(()=>[...l[13]||(l[13]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(n,{color:"#336FFF",onClick:N,loading:a.submitting},{default:e.withCtx(()=>[...l[14]||(l[14]=[e.createTextVNode(" 确定 ",-1)])]),_:1},8,["loading"])])],!0)]),default:e.withCtx(()=>[e.createElementVNode("div",ae,[o.$slots["dialog-form"]?e.renderSlot(o.$slots,"dialog-form",{key:0,formData:a.data,mode:a.mode,formRef:r=>{a.formRef=r}},void 0,!0):a.loading?(e.openBlock(),e.createBlock(he,{key:1,rows:5,animated:""})):a.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(T,{key:2,ref:r=>{a.formRef=r},"model-value":a.data,"form-config":O.value,rules:t.dialogFormRules,"label-width":t.dialogFormLabelWidth},null,8,["model-value","form-config","rules","label-width"]))])]),_:3},8,["modelValue","title","width","custom-class"]))],2)}}}),[["__scopeId","data-v-b7c9a2a3"]]);w.CrudTable=ce,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.header-cell-content[data-v-d23c8660]{display:inline-block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.crud-table-container[data-v-96732da5]{display:flex;flex-direction:column;height:100%;width:100%;min-width:0;min-height:0;overflow:hidden}.search-section-wrapper[data-v-96732da5]{flex-shrink:0}.table-content-wrapper[data-v-96732da5]{flex:1;min-height:0;overflow:hidden}.pagination-wrapper[data-v-96732da5]{flex-shrink:0;padding-top:1rem;display:flex;justify-content:flex-end}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.visible{visibility:visible}.relative{position:relative}.\\!mr-0{margin-right:0!important}.mt-2{margin-top:.5rem}.flex{display:flex}.hidden{display:none}.flex-shrink{flex-shrink:1}.flex-shrink-0{flex-shrink:0}.flex-wrap{flex-wrap:wrap}.flex-nowrap{flex-wrap:nowrap}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-between{justify-content:space-between}.gap-4{gap:1rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-3{-moz-column-gap:.75rem;column-gap:.75rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.px-8{padding-left:2rem;padding-right:2rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}body{background-color:#f0f2f5;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;margin:0}#app{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#2c3e50}.crud-container{transition:box-shadow .3s ease-in-out}.crud-container:hover{box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.query-form .el-form-item{margin-bottom:0!important}.el-table__expanded-cell{padding:1rem 3.5rem!important;background-color:#f8fafc}.action-buttons>*+*{margin-left:.75rem}.el-dialog__header{border-bottom:none;padding:24px 24px 10px}.el-dialog__title{font-size:1.25rem;font-weight:600}.el-dialog__footer{border-top:none;padding:10px 24px 24px}.el-dialog__body{padding:10px 24px}:root{--large-screen-border-color: rgba(120, 153, 199, 1);--large-screen-text-color: rgba(227, 246, 255, 1);--large-screen-search-bg: rgba(210, 224, 243, .1);--large-screen-button-bg: rgba(38, 120, 255, 1);--large-screen-action-link-color: rgba(39, 233, 255, 1);--large-screen-dialog-bg: #1e293b;--large-screen-hover-bg: rgba(120, 153, 199, .15)}.theme-large-screen{color:var(--large-screen-text-color)}.el-modal-dialog,.el-overlay-dialog{position:absolute!important}')),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
(function(w,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):(w=typeof globalThis<"u"?globalThis:w||self,e(w.ZCrudTable={},w.Vue,w.ElementPlus,w.axios))})(this,(function(w,e,b,j){"use strict";/*! Element Plus Icons Vue v2.3.2 */var W=e.defineComponent({name:"ArrowLeftBold",__name:"arrow-left-bold",setup(c){return(s,m)=>(e.openBlock(),e.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[e.createElementVNode("path",{fill:"currentColor",d:"M685.248 104.704a64 64 0 0 1 0 90.496L368.448 512l316.8 316.8a64 64 0 0 1-90.496 90.496L232.704 557.248a64 64 0 0 1 0-90.496l362.048-362.048a64 64 0 0 1 90.496 0"})]))}}),M=W;const T=e.defineComponent({__name:"DynamicForm",props:{modelValue:{},formConfig:{},rules:{}},setup(c,{expose:s}){const m=e.ref(null);return s({validate:()=>{var d;return(d=m.value)==null?void 0:d.validate()}}),(d,t)=>{const u=e.resolveComponent("el-input"),B=e.resolveComponent("el-option"),h=e.resolveComponent("el-select"),S=e.resolveComponent("el-radio"),p=e.resolveComponent("el-radio-group"),k=e.resolveComponent("el-form-item"),y=e.resolveComponent("el-form");return e.openBlock(),e.createBlock(y,e.mergeProps({model:d.modelValue,rules:d.rules,ref_key:"formRef",ref:m},d.$attrs),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.formConfig,i=>(e.openBlock(),e.createBlock(k,{key:i.prop,label:i.label,prop:i.prop},{default:e.withCtx(()=>[i.type==="input"?(e.openBlock(),e.createBlock(u,e.mergeProps({key:0,modelValue:d.modelValue[i.prop],"onUpdate:modelValue":f=>d.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="textarea"?(e.openBlock(),e.createBlock(u,e.mergeProps({key:1,type:"textarea",modelValue:d.modelValue[i.prop],"onUpdate:modelValue":f=>d.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="select"?(e.openBlock(),e.createBlock(h,e.mergeProps({key:2,modelValue:d.modelValue[i.prop],"onUpdate:modelValue":f=>d.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.options,f=>(e.openBlock(),e.createBlock(B,{key:f.value,label:f.label,value:f.value},null,8,["label","value"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="radio-group"?(e.openBlock(),e.createBlock(p,e.mergeProps({key:3,modelValue:d.modelValue[i.prop],"onUpdate:modelValue":f=>d.modelValue[i.prop]=f},{ref_for:!0},i.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.options,f=>(e.openBlock(),e.createBlock(S,{key:f.value,label:f.value},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(f.label),1)]),_:2},1032,["label"]))),128))]),_:2},1040,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),i.type==="input-disabled"?(e.openBlock(),e.createBlock(u,e.mergeProps({key:4,"model-value":d.modelValue[i.prop],disabled:""},{ref_for:!0},i.componentProps),null,16,["model-value"])):e.createCommentVNode("",!0)]),_:2},1032,["label","prop"]))),128))]),_:1},16,["model","rules"])}}}),_=j.create({baseURL:"",timeout:1e4});_.interceptors.request.use(c=>{const s=localStorage.getItem("token");return s&&(c.headers.Authorization="Bearer "+s),c},c=>(console.log(c),Promise.reject(c))),_.interceptors.response.use(c=>{const s=c.data;return s.code!==200?(b.ElMessage({message:s.msg||"Error",type:"error",duration:5*1e3}),(s.code===401||s.code===403)&&b.ElMessageBox.confirm("您的登录状态已失效,请重新登录","确认登出",{confirmButtonText:"重新登录",cancelButtonText:"取消",type:"warning"}).then(()=>{localStorage.removeItem("token"),location.reload()}),Promise.reject(new Error(s.msg||"Error"))):s},c=>(console.log("HTTP Error: "+c),b.ElMessage({message:"网络错误,请检查您的网络连接或联系管理员",type:"error",duration:5*1e3}),Promise.reject(c)));function q(c){return e.getCurrentScope()?(e.onScopeDispose(c),!0):!1}const L=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Q=L?window:void 0;function $(c){var s;const m=e.toValue(c);return(s=m==null?void 0:m.$el)!=null?s:m}function I(){const c=e.shallowRef(!1),s=e.getCurrentInstance();return s&&e.onMounted(()=>{c.value=!0},s),c}function H(c){const s=I();return e.computed(()=>(s.value,!!c()))}function G(c,s,m={}){const{window:d=Q,...t}=m;let u;const B=H(()=>d&&"ResizeObserver"in d),h=()=>{u&&(u.disconnect(),u=void 0)},S=e.computed(()=>{const y=e.toValue(c);return Array.isArray(y)?y.map(i=>$(i)):[$(y)]}),p=e.watch(S,y=>{if(h(),B.value&&d){u=new ResizeObserver(s);for(const i of y)i&&u.observe(i,t)}},{immediate:!0,flush:"post"}),k=()=>{h(),p()};return q(k),{isSupported:B,stop:k}}const Z=e.defineComponent({__name:"TableHeaderWithTooltip",props:{label:{},placement:{}},setup(c){const s=e.ref(null),m=e.ref(!1),d=()=>{s.value&&(m.value=s.value.scrollWidth>s.value.clientWidth)};return e.onMounted(()=>{d()}),G(s,()=>{d()}),(t,u)=>{const B=e.resolveComponent("el-tooltip");return m.value?(e.openBlock(),e.createBlock(B,{key:1,content:t.label,placement:t.placement||"top"},{default:e.withCtx(()=>[e.createElementVNode("span",{ref_key:"textRef",ref:s,class:"header-cell-content"},e.toDisplayString(t.label),513)]),_:1},8,["content","placement"])):(e.openBlock(),e.createElementBlock("span",{key:0,ref_key:"textRef",ref:s,class:"header-cell-content"},e.toDisplayString(t.label),513))}}}),A=(c,s)=>{const m=c.__vccOpts||c;for(const[d,t]of s)m[d]=t;return m},J=A(Z,[["__scopeId","data-v-d23c8660"]]),K={key:0,class:"search-section-wrapper"},X={class:"flex flex-wrap items-center justify-between gap-4"},Y={class:"flex items-center gap-x-2"},v={class:"flex items-center gap-x-3 action-buttons flex-shrink-0"},ee={class:"table-content-wrapper"},te={key:1},oe={key:0,class:"flex items-center gap-x-2"},le={key:1,class:"pagination-wrapper flex justify-end mt-2"},ae={style:{"overflow-y":"auto",flex:"1"}},re={class:"dialog-footer"},ne={class:"flex items-center"},ie={class:"el-dialog__title"},se={style:{"overflow-y":"auto",flex:"1"}},de={class:"dialog-footer"},ce=A(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},loadingText:{type:String,default:"加载中…"},loadingBackground:{type:String,default:"rgba(0, 0, 0, 0.3)"},showSearchSection:{type:Boolean,default:!0},showSearchActionButtons:{type:Boolean,default:!0},showSearchButton:{type:Boolean,default:!0},showClearButton:{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:()=>({})},dialogFormLabelWidth:{type:String,default:120},submitAsFormData:{type:Boolean,default:!1},dialogFullscreen:{type:Boolean,default:!1},addDialogTitle:{type:String,default:"新增"},editDialogTitle:{type:String,default:"编辑"}},emits:["open-dialog","submit","delete","update:initialSearchForm"],setup(c,{expose:s,emit:m}){const d=m,t=c,u=e.computed(()=>["crud-table-wrapper",`theme-${t.theme}`,t.customClass]),B=e.computed(()=>t.theme==="large-screen"?"large-screen-dialog":""),h=(o,l)=>o?!0:(b.ElMessage.error(`${l} prop is required.`),!1),S=async(o,l)=>{try{let n={...l};t.onBeforeSubmit&&(n=await t.onBeforeSubmit(n,o));let g=n;if(t.submitAsFormData){const D=new FormData;for(const C in n)if(Object.prototype.hasOwnProperty.call(n,C)){const E=n[C];D.append(C,E??"")}g=D}if(a.submitting=!0,o==="add"){if(!h(t.apiUrlCreate,"apiUrlCreate"))throw new Error("apiUrlCreate is not configured.");await _.post(t.apiUrlCreate,g),b.ElMessage.success("新增成功")}else{if(!h(t.apiUrlUpdate,"apiUrlUpdate"))throw new Error("apiUrlUpdate is not configured.");await _.put(t.apiUrlUpdate,g),b.ElMessage.success("更新成功")}return t.onAfterSubmit&&t.onAfterSubmit(o,n),d("submit",{mode:o,data:n}),a.visible&&(a.visible=!1),V(),Promise.resolve()}catch(n){return console.error("Submit failed:",n),Promise.reject(n)}finally{a.submitting=!1}},p=e.reactive({pageNum:1,pageSize:10,...t.initialSearchForm}),k=e.ref([]),y=e.ref(0),i=e.ref(!1),f=e.ref([]),a=e.reactive({visible:!1,loading:!1,submitting:!1,mode:"add",data:{},formRef:null}),O=e.computed(()=>a.mode==="add"?t.addDialogTitle:t.editDialogTitle),z=e.computed(()=>{if(a.mode==="add")return t.dialogFormConfig.filter(l=>l.prop!=="id");const o=[...t.dialogFormConfig.filter(l=>l.prop!=="id")];return o.some(l=>l.prop==="id")||o.unshift({type:"input-disabled",prop:"id",label:"用户ID"}),o}),V=async()=>{if(h(t.apiUrlQuery,"apiUrlQuery")){i.value=!0;try{let o={...p};t.onBeforeQuery&&(o=await t.onBeforeQuery(o));const l=await _.get(t.apiUrlQuery,{params:o});if(l&&l.data&&Array.isArray(l.data.rows)&&typeof l.data.total=="number"){let n=l.data.rows;t.onAfterQuery&&(n=await t.onAfterQuery(n,o)),k.value=n,y.value=l.data.total}else console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),k.value=[],y.value=0}catch(o){console.error("Fetch data failed:",o)}finally{i.value=!1}}},x=()=>{p.pageNum=1,V()},pe=()=>{const{pageNum:o,pageSize:l,...n}=t.initialSearchForm;Object.keys(p).forEach(g=>{g!=="pageNum"&&g!=="pageSize"&&delete p[g]}),Object.assign(p,n),x()},fe=o=>{f.value=o},F=async(o,l)=>{let n;if(o==="add"?n=l?{...l}:{role:"user"}:n={...l},t.onBeforeOpenDialog){const g=await t.onBeforeOpenDialog(o,n);g&&(n=g)}if(a.mode=o,a.visible=!0,o==="edit"){if(!h(t.apiUrlDetail,"apiUrlDetail"))return;a.loading=!0;try{const g=await _.get(t.apiUrlDetail+"/"+n.id.toString());a.data=g.data.data}finally{a.loading=!1,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,a.data),d("open-dialog",{mode:o,data:a.data})}}else a.data=n,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,a.data),d("open-dialog",{mode:o,data:a.data})},N=async()=>{try{a.formRef?await a.formRef.validate():console.warn("Dialog form ref is not available for validation."),await S(a.mode,a.data)}catch(o){console.log("Validation or submit error:",o)}},R=async o=>{if(h(t.apiUrlDelete,"apiUrlDelete"))try{const l=k.value.filter(g=>o.includes(g.id));if(t.onBeforeDelete&&await t.onBeforeDelete(o,l)===!1)return;const n=o.join(",");await _.delete(t.apiUrlDelete+"/"+n.toString()),b.ElMessage.success("删除成功"),t.onAfterDelete&&t.onAfterDelete(o,l),d("delete",o),k.value.length===o.length&&p.pageNum>1&&p.pageNum--,V()}catch(l){console.error("Delete failed",l)}},me=o=>{p.pageSize=o,x()},ge=o=>{p.pageNum=o,V()};e.onMounted(V);const ue=()=>{a.visible=!1};return e.watch(p,o=>{d("update:initialSearchForm",{...e.toRaw(o)})},{deep:!0}),e.watch(()=>t.initialSearchForm,o=>{Object.assign(p,o)},{deep:!0}),s({refresh:V,search:x,handleDelete:R,openDialog:F,submit:S,closeDialog:ue}),(o,l)=>{const n=e.resolveComponent("el-button"),g=e.resolveComponent("el-form-item"),D=e.resolveComponent("el-form"),C=e.resolveComponent("el-table-column"),E=e.resolveComponent("el-popconfirm"),ye=e.resolveComponent("el-table"),he=e.resolveComponent("el-pagination"),ke=e.resolveComponent("el-skeleton"),P=e.resolveComponent("el-dialog"),we=e.resolveComponent("el-icon"),Be=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([u.value,"crud-table-container"])},[t.showSearchSection?(e.openBlock(),e.createElementBlock("div",K,[e.renderSlot(o.$slots,"header",{},void 0,!0),e.createElementVNode("div",X,[e.createVNode(D,{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},void 0,!0),e.createVNode(g,{class:"!mr-0 flex-shrink-0"},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.renderSlot(o.$slots,"query-left",{searchForm:p},void 0,!0),t.showSearchActionButtons?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t.showSearchButton?(e.openBlock(),e.createBlock(n,{key:0,color:"#336FFF",onClick:x,loading:i.value},{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode("搜索",-1)])]),_:1},8,["loading"])):e.createCommentVNode("",!0),t.showClearButton?(e.openBlock(),e.createBlock(n,{key:1,color:"#336FFF",plain:"",onClick:pe},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("清空",-1)])]),_:1})):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"query-right",{searchForm:p},void 0,!0)])]),_:3})]),_:3},8,["model"]),e.createElementVNode("div",v,[e.renderSlot(o.$slots,"action-left",{selections:f.value},void 0,!0),e.renderSlot(o.$slots,"add-button-content",{selections:f.value},()=>[t.showNewBtn?(e.openBlock(),e.createBlock(n,{key:0,color:"#336FFF",onClick:l[0]||(l[0]=r=>F("add"))},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("新增",-1)])]),_:1})):e.createCommentVNode("",!0)],!0),e.renderSlot(o.$slots,"action-right",{selections:f.value},void 0,!0)])])])):e.createCommentVNode("",!0),e.createElementVNode("div",ee,[e.withDirectives((e.openBlock(),e.createBlock(ye,e.mergeProps({data:k.value,"element-loading-text":t.loadingText,"element-loading-background":t.loadingBackground,onSelectionChange:fe},o.$attrs,{height:"100%",style:{width:"100%"}}),{default:e.withCtx(()=>[t.showSelectionColumn?(e.openBlock(),e.createBlock(C,{key:0,type:"selection",width:"55",fixed:""})):e.createCommentVNode("",!0),t.showIndexColumn?(e.openBlock(),e.createBlock(C,{key:1,type:"index",label:"序号",width:"70",fixed:""})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,r=>(e.openBlock(),e.createBlock(C,e.mergeProps({key:r.prop,prop:r.prop,label:r.label,width:r.width,sortable:r.sortable||!1},{ref_for:!0},r.attrs),e.createSlots({header:e.withCtx(()=>[r.headerTooltip?(e.openBlock(),e.createBlock(J,{key:0,label:r.label,placement:r.placement},null,8,["label","placement"])):(e.openBlock(),e.createElementBlock("span",te,e.toDisplayString(r.label),1))]),_:2},[r.slot?{name:"default",fn:e.withCtx(U=>[e.renderSlot(o.$slots,r.slot,{row:U.row},void 0,!0)]),key:"0"}:void 0]),1040,["prop","label","width","sortable"]))),128)),t.showActionsColumn?(e.openBlock(),e.createBlock(C,{key:2,label:"操作",width:c.actionsColumnWidth},{default:e.withCtx(r=>[r.row?(e.openBlock(),e.createElementBlock("div",oe,[o.$slots.actions?e.renderSlot(o.$slots,"actions",{key:0,row:r.row},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(o.$slots,"action-before-edit",{row:r.row},void 0,!0),t.showEditButton?(e.openBlock(),e.createBlock(n,{key:0,size:"small",type:"primary",link:"",onClick:U=>F("edit",r.row)},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode("编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),t.showDeleteButton?(e.openBlock(),e.createBlock(E,{key:1,title:"确定要删除这条数据吗?",onConfirm:U=>R([r.row.id]),"confirm-button-text":"确定","cancel-button-text":"取消",width:"200"},{reference:e.withCtx(()=>[e.createVNode(n,{size:"small",type:"danger",link:""},{default:e.withCtx(()=>[...l[12]||(l[12]=[e.createTextVNode("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"action-after-delete",{row:r.row},void 0,!0)],64))])):e.createCommentVNode("",!0)]),_:3},8,["width"])):e.createCommentVNode("",!0)]),_:3},16,["data","element-loading-text","element-loading-background"])),[[Be,i.value]])]),t.showPagination&&y.value>0?(e.openBlock(),e.createElementBlock("div",le,[e.createVNode(he,{"current-page":p.pageNum,"onUpdate:currentPage":l[1]||(l[1]=r=>p.pageNum=r),"page-size":p.pageSize,"onUpdate:pageSize":l[2]||(l[2]=r=>p.pageSize=r),"page-sizes":t.pageSizes,layout:t.paginationLayout,total:y.value,background:t.paginationBackground,small:t.paginationSmall,"hide-on-single-page":t.paginationHideOnSinglePage,onSizeChange:me,onCurrentChange:ge},null,8,["current-page","page-size","page-sizes","layout","total","background","small","hide-on-single-page"])])):e.createCommentVNode("",!0),t.dialogFullscreen?(e.openBlock(),e.createBlock(P,{key:3,modelValue:a.visible,"onUpdate:modelValue":l[7]||(l[7]=r=>a.visible=r),fullscreen:!0,width:t.dialogWidth,"destroy-on-close":!0,modal:!t.dialogFullscreen,"custom-class":B.value,"show-close":!1,style:{display:"flex","flex-direction":"column","max-height":"100vh"}},{header:e.withCtx(()=>[e.createElementVNode("div",ne,[e.createVNode(n,{type:"info",text:"",onClick:l[5]||(l[5]=r=>a.visible=!1),style:{"margin-right":"12px"}},{default:e.withCtx(()=>[e.createVNode(we,{size:"20"},{default:e.withCtx(()=>[e.createVNode(e.unref(M))]),_:1})]),_:1}),e.createElementVNode("span",ie,e.toDisplayString(O.value),1)])]),footer:e.withCtx(()=>[e.renderSlot(o.$slots,"dialog-footer",{dialog:a,submit:N,cancel:()=>a.visible=!1},()=>[e.createElementVNode("span",de,[e.createVNode(n,{color:"#336FFF",plain:"",onClick:l[6]||(l[6]=r=>a.visible=!1)},{default:e.withCtx(()=>[...l[15]||(l[15]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(n,{color:"#336FFF",onClick:N,loading:a.submitting},{default:e.withCtx(()=>[...l[16]||(l[16]=[e.createTextVNode(" 确定 ",-1)])]),_:1},8,["loading"])])],!0)]),default:e.withCtx(()=>[e.createElementVNode("div",se,[o.$slots["dialog-form"]?e.renderSlot(o.$slots,"dialog-form",{key:0,formData:a.data,mode:a.mode,formRef:r=>{a.formRef=r}},void 0,!0):a.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(T,{key:1,ref:r=>{a.formRef=r},"model-value":a.data,"form-config":z.value,rules:t.dialogFormRules,"label-width":t.dialogFormLabelWidth},null,8,["model-value","form-config","rules","label-width"]))])]),_:3},8,["modelValue","width","modal","custom-class"])):(e.openBlock(),e.createBlock(P,{key:2,modelValue:a.visible,"onUpdate:modelValue":l[4]||(l[4]=r=>a.visible=r),title:O.value,width:t.dialogWidth,"destroy-on-close":!0,"custom-class":B.value,style:{display:"flex","flex-direction":"column","max-height":"80vh"}},{footer:e.withCtx(()=>[e.renderSlot(o.$slots,"dialog-footer",{dialog:a,submit:N,cancel:()=>a.visible=!1},()=>[e.createElementVNode("span",re,[e.createVNode(n,{color:"#336FFF",onClick:l[3]||(l[3]=r=>a.visible=!1)},{default:e.withCtx(()=>[...l[13]||(l[13]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(n,{color:"#336FFF",onClick:N,loading:a.submitting},{default:e.withCtx(()=>[...l[14]||(l[14]=[e.createTextVNode(" 确定 ",-1)])]),_:1},8,["loading"])])],!0)]),default:e.withCtx(()=>[e.createElementVNode("div",ae,[o.$slots["dialog-form"]?e.renderSlot(o.$slots,"dialog-form",{key:0,formData:a.data,mode:a.mode,formRef:r=>{a.formRef=r}},void 0,!0):a.loading?(e.openBlock(),e.createBlock(ke,{key:1,rows:5,animated:""})):a.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(T,{key:2,ref:r=>{a.formRef=r},"model-value":a.data,"form-config":z.value,rules:t.dialogFormRules,"label-width":t.dialogFormLabelWidth},null,8,["model-value","form-config","rules","label-width"]))])]),_:3},8,["modelValue","title","width","custom-class"]))],2)}}}),[["__scopeId","data-v-96732da5"]]);w.CrudTable=ce,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
|