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