zhihao-ui 1.2.41 → 1.2.42

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