@ithinkdt/ui 4.0.2 → 4.0.4

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/dist/page.js CHANGED
@@ -1,18 +1,218 @@
1
1
  import { n as e } from "./use-i18n-Cmb7Xx7d.js";
2
- import { a as t, h as n, i as r, r as i, s as a, x as o } from "./components-BOgApmgo.js";
3
- import { computed as s, createVNode as c, defineComponent as l, h as u, isVNode as d, mergeProps as f, nextTick as p, ref as m, shallowRef as h, toValue as g, unref as _ } from "vue";
4
- import { until as v, useClipboard as y } from "@vueuse/core";
5
- import { NButton as b, NCheckbox as x, NColorPicker as S, NDatePicker as C, NDrawer as w, NDrawerContent as T, NFlex as E, NIcon as D, NInput as O, NInputNumber as k, NModal as A, NScrollbar as j, NSelect as M, NText as N, NUpload as P, useMessage as F } from "ithinkdt-ui";
2
+ import { DataForm as t, DtDeptRender as n, DtUserDept as r, DtUserRender as i, NCheckboxes as a, NRadios as o } from "./components.js";
3
+ import { computed as s, createVNode as c, defineAsyncComponent as l, defineComponent as u, h as d, isVNode as f, mergeProps as p, nextTick as m, ref as h, shallowRef as g, toValue as _, unref as v } from "vue";
4
+ import { until as y, useClipboard as b } from "@vueuse/core";
5
+ import { NButton as x, NCheckbox as S, NColorPicker as C, NDrawer as w, NDrawerContent as T, NFlex as E, NIcon as D, NInput as O, NInputNumber as k, NModal as A, NScrollbar as j, NSelect as M, NText as N, NUpload as P, useMessage as F } from "ithinkdt-ui";
6
6
  import { nanoid as I } from "nanoid";
7
7
  import { format as L } from "date-fns";
8
8
  import { useFormItem as R } from "ithinkdt-ui/es/_mixins";
9
9
  import { useModal as z } from "@ithinkdt/page";
10
10
  import { isNullish as B } from "@ithinkdt/common";
11
11
  import { useDict as V, useDictMap as H } from "@ithinkdt/common/dict";
