zhihao-ui 1.3.64-alpha.1 → 1.3.64-alpha.2

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