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