12
- function U(e) {
13
- return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !d(e);
12
+ const U = (e) => Object.fromEntries(Object.entries(e || {}).map(([e, t]) => [e, v(t)]));
13
+ function W(e) {
14
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
14
15
  }
15
- var W = (e) => Object.fromEntries(Object.entries(e || {}).map(([e, t]) => [e, _(t)])), G = /* @__PURE__ */ l({
16
+ function G({ getDeptsByCode: e, getUsersByUsername: t, getFileInfos: r, previewFileUrl: a }) {
17
+ let o = (e) => (t, n, { params: r = {} }) => {
18
+ if (t != null) return L(t, r.formatter ?? e);
19
+ }, s = (e = {}) => c("svg", p({
20
+ xmlns: "http://www.w3.org/2000/svg",
21
+ width: "1em",
22
+ height: "1em",
23
+ viewBox: "0 0 32 32"
24
+ }, e), [c("circle", {
25
+ cx: "16",
26
+ cy: "16",
27
+ r: "8",
28
+ fill: "currentColor"
29
+ }, null)]), l = (e = {}) => c("svg", p({
30
+ xmlns: "http://www.w3.org/2000/svg",
31
+ width: "1em",
32
+ height: "1em",
33
+ viewBox: "0 0 24 24"
34
+ }, e), [c("path", {
35
+ fill: "currentColor",
36
+ d: "M12 9a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3m0-4.5c5 0 9.27 3.11 11 7.5c-1.73 4.39-6 7.5-11 7.5S2.73 16.39 1 12c1.73-4.39 6-7.5 11-7.5M3.18 12a9.821 9.821 0 0 0 17.64 0a9.821 9.821 0 0 0-17.64 0"
37
+ }, null)]), u = (e) => c("svg", p({
38
+ xmlns: "http://www.w3.org/2000/svg",
39
+ width: "1em",
40
+ height: "1em",
41
+ viewBox: "0 0 24 24"
42
+ }, e), [c("path", {
43
+ fill: "currentColor",
44
+ d: "M19 21H8V7h11m0-2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m-3-4H4a2 2 0 0 0-2 2v14h2V3h12z"
45
+ }, null)]), d = (e) => c("svg", p({
46
+ xmlns: "http://www.w3.org/2000/svg",
47
+ width: "1em",
48
+ height: "1em",
49
+ viewBox: "0 0 24 24"
50
+ }, e), [c("path", {
51
+ fill: "currentColor",
52
+ d: "M20 12a8 8 0 0 1-8 8a8 8 0 0 1-8-8a8 8 0 0 1 8-8c.76 0 1.5.11 2.2.31l1.57-1.57A9.8 9.8 0 0 0 12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10M7.91 10.08L6.5 11.5L11 16L21 6l-1.41-1.42L11 13.17z"
53
+ }, null)]);
54
+ return {
55
+ longtext: () => {
56
+ let e = h(), t = h(), n = h(), { open: r } = z({
57
+ type: "drawer",
58
+ resizable: !0,
59
+ content: () => c("div", null, [c("span", null, [e.value])]),
60
+ width: t,
61
+ footer: () => n.value?.() ?? null,
62
+ maskClosable: !0
63
+ }), { copy: i, copied: a } = b({ legacy: !0 }), o = (t, n, o) => {
64
+ if (!n) return r(t);
65
+ let s = () => {
66
+ o ? o(e.value) : i(e.value);
67
+ };
68
+ return r(() => c("div", { style: "display: flex; align-items: center; justify-content: space-between; margin-right: 4px;" }, [_(t), a.value ? c(x, {
69
+ quaternary: !0,
70
+ size: "tiny",
71
+ type: "success"
72
+ }, { icon: () => c(D, { size: 18 }, { default: () => [c(d, null, null)] }) }) : c(x, {
73
+ quaternary: !0,
74
+ size: "tiny",
75
+ onClick: s
76
+ }, { icon: () => c(D, { size: 16 }, { default: () => [c(u, null, null)] }) })]));
77
+ };
78
+ return {
79
+ renderer: (r, i, { params: a = {} }, { label: s }) => c("div", { style: "white-space: nowrap; overflow: hidden; display: flex; gap: 8px; align-items: center; justify-content: space-between" }, [c("div", { style: "flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" }, [r]), c(x, {
80
+ type: "info",
81
+ text: !0,
82
+ style: "position: sticky; right: 0; z-index: 2",
83
+ onClick: a.showText ? () => a.showText(r) : () => {
84
+ e.value = a.formatText ? a.formatText(r) : r, t.value = a.drawerWidth ?? 600, n.value = () => a.drawerFooter?.(r, i), o(a.title || s, a.copyable !== !1, a.onCopy);
85
+ }
86
+ }, { default: () => [c(D, { size: 18 }, { default: () => [c(l, null, null)] })] })]),
87
+ default: { table: { ellipsis: !1 } }
88
+ };
89
+ },
90
+ date: () => ({
91
+ renderer: o("yyyy-MM-dd"),
92
+ default: { table: {
93
+ width: 140,
94
+ align: "center",
95
+ sortable: !0
96
+ } }
97
+ }),
98
+ datetime: () => ({
99
+ renderer: o("yyyy-MM-dd HH:mm:ss"),
100
+ default: { table: {
101
+ width: 174,
102
+ align: "center",
103
+ sortable: !0
104
+ } }
105
+ }),
106
+ dict: () => {
107
+ let e, t, n;
108
+ return (r, i, { params: a = {} }) => {
109
+ if (r == null) return;
110
+ let { dictType: o, options: l, multiple: u, statusMap: d } = U(a);
111
+ if (l ? t !== l && (t = l, n = new Map(l.map((e) => [e[a.valueField || "value"], e]))) : e !== o && (e = o, !n && e && (n = H(e))), !u) {
112
+ if (r = r.toString(), d && r in d) {
113
+ let e = d[r] ?? "default";
114
+ return [
115
+ "primary",
116
+ "success",
117
+ "warning",
118
+ "danger"
119
+ ].includes(e) && (e = `var(--color-${e})`), c("span", { style: "position: relative; padding-left: 1.25em" }, [c(s, { style: `color: ${e}; position: absolute;left: 0; top: 1.5px` }, null), c("span", null, [n.get(r)?.[a.labelField || "label"] ?? r ?? ""])]);
120
+ }
121
+ return n.get(r)?.[a.labelField || "label"] ?? r ?? "";
122
+ }
123
+ return r?.map((e) => n.get(e?.toString())?.[a.labelField || "label"] ?? e?.toString() ?? "") ?? "";
124
+ };
125
+ },
126
+ number: () => ({
127
+ renderer: (e, t, { params: n = {} }) => {
128
+ if (e != null) {
129
+ switch (n.percent && (e = Number(e) * 100), "number") {
130
+ case typeof n.fixed:
131
+ e = e.toFixed(n.fixed);
132
+ break;
133
+ case typeof n.round:
134
+ e = e.toFixed(n.round).replace(/0+$/, "");
135
+ break;
136
+ case typeof n.precision:
137
+ e = e.toPrecision(n.precision);
138
+ break;
139
+ }
140
+ return n?.separator ? Number(e).toLocaleString() : e;
141
+ }
142
+ },
143
+ default: { table: {
144
+ width: 100,
145
+ align: "right",
146
+ sortable: !0
147
+ } }
148
+ }),
149
+ email: () => (e) => c("a", { href: `mailto:${e}` }, [e]),
150
+ url: () => (e) => c("a", { href: e }, [e]),
151
+ color: () => (e) => c(C, {
152
+ value: e,
153
+ disabled: !0,
154
+ size: "small"
155
+ }, null),
156
+ image: () => (e, t, { params: n = {} }) => {
157
+ let r;
158
+ return e ? c(E, {
159
+ gap: "8",
160
+ wrap: !0
161
+ }, W(r = (Array.isArray(e) ? e : n?.multiple ? e.split(",") : [e]).map((e) => a(e)).map((e) => c("img", {
162
+ key: e,
163
+ src: e,
164
+ style: "max-height: 32px; max-width: 100px; object-fit: contain"
165
+ }, null))) ? r : { default: () => [r] }) : void 0;
166
+ },
167
+ file: () => {
168
+ let e = I();
169
+ return (t, n, { params: i = {} }) => {
170
+ let a;
171
+ return t ? (n.__file_urls ??= {}, n.__file_urls[e] || r(Array.isArray(t) ? t : i?.multiple ? t.split(",") : [t]).then((t) => {
172
+ n.__file_urls[e] = t;
173
+ }), c(E, {
174
+ gap: "8",
175
+ wrap: !0
176
+ }, W(a = (n.__file_urls[e] || []).map((e) => c("a", {
177
+ key: e.id,
178
+ href: e.url,
179
+ target: "_blank",
180
+ rel: "noreferrer",
181
+ style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
182
+ }, [e.name]))) ? a : { default: () => [a] })) : void 0;
183
+ };
184
+ },
185
+ dept: () => (t, r, { params: i = {} }) => {
186
+ if (t) return c(n, {
187
+ value: t,
188
+ multiple: i?.multiple,
189
+ getDeptsByCode: e
190
+ }, null);
191
+ },
192
+ user: () => {
193
+ let e = { style: "padding-block: 0" };
194
+ return {
195
+ renderer: (e, n, { params: r = {} }) => {
196
+ if (e) return c(i, {
197
+ value: e,
198
+ multiple: r?.multiple,
199
+ getUsersByUsername: t
200
+ }, null);
201
+ },
202
+ default: { table: {
203
+ width: 150,
204
+ ellipsis: !1,
205
+ align: "center",
206
+ cellProps: () => e
207
+ } }
208
+ };
209
+ }
210
+ };
211
+ }
212
+ function K(e) {
213
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
214
+ }
215
+ var q = l(() => import("ithinkdt-ui/es/date-picker")), J = u({
16
216
  name: "SimpleUpload",
17
217
  props: {
18
218
  type: {
@@ -52,24 +252,24 @@ var W = (e) => Object.fromEntries(Object.entries(e || {}).map(([e, t]) => [e, _(
52
252
  },
53
253
  setup(t, { slots: n, expose: r }) {
54
254
  let { t: i } = e();
55
- G.t = i;
255
+ J.t = i;
56
256
  let a = R(t), o = F(), l = s(() => t.customRequest || (({ file: e, onProgress: n, onFinish: r, onError: i }) => {
57
257
  t.uploadFile(e.file, (e) => n({ percent: e })).then((t) => {
58
258
  e.file.fileId = t, r();
59
259
  }).catch((e) => {
60
260
  o.error(e.message), i(e);
61
261
  });
62
- })), u = m();
262
+ })), u = h();
63
263
  r({ submit() {
64
- return v(u).toBeTruthy().then((e) => e.submit());
264
+ return y(u).toBeTruthy().then((e) => e.submit());
65
265
  } });
66
266
  let d = (e) => {
67
267
  if (e) for (let n of e) n.size > t.maxSize * 1024 && (n.status = "error");
68
- t.onUpdateFileList?.(e), p(() => a.nTriggerFormChange());
268
+ t.onUpdateFileList?.(e), m(() => a.nTriggerFormChange());
69
269
  };
70
270
  return () => {
71
271
  let { type: e, onUpdateFileList: r, ...o } = t;
72
- return c(P, f(o, {
272
+ return c(P, p(o, {
73
273
  ref: u,
74
274
  customRequest: l.value,
75
275
  listType: e === "image" ? "image-card" : "text",
@@ -78,23 +278,23 @@ var W = (e) => Object.fromEntries(Object.entries(e || {}).map(([e, t]) => [e, _(
78
278
  }), {
79
279
  default: e === "image" ? void 0 : () => {
80
280
  let e;
81
- return c(b, {
281
+ return c(x, {
82
282
  disabled: a.mergedDisabledRef.value,
83
283
  size: a.mergedSizeRef.value
84
- }, U(e = i("common.page.form.selectFileText")) ? e : { default: () => [e] });
284
+ }, K(e = i("common.page.form.selectFileText")) ? e : { default: () => [e] });
85
285
  },
86
286
  ...n
87
287
  });
88
288
  };
89
289
  }
90
290
  });
91
- function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersByDept: s, getUsersByUsername: l, uploadFile: d, getFileInfos: f }) {
92
- let p = (e) => e, m = (e) => B(e) ? e : String(e), g = (e) => B(e) ? e : Number(e);
291
+ function Y({ getUserGroups: e, getUsersByGroup: t, getDeptsByCode: n, getUsersByDept: s, getUsersByUsername: l, uploadFile: u, getFileInfos: f }) {
292
+ let p = (e) => e, m = (e) => B(e) ? e : String(e), h = (e) => B(e) ? e : Number(e);
93
293
  return {
94
294
  input: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => a ? c(N, {
95
295
  depth: 2,
96
296
  style: "line-height: 1.25"
97
- }, { default: () => [n ?? ""] }) : (t = W(t), u(O, {
297
+ }, { default: () => [n ?? ""] }) : (t = U(t), d(O, {
98
298
  clearable: !0,
99
299
  ...t,
100
300
  ...o,
@@ -108,62 +308,63 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
108
308
  depth: 2,
109
309
  style: "line-height: 1.25"
110
310
  }, { default: () => [i ?? ""] });
111
- let { valueType: d = "number", ...f } = W(r), p = d === "string" ? g(i) : i;
112
- return e = a, d === "string" && !t && (t = (t, ...n) => {
311
+ let { valueType: u = "number", ...f } = U(r), p = u === "string" ? h(i) : i;
312
+ return e = a, u === "string" && !t && (t = (t, ...n) => {
113
313
  e(m(t), ...n);
114
- }), u(k, {
314
+ }), d(k, {
115
315
  clearable: !0,
116
316
  ...f,
117
317
  ...l,
118
318
  value: p,
119
- "onUpdate:value": d === "string" ? t : e
319
+ "onUpdate:value": u === "string" ? t : e
120
320
  }, n);
121
321
  };
122
322
  },
123
323
  select: () => {
124
324
  let e, t, n, r, i;
125
- return ({ slots: a, props: o }, { modelValue: s, "onUpdate:modelValue": l, required: d, readonly: f, ...h }) => {
126
- let { dictType: v, options: y, valueType: b = "string", ...x } = W(o), S = b === "number" ? m : p;
127
- y ? t = y : e !== v && (e = v, !t && e && (t = V(e)));
325
+ return ({ slots: a, props: o }, { modelValue: s, "onUpdate:modelValue": l, required: u, readonly: f, ...g }) => {
326
+ let { dictType: _, options: y, valueType: b = "string", ...x } = U(o), S = b === "number" ? m : p;
327
+ y ? t = y : e !== _ && (e = _, !t && e && (t = V(e)));
128
328
  let C = x.multiple ? s?.map(S) : S(s);
129
329
  if (f) if (x.multiple) {
130
330
  let e;
131
331
  return c(N, {
132
332
  depth: 2,
133
333
  style: "line-height: 1.25"
134
- }, U(e = (C?.map((e) => t?.find((t) => t[x.valueField || "value"] === e)) ?? []).map((e, t, n) => {
334
+ }, K(e = (C?.map((e) => v(t)?.find((t) => t[x.valueField || "value"] === e)) ?? []).map((e, t, n) => {
135
335
  let r = e ? x.renderLabel ? x.renderLabel(e) ?? "" : e[x.labelField || "label"] ?? "" : C[t] ?? "";
136
336
  return c("span", { key: e ? e[x.valueField || "value"] : C[t] ?? "" }, [r, t < n.length - 1 ? ", " : ""]);
137
337
  })) ? e : { default: () => [e] });
138
338
  } else {
139
- let e = t?.find((e) => e[x.valueField || "value"] === C);
339
+ let e = v(t)?.find((e) => e[x.valueField || "value"] === C);
140
340
  return c(N, {
141
341
  depth: 2,
142
342
  style: "line-height: 1.25"
143
343
  }, { default: () => [e ? x.renderLabel ? x.renderLabel(e) ?? "" : e[x.labelField || "label"] ?? "" : C ?? ""] });
144
344
  }
145
345
  return r = x.multiple, n = l, b === "number" && !i && (i = (e, ...t) => {
146
- n(r ? e?.map(g) : g(e), ...t);
147
- }), u(M, {
346
+ n(r ? e?.map(h) : h(e), ...t);
347
+ }), d(M, {
148
348
  clearable: !0,
349
+ filterable: v(t)?.length > 9,
149
350
  loading: t?.loading,
150
351
  ...x,
151
- options: _(t),
152
- ...h,
352
+ options: v(t),
353
+ ...g,
153
354
  value: C,
154
355
  "onUpdate:value": b === "number" ? i : n
155
356
  }, a);
156
357
  };
157
358
  },
158
359
  checkbox: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
159
- if (t = W(t), a) {
360
+ if (t = U(t), a) {
160
361
  let r;
161
- return r = n === (t.checkedValue ?? !0) ? e?.checked ? e.checked() : c(x, { checked: !0 }, null) : e?.unchecked ? e.unchecked() : c(x, { disabled: !0 }, null), c(N, {
362
+ return r = n === (t.checkedValue ?? !0) ? e?.checked ? e.checked() : c(S, { checked: !0 }, null) : e?.unchecked ? e.unchecked() : c(S, { disabled: !0 }, null), c(N, {
162
363
  depth: 2,
163
364
  style: "line-height: 1.25"
164
- }, U(r) ? r : { default: () => [r] });
365
+ }, K(r) ? r : { default: () => [r] });
165
366
  }
166
- return u(x, {
367
+ return d(S, {
167
368
  ...t,
168
369
  ...o,
169
370
  checked: n,
@@ -172,23 +373,23 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
172
373
  },
173
374
  checkboxes: () => {
174
375
  let e, t, n, r;
175
- return ({ props: i }, { modelValue: a, "onUpdate:modelValue": s, required: l, readonly: d, ...f }) => {
176
- let { dictType: h, options: _, valueType: v = "string", ...y } = W(i), b = v === "number" ? m : p;
177
- _ ? t = _ : e !== h && (e = h, !t && e && (t = V(e)));
178
- let x = a?.map(b) ?? [];
179
- if (d) {
376
+ return ({ props: i }, { modelValue: o, "onUpdate:modelValue": s, required: l, readonly: u, ...f }) => {
377
+ let { dictType: g, options: _, valueType: v = "string", ...y } = U(i), b = v === "number" ? m : p;
378
+ _ ? t = _ : e !== g && (e = g, !t && e && (t = V(e)));
379
+ let x = o?.map(b) ?? [];
380
+ if (u) {
180
381
  let e;
181
382
  return c(N, {
182
383
  depth: 2,
183
384
  style: "line-height: 2.4"
184
- }, U(e = (x?.map((e) => t?.find((t) => t[y.valueField || "value"] === e)) ?? []).map((e, t, n) => {
385
+ }, K(e = (x?.map((e) => t?.find((t) => t[y.valueField || "value"] === e)) ?? []).map((e, t, n) => {
185
386
  let r = e ? e[y.labelField ?? "label"] ?? "" : x[t] ?? "";
186
387
  return c("span", { key: e ? e[y.valueField ?? "value"] : x[t] ?? "" }, [r, t < n.length - 1 ? ", " : ""]);
187
388
  })) ? e : { default: () => [e] });
188
389
  }
189
390
  return n = s, v === "number" && !r && (r = (e, ...t) => {
190
- n(e?.map(g), ...t);
191
- }), u(o, {
391
+ n(e?.map(h), ...t);
392
+ }), d(a, {
192
393
  ...y,
193
394
  ...f,
194
395
  options: t,
@@ -199,11 +400,11 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
199
400
  },
200
401
  radios: () => {
201
402
  let e, t, n, r;
202
- return ({ props: i }, { modelValue: o, "onUpdate:modelValue": s, required: l, readonly: d, ...f }) => {
203
- let { dictType: h, options: _, valueType: v = "string", ...y } = W(i), b = v === "number" ? m : p;
204
- _ ? t = _ : e !== h && (e = h, !t && e && (t = V(e)));
205
- let x = b(o);
206
- if (d) {
403
+ return ({ props: i }, { modelValue: a, "onUpdate:modelValue": s, required: l, readonly: u, ...f }) => {
404
+ let { dictType: g, options: _, valueType: v = "string", ...y } = U(i), b = v === "number" ? m : p;
405
+ _ ? t = _ : e !== g && (e = g, !t && e && (t = V(e)));
406
+ let x = b(a);
407
+ if (u) {
207
408
  let e = t?.find((e) => e[y.valueField ?? "value"] === x);
208
409
  return c(N, {
209
410
  depth: 2,
@@ -211,8 +412,8 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
211
412
  }, { default: () => [e ? e[y.labelField ?? "label"] ?? "" : x ?? ""] });
212
413
  }
213
414
  return n = s, v === "number" && !r && (r = (e, ...t) => {
214
- n(g(e), ...t);
215
- }), u(a, {
415
+ n(h(e), ...t);
416
+ }), d(o, {
216
417
  ...y,
217
418
  ...f,
218
419
  options: t,
@@ -222,18 +423,18 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
222
423
  };
223
424
  },
224
425
  datepicker: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
225
- let { type: s = "date", format: l = s.startsWith("datetime") ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd", ...d } = W(t);
426
+ let { type: s = "date", format: l = s.startsWith("datetime") ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd", ...u } = U(t);
226
427
  return a ? s.endsWith("range") ? c(N, {
227
428
  depth: 2,
228
429
  style: "line-height: 1.25"
229
430
  }, { default: () => [n ? `${n[0] ? L(n[0], l) : ""} ~ ${n[1] ? L(n[1], l) : ""}` : ""] }) : c(N, {
230
431
  depth: 2,
231
432
  style: "line-height: 1.25"
232
- }, { default: () => [n ? L(n, l) : ""] }) : u(C, {
433
+ }, { default: () => [n ? L(n, l) : ""] }) : d(q, {
233
434
  actions: null,
234
435
  updateValueOnClose: !0,
235
436
  clearable: !0,
236
- ...d,
437
+ ...u,
237
438
  ...o,
238
439
  type: s,
239
440
  format: l,
@@ -242,12 +443,12 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
242
443
  }, e);
243
444
  },
244
445
  file: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
245
- if (t = W(t), a) {
446
+ if (t = U(t), a) {
246
447
  let e;
247
448
  return console.warn("[file] 原则上此组建不应该显示在详情中"), n?.length ? c(E, {
248
449
  gap: "8",
249
450
  vertical: !0
250
- }, U(e = n.map((e) => c("a", {
451
+ }, K(e = n.map((e) => c("a", {
251
452
  key: e.id,
252
453
  href: e.url,
253
454
  target: "_blank",
@@ -255,17 +456,17 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
255
456
  style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
256
457
  }, [e.name]))) ? e : { default: () => [e] }) : void 0;
257
458
  }
258
- return u(G, {
459
+ return d(J, {
259
460
  ...t,
260
461
  ...o,
261
462
  defaultUpload: !1,
262
- uploadFile: d,
463
+ uploadFile: u,
263
464
  fileList: n,
264
465
  onUpdateFileList: r
265
466
  }, e);
266
467
  },
267
468
  upload: () => {
268
- let e = null, t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = h([]), i = 0, a = (e) => {
469
+ let e = null, t = new Map(), n = new Map(), r = g([]), i = 0, a = (e) => {
269
470
  let t = ++i;
270
471
  r.value = e.map((e) => n.get(e)).filter(Boolean);
271
472
  let a = e.filter((e) => !n.has(e));
@@ -277,15 +478,15 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
277
478
  });
278
479
  }, o, s;
279
480
  return {
280
- renderer: ({ slots: i, props: l }, { modelValue: f, "onUpdate:modelValue": p, required: m, readonly: g, ..._ }) => {
281
- let v = W(l);
282
- if (s = v.maxSize, o = v.ref ??= h(), e !== f && (e = f, a(f?.split(",") ?? [])), g) {
481
+ renderer: ({ slots: i, props: l }, { modelValue: f, "onUpdate:modelValue": p, required: m, readonly: h, ..._ }) => {
482
+ let v = U(l);
483
+ if (s = v.maxSize, o = v.ref ??= g(), e !== f && (e = f, a(f?.split(",") ?? [])), h) {
283
484
  let e;
284
485
  return r.value.length === 0 ? void 0 : c(E, {
285
486
  gap: "8",
286
487
  vertical: !0,
287
488
  style: "padding: 6px 0"
288
- }, U(e = r.value.map((e) => c("a", {
489
+ }, K(e = r.value.map((e) => c("a", {
289
490
  key: e.id,
290
491
  href: e.url,
291
492
  target: "_blank",
@@ -295,10 +496,10 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
295
496
  style: "max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
296
497
  }, [e.name]))) ? e : { default: () => [e] });
297
498
  }
298
- return u(G, {
499
+ return d(J, {
299
500
  ...v,
300
501
  ..._,
301
- uploadFile: d,
502
+ uploadFile: u,
302
503
  fileList: r.value,
303
504
  onUpdateFileList: (e = []) => {
304
505
  n.clear();
@@ -308,298 +509,105 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
308
509
  }, i);
309
510
  },
310
511
  beforeSubmit: async () => {
311
- if (await o?.value?.submit(), await v(r).toMatch((e) => e.every((e) => !["pending", "uploading"].includes(e.status))), r.value.some((e) => e.size > s * 1024)) return G.t("common.page.form.validate.fileSizeExceeded", { maxSize: s });
312
- if (r.value.some((e) => e.status === "error")) return G.t("common.page.form.validate.fileErrorMessage");
512
+ if (await o?.value?.submit(), await y(r).toMatch((e) => e.every((e) => !["pending", "uploading"].includes(e.status))), r.value.some((e) => e.size > s * 1024)) return J.t("common.page.form.validate.fileSizeExceeded", { maxSize: s });
513
+ if (r.value.some((e) => e.status === "error")) return J.t("common.page.form.validate.fileErrorMessage");
313
514
  }
314
515
  };
315
516
  },
316
517
  user: () => {
317
- let a, o, d;
318
- return ({ slots: f, props: p }, { modelValue: m, "onUpdate:modelValue": g, required: _, readonly: v, ...y }) => {
319
- let b = W(p);
320
- return a || (a = h([]), o = h([]), d = h([]), l().then((e) => {
518
+ let a, o, u;
519
+ return ({ slots: f, props: p }, { modelValue: m, "onUpdate:modelValue": h, required: _, readonly: v, ...y }) => {
520
+ let b = U(p);
521
+ return a || (a = g([]), o = g([]), u = g([]), l().then((e) => {
321
522
  a.value = e;
322
523
  }), e().then((e) => {
323
524
  o.value = e;
324
- }), i().then((e) => {
325
- d.value = e;
326
- })), v ? c(t, {
525
+ }), n().then((e) => {
526
+ u.value = e;
527
+ })), v ? c(i, {
327
528
  value: m,
328
529
  multiple: b.multiple,
329
530
  getUsersByUsername: l,
330
531
  renderInfo: b.renderInfo
331
- }, null) : u(r, {
532
+ }, null) : d(r, {
332
533
  type: "user",
333
534
  users: a.value,
334
- depts: d.value,
535
+ depts: u.value,
335
536
  groups: o.value,
336
537
  getUsersByDept: s,
337
- getUsersByGroup: n,
538
+ getUsersByGroup: t,
338
539
  ...b,
339
540
  ...y,
340
541
  renderUserInfo: b.renderInfo,
341
542
  modelValue: m,
342
- "onUpdate:modelValue": g
543
+ "onUpdate:modelValue": h
343
544
  }, f);
344
545
  };
345
546
  }
346
547
  };
347
548
  }
348
- function q({ getDeptsByCode: e, getUsersByUsername: n, getFileInfos: r, previewFileUrl: a }) {
349
- let o = (e) => (t, n, { params: r = {} }) => {
350
- if (t != null) return L(t, r.formatter ?? e);
351
- }, s = (e = {}) => c("svg", f({
352
- xmlns: "http://www.w3.org/2000/svg",
353
- width: "1em",
354
- height: "1em",
355
- viewBox: "0 0 32 32"
356
- }, e), [c("circle", {
357
- cx: "16",
358
- cy: "16",
359
- r: "8",
360
- fill: "currentColor"
361
- }, null)]), l = (e = {}) => c("svg", f({
362
- xmlns: "http://www.w3.org/2000/svg",
363
- width: "1em",
364
- height: "1em",
365
- viewBox: "0 0 24 24"
366
- }, e), [c("path", {
367
- fill: "currentColor",
368
- d: "M12 9a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3m0-4.5c5 0 9.27 3.11 11 7.5c-1.73 4.39-6 7.5-11 7.5S2.73 16.39 1 12c1.73-4.39 6-7.5 11-7.5M3.18 12a9.821 9.821 0 0 0 17.64 0a9.821 9.821 0 0 0-17.64 0"
369
- }, null)]), u = (e) => c("svg", f({
370
- xmlns: "http://www.w3.org/2000/svg",
371
- width: "1em",
372
- height: "1em",
373
- viewBox: "0 0 24 24"
374
- }, e), [c("path", {
375
- fill: "currentColor",
376
- d: "M19 21H8V7h11m0-2H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2m-3-4H4a2 2 0 0 0-2 2v14h2V3h12z"
377
- }, null)]), d = (e) => c("svg", f({
378
- xmlns: "http://www.w3.org/2000/svg",
379
- width: "1em",
380
- height: "1em",
381
- viewBox: "0 0 24 24"
382
- }, e), [c("path", {
383
- fill: "currentColor",
384
- d: "M20 12a8 8 0 0 1-8 8a8 8 0 0 1-8-8a8 8 0 0 1 8-8c.76 0 1.5.11 2.2.31l1.57-1.57A9.8 9.8 0 0 0 12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10M7.91 10.08L6.5 11.5L11 16L21 6l-1.41-1.42L11 13.17z"
385
- }, null)]);
386
- return {
387
- longtext: () => {
388
- let e = m(), t = m(), n = m(), { open: r } = z({
389
- type: "drawer",
390
- resizable: !0,
391
- content: () => c("div", null, [c("span", null, [e.value])]),
392
- width: t,
393
- footer: () => n.value?.() ?? null,
394
- maskClosable: !0
395
- }), { copy: i, copied: a } = y({ legacy: !0 }), o = (t, n, o) => {
396
- if (!n) return r(t);
397
- let s = () => {
398
- o ? o(e.value) : i(e.value);
399
- };
400
- return r(() => c("div", { style: "display: flex; align-items: center; justify-content: space-between; margin-right: 4px;" }, [g(t), a.value ? c(b, {
401
- quaternary: !0,
402
- size: "tiny",
403
- type: "success"
404
- }, { icon: () => c(D, { size: 18 }, { default: () => [c(d, null, null)] }) }) : c(b, {
405
- quaternary: !0,
406
- size: "tiny",
407
- onClick: s
408
- }, { icon: () => c(D, { size: 16 }, { default: () => [c(u, null, null)] }) })]));
409
- };
410
- return {
411
- renderer: (r, i, { params: a = {} }, { label: s }) => c("div", { style: "white-space: nowrap; overflow: hidden; display: flex; gap: 8px; align-items: center; justify-content: space-between" }, [c("div", { style: "flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" }, [r]), c(b, {
412
- type: "info",
413
- text: !0,
414
- style: "position: sticky; right: 0; z-index: 2",
415
- onClick: a.showText ? () => a.showText(r) : () => {
416
- e.value = a.formatText ? a.formatText(r) : r, t.value = a.drawerWidth ?? 600, n.value = () => a.drawerFooter?.(r, i), o(a.title || s, a.copyable !== !1, a.onCopy);
417
- }
418
- }, { default: () => [c(D, { size: 18 }, { default: () => [c(l, null, null)] })] })]),
419
- default: { table: { ellipsis: !1 } }
420
- };
421
- },
422
- date: () => ({
423
- renderer: o("yyyy-MM-dd"),
424
- default: { table: {
425
- width: 140,
426
- align: "center",
427
- sortable: !0
428
- } }
429
- }),
430
- datetime: () => ({
431
- renderer: o("yyyy-MM-dd HH:mm:ss"),
432
- default: { table: {
433
- width: 174,
434
- align: "center",
435
- sortable: !0
436
- } }
437
- }),
438
- dict: () => {
439
- let e, t, n;
440
- return (r, i, { params: a = {} }) => {
441
- if (r == null) return;
442
- let { dictType: o, options: l, multiple: u, statusMap: d } = W(a);
443
- if (l ? t !== l && (t = l, n = new Map(l.map((e) => [e[a.valueField || "value"], e]))) : e !== o && (e = o, !n && e && (n = H(e))), !u) {
444
- if (r = r.toString(), d && r in d) {
445
- let e = d[r] ?? "default";
446
- return [
447
- "primary",
448
- "success",
449
- "warning",
450
- "danger"
451
- ].includes(e) && (e = `var(--color-${e})`), c("span", { style: "position: relative; padding-left: 1.25em" }, [c(s, { style: `color: ${e}; position: absolute;left: 0; top: 1.5px` }, null), c("span", null, [n.get(r)?.[a.labelField || "label"] ?? r ?? ""])]);
452
- }
453
- return n.get(r)?.[a.labelField || "label"] ?? r ?? "";
454
- }
455
- return r?.map((e) => n.get(e?.toString())?.[a.labelField || "label"] ?? e?.toString() ?? "") ?? "";
456
- };
457
- },
458
- number: () => ({
459
- renderer: (e, t, { params: n = {} }) => {
460
- if (e != null) {
461
- switch (n.percent && (e = Number(e) * 100), "number") {
462
- case typeof n.fixed:
463
- e = e.toFixed(n.fixed);
464
- break;
465
- case typeof n.round:
466
- e = e.toFixed(n.round).replace(/0+$/, "");
467
- break;
468
- case typeof n.precision:
469
- e = e.toPrecision(n.precision);
470
- break;
471
- }
472
- return n?.separator ? Number(e).toLocaleString() : e;
473
- }
474
- },
475
- default: { table: {
476
- width: 100,
477
- align: "right",
478
- sortable: !0
479
- } }
480
- }),
481
- email: () => (e) => c("a", { href: `mailto:${e}` }, [e]),
482
- url: () => (e) => c("a", { href: e }, [e]),
483
- color: () => (e) => c(S, {
484
- value: e,
485
- disabled: !0,
486
- size: "small"
487
- }, null),
488
- image: () => (e, t, { params: n = {} }) => {
489
- let r;
490
- return e ? c(E, {
491
- gap: "8",
492
- wrap: !0
493
- }, U(r = (Array.isArray(e) ? e : n?.multiple ? e.split(",") : [e]).map((e) => a(e)).map((e) => c("img", {
494
- key: e,
495
- src: e,
496
- style: "max-height: 32px; max-width: 100px; object-fit: contain"
497
- }, null))) ? r : { default: () => [r] }) : void 0;
498
- },
499
- file: () => {
500
- let e = I();
501
- return (t, n, { params: i = {} }) => {
502
- let a;
503
- return t ? (n.__file_urls ??= {}, n.__file_urls[e] || r(Array.isArray(t) ? t : i?.multiple ? t.split(",") : [t]).then((t) => {
504
- n.__file_urls[e] = t;
505
- }), c(E, {
506
- gap: "8",
507
- wrap: !0
508
- }, U(a = (n.__file_urls[e] || []).map((e) => c("a", {
509
- key: e.id,
510
- href: e.url,
511
- target: "_blank",
512
- rel: "noreferrer",
513
- style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
514
- }, [e.name]))) ? a : { default: () => [a] })) : void 0;
515
- };
516
- },
517
- dept: () => (t, n, { params: r = {} }) => {
518
- if (t) return c(i, {
519
- value: t,
520
- multiple: r?.multiple,
521
- getDeptsByCode: e
522
- }, null);
523
- },
524
- user: () => {
525
- let e = { style: "padding-block: 0" };
526
- return {
527
- renderer: (e, r, { params: i = {} }) => {
528
- if (e) return c(t, {
529
- value: e,
530
- multiple: i?.multiple,
531
- getUsersByUsername: n
532
- }, null);
533
- },
534
- default: { table: {
535
- width: 150,
536
- ellipsis: !1,
537
- align: "center",
538
- cellProps: () => e
539
- } }
540
- };
541
- }
542
- };
549
+ function X(e) {
550
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
543
551
  }
544
- function J() {
545
- return () => ({ items: e, model: t, handleSubmit: r, reset: i, validation: a, readonly: o, inModal: s, showFeedback: l, showColon: u, labelWidth: d, labelAlign: f, labelPlacement: p, showRequireMark: m, requireMarkPlacement: h }) => c(n, {
552
+ function Z() {
553
+ return () => ({ items: e, model: n, handleSubmit: r, reset: i, validation: a, readonly: o, inModal: s, showFeedback: l, showColon: u, labelWidth: d, labelAlign: f, labelPlacement: p, showRequireMark: m, requireMarkPlacement: h }) => c(t, {
546
554
  readonly: o,
547
- model: t,
555
+ model: n,
548
556
  items: e,
549
557
  validation: a,
550
- showColon: _(u) ?? !0,
551
- labelWidth: _(d),
552
- labelAlign: _(f),
553
- labelPlacement: _(p),
554
- showRequireMark: _(m),
555
- requireMarkPlacement: _(h),
556
- showFeedback: _(l) ?? !0,
558
+ showColon: v(u) ?? !0,
559
+ labelWidth: v(d),
560
+ labelAlign: v(f),
561
+ labelPlacement: v(p),
562
+ showRequireMark: v(m),
563
+ requireMarkPlacement: v(h),
564
+ showFeedback: v(l) ?? !0,
557
565
  showAction: !1,
558
566
  onSubmit: r,
559
567
  onReset: i,
560
568
  style: s ? "padding-right: 2rem; padding-top: 1rem" : void 0
561
569
  }, null);
562
570
  }
563
- function Y() {
571
+ function Q() {
564
572
  let e = (e) => typeof e == "number" ? `${e}px` : e, t = {
565
573
  maxHeight: "calc(100vh - 130px)",
566
574
  display: "flex",
567
575
  flexDirection: "column"
568
576
  }, n = { content: !0 };
569
- return () => ({ type: r = "dialog", visible: i, title: a, content: o, footer: s, placement: l, resizable: u, draggable: d, closeOnEsc: p, closable: m, showMask: h, maskClosable: g, width: _, height: v, style: y, onClose: x, onCancel: S, onConfirm: C, onAfterClose: D, onAfterOpen: O, confirmText: k, confirmDisabled: M, confirmLoading: N, cancelText: P, cancelDisabled: F, cancelLoading: I, nativeScrollbar: L, ...R }) => {
577
+ return () => ({ type: r = "dialog", visible: i, title: a, content: o, footer: s, placement: l, resizable: u, draggable: d, closeOnEsc: f, closable: m, showMask: h, maskClosable: g, width: _, height: v, style: y, onClose: b, onCancel: S, onConfirm: C, onAfterClose: D, onAfterOpen: O, confirmText: k, confirmDisabled: M, confirmLoading: N, cancelText: P, cancelDisabled: F, cancelLoading: I, nativeScrollbar: L, ...R }) => {
570
578
  let z = s ? () => s : s === null ? null : () => c(E, {
571
579
  justify: "end",
572
580
  gap: "16"
573
- }, { default: () => [P === null ? void 0 : c(b, {
581
+ }, { default: () => [P === null ? void 0 : c(x, {
574
582
  onClick: S,
575
583
  disabled: F,
576
584
  loading: I,
577
585
  style: "min-width: 60px"
578
- }, U(P) ? P : { default: () => [P] }), k === null ? void 0 : c(b, {
586
+ }, X(P) ? P : { default: () => [P] }), k === null ? void 0 : c(x, {
579
587
  type: "primary",
580
588
  onClick: C,
581
589
  disabled: M,
582
590
  loading: N,
583
591
  style: "min-width: 60px"
584
- }, U(k) ? k : { default: () => [k] })] });
592
+ }, X(k) ? k : { default: () => [k] })] });
585
593
  if (r === "dialog") {
586
- let { style: r } = f({ style: {
594
+ let { style: r } = p({ style: {
587
595
  width: e(_ ?? 520),
588
596
  height: e(v)
589
597
  } }, { style: y });
590
- return c(A, f({
598
+ return c(A, p({
591
599
  show: i,
592
600
  preset: "card",
593
601
  title: () => a,
594
602
  maskClosable: g ?? !1,
595
- closeOnEsc: p,
603
+ closeOnEsc: f,
596
604
  closable: m,
597
- onClose: x,
605
+ onClose: b,
598
606
  segmented: n,
599
607
  size: "small",
600
608
  onAfterEnter: O,
601
609
  onAfterLeave: D,
602
- onUpdateShow: x,
610
+ onUpdateShow: b,
603
611
  draggable: d ?? !0,
604
612
  style: r,
605
613
  contentStyle: t
@@ -607,15 +615,15 @@ function Y() {
607
615
  default: () => c(j, {
608
616
  abstract: !0,
609
617
  style: "display: flex; flex-direction: column"
610
- }, U(o) ? o : { default: () => [o] }),
618
+ }, X(o) ? o : { default: () => [o] }),
611
619
  action: z
612
620
  });
613
621
  }
614
622
  let { bodyContentClass: B, bodyContentStyle: V, ...H } = R;
615
- return c(w, f({
623
+ return c(w, p({
616
624
  show: i,
617
625
  trapFocus: !1,
618
- closeOnEsc: p,
626
+ closeOnEsc: f,
619
627
  showMask: h,
620
628
  maskClosable: g,
621
629
  resizable: u,
@@ -623,7 +631,7 @@ function Y() {
623
631
  width: u ? void 0 : _ ?? 440,
624
632
  defaultWidth: u ? _ ?? 440 : void 0,
625
633
  height: v,
626
- onUpdateShow: x,
634
+ onUpdateShow: b,
627
635
  onAfterEnter: O,
628
636
  onAfterLeave: D,
629
637
  style: y
@@ -639,4 +647,4 @@ function Y() {
639
647
  })] });
640
648
  };
641
649
  }
642
- export { q as createDescriptionHelper, J as createFormHelper, Y as createModalHelper, K as createPageFormHelper };
650
+ export { G as createDescriptionHelper, Z as createFormHelper, Q as createModalHelper, Y as createPageFormHelper };