zhihao-ui 1.2.21 → 1.2.22

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