zxt-table 0.0.1
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/README.md +5 -0
- package/dist/vite.svg +1 -0
- package/dist/zxt-table.css +1 -0
- package/dist/zxt-table.es.js +418 -0
- package/dist/zxt-table.umd.js +1 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Vue 3 + Vite
|
|
2
|
+
|
|
3
|
+
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
|
4
|
+
|
|
5
|
+
Learn more about IDE Support for Vue in the [Vue Docs Scaling up Guide](https://vuejs.org/guide/scaling-up/tooling.html#ide-support).
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.my-button[data-v-4480e77d]{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;text-align:center;box-sizing:border-box;outline:none;margin:0;transition:.1s;font-weight:500;padding:12px 20px;font-size:14px;border-radius:4px}.my-button--primary[data-v-4480e77d]{color:#fff;background-color:#409eff;border-color:#409eff}.my-button--success[data-v-4480e77d]{color:#fff;background-color:#67c23a;border-color:#67c23a}.my-button--warning[data-v-4480e77d]{color:#fff;background-color:#e6a23c;border-color:#e6a23c}.my-button--danger[data-v-4480e77d]{color:#fff;background-color:#f56c6c;border-color:#f56c6c}.my-button.is-disabled[data-v-4480e77d]{cursor:not-allowed;opacity:.7}.jsx-button{display:inline-block;line-height:1;white-space:nowrap;cursor:pointer;background:#fff;border:1px solid #dcdfe6;color:#606266;text-align:center;box-sizing:border-box;outline:none;margin:0;transition:.1s;font-weight:500;padding:12px 20px;font-size:14px;border-radius:4px}.jsx-button--primary{color:#fff;background-color:#409eff;border-color:#409eff}.jsx-button--success{color:#fff;background-color:#67c23a;border-color:#67c23a}.jsx-button--warning{color:#fff;background-color:#e6a23c;border-color:#e6a23c}.jsx-button--danger{color:#fff;background-color:#f56c6c;border-color:#f56c6c}.jsx-button.is-disabled{cursor:not-allowed;opacity:.7}.zxt-form-container[data-v-2148c373]{padding:20px}.form-actions[data-v-2148c373]{display:flex;justify-content:center;margin-top:30px;gap:10px}.zxt-pagination[data-v-e6813cef]{display:flex;justify-content:flex-end;margin-top:20px}.zxt-table-container[data-v-aca49573]{width:100%}
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { createElementBlock as h, openBlock as r, normalizeClass as O, renderSlot as _, defineComponent as D, createVNode as $, ref as C, reactive as A, watch as B, computed as v, resolveComponent as p, withCtx as c, Fragment as k, renderList as R, createBlock as g, createCommentVNode as N, normalizeStyle as T, createSlots as q, normalizeProps as L, guardReactiveProps as E, mergeProps as j, resolveDynamicComponent as I, createTextVNode as M, toDisplayString as J } from "vue";
|
|
2
|
+
const w = (e, a) => {
|
|
3
|
+
const n = e.__vccOpts || e;
|
|
4
|
+
for (const [l, s] of a)
|
|
5
|
+
n[l] = s;
|
|
6
|
+
return n;
|
|
7
|
+
}, G = {
|
|
8
|
+
name: "MyButton",
|
|
9
|
+
props: {
|
|
10
|
+
type: {
|
|
11
|
+
type: String,
|
|
12
|
+
default: "default",
|
|
13
|
+
validator: (e) => ["default", "primary", "success", "warning", "danger"].includes(e)
|
|
14
|
+
},
|
|
15
|
+
disabled: {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
default: !1
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
emits: ["click"],
|
|
21
|
+
setup(e, { emit: a }) {
|
|
22
|
+
return {
|
|
23
|
+
handleClick: (l) => {
|
|
24
|
+
a("click", l);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}, H = ["disabled"];
|
|
29
|
+
function K(e, a, n, l, s, y) {
|
|
30
|
+
return r(), h("button", {
|
|
31
|
+
class: O(["my-button", [`my-button--${n.type}`, { "is-disabled": n.disabled }]]),
|
|
32
|
+
disabled: n.disabled,
|
|
33
|
+
onClick: a[0] || (a[0] = (...o) => l.handleClick && l.handleClick(...o))
|
|
34
|
+
}, [
|
|
35
|
+
_(e.$slots, "default", {}, void 0, !0)
|
|
36
|
+
], 10, H);
|
|
37
|
+
}
|
|
38
|
+
const F = /* @__PURE__ */ w(G, [["render", K], ["__scopeId", "data-v-4480e77d"]]);
|
|
39
|
+
F.install = function(e) {
|
|
40
|
+
e.component(F.name, F);
|
|
41
|
+
};
|
|
42
|
+
const V = /* @__PURE__ */ D({
|
|
43
|
+
name: "JsxButton",
|
|
44
|
+
props: {
|
|
45
|
+
type: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: "default",
|
|
48
|
+
validator: (e) => ["default", "primary", "success", "warning", "danger"].includes(e)
|
|
49
|
+
},
|
|
50
|
+
disabled: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: !1
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
emits: ["click"],
|
|
56
|
+
setup(e, {
|
|
57
|
+
emit: a,
|
|
58
|
+
slots: n
|
|
59
|
+
}) {
|
|
60
|
+
const l = (s) => {
|
|
61
|
+
e.disabled || a("click", s);
|
|
62
|
+
};
|
|
63
|
+
return () => $("button", {
|
|
64
|
+
class: ["jsx-button", `jsx-button--${e.type}`, {
|
|
65
|
+
"is-disabled": e.disabled
|
|
66
|
+
}],
|
|
67
|
+
disabled: e.disabled,
|
|
68
|
+
onClick: l
|
|
69
|
+
}, [n.default?.()]);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
V.install = function(e) {
|
|
73
|
+
e.component(V.name, V);
|
|
74
|
+
};
|
|
75
|
+
const Q = D({
|
|
76
|
+
name: "ZxtForm",
|
|
77
|
+
props: {
|
|
78
|
+
formColumns: { type: Array, default: () => [] },
|
|
79
|
+
initialFormData: { type: Object, default: () => ({}) },
|
|
80
|
+
rules: { type: Object, default: () => ({}) }
|
|
81
|
+
},
|
|
82
|
+
emits: ["submit", "reset"],
|
|
83
|
+
setup(e, { emit: a, expose: n }) {
|
|
84
|
+
const l = C(null), s = A({});
|
|
85
|
+
B(
|
|
86
|
+
() => e.initialFormData,
|
|
87
|
+
(u) => {
|
|
88
|
+
Object.keys(s).forEach((d) => {
|
|
89
|
+
delete s[d];
|
|
90
|
+
}), Object.assign(s, u);
|
|
91
|
+
},
|
|
92
|
+
{ immediate: !0, deep: !0 }
|
|
93
|
+
);
|
|
94
|
+
const y = v(() => {
|
|
95
|
+
const u = { ...e.rules };
|
|
96
|
+
return Object.keys(u).length === 0 && e.formColumns.length > 0 && e.formColumns.forEach((d) => {
|
|
97
|
+
d.required && (u[d.prop] = [
|
|
98
|
+
{
|
|
99
|
+
required: !0,
|
|
100
|
+
message: `请${d.type === "select" || d.type === "date" ? "选择" : "输入"}${d.label}`,
|
|
101
|
+
trigger: d.type === "select" || d.type === "date" ? "change" : "blur"
|
|
102
|
+
}
|
|
103
|
+
]);
|
|
104
|
+
}), u;
|
|
105
|
+
}), o = () => {
|
|
106
|
+
l.value && l.value.validate((u) => {
|
|
107
|
+
u && a("submit", { ...s });
|
|
108
|
+
});
|
|
109
|
+
}, f = () => {
|
|
110
|
+
l.value && l.value.resetFields(), a("reset");
|
|
111
|
+
};
|
|
112
|
+
return n({
|
|
113
|
+
validate: () => l.value ? l.value.validate() : Promise.resolve(!1),
|
|
114
|
+
resetFields: () => l.value && l.value.resetFields(),
|
|
115
|
+
getFormData: () => ({ ...s })
|
|
116
|
+
}), { formRef: l, formData: s, formRules: y, submitForm: o, resetForm: f };
|
|
117
|
+
}
|
|
118
|
+
}), W = { class: "zxt-form-container" };
|
|
119
|
+
function X(e, a, n, l, s, y) {
|
|
120
|
+
const o = p("el-input"), f = p("el-option"), u = p("el-select"), d = p("el-date-picker"), i = p("el-form-item"), z = p("el-col"), m = p("el-row"), S = p("el-form");
|
|
121
|
+
return r(), h("div", W, [
|
|
122
|
+
$(S, {
|
|
123
|
+
ref: "formRef",
|
|
124
|
+
model: e.formData,
|
|
125
|
+
rules: e.formRules,
|
|
126
|
+
"label-width": "100px",
|
|
127
|
+
class: "zxt-form"
|
|
128
|
+
}, {
|
|
129
|
+
default: c(() => [
|
|
130
|
+
$(m, { gutter: 20 }, {
|
|
131
|
+
default: c(() => [
|
|
132
|
+
(r(!0), h(k, null, R(e.formColumns, (t, Z) => (r(), g(z, {
|
|
133
|
+
key: Z,
|
|
134
|
+
xs: t.xs || 24,
|
|
135
|
+
sm: t.sm || 12,
|
|
136
|
+
md: t.md || 12,
|
|
137
|
+
lg: t.lg || t.span || 12,
|
|
138
|
+
xl: t.xl || t.span || 12
|
|
139
|
+
}, {
|
|
140
|
+
default: c(() => [
|
|
141
|
+
$(i, {
|
|
142
|
+
label: t.label,
|
|
143
|
+
prop: t.prop,
|
|
144
|
+
required: t.required
|
|
145
|
+
}, {
|
|
146
|
+
default: c(() => [
|
|
147
|
+
t.type === "input" || !t.type ? (r(), g(o, {
|
|
148
|
+
key: 0,
|
|
149
|
+
modelValue: e.formData[t.prop],
|
|
150
|
+
"onUpdate:modelValue": (b) => e.formData[t.prop] = b,
|
|
151
|
+
placeholder: t.placeholder || `请输入${t.label}`,
|
|
152
|
+
disabled: t.disabled
|
|
153
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled"])) : t.type === "select" ? (r(), g(u, {
|
|
154
|
+
key: 1,
|
|
155
|
+
modelValue: e.formData[t.prop],
|
|
156
|
+
"onUpdate:modelValue": (b) => e.formData[t.prop] = b,
|
|
157
|
+
placeholder: t.placeholder || `请选择${t.label}`,
|
|
158
|
+
disabled: t.disabled,
|
|
159
|
+
style: { width: "100%" }
|
|
160
|
+
}, {
|
|
161
|
+
default: c(() => [
|
|
162
|
+
(r(!0), h(k, null, R(t.options, (b, U) => (r(), g(f, {
|
|
163
|
+
key: U,
|
|
164
|
+
label: b.label,
|
|
165
|
+
value: b.value
|
|
166
|
+
}, null, 8, ["label", "value"]))), 128))
|
|
167
|
+
]),
|
|
168
|
+
_: 2
|
|
169
|
+
}, 1032, ["modelValue", "onUpdate:modelValue", "placeholder", "disabled"])) : t.type === "date" ? (r(), g(d, {
|
|
170
|
+
key: 2,
|
|
171
|
+
modelValue: e.formData[t.prop],
|
|
172
|
+
"onUpdate:modelValue": (b) => e.formData[t.prop] = b,
|
|
173
|
+
type: t.dateType || "date",
|
|
174
|
+
placeholder: t.placeholder || `请选择${t.label}`,
|
|
175
|
+
disabled: t.disabled,
|
|
176
|
+
style: { width: "100%" }
|
|
177
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "type", "placeholder", "disabled"])) : t.type === "slot" ? _(e.$slots, t.slotName || t.prop, {
|
|
178
|
+
key: 3,
|
|
179
|
+
formData: e.formData,
|
|
180
|
+
column: t
|
|
181
|
+
}, void 0, !0) : N("", !0)
|
|
182
|
+
]),
|
|
183
|
+
_: 2
|
|
184
|
+
}, 1032, ["label", "prop", "required"])
|
|
185
|
+
]),
|
|
186
|
+
_: 2
|
|
187
|
+
}, 1032, ["xs", "sm", "md", "lg", "xl"]))), 128))
|
|
188
|
+
]),
|
|
189
|
+
_: 3
|
|
190
|
+
})
|
|
191
|
+
]),
|
|
192
|
+
_: 3
|
|
193
|
+
}, 8, ["model", "rules"])
|
|
194
|
+
]);
|
|
195
|
+
}
|
|
196
|
+
const Y = /* @__PURE__ */ w(Q, [["render", X], ["__scopeId", "data-v-2148c373"]]), x = D({
|
|
197
|
+
name: "ZxtPagination",
|
|
198
|
+
props: {
|
|
199
|
+
// 当前页码
|
|
200
|
+
modelValue: { type: Number, default: 1 },
|
|
201
|
+
// 每页显示条数
|
|
202
|
+
pageSize: { type: Number, default: 10 },
|
|
203
|
+
// 可选的分页大小
|
|
204
|
+
pageSizes: { type: Array, default: () => [10, 20, 50, 100] },
|
|
205
|
+
// 总条数
|
|
206
|
+
total: { type: Number, default: 0 },
|
|
207
|
+
// 分页布局
|
|
208
|
+
layout: {
|
|
209
|
+
type: String,
|
|
210
|
+
default: "total, sizes, prev, pager, next, jumper"
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
emits: ["update:modelValue", "update:pageSize", "page-change", "size-change"],
|
|
214
|
+
setup(e, { emit: a }) {
|
|
215
|
+
const n = C(e.modelValue), l = C(e.pageSize);
|
|
216
|
+
return B(
|
|
217
|
+
() => e.modelValue,
|
|
218
|
+
(o) => {
|
|
219
|
+
n.value = o;
|
|
220
|
+
}
|
|
221
|
+
), B(
|
|
222
|
+
() => e.pageSize,
|
|
223
|
+
(o) => {
|
|
224
|
+
l.value = o;
|
|
225
|
+
}
|
|
226
|
+
), {
|
|
227
|
+
currentPage: n,
|
|
228
|
+
pageSize: l,
|
|
229
|
+
handleSizeChange: (o) => {
|
|
230
|
+
l.value = o, n.value = 1, a("update:pageSize", o), a("size-change", { page: n.value, size: o });
|
|
231
|
+
},
|
|
232
|
+
handleCurrentChange: (o) => {
|
|
233
|
+
n.value = o, a("update:modelValue", o), a("page-change", { page: o, size: l.value });
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
function ee(e, a, n, l, s, y) {
|
|
239
|
+
const o = p("el-pagination");
|
|
240
|
+
return r(), g(o, {
|
|
241
|
+
"current-page": e.currentPage,
|
|
242
|
+
"onUpdate:currentPage": a[0] || (a[0] = (f) => e.currentPage = f),
|
|
243
|
+
"page-size": e.pageSize,
|
|
244
|
+
"onUpdate:pageSize": a[1] || (a[1] = (f) => e.pageSize = f),
|
|
245
|
+
"page-sizes": e.pageSizes,
|
|
246
|
+
total: e.total,
|
|
247
|
+
layout: e.layout,
|
|
248
|
+
class: "zxt-pagination",
|
|
249
|
+
onSizeChange: e.handleSizeChange,
|
|
250
|
+
onCurrentChange: e.handleCurrentChange
|
|
251
|
+
}, null, 8, ["current-page", "page-size", "page-sizes", "total", "layout", "onSizeChange", "onCurrentChange"]);
|
|
252
|
+
}
|
|
253
|
+
const te = /* @__PURE__ */ w(x, [["render", ee], ["__scopeId", "data-v-e6813cef"]]), ae = D({
|
|
254
|
+
name: "ZxtTable",
|
|
255
|
+
components: { ZxtForm: Y, ZxtPagination: te },
|
|
256
|
+
props: {
|
|
257
|
+
// 表格唯一标识
|
|
258
|
+
id: { type: String, default: "" },
|
|
259
|
+
// 列配置
|
|
260
|
+
columns: { type: Array, default: () => [] },
|
|
261
|
+
// 表格数据
|
|
262
|
+
data: { type: Array, default: () => [] },
|
|
263
|
+
// 表格高度
|
|
264
|
+
height: { type: [String, Number], default: "" },
|
|
265
|
+
// 是否为表单模式
|
|
266
|
+
formMode: { type: Boolean, default: !1 },
|
|
267
|
+
// 表单列配置
|
|
268
|
+
formColumns: { type: Array, default: () => [] },
|
|
269
|
+
// 表单初始数据
|
|
270
|
+
initialFormData: { type: Object, default: () => ({}) },
|
|
271
|
+
// 表单验证规则
|
|
272
|
+
rules: { type: Object, default: () => ({}) },
|
|
273
|
+
// 是否启用分页
|
|
274
|
+
pageable: { type: Boolean, default: !0 },
|
|
275
|
+
// 当前页码
|
|
276
|
+
currentPage: { type: Number, default: 1 },
|
|
277
|
+
// 每页显示条数
|
|
278
|
+
pageSize: { type: Number, default: 10 },
|
|
279
|
+
// 可选的分页大小
|
|
280
|
+
pageSizes: { type: Array, default: () => [10, 20, 50, 100] },
|
|
281
|
+
// 总条数
|
|
282
|
+
total: { type: Number, default: 0 },
|
|
283
|
+
// 分页布局
|
|
284
|
+
paginationLayout: {
|
|
285
|
+
type: String,
|
|
286
|
+
default: "total, sizes, prev, pager, next, jumper"
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
emits: ["submit", "reset", "page-change", "size-change"],
|
|
290
|
+
setup(e, { emit: a }) {
|
|
291
|
+
const n = C(null), l = C(null), s = C(e.pageSize), y = v(() => e.height === "full" ? { height: "100%" } : {}), o = v(() => e.total > 0 ? e.total : e.data.length), f = (S) => {
|
|
292
|
+
a("size-change", S);
|
|
293
|
+
}, u = (S) => {
|
|
294
|
+
a("page-change", S);
|
|
295
|
+
};
|
|
296
|
+
return {
|
|
297
|
+
tableRef: n,
|
|
298
|
+
formRef: l,
|
|
299
|
+
containerStyle: y,
|
|
300
|
+
onFormSubmit: (S) => {
|
|
301
|
+
a("submit", S);
|
|
302
|
+
},
|
|
303
|
+
onFormReset: () => {
|
|
304
|
+
a("reset");
|
|
305
|
+
},
|
|
306
|
+
getTableRef: () => n.value,
|
|
307
|
+
getFormRef: () => l.value,
|
|
308
|
+
pageSize: s,
|
|
309
|
+
total: o,
|
|
310
|
+
pageSizes: v(() => e.pageSizes),
|
|
311
|
+
paginationLayout: v(() => e.paginationLayout),
|
|
312
|
+
handleSizeChange: f,
|
|
313
|
+
handlePageChange: u
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
function le(e, a, n, l, s, y) {
|
|
318
|
+
const o = p("ZxtForm"), f = p("el-table-column"), u = p("el-table"), d = p("ZxtPagination");
|
|
319
|
+
return r(), h("div", {
|
|
320
|
+
class: "zxt-table-container",
|
|
321
|
+
style: T(e.containerStyle)
|
|
322
|
+
}, [
|
|
323
|
+
e.formMode ? (r(), g(o, {
|
|
324
|
+
key: 0,
|
|
325
|
+
ref: "formRef",
|
|
326
|
+
"form-columns": e.formColumns,
|
|
327
|
+
"initial-form-data": e.initialFormData,
|
|
328
|
+
rules: e.rules,
|
|
329
|
+
onSubmit: e.onFormSubmit,
|
|
330
|
+
onReset: e.onFormReset
|
|
331
|
+
}, q({
|
|
332
|
+
"form-actions": c(() => [
|
|
333
|
+
_(e.$slots, "form-actions", {}, void 0, !0)
|
|
334
|
+
]),
|
|
335
|
+
_: 2
|
|
336
|
+
}, [
|
|
337
|
+
R(e.$slots, (i, z) => ({
|
|
338
|
+
name: z,
|
|
339
|
+
fn: c((m) => [
|
|
340
|
+
_(e.$slots, z, L(E(m)), void 0, !0)
|
|
341
|
+
])
|
|
342
|
+
}))
|
|
343
|
+
]), 1032, ["form-columns", "initial-form-data", "rules", "onSubmit", "onReset"])) : N("", !0),
|
|
344
|
+
$(u, j({
|
|
345
|
+
ref: "tableRef",
|
|
346
|
+
data: e.data,
|
|
347
|
+
height: e.height
|
|
348
|
+
}, e.$attrs, { id: e.id }), {
|
|
349
|
+
default: c(() => [
|
|
350
|
+
(r(!0), h(k, null, R(e.columns, (i, z) => (r(), h(k, { key: z }, [
|
|
351
|
+
i.slot ? (r(), g(f, j({
|
|
352
|
+
key: 1,
|
|
353
|
+
ref_for: !0
|
|
354
|
+
}, i), {
|
|
355
|
+
default: c((m) => [
|
|
356
|
+
_(e.$slots, i.slot, {
|
|
357
|
+
row: m.row,
|
|
358
|
+
index: m.$index
|
|
359
|
+
}, void 0, !0)
|
|
360
|
+
]),
|
|
361
|
+
_: 2
|
|
362
|
+
}, 1040)) : (r(), g(f, j({
|
|
363
|
+
key: 0,
|
|
364
|
+
ref_for: !0
|
|
365
|
+
}, i), {
|
|
366
|
+
default: c((m) => [
|
|
367
|
+
i.render ? (r(), g(I(i.render), {
|
|
368
|
+
key: 0,
|
|
369
|
+
row: m.row,
|
|
370
|
+
column: i,
|
|
371
|
+
index: m.$index
|
|
372
|
+
}, null, 8, ["row", "column", "index"])) : (r(), h(k, { key: 1 }, [
|
|
373
|
+
M(J(m.row[i.prop]), 1)
|
|
374
|
+
], 64))
|
|
375
|
+
]),
|
|
376
|
+
_: 2
|
|
377
|
+
}, 1040))
|
|
378
|
+
], 64))), 128))
|
|
379
|
+
]),
|
|
380
|
+
_: 3
|
|
381
|
+
}, 16, ["data", "height", "id"]),
|
|
382
|
+
e.pageable ? (r(), g(d, {
|
|
383
|
+
key: 1,
|
|
384
|
+
"model-value": e.currentPage,
|
|
385
|
+
"page-size": e.pageSize,
|
|
386
|
+
"onUpdate:pageSize": a[0] || (a[0] = (i) => e.pageSize = i),
|
|
387
|
+
"page-sizes": e.pageSizes,
|
|
388
|
+
total: e.total,
|
|
389
|
+
layout: e.paginationLayout,
|
|
390
|
+
onPageChange: e.handlePageChange,
|
|
391
|
+
onSizeChange: e.handleSizeChange
|
|
392
|
+
}, null, 8, ["model-value", "page-size", "page-sizes", "total", "layout", "onPageChange", "onSizeChange"])) : N("", !0)
|
|
393
|
+
], 4);
|
|
394
|
+
}
|
|
395
|
+
const P = /* @__PURE__ */ w(ae, [["render", le], ["__scopeId", "data-v-aca49573"]]);
|
|
396
|
+
P.install = function(e) {
|
|
397
|
+
e.component(P.name, P);
|
|
398
|
+
};
|
|
399
|
+
const ne = [
|
|
400
|
+
F,
|
|
401
|
+
V,
|
|
402
|
+
P
|
|
403
|
+
], oe = (e) => {
|
|
404
|
+
ne.forEach((a) => {
|
|
405
|
+
e.component(a.name, a);
|
|
406
|
+
});
|
|
407
|
+
}, se = {
|
|
408
|
+
install: oe,
|
|
409
|
+
MyButton: F,
|
|
410
|
+
JsxButton: V,
|
|
411
|
+
ZxtTable: P
|
|
412
|
+
};
|
|
413
|
+
export {
|
|
414
|
+
V as JsxButton,
|
|
415
|
+
F as MyButton,
|
|
416
|
+
P as ZxtTable,
|
|
417
|
+
se as default
|
|
418
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(f,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(f=typeof globalThis<"u"?globalThis:f||self,e(f.ZxtTable={},f.Vue))})(this,(function(f,e){"use strict";const S=(t,o)=>{const l=t.__vccOpts||t;for(const[n,s]of o)l[n]=s;return l},z={name:"MyButton",props:{type:{type:String,default:"default",validator:t=>["default","primary","success","warning","danger"].includes(t)},disabled:{type:Boolean,default:!1}},emits:["click"],setup(t,{emit:o}){return{handleClick:n=>{o("click",n)}}}},B=["disabled"];function _(t,o,l,n,s,g){return e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["my-button",[`my-button--${l.type}`,{"is-disabled":l.disabled}]]),disabled:l.disabled,onClick:o[0]||(o[0]=(...r)=>n.handleClick&&n.handleClick(...r))},[e.renderSlot(t.$slots,"default",{},void 0,!0)],10,B)}const b=S(z,[["render",_],["__scopeId","data-v-4480e77d"]]);b.install=function(t){t.component(b.name,b)};const C=e.defineComponent({name:"JsxButton",props:{type:{type:String,default:"default",validator:t=>["default","primary","success","warning","danger"].includes(t)},disabled:{type:Boolean,default:!1}},emits:["click"],setup(t,{emit:o,slots:l}){const n=s=>{t.disabled||o("click",s)};return()=>e.createVNode("button",{class:["jsx-button",`jsx-button--${t.type}`,{"is-disabled":t.disabled}],disabled:t.disabled,onClick:n},[l.default?.()])}});C.install=function(t){t.component(C.name,C)};const $=e.defineComponent({name:"ZxtForm",props:{formColumns:{type:Array,default:()=>[]},initialFormData:{type:Object,default:()=>({})},rules:{type:Object,default:()=>({})}},emits:["submit","reset"],setup(t,{emit:o,expose:l}){const n=e.ref(null),s=e.reactive({});e.watch(()=>t.initialFormData,p=>{Object.keys(s).forEach(d=>{delete s[d]}),Object.assign(s,p)},{immediate:!0,deep:!0});const g=e.computed(()=>{const p={...t.rules};return Object.keys(p).length===0&&t.formColumns.length>0&&t.formColumns.forEach(d=>{d.required&&(p[d.prop]=[{required:!0,message:`请${d.type==="select"||d.type==="date"?"选择":"输入"}${d.label}`,trigger:d.type==="select"||d.type==="date"?"change":"blur"}])}),p}),r=()=>{n.value&&n.value.validate(p=>{p&&o("submit",{...s})})},c=()=>{n.value&&n.value.resetFields(),o("reset")};return l({validate:()=>n.value?n.value.validate():Promise.resolve(!1),resetFields:()=>n.value&&n.value.resetFields(),getFormData:()=>({...s})}),{formRef:n,formData:s,formRules:g,submitForm:r,resetForm:c}}}),F={class:"zxt-form-container"};function V(t,o,l,n,s,g){const r=e.resolveComponent("el-input"),c=e.resolveComponent("el-option"),p=e.resolveComponent("el-select"),d=e.resolveComponent("el-date-picker"),i=e.resolveComponent("el-form-item"),y=e.resolveComponent("el-col"),m=e.resolveComponent("el-row"),h=e.resolveComponent("el-form");return e.openBlock(),e.createElementBlock("div",F,[e.createVNode(h,{ref:"formRef",model:t.formData,rules:t.formRules,"label-width":"100px",class:"zxt-form"},{default:e.withCtx(()=>[e.createVNode(m,{gutter:20},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.formColumns,(a,T)=>(e.openBlock(),e.createBlock(y,{key:T,xs:a.xs||24,sm:a.sm||12,md:a.md||12,lg:a.lg||a.span||12,xl:a.xl||a.span||12},{default:e.withCtx(()=>[e.createVNode(i,{label:a.label,prop:a.prop,required:a.required},{default:e.withCtx(()=>[a.type==="input"||!a.type?(e.openBlock(),e.createBlock(r,{key:0,modelValue:t.formData[a.prop],"onUpdate:modelValue":u=>t.formData[a.prop]=u,placeholder:a.placeholder||`请输入${a.label}`,disabled:a.disabled},null,8,["modelValue","onUpdate:modelValue","placeholder","disabled"])):a.type==="select"?(e.openBlock(),e.createBlock(p,{key:1,modelValue:t.formData[a.prop],"onUpdate:modelValue":u=>t.formData[a.prop]=u,placeholder:a.placeholder||`请选择${a.label}`,disabled:a.disabled,style:{width:"100%"}},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.options,(u,O)=>(e.openBlock(),e.createBlock(c,{key:O,label:u.label,value:u.value},null,8,["label","value"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue","placeholder","disabled"])):a.type==="date"?(e.openBlock(),e.createBlock(d,{key:2,modelValue:t.formData[a.prop],"onUpdate:modelValue":u=>t.formData[a.prop]=u,type:a.dateType||"date",placeholder:a.placeholder||`请选择${a.label}`,disabled:a.disabled,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","type","placeholder","disabled"])):a.type==="slot"?e.renderSlot(t.$slots,a.slotName||a.prop,{key:3,formData:t.formData,column:a},void 0,!0):e.createCommentVNode("",!0)]),_:2},1032,["label","prop","required"])]),_:2},1032,["xs","sm","md","lg","xl"]))),128))]),_:3})]),_:3},8,["model","rules"])])}const w=S($,[["render",V],["__scopeId","data-v-2148c373"]]),P=e.defineComponent({name:"ZxtPagination",props:{modelValue:{type:Number,default:1},pageSize:{type:Number,default:10},pageSizes:{type:Array,default:()=>[10,20,50,100]},total:{type:Number,default:0},layout:{type:String,default:"total, sizes, prev, pager, next, jumper"}},emits:["update:modelValue","update:pageSize","page-change","size-change"],setup(t,{emit:o}){const l=e.ref(t.modelValue),n=e.ref(t.pageSize);return e.watch(()=>t.modelValue,r=>{l.value=r}),e.watch(()=>t.pageSize,r=>{n.value=r}),{currentPage:l,pageSize:n,handleSizeChange:r=>{n.value=r,l.value=1,o("update:pageSize",r),o("size-change",{page:l.value,size:r})},handleCurrentChange:r=>{l.value=r,o("update:modelValue",r),o("page-change",{page:r,size:n.value})}}}});function R(t,o,l,n,s,g){const r=e.resolveComponent("el-pagination");return e.openBlock(),e.createBlock(r,{"current-page":t.currentPage,"onUpdate:currentPage":o[0]||(o[0]=c=>t.currentPage=c),"page-size":t.pageSize,"onUpdate:pageSize":o[1]||(o[1]=c=>t.pageSize=c),"page-sizes":t.pageSizes,total:t.total,layout:t.layout,class:"zxt-pagination",onSizeChange:t.handleSizeChange,onCurrentChange:t.handleCurrentChange},null,8,["current-page","page-size","page-sizes","total","layout","onSizeChange","onCurrentChange"])}const D=S(P,[["render",R],["__scopeId","data-v-e6813cef"]]),N=e.defineComponent({name:"ZxtTable",components:{ZxtForm:w,ZxtPagination:D},props:{id:{type:String,default:""},columns:{type:Array,default:()=>[]},data:{type:Array,default:()=>[]},height:{type:[String,Number],default:""},formMode:{type:Boolean,default:!1},formColumns:{type:Array,default:()=>[]},initialFormData:{type:Object,default:()=>({})},rules:{type:Object,default:()=>({})},pageable:{type:Boolean,default:!0},currentPage:{type:Number,default:1},pageSize:{type:Number,default:10},pageSizes:{type:Array,default:()=>[10,20,50,100]},total:{type:Number,default:0},paginationLayout:{type:String,default:"total, sizes, prev, pager, next, jumper"}},emits:["submit","reset","page-change","size-change"],setup(t,{emit:o}){const l=e.ref(null),n=e.ref(null),s=e.ref(t.pageSize),g=e.computed(()=>t.height==="full"?{height:"100%"}:{}),r=e.computed(()=>t.total>0?t.total:t.data.length),c=h=>{o("size-change",h)},p=h=>{o("page-change",h)};return{tableRef:l,formRef:n,containerStyle:g,onFormSubmit:h=>{o("submit",h)},onFormReset:()=>{o("reset")},getTableRef:()=>l.value,getFormRef:()=>n.value,pageSize:s,total:r,pageSizes:e.computed(()=>t.pageSizes),paginationLayout:e.computed(()=>t.paginationLayout),handleSizeChange:c,handlePageChange:p}}});function j(t,o,l,n,s,g){const r=e.resolveComponent("ZxtForm"),c=e.resolveComponent("el-table-column"),p=e.resolveComponent("el-table"),d=e.resolveComponent("ZxtPagination");return e.openBlock(),e.createElementBlock("div",{class:"zxt-table-container",style:e.normalizeStyle(t.containerStyle)},[t.formMode?(e.openBlock(),e.createBlock(r,{key:0,ref:"formRef","form-columns":t.formColumns,"initial-form-data":t.initialFormData,rules:t.rules,onSubmit:t.onFormSubmit,onReset:t.onFormReset},e.createSlots({"form-actions":e.withCtx(()=>[e.renderSlot(t.$slots,"form-actions",{},void 0,!0)]),_:2},[e.renderList(t.$slots,(i,y)=>({name:y,fn:e.withCtx(m=>[e.renderSlot(t.$slots,y,e.normalizeProps(e.guardReactiveProps(m)),void 0,!0)])}))]),1032,["form-columns","initial-form-data","rules","onSubmit","onReset"])):e.createCommentVNode("",!0),e.createVNode(p,e.mergeProps({ref:"tableRef",data:t.data,height:t.height},t.$attrs,{id:t.id}),{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,(i,y)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:y},[i.slot?(e.openBlock(),e.createBlock(c,e.mergeProps({key:1,ref_for:!0},i),{default:e.withCtx(m=>[e.renderSlot(t.$slots,i.slot,{row:m.row,index:m.$index},void 0,!0)]),_:2},1040)):(e.openBlock(),e.createBlock(c,e.mergeProps({key:0,ref_for:!0},i),{default:e.withCtx(m=>[i.render?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.render),{key:0,row:m.row,column:i,index:m.$index},null,8,["row","column","index"])):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(m.row[i.prop]),1)],64))]),_:2},1040))],64))),128))]),_:3},16,["data","height","id"]),t.pageable?(e.openBlock(),e.createBlock(d,{key:1,"model-value":t.currentPage,"page-size":t.pageSize,"onUpdate:pageSize":o[0]||(o[0]=i=>t.pageSize=i),"page-sizes":t.pageSizes,total:t.total,layout:t.paginationLayout,onPageChange:t.handlePageChange,onSizeChange:t.handleSizeChange},null,8,["model-value","page-size","page-sizes","total","layout","onPageChange","onSizeChange"])):e.createCommentVNode("",!0)],4)}const k=S(N,[["render",j],["__scopeId","data-v-aca49573"]]);k.install=function(t){t.component(k.name,k)};const Z=[b,C,k],E={install:t=>{Z.forEach(o=>{t.component(o.name,o)})},MyButton:b,JsxButton:C,ZxtTable:k};f.JsxButton=C,f.MyButton=b,f.ZxtTable=k,f.default=E,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zxt-table",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/zxt-table.umd.js",
|
|
7
|
+
"module": "./dist/zxt-table.es.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/zxt-table.es.js",
|
|
11
|
+
"require": "./dist/zxt-table.umd.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"dev": "vite",
|
|
19
|
+
"build": "vite build",
|
|
20
|
+
"preview": "vite preview"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"element-plus": "^2.11.5",
|
|
24
|
+
"vue": "^3.5.22"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
28
|
+
"@vitejs/plugin-vue-jsx": "^5.1.1",
|
|
29
|
+
"autoprefixer": "^10.4.21",
|
|
30
|
+
"postcss": "^8.5.6",
|
|
31
|
+
"tailwindcss": "^4.1.16",
|
|
32
|
+
"vite": "^7.1.7"
|
|
33
|
+
}
|
|
34
|
+
}
|