zhihao-ui 1.3.64-alpha.1 → 1.3.64

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