zhihao-ui 1.2.21 → 1.2.22
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/es/DiyDataTable-DHGMMFO9.js +315 -0
- package/dist/es/index.js +2 -2
- package/dist/index.css +1 -1
- package/dist/types/components/DiyDataTable/DiyDataTable.vue.d.ts +6 -0
- package/dist/types/components/DiyDataTable/index.d.ts +9 -0
- package/dist/umd/index.css +1 -1
- package/dist/umd/index.umd.cjs +17 -17
- package/package.json +1 -1
- package/dist/es/DiyDataTable-uIkGrO_i.js +0 -306
package/package.json
CHANGED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { defineComponent as H, useModel as N, ref as b, openBlock as d, createBlock as g, unref as s, withCtx as p, createVNode as v, createElementBlock as f, Fragment as W, renderList as Z, normalizeClass as D, toDisplayString as c, renderSlot as C, createCommentVNode as k, createElementVNode as y, createTextVNode as V, mergeModels as z } from "vue";
|
|
2
|
-
import { D as P } from "./DatePicker-BrD1XS6-.js";
|
|
3
|
-
import { d as w, e as $, f as X, g as j, i as E, j as T, k as K, l as M, E as A } from "./vendor-gTOtiVzA.js";
|
|
4
|
-
import { _ as G } from "./Button-Va8xfPJd.js";
|
|
5
|
-
import { w as J } from "./utils-D-zYpBSZ.js";
|
|
6
|
-
var m = /* @__PURE__ */ ((u) => (u.AUTOCOMPLETE = "autocomplete", u.FORMAT = "format", u.TEXT = "text", u))(m || {});
|
|
7
|
-
const Q = { key: 0 }, Y = {
|
|
8
|
-
key: 1,
|
|
9
|
-
class: "col-edit-header"
|
|
10
|
-
}, ee = ["onClick"], te = { key: 0 }, ae = { key: 2 }, re = { class: "header-operation-container" }, le = { class: "operation-container" }, oe = ["onClick"], L = "$ZH_DIV$", ie = /* @__PURE__ */ H({
|
|
11
|
-
name: "zh-diy-data-table",
|
|
12
|
-
__name: "DiyDataTable",
|
|
13
|
-
props: /* @__PURE__ */ z({
|
|
14
|
-
isEdit: { type: Boolean, default: !1 },
|
|
15
|
-
maxRowLength: { default: 50 },
|
|
16
|
-
maxColLength: { default: 10 },
|
|
17
|
-
defaultMinWidth: { default: 120 }
|
|
18
|
-
}, {
|
|
19
|
-
rawData: { required: !0 },
|
|
20
|
-
rawDataModifiers: {}
|
|
21
|
-
}),
|
|
22
|
-
emits: ["update:rawData"],
|
|
23
|
-
setup(u, { expose: R }) {
|
|
24
|
-
const h = u, n = N(u, "rawData"), o = b([]), F = () => {
|
|
25
|
-
if (n.value.length === h.maxRowLength) {
|
|
26
|
-
w({
|
|
27
|
-
message: `最多添加${h.maxRowLength}行`,
|
|
28
|
-
type: "warning"
|
|
29
|
-
});
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
n.value.push({});
|
|
33
|
-
}, U = () => {
|
|
34
|
-
if (o.value.filter((e) => e.isAdd).length >= h.maxColLength) {
|
|
35
|
-
w({
|
|
36
|
-
message: `最多添加${h.maxColLength}列`,
|
|
37
|
-
type: "warning"
|
|
38
|
-
});
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const r = String(Date.now());
|
|
42
|
-
o.value.push({
|
|
43
|
-
prop: r,
|
|
44
|
-
label: "",
|
|
45
|
-
isEditHeader: !0,
|
|
46
|
-
isAdd: !0,
|
|
47
|
-
maxlength: 15,
|
|
48
|
-
minWidth: 150,
|
|
49
|
-
headerMaxlength: 15
|
|
50
|
-
});
|
|
51
|
-
}, S = (a, r) => {
|
|
52
|
-
o.value.splice(a, 1), n.value.forEach((e) => {
|
|
53
|
-
delete e[r.prop];
|
|
54
|
-
});
|
|
55
|
-
}, I = (a) => {
|
|
56
|
-
n.value.splice(a, 1);
|
|
57
|
-
}, O = (a, r, e) => {
|
|
58
|
-
r(
|
|
59
|
-
e.completeList.filter((l) => l.includes(a)).map((l) => ({ value: l }))
|
|
60
|
-
);
|
|
61
|
-
}, q = (a) => [
|
|
62
|
-
{
|
|
63
|
-
validator: (r, e, l) => {
|
|
64
|
-
if (!o.value[a].label) {
|
|
65
|
-
l(new Error("请输入表头"));
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
l();
|
|
69
|
-
},
|
|
70
|
-
message: "请输入表头",
|
|
71
|
-
trigger: ["blur", "change"]
|
|
72
|
-
}
|
|
73
|
-
], B = (a) => {
|
|
74
|
-
const r = [];
|
|
75
|
-
return a.required && r.push({
|
|
76
|
-
required: !0,
|
|
77
|
-
message: "请输入" + a.label,
|
|
78
|
-
trigger: a.slot ? void 0 : "blur"
|
|
79
|
-
}), a.varidate && r.push({
|
|
80
|
-
validator: (e, l, t) => {
|
|
81
|
-
const i = a.varidate(l);
|
|
82
|
-
i !== !0 ? t(new Error(i)) : t();
|
|
83
|
-
},
|
|
84
|
-
trigger: a.slot ? void 0 : "blur"
|
|
85
|
-
}), r;
|
|
86
|
-
}, _ = b();
|
|
87
|
-
return R({
|
|
88
|
-
/** 初始化数据 */
|
|
89
|
-
initData: (a, r) => {
|
|
90
|
-
console.log("initData", a, r), a = $(a) || [], a.length === 0 && a.push({}), r = [...r];
|
|
91
|
-
for (const e in a[0])
|
|
92
|
-
if (!r.some(
|
|
93
|
-
(l) => l.prop === e
|
|
94
|
-
)) {
|
|
95
|
-
const l = Date.now() + e, t = e.split(L);
|
|
96
|
-
if (t.length !== 2) {
|
|
97
|
-
console.log("keySplit 失败", e);
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
const i = Number(t[1]);
|
|
101
|
-
r[i] = {
|
|
102
|
-
prop: e,
|
|
103
|
-
isEditHeader: !0,
|
|
104
|
-
label: t[0],
|
|
105
|
-
key: l,
|
|
106
|
-
isAdd: !0,
|
|
107
|
-
maxlength: 15,
|
|
108
|
-
headerMaxlength: 15
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
n.value = a, o.value = r;
|
|
112
|
-
},
|
|
113
|
-
/** 获取数据 */
|
|
114
|
-
getData: async () => {
|
|
115
|
-
await _.value.validate();
|
|
116
|
-
for (const r in o.value) {
|
|
117
|
-
const e = o.value[r];
|
|
118
|
-
for (const l of o.value)
|
|
119
|
-
if (e.prop !== l.prop && e.label === l.label) {
|
|
120
|
-
w({
|
|
121
|
-
message: "所有列的表头不可重复",
|
|
122
|
-
type: "warning"
|
|
123
|
-
});
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const a = $(n.value);
|
|
128
|
-
for (const r in a) {
|
|
129
|
-
const e = a[r];
|
|
130
|
-
for (const l in o.value) {
|
|
131
|
-
const t = o.value[l];
|
|
132
|
-
if (t.isSameData && r !== "0" && (e[t.prop] = a[0][t.prop]), t.varidate && !t.varidate(e[t.prop]))
|
|
133
|
-
return;
|
|
134
|
-
if (t.isAdd) {
|
|
135
|
-
const i = t.label + L + l;
|
|
136
|
-
e[i] = e[t.prop], delete e[t.prop];
|
|
137
|
-
}
|
|
138
|
-
t.formatter && t.type === m.FORMAT && (e[t.prop] = t.formatter(e));
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return console.log("DiyDataTable 获取数据", a, o.value), {
|
|
142
|
-
data: a,
|
|
143
|
-
columns: o.value
|
|
144
|
-
};
|
|
145
|
-
},
|
|
146
|
-
/** 更新列配置数据 */
|
|
147
|
-
updateColumn: (a, r) => {
|
|
148
|
-
const e = o.value[a].prop;
|
|
149
|
-
if (o.value[a] = r, e !== r.prop)
|
|
150
|
-
for (const l of n.value)
|
|
151
|
-
l[r.prop] = l[e], delete l[e];
|
|
152
|
-
},
|
|
153
|
-
/** 重置默认列配置数据 */
|
|
154
|
-
resetColumns: (a) => {
|
|
155
|
-
const e = o.value.filter((t) => !t.isAdd).reduce((t, i) => (a.some((x) => x.prop === i.prop) || t.push(i.prop), t), []);
|
|
156
|
-
n.value.forEach((t) => {
|
|
157
|
-
e.forEach((i) => {
|
|
158
|
-
delete t[i];
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
const l = a.filter((t) => t.isAdd);
|
|
162
|
-
o.value = [...a, ...l];
|
|
163
|
-
}
|
|
164
|
-
}), (a, r) => (d(), g(s(X), {
|
|
165
|
-
class: "diy-data-table",
|
|
166
|
-
model: u.rawData,
|
|
167
|
-
ref_key: "formRef",
|
|
168
|
-
ref: _
|
|
169
|
-
}, {
|
|
170
|
-
default: p(() => [
|
|
171
|
-
v(s(j), { data: n.value }, {
|
|
172
|
-
default: p(() => [
|
|
173
|
-
v(s(E), {
|
|
174
|
-
type: "index",
|
|
175
|
-
label: "序号",
|
|
176
|
-
width: "132",
|
|
177
|
-
fixed: "left"
|
|
178
|
-
}),
|
|
179
|
-
(d(!0), f(W, null, Z(o.value, (e, l) => (d(), g(s(E), {
|
|
180
|
-
key: e.key || l,
|
|
181
|
-
prop: e.prop,
|
|
182
|
-
label: e.label,
|
|
183
|
-
width: e.width,
|
|
184
|
-
"min-width": e.minWidth || a.defaultMinWidth,
|
|
185
|
-
fixed: e.fixed
|
|
186
|
-
}, {
|
|
187
|
-
header: p(() => [
|
|
188
|
-
a.isEdit ? e.isEditHeader ? (d(), f("div", Y, [
|
|
189
|
-
v(s(T), {
|
|
190
|
-
prop: `columns.${l}`,
|
|
191
|
-
rules: q(l)
|
|
192
|
-
}, {
|
|
193
|
-
default: p(() => [
|
|
194
|
-
v(s(M), {
|
|
195
|
-
modelValue: e.label,
|
|
196
|
-
"onUpdate:modelValue": (t) => e.label = t,
|
|
197
|
-
maxlength: e.headerMaxlength || 20,
|
|
198
|
-
placeholder: "请输入表头"
|
|
199
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "maxlength"])
|
|
200
|
-
]),
|
|
201
|
-
_: 2
|
|
202
|
-
}, 1032, ["prop", "rules"]),
|
|
203
|
-
e.isAdd ? (d(), f("i", {
|
|
204
|
-
key: 0,
|
|
205
|
-
class: "iconfont icon-close",
|
|
206
|
-
onClick: (t) => S(l, e)
|
|
207
|
-
}, null, 8, ee)) : k("", !0)
|
|
208
|
-
])) : (d(), f("div", {
|
|
209
|
-
key: 2,
|
|
210
|
-
class: D({ "is-required-label": e.required })
|
|
211
|
-
}, c(e.label), 3)) : (d(), f("div", Q, c(e.label), 1))
|
|
212
|
-
]),
|
|
213
|
-
default: p((t) => [
|
|
214
|
-
h.isEdit && (!e.isSameData || t.$index === 0) && e.type !== s(m).TEXT ? (d(), g(s(T), {
|
|
215
|
-
key: 0,
|
|
216
|
-
prop: `${t.$index}.${e.prop}`,
|
|
217
|
-
rules: B(e),
|
|
218
|
-
class: D(["col-edit-container", { "close-padding": e.isAdd }])
|
|
219
|
-
}, {
|
|
220
|
-
default: p(() => [
|
|
221
|
-
e.type === s(m).FORMAT && e.formatter ? (d(), f("div", te, c(e.showFormatter ? e.showFormatter(
|
|
222
|
-
e.formatter(t.row)
|
|
223
|
-
) : e.formatter(t.row)), 1)) : e.type === s(m).AUTOCOMPLETE ? (d(), g(s(K), {
|
|
224
|
-
key: 1,
|
|
225
|
-
modelValue: t.row[e.prop],
|
|
226
|
-
"onUpdate:modelValue": (i) => t.row[e.prop] = i,
|
|
227
|
-
placeholder: e.placeholder || "请输入",
|
|
228
|
-
"fetch-suggestions": (i, x) => O(i, x, e),
|
|
229
|
-
maxlength: e.maxlength || 20
|
|
230
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "fetch-suggestions", "maxlength"])) : e.slot ? C(a.$slots, e.slot, {
|
|
231
|
-
key: 2,
|
|
232
|
-
row: t.row,
|
|
233
|
-
$index: t.$index
|
|
234
|
-
}, void 0, !0) : (d(), g(s(M), {
|
|
235
|
-
key: 3,
|
|
236
|
-
modelValue: t.row[e.prop],
|
|
237
|
-
"onUpdate:modelValue": (i) => t.row[e.prop] = i,
|
|
238
|
-
placeholder: e.placeholder || "请输入",
|
|
239
|
-
formatter: e.formatter,
|
|
240
|
-
parser: e.parser,
|
|
241
|
-
maxlength: e.maxlength || 20
|
|
242
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder", "formatter", "parser", "maxlength"]))
|
|
243
|
-
]),
|
|
244
|
-
_: 2
|
|
245
|
-
}, 1032, ["prop", "rules", "class"])) : e.slot ? C(a.$slots, e.slot, {
|
|
246
|
-
key: 1,
|
|
247
|
-
row: t.row,
|
|
248
|
-
$index: t.$index
|
|
249
|
-
}, void 0, !0) : (d(), f("div", ae, c((e.isSameData ? n.value[0][e.prop] : t.row[e.prop]) || s(P)), 1))
|
|
250
|
-
]),
|
|
251
|
-
_: 2
|
|
252
|
-
}, 1032, ["prop", "label", "width", "min-width", "fixed"]))), 128)),
|
|
253
|
-
h.isEdit ? (d(), g(s(E), {
|
|
254
|
-
key: 0,
|
|
255
|
-
width: "150",
|
|
256
|
-
fixed: "right"
|
|
257
|
-
}, {
|
|
258
|
-
header: p(() => [
|
|
259
|
-
y("div", re, [
|
|
260
|
-
v(s(A), {
|
|
261
|
-
type: "primary",
|
|
262
|
-
link: "",
|
|
263
|
-
onClick: F
|
|
264
|
-
}, {
|
|
265
|
-
default: p(() => r[0] || (r[0] = [
|
|
266
|
-
y("i", { class: "iconfont icon-Frame1" }, null, -1),
|
|
267
|
-
V("增行")
|
|
268
|
-
])),
|
|
269
|
-
_: 1
|
|
270
|
-
}),
|
|
271
|
-
v(s(A), {
|
|
272
|
-
type: "primary",
|
|
273
|
-
link: "",
|
|
274
|
-
onClick: U
|
|
275
|
-
}, {
|
|
276
|
-
default: p(() => r[1] || (r[1] = [
|
|
277
|
-
y("i", { class: "iconfont icon-Frame-11" }, null, -1),
|
|
278
|
-
V("增列")
|
|
279
|
-
])),
|
|
280
|
-
_: 1
|
|
281
|
-
})
|
|
282
|
-
])
|
|
283
|
-
]),
|
|
284
|
-
default: p(({ $index: e }) => [
|
|
285
|
-
y("div", le, [
|
|
286
|
-
n.value.length > 1 ? (d(), f("i", {
|
|
287
|
-
key: 0,
|
|
288
|
-
class: "iconfont icon-close",
|
|
289
|
-
onClick: (l) => I(e)
|
|
290
|
-
}, null, 8, oe)) : k("", !0)
|
|
291
|
-
])
|
|
292
|
-
]),
|
|
293
|
-
_: 1
|
|
294
|
-
})) : k("", !0)
|
|
295
|
-
]),
|
|
296
|
-
_: 3
|
|
297
|
-
}, 8, ["data"])
|
|
298
|
-
]),
|
|
299
|
-
_: 3
|
|
300
|
-
}, 8, ["model"]));
|
|
301
|
-
}
|
|
302
|
-
}), se = /* @__PURE__ */ G(ie, [["__scopeId", "data-v-74d07c51"]]), he = J(se);
|
|
303
|
-
export {
|
|
304
|
-
m as D,
|
|
305
|
-
he as Z
|
|
306
|
-
};
|