z-crud-table 0.0.45 → 0.0.46
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 +400 -308
- package/dist/z-crud-table.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/z-crud-table.js
CHANGED
|
@@ -1,54 +1,70 @@
|
|
|
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
|
|
3
|
-
import { ElMessage as
|
|
4
|
-
import
|
|
5
|
-
|
|
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-833f1fc3]{display:flex;flex-direction:column;height:100%;width:100%;min-width:0;min-height:0;overflow:hidden}.search-section-wrapper[data-v-833f1fc3]{flex-shrink:0}.table-content-wrapper[data-v-833f1fc3]{flex:1;min-height:0;overflow:hidden}.pagination-wrapper[data-v-833f1fc3]{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 q, createElementBlock as _, openBlock as n, createElementVNode as C, ref as x, resolveComponent as g, createBlock as f, mergeProps as A, withCtx as p, Fragment as T, renderList as j, createCommentVNode as b, createTextVNode as U, toDisplayString as N, getCurrentScope as fe, onScopeDispose as ce, computed as R, toValue as te, watch as me, shallowRef as ge, getCurrentInstance as ye, onMounted as M, reactive as Y, resolveDirective as ve, normalizeClass as be, renderSlot as h, createVNode as w, withDirectives as he, createSlots as we, unref as _e } from "vue";
|
|
3
|
+
import { ElMessage as P, ElMessageBox as ke } from "element-plus";
|
|
4
|
+
import Se from "axios";
|
|
5
|
+
/*! Element Plus Icons Vue v2.3.2 */
|
|
6
|
+
var Ce = /* @__PURE__ */ q({
|
|
7
|
+
name: "ArrowLeftBold",
|
|
8
|
+
__name: "arrow-left-bold",
|
|
9
|
+
setup(u) {
|
|
10
|
+
return (s, y) => (n(), _("svg", {
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
viewBox: "0 0 1024 1024"
|
|
13
|
+
}, [
|
|
14
|
+
C("path", {
|
|
15
|
+
fill: "currentColor",
|
|
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
|
+
})
|
|
18
|
+
]));
|
|
19
|
+
}
|
|
20
|
+
}), De = Ce;
|
|
21
|
+
const Z = /* @__PURE__ */ q({
|
|
6
22
|
__name: "DynamicForm",
|
|
7
23
|
props: {
|
|
8
24
|
modelValue: {},
|
|
9
25
|
formConfig: {},
|
|
10
26
|
rules: {}
|
|
11
27
|
},
|
|
12
|
-
setup(
|
|
13
|
-
const
|
|
14
|
-
return
|
|
28
|
+
setup(u, { expose: s }) {
|
|
29
|
+
const y = x(null);
|
|
30
|
+
return s({
|
|
15
31
|
validate: () => {
|
|
16
|
-
var
|
|
17
|
-
return (
|
|
32
|
+
var d;
|
|
33
|
+
return (d = y.value) == null ? void 0 : d.validate();
|
|
18
34
|
}
|
|
19
|
-
}), (
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
model:
|
|
23
|
-
rules:
|
|
35
|
+
}), (d, e) => {
|
|
36
|
+
const k = g("el-input"), V = g("el-option"), D = g("el-select"), z = g("el-radio"), c = g("el-radio-group"), B = g("el-form-item"), S = g("el-form");
|
|
37
|
+
return n(), f(S, A({
|
|
38
|
+
model: d.modelValue,
|
|
39
|
+
rules: d.rules,
|
|
24
40
|
ref_key: "formRef",
|
|
25
|
-
ref:
|
|
26
|
-
},
|
|
41
|
+
ref: y
|
|
42
|
+
}, d.$attrs), {
|
|
27
43
|
default: p(() => [
|
|
28
|
-
(
|
|
29
|
-
key:
|
|
30
|
-
label:
|
|
31
|
-
prop:
|
|
44
|
+
(n(!0), _(T, null, j(d.formConfig, (i) => (n(), f(B, {
|
|
45
|
+
key: i.prop,
|
|
46
|
+
label: i.label,
|
|
47
|
+
prop: i.prop
|
|
32
48
|
}, {
|
|
33
49
|
default: p(() => [
|
|
34
|
-
|
|
50
|
+
i.type === "input" ? (n(), f(k, A({
|
|
35
51
|
key: 0,
|
|
36
|
-
modelValue:
|
|
37
|
-
"onUpdate:modelValue": (m) =>
|
|
38
|
-
}, { ref_for: !0 },
|
|
39
|
-
|
|
52
|
+
modelValue: d.modelValue[i.prop],
|
|
53
|
+
"onUpdate:modelValue": (m) => d.modelValue[i.prop] = m
|
|
54
|
+
}, { ref_for: !0 }, i.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) : b("", !0),
|
|
55
|
+
i.type === "textarea" ? (n(), f(k, A({
|
|
40
56
|
key: 1,
|
|
41
57
|
type: "textarea",
|
|
42
|
-
modelValue:
|
|
43
|
-
"onUpdate:modelValue": (m) =>
|
|
44
|
-
}, { ref_for: !0 },
|
|
45
|
-
|
|
58
|
+
modelValue: d.modelValue[i.prop],
|
|
59
|
+
"onUpdate:modelValue": (m) => d.modelValue[i.prop] = m
|
|
60
|
+
}, { ref_for: !0 }, i.componentProps), null, 16, ["modelValue", "onUpdate:modelValue"])) : b("", !0),
|
|
61
|
+
i.type === "select" ? (n(), f(D, A({
|
|
46
62
|
key: 2,
|
|
47
|
-
modelValue:
|
|
48
|
-
"onUpdate:modelValue": (m) =>
|
|
49
|
-
}, { ref_for: !0 },
|
|
63
|
+
modelValue: d.modelValue[i.prop],
|
|
64
|
+
"onUpdate:modelValue": (m) => d.modelValue[i.prop] = m
|
|
65
|
+
}, { ref_for: !0 }, i.componentProps), {
|
|
50
66
|
default: p(() => [
|
|
51
|
-
(
|
|
67
|
+
(n(!0), _(T, null, j(i.options, (m) => (n(), f(V, {
|
|
52
68
|
key: m.value,
|
|
53
69
|
label: m.label,
|
|
54
70
|
value: m.value
|
|
@@ -56,29 +72,29 @@ const _e = /* @__PURE__ */ L({
|
|
|
56
72
|
]),
|
|
57
73
|
_: 2
|
|
58
74
|
}, 1040, ["modelValue", "onUpdate:modelValue"])) : b("", !0),
|
|
59
|
-
|
|
75
|
+
i.type === "radio-group" ? (n(), f(c, A({
|
|
60
76
|
key: 3,
|
|
61
|
-
modelValue:
|
|
62
|
-
"onUpdate:modelValue": (m) =>
|
|
63
|
-
}, { ref_for: !0 },
|
|
77
|
+
modelValue: d.modelValue[i.prop],
|
|
78
|
+
"onUpdate:modelValue": (m) => d.modelValue[i.prop] = m
|
|
79
|
+
}, { ref_for: !0 }, i.componentProps), {
|
|
64
80
|
default: p(() => [
|
|
65
|
-
(
|
|
81
|
+
(n(!0), _(T, null, j(i.options, (m) => (n(), f(z, {
|
|
66
82
|
key: m.value,
|
|
67
83
|
label: m.value
|
|
68
84
|
}, {
|
|
69
85
|
default: p(() => [
|
|
70
|
-
|
|
86
|
+
U(N(m.label), 1)
|
|
71
87
|
]),
|
|
72
88
|
_: 2
|
|
73
89
|
}, 1032, ["label"]))), 128))
|
|
74
90
|
]),
|
|
75
91
|
_: 2
|
|
76
92
|
}, 1040, ["modelValue", "onUpdate:modelValue"])) : b("", !0),
|
|
77
|
-
|
|
93
|
+
i.type === "input-disabled" ? (n(), f(k, A({
|
|
78
94
|
key: 4,
|
|
79
|
-
"model-value":
|
|
95
|
+
"model-value": d.modelValue[i.prop],
|
|
80
96
|
disabled: ""
|
|
81
|
-
}, { ref_for: !0 },
|
|
97
|
+
}, { ref_for: !0 }, i.componentProps), null, 16, ["model-value"])) : b("", !0)
|
|
82
98
|
]),
|
|
83
99
|
_: 2
|
|
84
100
|
}, 1032, ["label", "prop"]))), 128))
|
|
@@ -87,32 +103,32 @@ const _e = /* @__PURE__ */ L({
|
|
|
87
103
|
}, 16, ["model", "rules"]);
|
|
88
104
|
};
|
|
89
105
|
}
|
|
90
|
-
}), $ =
|
|
106
|
+
}), $ = Se.create({
|
|
91
107
|
// VITE_APP_BASE_API 是在 .env 文件中定义的基础 URL
|
|
92
108
|
baseURL: "",
|
|
93
109
|
timeout: 1e4
|
|
94
110
|
// 请求超时时间
|
|
95
111
|
});
|
|
96
112
|
$.interceptors.request.use(
|
|
97
|
-
(
|
|
98
|
-
const
|
|
99
|
-
return
|
|
113
|
+
(u) => {
|
|
114
|
+
const s = localStorage.getItem("token");
|
|
115
|
+
return s && (u.headers.Authorization = "Bearer " + s), u;
|
|
100
116
|
},
|
|
101
|
-
(
|
|
117
|
+
(u) => (console.log(u), Promise.reject(u))
|
|
102
118
|
);
|
|
103
119
|
$.interceptors.response.use(
|
|
104
120
|
/**
|
|
105
121
|
* @description 如果您想直接获取诸如 headers 或 status 之类的信息,
|
|
106
122
|
* 请直接返回 response => response
|
|
107
123
|
*/
|
|
108
|
-
(
|
|
109
|
-
const
|
|
110
|
-
return
|
|
111
|
-
message:
|
|
124
|
+
(u) => {
|
|
125
|
+
const s = u.data;
|
|
126
|
+
return s.code !== 200 ? (P({
|
|
127
|
+
message: s.msg || "Error",
|
|
112
128
|
// 使用后端返回的 `msg` 作为错误提示
|
|
113
129
|
type: "error",
|
|
114
130
|
duration: 5 * 1e3
|
|
115
|
-
}), (
|
|
131
|
+
}), (s.code === 401 || s.code === 403) && ke.confirm(
|
|
116
132
|
"您的登录状态已失效,请重新登录",
|
|
117
133
|
"确认登出",
|
|
118
134
|
{
|
|
@@ -122,116 +138,116 @@ $.interceptors.response.use(
|
|
|
122
138
|
}
|
|
123
139
|
).then(() => {
|
|
124
140
|
localStorage.removeItem("token"), location.reload();
|
|
125
|
-
}), Promise.reject(new Error(
|
|
141
|
+
}), Promise.reject(new Error(s.msg || "Error"))) : s;
|
|
126
142
|
},
|
|
127
|
-
(
|
|
143
|
+
(u) => (console.log("HTTP Error: " + u), P({
|
|
128
144
|
message: "网络错误,请检查您的网络连接或联系管理员",
|
|
129
145
|
// 提供更友好的网络错误提示
|
|
130
146
|
type: "error",
|
|
131
147
|
duration: 5 * 1e3
|
|
132
|
-
}), Promise.reject(
|
|
148
|
+
}), Promise.reject(u))
|
|
133
149
|
);
|
|
134
|
-
function
|
|
135
|
-
return
|
|
150
|
+
function Be(u) {
|
|
151
|
+
return fe() ? (ce(u), !0) : !1;
|
|
136
152
|
}
|
|
137
|
-
const
|
|
153
|
+
const Ue = typeof window < "u" && typeof document < "u";
|
|
138
154
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
139
|
-
const
|
|
140
|
-
function
|
|
141
|
-
var
|
|
142
|
-
const
|
|
143
|
-
return (
|
|
155
|
+
const Ve = Ue ? window : void 0;
|
|
156
|
+
function ee(u) {
|
|
157
|
+
var s;
|
|
158
|
+
const y = te(u);
|
|
159
|
+
return (s = y == null ? void 0 : y.$el) != null ? s : y;
|
|
144
160
|
}
|
|
145
161
|
// @__NO_SIDE_EFFECTS__
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
},
|
|
162
|
+
function Fe() {
|
|
163
|
+
const u = ge(!1), s = ye();
|
|
164
|
+
return s && M(() => {
|
|
165
|
+
u.value = !0;
|
|
166
|
+
}, s), u;
|
|
151
167
|
}
|
|
152
168
|
// @__NO_SIDE_EFFECTS__
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
return
|
|
169
|
+
function Ae(u) {
|
|
170
|
+
const s = /* @__PURE__ */ Fe();
|
|
171
|
+
return R(() => (s.value, !!u()));
|
|
156
172
|
}
|
|
157
|
-
function
|
|
158
|
-
const { window:
|
|
159
|
-
let
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
const
|
|
164
|
-
return Array.isArray(
|
|
165
|
-
}),
|
|
166
|
-
|
|
167
|
-
(
|
|
168
|
-
if (
|
|
169
|
-
|
|
170
|
-
for (const
|
|
171
|
-
|
|
173
|
+
function $e(u, s, y = {}) {
|
|
174
|
+
const { window: d = Ve, ...e } = y;
|
|
175
|
+
let k;
|
|
176
|
+
const V = /* @__PURE__ */ Ae(() => d && "ResizeObserver" in d), D = () => {
|
|
177
|
+
k && (k.disconnect(), k = void 0);
|
|
178
|
+
}, z = R(() => {
|
|
179
|
+
const S = te(u);
|
|
180
|
+
return Array.isArray(S) ? S.map((i) => ee(i)) : [ee(S)];
|
|
181
|
+
}), c = me(
|
|
182
|
+
z,
|
|
183
|
+
(S) => {
|
|
184
|
+
if (D(), V.value && d) {
|
|
185
|
+
k = new ResizeObserver(s);
|
|
186
|
+
for (const i of S)
|
|
187
|
+
i && k.observe(i, e);
|
|
172
188
|
}
|
|
173
189
|
},
|
|
174
190
|
{ immediate: !0, flush: "post" }
|
|
175
|
-
),
|
|
176
|
-
|
|
191
|
+
), B = () => {
|
|
192
|
+
D(), c();
|
|
177
193
|
};
|
|
178
|
-
return
|
|
179
|
-
isSupported:
|
|
180
|
-
stop:
|
|
194
|
+
return Be(B), {
|
|
195
|
+
isSupported: V,
|
|
196
|
+
stop: B
|
|
181
197
|
};
|
|
182
198
|
}
|
|
183
|
-
const
|
|
199
|
+
const xe = /* @__PURE__ */ q({
|
|
184
200
|
__name: "TableHeaderWithTooltip",
|
|
185
201
|
props: {
|
|
186
202
|
label: {},
|
|
187
203
|
placement: {}
|
|
188
204
|
},
|
|
189
|
-
setup(
|
|
190
|
-
const
|
|
191
|
-
|
|
205
|
+
setup(u) {
|
|
206
|
+
const s = x(null), y = x(!1), d = () => {
|
|
207
|
+
s.value && (y.value = s.value.scrollWidth > s.value.clientWidth);
|
|
192
208
|
};
|
|
193
209
|
return M(() => {
|
|
194
|
-
|
|
195
|
-
}),
|
|
196
|
-
|
|
197
|
-
}), (e,
|
|
198
|
-
const
|
|
199
|
-
return
|
|
210
|
+
d();
|
|
211
|
+
}), $e(s, () => {
|
|
212
|
+
d();
|
|
213
|
+
}), (e, k) => {
|
|
214
|
+
const V = g("el-tooltip");
|
|
215
|
+
return y.value ? (n(), f(V, {
|
|
200
216
|
key: 1,
|
|
201
217
|
content: e.label,
|
|
202
218
|
placement: e.placement || "top"
|
|
203
219
|
}, {
|
|
204
220
|
default: p(() => [
|
|
205
|
-
|
|
221
|
+
C("span", {
|
|
206
222
|
ref_key: "textRef",
|
|
207
|
-
ref:
|
|
223
|
+
ref: s,
|
|
208
224
|
class: "header-cell-content"
|
|
209
|
-
},
|
|
225
|
+
}, N(e.label), 513)
|
|
210
226
|
]),
|
|
211
227
|
_: 1
|
|
212
|
-
}, 8, ["content", "placement"])) : (
|
|
228
|
+
}, 8, ["content", "placement"])) : (n(), _("span", {
|
|
213
229
|
key: 0,
|
|
214
230
|
ref_key: "textRef",
|
|
215
|
-
ref:
|
|
231
|
+
ref: s,
|
|
216
232
|
class: "header-cell-content"
|
|
217
|
-
},
|
|
233
|
+
}, N(e.label), 513));
|
|
218
234
|
};
|
|
219
235
|
}
|
|
220
|
-
}),
|
|
221
|
-
const
|
|
222
|
-
for (const [
|
|
223
|
-
|
|
224
|
-
return
|
|
225
|
-
},
|
|
236
|
+
}), oe = (u, s) => {
|
|
237
|
+
const y = u.__vccOpts || u;
|
|
238
|
+
for (const [d, e] of s)
|
|
239
|
+
y[d] = e;
|
|
240
|
+
return y;
|
|
241
|
+
}, ze = /* @__PURE__ */ oe(xe, [["__scopeId", "data-v-d23c8660"]]), Oe = {
|
|
226
242
|
key: 0,
|
|
227
243
|
class: "search-section-wrapper"
|
|
228
|
-
},
|
|
244
|
+
}, Re = { class: "flex flex-wrap items-center justify-between gap-4" }, Pe = { class: "flex items-center gap-x-2" }, Te = { class: "flex items-center gap-x-3 action-buttons flex-shrink-0" }, Ne = { class: "table-content-wrapper" }, We = { key: 1 }, Ee = {
|
|
229
245
|
key: 0,
|
|
230
246
|
class: "flex items-center gap-x-2"
|
|
231
|
-
},
|
|
247
|
+
}, je = {
|
|
232
248
|
key: 1,
|
|
233
249
|
class: "pagination-wrapper flex justify-end mt-2"
|
|
234
|
-
},
|
|
250
|
+
}, qe = { style: { "overflow-y": "auto", flex: "1" } }, Le = { class: "dialog-footer" }, Qe = { class: "flex items-center" }, Ie = { class: "el-dialog__title" }, Me = { style: { "overflow-y": "auto", flex: "1" } }, He = { class: "dialog-footer" }, Ge = /* @__PURE__ */ q({
|
|
235
251
|
__name: "CrudTable",
|
|
236
252
|
props: {
|
|
237
253
|
/**
|
|
@@ -330,153 +346,153 @@ const Ve = /* @__PURE__ */ L({
|
|
|
330
346
|
dialogFullscreen: { type: Boolean, default: !1 }
|
|
331
347
|
},
|
|
332
348
|
emits: ["open-dialog", "submit", "delete"],
|
|
333
|
-
setup(
|
|
334
|
-
const
|
|
349
|
+
setup(u, { expose: s, emit: y }) {
|
|
350
|
+
const d = y, e = u, k = R(() => ["crud-table-wrapper", `theme-${e.theme}`, e.customClass]), V = R(() => e.theme === "large-screen" ? "large-screen-dialog" : ""), D = (o, t) => o ? !0 : (P.error(`${t} prop is required.`), !1), z = async (o, t) => {
|
|
335
351
|
try {
|
|
336
|
-
let
|
|
337
|
-
e.onBeforeSubmit && (
|
|
338
|
-
let
|
|
352
|
+
let r = { ...t };
|
|
353
|
+
e.onBeforeSubmit && (r = await e.onBeforeSubmit(r, o));
|
|
354
|
+
let v = r;
|
|
339
355
|
if (e.submitAsFormData) {
|
|
340
356
|
const E = new FormData();
|
|
341
|
-
for (const
|
|
342
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
343
|
-
const Q =
|
|
344
|
-
E.append(
|
|
357
|
+
for (const F in r)
|
|
358
|
+
if (Object.prototype.hasOwnProperty.call(r, F)) {
|
|
359
|
+
const Q = r[F];
|
|
360
|
+
E.append(F, Q ?? "");
|
|
345
361
|
}
|
|
346
|
-
|
|
362
|
+
v = E;
|
|
347
363
|
}
|
|
348
|
-
if (
|
|
349
|
-
if (!
|
|
350
|
-
await $.post(e.apiUrlCreate,
|
|
364
|
+
if (l.submitting = !0, o === "add") {
|
|
365
|
+
if (!D(e.apiUrlCreate, "apiUrlCreate")) throw new Error("apiUrlCreate is not configured.");
|
|
366
|
+
await $.post(e.apiUrlCreate, v), P.success("新增成功");
|
|
351
367
|
} else {
|
|
352
|
-
if (!
|
|
353
|
-
await $.put(e.apiUrlUpdate,
|
|
368
|
+
if (!D(e.apiUrlUpdate, "apiUrlUpdate")) throw new Error("apiUrlUpdate is not configured.");
|
|
369
|
+
await $.put(e.apiUrlUpdate, v), P.success("更新成功");
|
|
354
370
|
}
|
|
355
|
-
return e.onAfterSubmit && e.onAfterSubmit(
|
|
356
|
-
} catch (
|
|
357
|
-
return console.error("Submit failed:",
|
|
371
|
+
return e.onAfterSubmit && e.onAfterSubmit(o, r), d("submit", { mode: o, data: r }), l.visible && (l.visible = !1), O(), Promise.resolve();
|
|
372
|
+
} catch (r) {
|
|
373
|
+
return console.error("Submit failed:", r), Promise.reject(r);
|
|
358
374
|
} finally {
|
|
359
|
-
|
|
375
|
+
l.submitting = !1;
|
|
360
376
|
}
|
|
361
|
-
},
|
|
362
|
-
if (
|
|
363
|
-
const
|
|
364
|
-
return
|
|
365
|
-
}),
|
|
366
|
-
if (
|
|
367
|
-
|
|
377
|
+
}, c = Y({ pageNum: 1, pageSize: 10, ...e.initialSearchForm }), B = x([]), S = x(0), i = x(!1), m = x([]), l = Y({ visible: !1, loading: !1, submitting: !1, mode: "add", data: {}, formRef: null }), H = R(() => l.mode === "add" ? "新增" : "编辑"), G = R(() => {
|
|
378
|
+
if (l.mode === "add") return e.dialogFormConfig.filter((t) => t.prop !== "id");
|
|
379
|
+
const o = [...e.dialogFormConfig.filter((t) => t.prop !== "id")];
|
|
380
|
+
return o.some((t) => t.prop === "id") || o.unshift({ type: "input-disabled", prop: "id", label: "用户ID" }), o;
|
|
381
|
+
}), O = async () => {
|
|
382
|
+
if (D(e.apiUrlQuery, "apiUrlQuery")) {
|
|
383
|
+
i.value = !0;
|
|
368
384
|
try {
|
|
369
|
-
let
|
|
370
|
-
e.onBeforeQuery && (
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
let
|
|
374
|
-
e.onAfterQuery && (
|
|
385
|
+
let o = { ...c };
|
|
386
|
+
e.onBeforeQuery && (o = await e.onBeforeQuery(o));
|
|
387
|
+
const t = await $.get(e.apiUrlQuery, { params: o });
|
|
388
|
+
if (t && t.data && Array.isArray(t.data.rows) && typeof t.data.total == "number") {
|
|
389
|
+
let r = t.data.rows;
|
|
390
|
+
e.onAfterQuery && (r = await e.onAfterQuery(r, o)), B.value = r, S.value = t.data.total;
|
|
375
391
|
} else
|
|
376
|
-
console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),
|
|
377
|
-
} catch (
|
|
378
|
-
console.error("Fetch data failed:",
|
|
392
|
+
console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."), B.value = [], S.value = 0;
|
|
393
|
+
} catch (o) {
|
|
394
|
+
console.error("Fetch data failed:", o);
|
|
379
395
|
} finally {
|
|
380
|
-
|
|
396
|
+
i.value = !1;
|
|
381
397
|
}
|
|
382
398
|
}
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
const { pageNum:
|
|
387
|
-
Object.keys(
|
|
388
|
-
|
|
389
|
-
}), Object.assign(
|
|
390
|
-
},
|
|
391
|
-
m.value =
|
|
392
|
-
},
|
|
393
|
-
let
|
|
394
|
-
if (
|
|
395
|
-
const
|
|
396
|
-
|
|
399
|
+
}, W = () => {
|
|
400
|
+
c.pageNum = 1, O();
|
|
401
|
+
}, le = () => {
|
|
402
|
+
const { pageNum: o, pageSize: t, ...r } = e.initialSearchForm;
|
|
403
|
+
Object.keys(c).forEach((v) => {
|
|
404
|
+
v !== "pageNum" && v !== "pageSize" && delete c[v];
|
|
405
|
+
}), Object.assign(c, r), W();
|
|
406
|
+
}, ae = (o) => {
|
|
407
|
+
m.value = o;
|
|
408
|
+
}, L = async (o, t) => {
|
|
409
|
+
let r;
|
|
410
|
+
if (o === "add" ? r = t ? { ...t } : { role: "user" } : r = { ...t }, e.onBeforeOpenDialog) {
|
|
411
|
+
const v = await e.onBeforeOpenDialog(o, r);
|
|
412
|
+
v && (r = v);
|
|
397
413
|
}
|
|
398
|
-
if (
|
|
399
|
-
if (!
|
|
400
|
-
|
|
414
|
+
if (l.mode = o, l.visible = !0, o === "edit") {
|
|
415
|
+
if (!D(e.apiUrlDetail, "apiUrlDetail")) return;
|
|
416
|
+
l.loading = !0;
|
|
401
417
|
try {
|
|
402
|
-
const
|
|
403
|
-
|
|
418
|
+
const v = await $.get(e.apiUrlDetail + "/" + r.id.toString());
|
|
419
|
+
l.data = v.data.data;
|
|
404
420
|
} finally {
|
|
405
|
-
|
|
421
|
+
l.loading = !1, e.onAfterOpenDialog && e.onAfterOpenDialog(o, l.data), d("open-dialog", { mode: o, data: l.data });
|
|
406
422
|
}
|
|
407
423
|
} else
|
|
408
|
-
|
|
409
|
-
},
|
|
424
|
+
l.data = r, e.onAfterOpenDialog && e.onAfterOpenDialog(o, l.data), d("open-dialog", { mode: o, data: l.data });
|
|
425
|
+
}, J = async () => {
|
|
410
426
|
try {
|
|
411
|
-
|
|
412
|
-
} catch (
|
|
413
|
-
console.log("Validation or submit error:",
|
|
427
|
+
l.formRef ? await l.formRef.validate() : console.warn("Dialog form ref is not available for validation."), await z(l.mode, l.data);
|
|
428
|
+
} catch (o) {
|
|
429
|
+
console.log("Validation or submit error:", o);
|
|
414
430
|
}
|
|
415
|
-
},
|
|
416
|
-
if (
|
|
431
|
+
}, K = async (o) => {
|
|
432
|
+
if (D(e.apiUrlDelete, "apiUrlDelete"))
|
|
417
433
|
try {
|
|
418
|
-
const
|
|
419
|
-
if (e.onBeforeDelete && await e.onBeforeDelete(
|
|
434
|
+
const t = B.value.filter((v) => o.includes(v.id));
|
|
435
|
+
if (e.onBeforeDelete && await e.onBeforeDelete(o, t) === !1)
|
|
420
436
|
return;
|
|
421
|
-
const
|
|
422
|
-
await $.delete(e.apiUrlDelete + "/" +
|
|
423
|
-
} catch (
|
|
424
|
-
console.error("Delete failed",
|
|
437
|
+
const r = o.join(",");
|
|
438
|
+
await $.delete(e.apiUrlDelete + "/" + r.toString()), P.success("删除成功"), e.onAfterDelete && e.onAfterDelete(o, t), d("delete", o), B.value.length === o.length && c.pageNum > 1 && c.pageNum--, O();
|
|
439
|
+
} catch (t) {
|
|
440
|
+
console.error("Delete failed", t);
|
|
425
441
|
}
|
|
426
|
-
},
|
|
427
|
-
|
|
428
|
-
},
|
|
429
|
-
|
|
442
|
+
}, re = (o) => {
|
|
443
|
+
c.pageSize = o, W();
|
|
444
|
+
}, ne = (o) => {
|
|
445
|
+
c.pageNum = o, O();
|
|
430
446
|
};
|
|
431
|
-
return M(
|
|
432
|
-
refresh:
|
|
447
|
+
return M(O), s({
|
|
448
|
+
refresh: O,
|
|
433
449
|
// 刷新表格
|
|
434
|
-
search:
|
|
450
|
+
search: W,
|
|
435
451
|
// 按当前条件搜索
|
|
436
|
-
handleDelete:
|
|
452
|
+
handleDelete: K,
|
|
437
453
|
// 手动触发删除
|
|
438
|
-
openDialog:
|
|
454
|
+
openDialog: L,
|
|
439
455
|
// 手动打开弹窗
|
|
440
|
-
submit:
|
|
456
|
+
submit: z
|
|
441
457
|
// 手动提交
|
|
442
|
-
}), (
|
|
443
|
-
const
|
|
444
|
-
return
|
|
445
|
-
class:
|
|
458
|
+
}), (o, t) => {
|
|
459
|
+
const r = g("el-button"), v = g("el-form-item"), E = g("el-form"), F = g("el-table-column"), Q = g("el-popconfirm"), ie = g("el-table"), se = g("el-pagination"), ue = g("el-skeleton"), X = g("el-dialog"), de = g("el-icon"), pe = ve("loading");
|
|
460
|
+
return n(), _("div", {
|
|
461
|
+
class: be([k.value, "crud-table-container"])
|
|
446
462
|
}, [
|
|
447
|
-
e.showSearchSection ? (
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
model:
|
|
463
|
+
e.showSearchSection ? (n(), _("div", Oe, [
|
|
464
|
+
h(o.$slots, "header", {}, void 0, !0),
|
|
465
|
+
C("div", Re, [
|
|
466
|
+
w(E, {
|
|
467
|
+
model: c,
|
|
452
468
|
class: "query-form flex flex-nowrap items-center gap-x-4",
|
|
453
469
|
style: { "overflow-x": "auto", "padding-bottom": "8px" }
|
|
454
470
|
}, {
|
|
455
471
|
default: p(() => [
|
|
456
|
-
|
|
457
|
-
|
|
472
|
+
h(o.$slots, "query-conditions", { searchForm: c }, void 0, !0),
|
|
473
|
+
w(v, { class: "!mr-0 flex-shrink-0" }, {
|
|
458
474
|
default: p(() => [
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
e.showSearchActionButtons ? (
|
|
462
|
-
|
|
475
|
+
C("div", Pe, [
|
|
476
|
+
h(o.$slots, "query-left", { searchForm: c }, void 0, !0),
|
|
477
|
+
e.showSearchActionButtons ? (n(), _(T, { key: 0 }, [
|
|
478
|
+
w(r, {
|
|
463
479
|
type: "primary",
|
|
464
|
-
onClick:
|
|
465
|
-
loading:
|
|
480
|
+
onClick: W,
|
|
481
|
+
loading: i.value
|
|
466
482
|
}, {
|
|
467
|
-
default: p(() => [...
|
|
468
|
-
|
|
483
|
+
default: p(() => [...t[8] || (t[8] = [
|
|
484
|
+
U("搜索", -1)
|
|
469
485
|
])]),
|
|
470
486
|
_: 1
|
|
471
487
|
}, 8, ["loading"]),
|
|
472
|
-
|
|
473
|
-
default: p(() => [...
|
|
474
|
-
|
|
488
|
+
w(r, { onClick: le }, {
|
|
489
|
+
default: p(() => [...t[9] || (t[9] = [
|
|
490
|
+
U("清空", -1)
|
|
475
491
|
])]),
|
|
476
492
|
_: 1
|
|
477
493
|
})
|
|
478
494
|
], 64)) : b("", !0),
|
|
479
|
-
|
|
495
|
+
h(o.$slots, "query-right", { searchForm: c }, void 0, !0)
|
|
480
496
|
])
|
|
481
497
|
]),
|
|
482
498
|
_: 3
|
|
@@ -484,124 +500,124 @@ const Ve = /* @__PURE__ */ L({
|
|
|
484
500
|
]),
|
|
485
501
|
_: 3
|
|
486
502
|
}, 8, ["model"]),
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
e.showNewBtn ? (
|
|
503
|
+
C("div", Te, [
|
|
504
|
+
h(o.$slots, "action-left", { selections: m.value }, void 0, !0),
|
|
505
|
+
h(o.$slots, "add-button-content", { selections: m.value }, () => [
|
|
506
|
+
e.showNewBtn ? (n(), f(r, {
|
|
491
507
|
key: 0,
|
|
492
508
|
type: "success",
|
|
493
|
-
onClick:
|
|
509
|
+
onClick: t[0] || (t[0] = (a) => L("add"))
|
|
494
510
|
}, {
|
|
495
|
-
default: p(() => [...
|
|
496
|
-
|
|
511
|
+
default: p(() => [...t[10] || (t[10] = [
|
|
512
|
+
U("新增", -1)
|
|
497
513
|
])]),
|
|
498
514
|
_: 1
|
|
499
515
|
})) : b("", !0)
|
|
500
516
|
], !0),
|
|
501
|
-
|
|
517
|
+
h(o.$slots, "action-right", { selections: m.value }, void 0, !0)
|
|
502
518
|
])
|
|
503
519
|
])
|
|
504
520
|
])) : b("", !0),
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
data:
|
|
521
|
+
C("div", Ne, [
|
|
522
|
+
he((n(), f(ie, A({
|
|
523
|
+
data: B.value,
|
|
508
524
|
"element-loading-text": e.loadingText,
|
|
509
525
|
"element-loading-background": e.loadingBackground,
|
|
510
|
-
onSelectionChange:
|
|
511
|
-
},
|
|
526
|
+
onSelectionChange: ae
|
|
527
|
+
}, o.$attrs, {
|
|
512
528
|
height: "100%",
|
|
513
529
|
style: { width: "100%" }
|
|
514
530
|
}), {
|
|
515
531
|
default: p(() => [
|
|
516
|
-
e.showSelectionColumn ? (
|
|
532
|
+
e.showSelectionColumn ? (n(), f(F, {
|
|
517
533
|
key: 0,
|
|
518
534
|
type: "selection",
|
|
519
535
|
width: "55",
|
|
520
536
|
fixed: ""
|
|
521
537
|
})) : b("", !0),
|
|
522
|
-
e.showIndexColumn ? (
|
|
538
|
+
e.showIndexColumn ? (n(), f(F, {
|
|
523
539
|
key: 1,
|
|
524
540
|
type: "index",
|
|
525
541
|
label: "序号",
|
|
526
542
|
width: "70",
|
|
527
543
|
fixed: ""
|
|
528
544
|
})) : b("", !0),
|
|
529
|
-
(
|
|
530
|
-
key:
|
|
531
|
-
prop:
|
|
532
|
-
label:
|
|
533
|
-
width:
|
|
534
|
-
sortable:
|
|
535
|
-
}, { ref_for: !0 },
|
|
545
|
+
(n(!0), _(T, null, j(e.columns, (a) => (n(), f(F, A({
|
|
546
|
+
key: a.prop,
|
|
547
|
+
prop: a.prop,
|
|
548
|
+
label: a.label,
|
|
549
|
+
width: a.width,
|
|
550
|
+
sortable: a.sortable || !1
|
|
551
|
+
}, { ref_for: !0 }, a.attrs), we({
|
|
536
552
|
header: p(() => [
|
|
537
|
-
|
|
553
|
+
a.headerTooltip ? (n(), f(ze, {
|
|
538
554
|
key: 0,
|
|
539
|
-
label:
|
|
540
|
-
placement:
|
|
541
|
-
}, null, 8, ["label", "placement"])) : (
|
|
555
|
+
label: a.label,
|
|
556
|
+
placement: a.placement
|
|
557
|
+
}, null, 8, ["label", "placement"])) : (n(), _("span", We, N(a.label), 1))
|
|
542
558
|
]),
|
|
543
559
|
_: 2
|
|
544
560
|
}, [
|
|
545
|
-
|
|
561
|
+
a.slot ? {
|
|
546
562
|
name: "default",
|
|
547
563
|
fn: p((I) => [
|
|
548
|
-
|
|
564
|
+
h(o.$slots, a.slot, {
|
|
549
565
|
row: I.row
|
|
550
566
|
}, void 0, !0)
|
|
551
567
|
]),
|
|
552
568
|
key: "0"
|
|
553
569
|
} : void 0
|
|
554
570
|
]), 1040, ["prop", "label", "width", "sortable"]))), 128)),
|
|
555
|
-
e.showActionsColumn ? (
|
|
571
|
+
e.showActionsColumn ? (n(), f(F, {
|
|
556
572
|
key: 2,
|
|
557
573
|
label: "操作",
|
|
558
|
-
width:
|
|
574
|
+
width: u.actionsColumnWidth
|
|
559
575
|
}, {
|
|
560
|
-
default: p((
|
|
561
|
-
|
|
562
|
-
|
|
576
|
+
default: p((a) => [
|
|
577
|
+
a.row ? (n(), _("div", Ee, [
|
|
578
|
+
o.$slots.actions ? h(o.$slots, "actions", {
|
|
563
579
|
key: 0,
|
|
564
|
-
row:
|
|
565
|
-
}, void 0, !0) : (
|
|
566
|
-
|
|
567
|
-
row:
|
|
580
|
+
row: a.row
|
|
581
|
+
}, void 0, !0) : (n(), _(T, { key: 1 }, [
|
|
582
|
+
h(o.$slots, "action-before-edit", {
|
|
583
|
+
row: a.row
|
|
568
584
|
}, void 0, !0),
|
|
569
|
-
e.showEditButton ? (
|
|
585
|
+
e.showEditButton ? (n(), f(r, {
|
|
570
586
|
key: 0,
|
|
571
587
|
size: "small",
|
|
572
588
|
type: "primary",
|
|
573
589
|
link: "",
|
|
574
|
-
onClick: (I) =>
|
|
590
|
+
onClick: (I) => L("edit", a.row)
|
|
575
591
|
}, {
|
|
576
|
-
default: p(() => [...
|
|
577
|
-
|
|
592
|
+
default: p(() => [...t[11] || (t[11] = [
|
|
593
|
+
U("编辑 ", -1)
|
|
578
594
|
])]),
|
|
579
595
|
_: 1
|
|
580
596
|
}, 8, ["onClick"])) : b("", !0),
|
|
581
|
-
e.showDeleteButton ? (
|
|
597
|
+
e.showDeleteButton ? (n(), f(Q, {
|
|
582
598
|
key: 1,
|
|
583
599
|
title: "确定要删除这条数据吗?",
|
|
584
|
-
onConfirm: (I) =>
|
|
600
|
+
onConfirm: (I) => K([a.row.id]),
|
|
585
601
|
"confirm-button-text": "确定",
|
|
586
602
|
"cancel-button-text": "取消",
|
|
587
603
|
width: "200"
|
|
588
604
|
}, {
|
|
589
605
|
reference: p(() => [
|
|
590
|
-
|
|
606
|
+
w(r, {
|
|
591
607
|
size: "small",
|
|
592
608
|
type: "danger",
|
|
593
609
|
link: ""
|
|
594
610
|
}, {
|
|
595
|
-
default: p(() => [...
|
|
596
|
-
|
|
611
|
+
default: p(() => [...t[12] || (t[12] = [
|
|
612
|
+
U("删除", -1)
|
|
597
613
|
])]),
|
|
598
614
|
_: 1
|
|
599
615
|
})
|
|
600
616
|
]),
|
|
601
617
|
_: 1
|
|
602
618
|
}, 8, ["onConfirm"])) : b("", !0),
|
|
603
|
-
|
|
604
|
-
row:
|
|
619
|
+
h(o.$slots, "action-after-delete", {
|
|
620
|
+
row: a.row
|
|
605
621
|
}, void 0, !0)
|
|
606
622
|
], 64))
|
|
607
623
|
])) : b("", !0)
|
|
@@ -611,89 +627,165 @@ const Ve = /* @__PURE__ */ L({
|
|
|
611
627
|
]),
|
|
612
628
|
_: 3
|
|
613
629
|
}, 16, ["data", "element-loading-text", "element-loading-background"])), [
|
|
614
|
-
[
|
|
630
|
+
[pe, i.value]
|
|
615
631
|
])
|
|
616
632
|
]),
|
|
617
|
-
e.showPagination &&
|
|
618
|
-
|
|
619
|
-
"current-page":
|
|
620
|
-
"onUpdate:currentPage":
|
|
621
|
-
"page-size":
|
|
622
|
-
"onUpdate:pageSize":
|
|
633
|
+
e.showPagination && S.value > 0 ? (n(), _("div", je, [
|
|
634
|
+
w(se, {
|
|
635
|
+
"current-page": c.pageNum,
|
|
636
|
+
"onUpdate:currentPage": t[1] || (t[1] = (a) => c.pageNum = a),
|
|
637
|
+
"page-size": c.pageSize,
|
|
638
|
+
"onUpdate:pageSize": t[2] || (t[2] = (a) => c.pageSize = a),
|
|
623
639
|
"page-sizes": e.pageSizes,
|
|
624
640
|
layout: e.paginationLayout,
|
|
625
|
-
total:
|
|
641
|
+
total: S.value,
|
|
626
642
|
background: e.paginationBackground,
|
|
627
643
|
small: e.paginationSmall,
|
|
628
644
|
"hide-on-single-page": e.paginationHideOnSinglePage,
|
|
629
|
-
onSizeChange:
|
|
630
|
-
onCurrentChange:
|
|
645
|
+
onSizeChange: re,
|
|
646
|
+
onCurrentChange: ne
|
|
631
647
|
}, null, 8, ["current-page", "page-size", "page-sizes", "layout", "total", "background", "small", "hide-on-single-page"])
|
|
632
648
|
])) : b("", !0),
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
649
|
+
e.dialogFullscreen ? (n(), f(X, {
|
|
650
|
+
key: 3,
|
|
651
|
+
modelValue: l.visible,
|
|
652
|
+
"onUpdate:modelValue": t[7] || (t[7] = (a) => l.visible = a),
|
|
653
|
+
fullscreen: !0,
|
|
638
654
|
width: e.dialogWidth,
|
|
639
655
|
"destroy-on-close": !0,
|
|
640
656
|
modal: !e.dialogFullscreen,
|
|
641
|
-
"custom-class":
|
|
657
|
+
"custom-class": V.value,
|
|
658
|
+
"show-close": !1,
|
|
642
659
|
style: { display: "flex", "flex-direction": "column", "max-height": "100vh" }
|
|
660
|
+
}, {
|
|
661
|
+
header: p(() => [
|
|
662
|
+
C("div", Qe, [
|
|
663
|
+
w(r, {
|
|
664
|
+
type: "info",
|
|
665
|
+
text: "",
|
|
666
|
+
onClick: t[5] || (t[5] = (a) => l.visible = !1),
|
|
667
|
+
style: { "margin-right": "12px" }
|
|
668
|
+
}, {
|
|
669
|
+
default: p(() => [
|
|
670
|
+
w(de, { size: "20" }, {
|
|
671
|
+
default: p(() => [
|
|
672
|
+
w(_e(De))
|
|
673
|
+
]),
|
|
674
|
+
_: 1
|
|
675
|
+
})
|
|
676
|
+
]),
|
|
677
|
+
_: 1
|
|
678
|
+
}),
|
|
679
|
+
C("span", Ie, N(H.value), 1)
|
|
680
|
+
])
|
|
681
|
+
]),
|
|
682
|
+
footer: p(() => [
|
|
683
|
+
C("span", He, [
|
|
684
|
+
w(r, {
|
|
685
|
+
onClick: t[6] || (t[6] = (a) => l.visible = !1)
|
|
686
|
+
}, {
|
|
687
|
+
default: p(() => [...t[15] || (t[15] = [
|
|
688
|
+
U("取消", -1)
|
|
689
|
+
])]),
|
|
690
|
+
_: 1
|
|
691
|
+
}),
|
|
692
|
+
w(r, {
|
|
693
|
+
type: "primary",
|
|
694
|
+
onClick: J,
|
|
695
|
+
loading: l.submitting
|
|
696
|
+
}, {
|
|
697
|
+
default: p(() => [...t[16] || (t[16] = [
|
|
698
|
+
U(" 确定 ", -1)
|
|
699
|
+
])]),
|
|
700
|
+
_: 1
|
|
701
|
+
}, 8, ["loading"])
|
|
702
|
+
])
|
|
703
|
+
]),
|
|
704
|
+
default: p(() => [
|
|
705
|
+
C("div", Me, [
|
|
706
|
+
o.$slots["dialog-form"] ? h(o.$slots, "dialog-form", {
|
|
707
|
+
key: 0,
|
|
708
|
+
formData: l.data,
|
|
709
|
+
mode: l.mode,
|
|
710
|
+
formRef: (a) => {
|
|
711
|
+
l.formRef = a;
|
|
712
|
+
}
|
|
713
|
+
}, void 0, !0) : l.loading ? b("", !0) : (n(), f(Z, {
|
|
714
|
+
key: 1,
|
|
715
|
+
ref: (a) => {
|
|
716
|
+
l.formRef = a;
|
|
717
|
+
},
|
|
718
|
+
"model-value": l.data,
|
|
719
|
+
"form-config": G.value,
|
|
720
|
+
rules: e.dialogFormRules,
|
|
721
|
+
"label-width": e.dialogFormLabelWidth
|
|
722
|
+
}, null, 8, ["model-value", "form-config", "rules", "label-width"]))
|
|
723
|
+
])
|
|
724
|
+
]),
|
|
725
|
+
_: 3
|
|
726
|
+
}, 8, ["modelValue", "width", "modal", "custom-class"])) : (n(), f(X, {
|
|
727
|
+
key: 2,
|
|
728
|
+
modelValue: l.visible,
|
|
729
|
+
"onUpdate:modelValue": t[4] || (t[4] = (a) => l.visible = a),
|
|
730
|
+
title: H.value,
|
|
731
|
+
width: e.dialogWidth,
|
|
732
|
+
"destroy-on-close": !0,
|
|
733
|
+
"custom-class": V.value,
|
|
734
|
+
style: { display: "flex", "flex-direction": "column", "max-height": "80vh" }
|
|
643
735
|
}, {
|
|
644
736
|
footer: p(() => [
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
onClick:
|
|
737
|
+
C("span", Le, [
|
|
738
|
+
w(r, {
|
|
739
|
+
onClick: t[3] || (t[3] = (a) => l.visible = !1)
|
|
648
740
|
}, {
|
|
649
|
-
default: p(() => [...
|
|
650
|
-
|
|
741
|
+
default: p(() => [...t[13] || (t[13] = [
|
|
742
|
+
U("取消", -1)
|
|
651
743
|
])]),
|
|
652
744
|
_: 1
|
|
653
745
|
}),
|
|
654
|
-
|
|
746
|
+
w(r, {
|
|
655
747
|
type: "primary",
|
|
656
|
-
onClick:
|
|
657
|
-
loading:
|
|
748
|
+
onClick: J,
|
|
749
|
+
loading: l.submitting
|
|
658
750
|
}, {
|
|
659
|
-
default: p(() => [...
|
|
660
|
-
|
|
751
|
+
default: p(() => [...t[14] || (t[14] = [
|
|
752
|
+
U(" 确定 ", -1)
|
|
661
753
|
])]),
|
|
662
754
|
_: 1
|
|
663
755
|
}, 8, ["loading"])
|
|
664
756
|
])
|
|
665
757
|
]),
|
|
666
758
|
default: p(() => [
|
|
667
|
-
|
|
668
|
-
|
|
759
|
+
C("div", qe, [
|
|
760
|
+
o.$slots["dialog-form"] ? h(o.$slots, "dialog-form", {
|
|
669
761
|
key: 0,
|
|
670
|
-
formData:
|
|
671
|
-
mode:
|
|
672
|
-
formRef: (
|
|
673
|
-
|
|
762
|
+
formData: l.data,
|
|
763
|
+
mode: l.mode,
|
|
764
|
+
formRef: (a) => {
|
|
765
|
+
l.formRef = a;
|
|
674
766
|
}
|
|
675
|
-
}, void 0, !0) :
|
|
767
|
+
}, void 0, !0) : l.loading ? (n(), f(ue, {
|
|
676
768
|
key: 1,
|
|
677
769
|
rows: 5,
|
|
678
770
|
animated: ""
|
|
679
|
-
})) :
|
|
771
|
+
})) : l.loading ? b("", !0) : (n(), f(Z, {
|
|
680
772
|
key: 2,
|
|
681
|
-
ref: (
|
|
682
|
-
|
|
773
|
+
ref: (a) => {
|
|
774
|
+
l.formRef = a;
|
|
683
775
|
},
|
|
684
|
-
"model-value":
|
|
685
|
-
"form-config":
|
|
776
|
+
"model-value": l.data,
|
|
777
|
+
"form-config": G.value,
|
|
686
778
|
rules: e.dialogFormRules,
|
|
687
779
|
"label-width": e.dialogFormLabelWidth
|
|
688
780
|
}, null, 8, ["model-value", "form-config", "rules", "label-width"]))
|
|
689
781
|
])
|
|
690
782
|
]),
|
|
691
783
|
_: 3
|
|
692
|
-
}, 8, ["modelValue", "
|
|
784
|
+
}, 8, ["modelValue", "title", "width", "custom-class"]))
|
|
693
785
|
], 2);
|
|
694
786
|
};
|
|
695
787
|
}
|
|
696
|
-
}),
|
|
788
|
+
}), Ye = /* @__PURE__ */ oe(Ge, [["__scopeId", "data-v-833f1fc3"]]);
|
|
697
789
|
export {
|
|
698
|
-
|
|
790
|
+
Ye as CrudTable
|
|
699
791
|
};
|
|
@@ -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,O){"use strict";const $=e.defineComponent({__name:"DynamicForm",props:{modelValue:{},formConfig:{},rules:{}},setup(c,{expose:a}){const u=e.ref(null);return a({validate:()=>{var d;return(d=u.value)==null?void 0:d.validate()}}),(d,t)=>{const g=e.resolveComponent("el-input"),B=e.resolveComponent("el-option"),k=e.resolveComponent("el-select"),_=e.resolveComponent("el-radio"),p=e.resolveComponent("el-radio-group"),h=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:u},d.$attrs),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.formConfig,r=>(e.openBlock(),e.createBlock(h,{key:r.prop,label:r.label,prop:r.prop},{default:e.withCtx(()=>[r.type==="input"?(e.openBlock(),e.createBlock(g,e.mergeProps({key:0,modelValue:d.modelValue[r.prop],"onUpdate:modelValue":f=>d.modelValue[r.prop]=f},{ref_for:!0},r.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),r.type==="textarea"?(e.openBlock(),e.createBlock(g,e.mergeProps({key:1,type:"textarea",modelValue:d.modelValue[r.prop],"onUpdate:modelValue":f=>d.modelValue[r.prop]=f},{ref_for:!0},r.componentProps),null,16,["modelValue","onUpdate:modelValue"])):e.createCommentVNode("",!0),r.type==="select"?(e.openBlock(),e.createBlock(k,e.mergeProps({key:2,modelValue:d.modelValue[r.prop],"onUpdate:modelValue":f=>d.modelValue[r.prop]=f},{ref_for:!0},r.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.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),r.type==="radio-group"?(e.openBlock(),e.createBlock(p,e.mergeProps({key:3,modelValue:d.modelValue[r.prop],"onUpdate:modelValue":f=>d.modelValue[r.prop]=f},{ref_for:!0},r.componentProps),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.options,f=>(e.openBlock(),e.createBlock(_,{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),r.type==="input-disabled"?(e.openBlock(),e.createBlock(g,e.mergeProps({key:4,"model-value":d.modelValue[r.prop],disabled:""},{ref_for:!0},r.componentProps),null,16,["model-value"])):e.createCommentVNode("",!0)]),_:2},1032,["label","prop"]))),128))]),_:1},16,["model","rules"])}}}),S=O.create({baseURL:"",timeout:1e4});S.interceptors.request.use(c=>{const a=localStorage.getItem("token");return a&&(c.headers.Authorization="Bearer "+a),c},c=>(console.log(c),Promise.reject(c))),S.interceptors.response.use(c=>{const a=c.data;return a.code!==200?(b.ElMessage({message:a.msg||"Error",type:"error",duration:5*1e3}),(a.code===401||a.code===403)&&b.ElMessageBox.confirm("您的登录状态已失效,请重新登录","确认登出",{confirmButtonText:"重新登录",cancelButtonText:"取消",type:"warning"}).then(()=>{localStorage.removeItem("token"),location.reload()}),Promise.reject(new Error(a.msg||"Error"))):a},c=>(console.log("HTTP Error: "+c),b.ElMessage({message:"网络错误,请检查您的网络连接或联系管理员",type:"error",duration:5*1e3}),Promise.reject(c)));function z(c){return e.getCurrentScope()?(e.onScopeDispose(c),!0):!1}const P=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const R=P?window:void 0;function F(c){var a;const u=e.toValue(c);return(a=u==null?void 0:u.$el)!=null?a:u}function j(){const c=e.shallowRef(!1),a=e.getCurrentInstance();return a&&e.onMounted(()=>{c.value=!0},a),c}function q(c){const a=j();return e.computed(()=>(a.value,!!c()))}function M(c,a,u={}){const{window:d=R,...t}=u;let g;const B=q(()=>d&&"ResizeObserver"in d),k=()=>{g&&(g.disconnect(),g=void 0)},_=e.computed(()=>{const y=e.toValue(c);return Array.isArray(y)?y.map(r=>F(r)):[F(y)]}),p=e.watch(_,y=>{if(k(),B.value&&d){g=new ResizeObserver(a);for(const r of y)r&&g.observe(r,t)}},{immediate:!0,flush:"post"}),h=()=>{k(),p()};return z(h),{isSupported:B,stop:h}}const W=e.defineComponent({__name:"TableHeaderWithTooltip",props:{label:{},placement:{}},setup(c){const a=e.ref(null),u=e.ref(!1),d=()=>{a.value&&(u.value=a.value.scrollWidth>a.value.clientWidth)};return e.onMounted(()=>{d()}),M(a,()=>{d()}),(t,g)=>{const B=e.resolveComponent("el-tooltip");return u.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:a,class:"header-cell-content"},e.toDisplayString(t.label),513)]),_:1},8,["content","placement"])):(e.openBlock(),e.createElementBlock("span",{key:0,ref_key:"textRef",ref:a,class:"header-cell-content"},e.toDisplayString(t.label),513))}}}),T=(c,a)=>{const u=c.__vccOpts||c;for(const[d,t]of a)u[d]=t;return u},Q=T(W,[["__scopeId","data-v-d23c8660"]]),I={key:0,class:"search-section-wrapper"},L={class:"flex flex-wrap items-center justify-between gap-4"},H={class:"flex items-center gap-x-2"},G={class:"flex items-center gap-x-3 action-buttons flex-shrink-0"},Z={class:"table-content-wrapper"},J={key:1},K={key:0,class:"flex items-center gap-x-2"},X={key:1,class:"pagination-wrapper flex justify-end mt-2"},Y={style:{"overflow-y":"auto",flex:"1"}},v={class:"dialog-footer"},ee=T(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},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}},emits:["open-dialog","submit","delete"],setup(c,{expose:a,emit:u}){const d=u,t=c,g=e.computed(()=>["crud-table-wrapper",`theme-${t.theme}`,t.customClass]),B=e.computed(()=>t.theme==="large-screen"?"large-screen-dialog":""),k=(o,l)=>o?!0:(b.ElMessage.error(`${l} prop is required.`),!1),_=async(o,l)=>{try{let n={...l};t.onBeforeSubmit&&(n=await t.onBeforeSubmit(n,o));let m=n;if(t.submitAsFormData){const N=new FormData;for(const C in n)if(Object.prototype.hasOwnProperty.call(n,C)){const U=n[C];N.append(C,U??"")}m=N}if(i.submitting=!0,o==="add"){if(!k(t.apiUrlCreate,"apiUrlCreate"))throw new Error("apiUrlCreate is not configured.");await S.post(t.apiUrlCreate,m),b.ElMessage.success("新增成功")}else{if(!k(t.apiUrlUpdate,"apiUrlUpdate"))throw new Error("apiUrlUpdate is not configured.");await S.put(t.apiUrlUpdate,m),b.ElMessage.success("更新成功")}return t.onAfterSubmit&&t.onAfterSubmit(o,n),d("submit",{mode:o,data:n}),i.visible&&(i.visible=!1),V(),Promise.resolve()}catch(n){return console.error("Submit failed:",n),Promise.reject(n)}finally{i.submitting=!1}},p=e.reactive({pageNum:1,pageSize:10,...t.initialSearchForm}),h=e.ref([]),y=e.ref(0),r=e.ref(!1),f=e.ref([]),i=e.reactive({visible:!1,loading:!1,submitting:!1,mode:"add",data:{},formRef:null}),te=e.computed(()=>i.mode==="add"?"新增":"编辑"),oe=e.computed(()=>{if(i.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(k(t.apiUrlQuery,"apiUrlQuery")){r.value=!0;try{let o={...p};t.onBeforeQuery&&(o=await t.onBeforeQuery(o));const l=await S.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)),h.value=n,y.value=l.data.total}else console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),h.value=[],y.value=0}catch(o){console.error("Fetch data failed:",o)}finally{r.value=!1}}},D=()=>{p.pageNum=1,V()},le=()=>{const{pageNum:o,pageSize:l,...n}=t.initialSearchForm;Object.keys(p).forEach(m=>{m!=="pageNum"&&m!=="pageSize"&&delete p[m]}),Object.assign(p,n),D()},re=o=>{f.value=o},x=async(o,l)=>{let n;if(o==="add"?n=l?{...l}:{role:"user"}:n={...l},t.onBeforeOpenDialog){const m=await t.onBeforeOpenDialog(o,n);m&&(n=m)}if(i.mode=o,i.visible=!0,o==="edit"){if(!k(t.apiUrlDetail,"apiUrlDetail"))return;i.loading=!0;try{const m=await S.get(t.apiUrlDetail+"/"+n.id.toString());i.data=m.data.data}finally{i.loading=!1,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,i.data),d("open-dialog",{mode:o,data:i.data})}}else i.data=n,t.onAfterOpenDialog&&t.onAfterOpenDialog(o,i.data),d("open-dialog",{mode:o,data:i.data})},ne=async()=>{try{i.formRef?await i.formRef.validate():console.warn("Dialog form ref is not available for validation."),await _(i.mode,i.data)}catch(o){console.log("Validation or submit error:",o)}},A=async o=>{if(k(t.apiUrlDelete,"apiUrlDelete"))try{const l=h.value.filter(m=>o.includes(m.id));if(t.onBeforeDelete&&await t.onBeforeDelete(o,l)===!1)return;const n=o.join(",");await S.delete(t.apiUrlDelete+"/"+n.toString()),b.ElMessage.success("删除成功"),t.onAfterDelete&&t.onAfterDelete(o,l),d("delete",o),h.value.length===o.length&&p.pageNum>1&&p.pageNum--,V()}catch(l){console.error("Delete failed",l)}},ae=o=>{p.pageSize=o,D()},ie=o=>{p.pageNum=o,V()};return e.onMounted(V),a({refresh:V,search:D,handleDelete:A,openDialog:x,submit:_}),(o,l)=>{const n=e.resolveComponent("el-button"),m=e.resolveComponent("el-form-item"),N=e.resolveComponent("el-form"),C=e.resolveComponent("el-table-column"),U=e.resolveComponent("el-popconfirm"),se=e.resolveComponent("el-table"),de=e.resolveComponent("el-pagination"),ce=e.resolveComponent("el-skeleton"),pe=e.resolveComponent("el-dialog"),fe=e.resolveDirective("loading");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([g.value,"crud-table-container"])},[t.showSearchSection?(e.openBlock(),e.createElementBlock("div",I,[e.renderSlot(o.$slots,"header",{},void 0,!0),e.createElementVNode("div",L,[e.createVNode(N,{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(m,{class:"!mr-0 flex-shrink-0"},{default:e.withCtx(()=>[e.createElementVNode("div",H,[e.renderSlot(o.$slots,"query-left",{searchForm:p},void 0,!0),t.showSearchActionButtons?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(n,{type:"primary",onClick:D,loading:r.value},{default:e.withCtx(()=>[...l[5]||(l[5]=[e.createTextVNode("搜索",-1)])]),_:1},8,["loading"]),e.createVNode(n,{onClick:le},{default:e.withCtx(()=>[...l[6]||(l[6]=[e.createTextVNode("清空",-1)])]),_:1})],64)):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"query-right",{searchForm:p},void 0,!0)])]),_:3})]),_:3},8,["model"]),e.createElementVNode("div",G,[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,type:"success",onClick:l[0]||(l[0]=s=>x("add"))},{default:e.withCtx(()=>[...l[7]||(l[7]=[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",Z,[e.withDirectives((e.openBlock(),e.createBlock(se,e.mergeProps({data:h.value,"element-loading-text":t.loadingText,"element-loading-background":t.loadingBackground,onSelectionChange:re},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,s=>(e.openBlock(),e.createBlock(C,e.mergeProps({key:s.prop,prop:s.prop,label:s.label,width:s.width,sortable:s.sortable||!1},{ref_for:!0},s.attrs),e.createSlots({header:e.withCtx(()=>[s.headerTooltip?(e.openBlock(),e.createBlock(Q,{key:0,label:s.label,placement:s.placement},null,8,["label","placement"])):(e.openBlock(),e.createElementBlock("span",J,e.toDisplayString(s.label),1))]),_:2},[s.slot?{name:"default",fn:e.withCtx(E=>[e.renderSlot(o.$slots,s.slot,{row:E.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(s=>[s.row?(e.openBlock(),e.createElementBlock("div",K,[o.$slots.actions?e.renderSlot(o.$slots,"actions",{key:0,row:s.row},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(o.$slots,"action-before-edit",{row:s.row},void 0,!0),t.showEditButton?(e.openBlock(),e.createBlock(n,{key:0,size:"small",type:"primary",link:"",onClick:E=>x("edit",s.row)},{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode("编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),t.showDeleteButton?(e.openBlock(),e.createBlock(U,{key:1,title:"确定要删除这条数据吗?",onConfirm:E=>A([s.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[9]||(l[9]=[e.createTextVNode("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])):e.createCommentVNode("",!0),e.renderSlot(o.$slots,"action-after-delete",{row:s.row},void 0,!0)],64))])):e.createCommentVNode("",!0)]),_:3},8,["width"])):e.createCommentVNode("",!0)]),_:3},16,["data","element-loading-text","element-loading-background"])),[[fe,r.value]])]),t.showPagination&&y.value>0?(e.openBlock(),e.createElementBlock("div",X,[e.createVNode(de,{"current-page":p.pageNum,"onUpdate:currentPage":l[1]||(l[1]=s=>p.pageNum=s),"page-size":p.pageSize,"onUpdate:pageSize":l[2]||(l[2]=s=>p.pageSize=s),"page-sizes":t.pageSizes,layout:t.paginationLayout,total:y.value,background:t.paginationBackground,small:t.paginationSmall,"hide-on-single-page":t.paginationHideOnSinglePage,onSizeChange:ae,onCurrentChange:ie},null,8,["current-page","page-size","page-sizes","layout","total","background","small","hide-on-single-page"])])):e.createCommentVNode("",!0),e.createVNode(pe,{modelValue:i.visible,"onUpdate:modelValue":l[4]||(l[4]=s=>i.visible=s),fullscreen:t.dialogFullscreen,title:te.value,width:t.dialogWidth,"destroy-on-close":!0,modal:!t.dialogFullscreen,"custom-class":B.value,style:{display:"flex","flex-direction":"column","max-height":"100vh"}},{footer:e.withCtx(()=>[e.createElementVNode("span",v,[e.createVNode(n,{onClick:l[3]||(l[3]=s=>i.visible=!1)},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(n,{type:"primary",onClick:ne,loading:i.submitting},{default:e.withCtx(()=>[...l[11]||(l[11]=[e.createTextVNode(" 确定 ",-1)])]),_:1},8,["loading"])])]),default:e.withCtx(()=>[e.createElementVNode("div",Y,[o.$slots["dialog-form"]?e.renderSlot(o.$slots,"dialog-form",{key:0,formData:i.data,mode:i.mode,formRef:s=>{i.formRef=s}},void 0,!0):i.loading?(e.openBlock(),e.createBlock(ce,{key:1,rows:5,animated:""})):i.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock($,{key:2,ref:s=>{i.formRef=s},"model-value":i.data,"form-config":oe.value,rules:t.dialogFormRules,"label-width":t.dialogFormLabelWidth},null,8,["model-value","form-config","rules","label-width"]))])]),_:3},8,["modelValue","fullscreen","title","width","modal","custom-class"])],2)}}}),[["__scopeId","data-v-cfc138a6"]]);w.CrudTable=ee,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-833f1fc3]{display:flex;flex-direction:column;height:100%;width:100%;min-width:0;min-height:0;overflow:hidden}.search-section-wrapper[data-v-833f1fc3]{flex-shrink:0}.table-content-wrapper[data-v-833f1fc3]{flex:1;min-height:0;overflow:hidden}.pagination-wrapper[data-v-833f1fc3]{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,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 F=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"),C=e.resolveComponent("el-option"),h=e.resolveComponent("el-select"),V=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(C,{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(V,{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 T(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 C=H(()=>c&&"ResizeObserver"in c),h=()=>{u&&(u.disconnect(),u=void 0)},V=e.computed(()=>{const y=e.toValue(d);return Array.isArray(y)?y.map(i=>T(i)):[T(y)]}),p=e.watch(V,y=>{if(h(),C.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:C,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 C=e.resolveComponent("el-tooltip");return m.value?(e.openBlock(),e.createBlock(C,{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"},re={style:{"overflow-y":"auto",flex:"1"}},ae={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},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}},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]),C=e.computed(()=>t.theme==="large-screen"?"large-screen-dialog":""),h=(l,o)=>l?!0:(b.ElMessage.error(`${o} prop is required.`),!1),V=async(l,o)=>{try{let n={...o};t.onBeforeSubmit&&(n=await t.onBeforeSubmit(n,l));let g=n;if(t.submitAsFormData){const N=new FormData;for(const B in n)if(Object.prototype.hasOwnProperty.call(n,B)){const E=n[B];N.append(B,E??"")}g=N}if(r.submitting=!0,l==="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(l,n),c("submit",{mode:l,data:n}),r.visible&&(r.visible=!1),S(),Promise.resolve()}catch(n){return console.error("Submit failed:",n),Promise.reject(n)}finally{r.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([]),r=e.reactive({visible:!1,loading:!1,submitting:!1,mode:"add",data:{},formRef:null}),$=e.computed(()=>r.mode==="add"?"新增":"编辑"),z=e.computed(()=>{if(r.mode==="add")return t.dialogFormConfig.filter(o=>o.prop!=="id");const l=[...t.dialogFormConfig.filter(o=>o.prop!=="id")];return l.some(o=>o.prop==="id")||l.unshift({type:"input-disabled",prop:"id",label:"用户ID"}),l}),S=async()=>{if(h(t.apiUrlQuery,"apiUrlQuery")){i.value=!0;try{let l={...p};t.onBeforeQuery&&(l=await t.onBeforeQuery(l));const o=await _.get(t.apiUrlQuery,{params:l});if(o&&o.data&&Array.isArray(o.data.rows)&&typeof o.data.total=="number"){let n=o.data.rows;t.onAfterQuery&&(n=await t.onAfterQuery(n,l)),k.value=n,y.value=o.data.total}else console.warn("API response is not in the expected { data: { rows: [], total: 0 } } format."),k.value=[],y.value=0}catch(l){console.error("Fetch data failed:",l)}finally{i.value=!1}}},x=()=>{p.pageNum=1,S()},pe=()=>{const{pageNum:l,pageSize:o,...n}=t.initialSearchForm;Object.keys(p).forEach(g=>{g!=="pageNum"&&g!=="pageSize"&&delete p[g]}),Object.assign(p,n),x()},fe=l=>{f.value=l},D=async(l,o)=>{let n;if(l==="add"?n=o?{...o}:{role:"user"}:n={...o},t.onBeforeOpenDialog){const g=await t.onBeforeOpenDialog(l,n);g&&(n=g)}if(r.mode=l,r.visible=!0,l==="edit"){if(!h(t.apiUrlDetail,"apiUrlDetail"))return;r.loading=!0;try{const g=await _.get(t.apiUrlDetail+"/"+n.id.toString());r.data=g.data.data}finally{r.loading=!1,t.onAfterOpenDialog&&t.onAfterOpenDialog(l,r.data),c("open-dialog",{mode:l,data:r.data})}}else r.data=n,t.onAfterOpenDialog&&t.onAfterOpenDialog(l,r.data),c("open-dialog",{mode:l,data:r.data})},O=async()=>{try{r.formRef?await r.formRef.validate():console.warn("Dialog form ref is not available for validation."),await V(r.mode,r.data)}catch(l){console.log("Validation or submit error:",l)}},R=async l=>{if(h(t.apiUrlDelete,"apiUrlDelete"))try{const o=k.value.filter(g=>l.includes(g.id));if(t.onBeforeDelete&&await t.onBeforeDelete(l,o)===!1)return;const n=l.join(",");await _.delete(t.apiUrlDelete+"/"+n.toString()),b.ElMessage.success("删除成功"),t.onAfterDelete&&t.onAfterDelete(l,o),c("delete",l),k.value.length===l.length&&p.pageNum>1&&p.pageNum--,S()}catch(o){console.error("Delete failed",o)}},me=l=>{p.pageSize=l,x()},ge=l=>{p.pageNum=l,S()};return e.onMounted(S),s({refresh:S,search:x,handleDelete:R,openDialog:D,submit:V}),(l,o)=>{const n=e.resolveComponent("el-button"),g=e.resolveComponent("el-form-item"),N=e.resolveComponent("el-form"),B=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(l.$slots,"header",{},void 0,!0),e.createElementVNode("div",X,[e.createVNode(N,{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(l.$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(l.$slots,"query-left",{searchForm:p},void 0,!0),t.showSearchActionButtons?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createVNode(n,{type:"primary",onClick:x,loading:i.value},{default:e.withCtx(()=>[...o[8]||(o[8]=[e.createTextVNode("搜索",-1)])]),_:1},8,["loading"]),e.createVNode(n,{onClick:pe},{default:e.withCtx(()=>[...o[9]||(o[9]=[e.createTextVNode("清空",-1)])]),_:1})],64)):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"query-right",{searchForm:p},void 0,!0)])]),_:3})]),_:3},8,["model"]),e.createElementVNode("div",v,[e.renderSlot(l.$slots,"action-left",{selections:f.value},void 0,!0),e.renderSlot(l.$slots,"add-button-content",{selections:f.value},()=>[t.showNewBtn?(e.openBlock(),e.createBlock(n,{key:0,type:"success",onClick:o[0]||(o[0]=a=>D("add"))},{default:e.withCtx(()=>[...o[10]||(o[10]=[e.createTextVNode("新增",-1)])]),_:1})):e.createCommentVNode("",!0)],!0),e.renderSlot(l.$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},l.$attrs,{height:"100%",style:{width:"100%"}}),{default:e.withCtx(()=>[t.showSelectionColumn?(e.openBlock(),e.createBlock(B,{key:0,type:"selection",width:"55",fixed:""})):e.createCommentVNode("",!0),t.showIndexColumn?(e.openBlock(),e.createBlock(B,{key:1,type:"index",label:"序号",width:"70",fixed:""})):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,a=>(e.openBlock(),e.createBlock(B,e.mergeProps({key:a.prop,prop:a.prop,label:a.label,width:a.width,sortable:a.sortable||!1},{ref_for:!0},a.attrs),e.createSlots({header:e.withCtx(()=>[a.headerTooltip?(e.openBlock(),e.createBlock(J,{key:0,label:a.label,placement:a.placement},null,8,["label","placement"])):(e.openBlock(),e.createElementBlock("span",te,e.toDisplayString(a.label),1))]),_:2},[a.slot?{name:"default",fn:e.withCtx(U=>[e.renderSlot(l.$slots,a.slot,{row:U.row},void 0,!0)]),key:"0"}:void 0]),1040,["prop","label","width","sortable"]))),128)),t.showActionsColumn?(e.openBlock(),e.createBlock(B,{key:2,label:"操作",width:d.actionsColumnWidth},{default:e.withCtx(a=>[a.row?(e.openBlock(),e.createElementBlock("div",oe,[l.$slots.actions?e.renderSlot(l.$slots,"actions",{key:0,row:a.row},void 0,!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.renderSlot(l.$slots,"action-before-edit",{row:a.row},void 0,!0),t.showEditButton?(e.openBlock(),e.createBlock(n,{key:0,size:"small",type:"primary",link:"",onClick:U=>D("edit",a.row)},{default:e.withCtx(()=>[...o[11]||(o[11]=[e.createTextVNode("编辑 ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),t.showDeleteButton?(e.openBlock(),e.createBlock(E,{key:1,title:"确定要删除这条数据吗?",onConfirm:U=>R([a.row.id]),"confirm-button-text":"确定","cancel-button-text":"取消",width:"200"},{reference:e.withCtx(()=>[e.createVNode(n,{size:"small",type:"danger",link:""},{default:e.withCtx(()=>[...o[12]||(o[12]=[e.createTextVNode("删除",-1)])]),_:1})]),_:1},8,["onConfirm"])):e.createCommentVNode("",!0),e.renderSlot(l.$slots,"action-after-delete",{row:a.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":o[1]||(o[1]=a=>p.pageNum=a),"page-size":p.pageSize,"onUpdate:pageSize":o[2]||(o[2]=a=>p.pageSize=a),"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:r.visible,"onUpdate:modelValue":o[7]||(o[7]=a=>r.visible=a),fullscreen:!0,width:t.dialogWidth,"destroy-on-close":!0,modal:!t.dialogFullscreen,"custom-class":C.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:o[5]||(o[5]=a=>r.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($.value),1)])]),footer:e.withCtx(()=>[e.createElementVNode("span",de,[e.createVNode(n,{onClick:o[6]||(o[6]=a=>r.visible=!1)},{default:e.withCtx(()=>[...o[15]||(o[15]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(n,{type:"primary",onClick:O,loading:r.submitting},{default:e.withCtx(()=>[...o[16]||(o[16]=[e.createTextVNode(" 确定 ",-1)])]),_:1},8,["loading"])])]),default:e.withCtx(()=>[e.createElementVNode("div",se,[l.$slots["dialog-form"]?e.renderSlot(l.$slots,"dialog-form",{key:0,formData:r.data,mode:r.mode,formRef:a=>{r.formRef=a}},void 0,!0):r.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(F,{key:1,ref:a=>{r.formRef=a},"model-value":r.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:r.visible,"onUpdate:modelValue":o[4]||(o[4]=a=>r.visible=a),title:$.value,width:t.dialogWidth,"destroy-on-close":!0,"custom-class":C.value,style:{display:"flex","flex-direction":"column","max-height":"80vh"}},{footer:e.withCtx(()=>[e.createElementVNode("span",ae,[e.createVNode(n,{onClick:o[3]||(o[3]=a=>r.visible=!1)},{default:e.withCtx(()=>[...o[13]||(o[13]=[e.createTextVNode("取消",-1)])]),_:1}),e.createVNode(n,{type:"primary",onClick:O,loading:r.submitting},{default:e.withCtx(()=>[...o[14]||(o[14]=[e.createTextVNode(" 确定 ",-1)])]),_:1},8,["loading"])])]),default:e.withCtx(()=>[e.createElementVNode("div",re,[l.$slots["dialog-form"]?e.renderSlot(l.$slots,"dialog-form",{key:0,formData:r.data,mode:r.mode,formRef:a=>{r.formRef=a}},void 0,!0):r.loading?(e.openBlock(),e.createBlock(he,{key:1,rows:5,animated:""})):r.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(F,{key:2,ref:a=>{r.formRef=a},"model-value":r.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-833f1fc3"]]);w.CrudTable=ce,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
|