@ithinkdt/ui 4.0.3 → 4.0.5

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-Blh7O5zj.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 = 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() ?? "").join(", ") ?? "";
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,63 +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,
149
- filterable: _(t)?.length > 9,
349
+ filterable: v(t)?.length > 9,
150
350
  loading: t?.loading,
151
351
  ...x,
152
- options: _(t),
153
- ...h,
352
+ options: v(t),
353
+ ...g,
154
354
  value: C,
155
355
  "onUpdate:value": b === "number" ? i : n
156
356
  }, a);
157
357
  };
158
358
  },
159
359
  checkbox: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
160
- if (t = W(t), a) {
360
+ if (t = U(t), a) {
161
361
  let r;
162
- 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, {
163
363
  depth: 2,
164
364
  style: "line-height: 1.25"
165
- }, U(r) ? r : { default: () => [r] });
365
+ }, K(r) ? r : { default: () => [r] });
166
366
  }
167
- return u(x, {
367
+ return d(S, {
168
368
  ...t,
169
369
  ...o,
170
370
  checked: n,
@@ -173,23 +373,23 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
173
373
  },
174
374
  checkboxes: () => {
175
375
  let e, t, n, r;
176
- return ({ props: i }, { modelValue: a, "onUpdate:modelValue": s, required: l, readonly: d, ...f }) => {
177
- let { dictType: h, options: _, valueType: v = "string", ...y } = W(i), b = v === "number" ? m : p;
178
- _ ? t = _ : e !== h && (e = h, !t && e && (t = V(e)));
179
- let x = a?.map(b) ?? [];
180
- 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) {
181
381
  let e;
182
382
  return c(N, {
183
383
  depth: 2,
184
384
  style: "line-height: 2.4"
185
- }, 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) => {
186
386
  let r = e ? e[y.labelField ?? "label"] ?? "" : x[t] ?? "";
187
387
  return c("span", { key: e ? e[y.valueField ?? "value"] : x[t] ?? "" }, [r, t < n.length - 1 ? ", " : ""]);
188
388
  })) ? e : { default: () => [e] });
189
389
  }
190
390
  return n = s, v === "number" && !r && (r = (e, ...t) => {
191
- n(e?.map(g), ...t);
192
- }), u(o, {
391
+ n(e?.map(h), ...t);
392
+ }), d(a, {
193
393
  ...y,
194
394
  ...f,
195
395
  options: t,
@@ -200,11 +400,11 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
200
400
  },
201
401
  radios: () => {
202
402
  let e, t, n, r;
203
- return ({ props: i }, { modelValue: o, "onUpdate:modelValue": s, required: l, readonly: d, ...f }) => {
204
- let { dictType: h, options: _, valueType: v = "string", ...y } = W(i), b = v === "number" ? m : p;
205
- _ ? t = _ : e !== h && (e = h, !t && e && (t = V(e)));
206
- let x = b(o);
207
- 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) {
208
408
  let e = t?.find((e) => e[y.valueField ?? "value"] === x);
209
409
  return c(N, {
210
410
  depth: 2,
@@ -212,8 +412,8 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
212
412
  }, { default: () => [e ? e[y.labelField ?? "label"] ?? "" : x ?? ""] });
213
413
  }
214
414
  return n = s, v === "number" && !r && (r = (e, ...t) => {
215
- n(g(e), ...t);
216
- }), u(a, {
415
+ n(h(e), ...t);
416
+ }), d(o, {
217
417
  ...y,
218
418
  ...f,
219
419
  options: t,
@@ -223,18 +423,18 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
223
423
  };
224
424
  },
225
425
  datepicker: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
226
- 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);
227
427
  return a ? s.endsWith("range") ? c(N, {
228
428
  depth: 2,
229
429
  style: "line-height: 1.25"
230
430
  }, { default: () => [n ? `${n[0] ? L(n[0], l) : ""} ~ ${n[1] ? L(n[1], l) : ""}` : ""] }) : c(N, {
231
431
  depth: 2,
232
432
  style: "line-height: 1.25"
233
- }, { default: () => [n ? L(n, l) : ""] }) : u(C, {
433
+ }, { default: () => [n ? L(n, l) : ""] }) : d(q, {
234
434
  actions: null,
235
435
  updateValueOnClose: !0,
236
436
  clearable: !0,
237
- ...d,
437
+ ...u,
238
438
  ...o,
239
439
  type: s,
240
440
  format: l,
@@ -243,12 +443,12 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
243
443
  }, e);
244
444
  },
245
445
  file: () => ({ slots: e, props: t }, { modelValue: n, "onUpdate:modelValue": r, required: i, readonly: a, ...o }) => {
246
- if (t = W(t), a) {
446
+ if (t = U(t), a) {
247
447
  let e;
248
448
  return console.warn("[file] 原则上此组建不应该显示在详情中"), n?.length ? c(E, {
249
449
  gap: "8",
250
450
  vertical: !0
251
- }, U(e = n.map((e) => c("a", {
451
+ }, K(e = n.map((e) => c("a", {
252
452
  key: e.id,
253
453
  href: e.url,
254
454
  target: "_blank",
@@ -256,17 +456,17 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
256
456
  style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
257
457
  }, [e.name]))) ? e : { default: () => [e] }) : void 0;
258
458
  }
259
- return u(G, {
459
+ return d(J, {
260
460
  ...t,
261
461
  ...o,
262
462
  defaultUpload: !1,
263
- uploadFile: d,
463
+ uploadFile: u,
264
464
  fileList: n,
265
465
  onUpdateFileList: r
266
466
  }, e);
267
467
  },
268
468
  upload: () => {
269
- let e = null, t = new Map(), n = new Map(), r = h([]), i = 0, a = (e) => {
469
+ let e = null, t = new Map(), n = new Map(), r = g([]), i = 0, a = (e) => {
270
470
  let t = ++i;
271
471
  r.value = e.map((e) => n.get(e)).filter(Boolean);
272
472
  let a = e.filter((e) => !n.has(e));
@@ -278,15 +478,15 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
278
478
  });
279
479
  }, o, s;
280
480
  return {
281
- renderer: ({ slots: i, props: l }, { modelValue: f, "onUpdate:modelValue": p, required: m, readonly: g, ..._ }) => {
282
- let v = W(l);
283
- 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) {
284
484
  let e;
285
485
  return r.value.length === 0 ? void 0 : c(E, {
286
486
  gap: "8",
287
487
  vertical: !0,
288
488
  style: "padding: 6px 0"
289
- }, U(e = r.value.map((e) => c("a", {
489
+ }, K(e = r.value.map((e) => c("a", {
290
490
  key: e.id,
291
491
  href: e.url,
292
492
  target: "_blank",
@@ -296,10 +496,10 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
296
496
  style: "max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
297
497
  }, [e.name]))) ? e : { default: () => [e] });
298
498
  }
299
- return u(G, {
499
+ return d(J, {
300
500
  ...v,
301
501
  ..._,
302
- uploadFile: d,
502
+ uploadFile: u,
303
503
  fileList: r.value,
304
504
  onUpdateFileList: (e = []) => {
305
505
  n.clear();
@@ -309,298 +509,105 @@ function K({ getUserGroups: e, getUsersByGroup: n, getDeptsByCode: i, getUsersBy
309
509
  }, i);
310
510
  },
311
511
  beforeSubmit: async () => {
312
- 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 });
313
- 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");
314
514
  }
315
515
  };
316
516
  },
317
517
  user: () => {
318
- let a, o, d;
319
- return ({ slots: f, props: p }, { modelValue: m, "onUpdate:modelValue": g, required: _, readonly: v, ...y }) => {
320
- let b = W(p);
321
- 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) => {
322
522
  a.value = e;
323
523
  }), e().then((e) => {
324
524
  o.value = e;
325
- }), i().then((e) => {
326
- d.value = e;
327
- })), v ? c(t, {
525
+ }), n().then((e) => {
526
+ u.value = e;
527
+ })), v ? c(i, {
328
528
  value: m,
329
529
  multiple: b.multiple,
330
530
  getUsersByUsername: l,
331
531
  renderInfo: b.renderInfo
332
- }, null) : u(r, {
532
+ }, null) : d(r, {
333
533
  type: "user",
334
534
  users: a.value,
335
- depts: d.value,
535
+ depts: u.value,
336
536
  groups: o.value,
337
537
  getUsersByDept: s,
338
- getUsersByGroup: n,
538
+ getUsersByGroup: t,
339
539
  ...b,
340
540
  ...y,
341
541
  renderUserInfo: b.renderInfo,
342
542
  modelValue: m,
343
- "onUpdate:modelValue": g
543
+ "onUpdate:modelValue": h
344
544
  }, f);
345
545
  };
346
546
  }
347
547
  };
348
548
  }
349
- function q({ getDeptsByCode: e, getUsersByUsername: n, getFileInfos: r, previewFileUrl: a }) {
350
- let o = (e) => (t, n, { params: r = {} }) => {
351
- if (t != null) return L(t, r.formatter ?? e);
352
- }, s = (e = {}) => c("svg", f({
353
- xmlns: "http://www.w3.org/2000/svg",
354
- width: "1em",
355
- height: "1em",
356
- viewBox: "0 0 32 32"
357
- }, e), [c("circle", {
358
- cx: "16",
359
- cy: "16",
360
- r: "8",
361
- fill: "currentColor"
362
- }, null)]), l = (e = {}) => c("svg", f({
363
- xmlns: "http://www.w3.org/2000/svg",
364
- width: "1em",
365
- height: "1em",
366
- viewBox: "0 0 24 24"
367
- }, e), [c("path", {
368
- fill: "currentColor",
369
- 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"
370
- }, null)]), u = (e) => c("svg", f({
371
- xmlns: "http://www.w3.org/2000/svg",
372
- width: "1em",
373
- height: "1em",
374
- viewBox: "0 0 24 24"
375
- }, e), [c("path", {
376
- fill: "currentColor",
377
- 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"
378
- }, null)]), d = (e) => c("svg", f({
379
- xmlns: "http://www.w3.org/2000/svg",
380
- width: "1em",
381
- height: "1em",
382
- viewBox: "0 0 24 24"
383
- }, e), [c("path", {
384
- fill: "currentColor",
385
- 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"
386
- }, null)]);
387
- return {
388
- longtext: () => {
389
- let e = m(), t = m(), n = m(), { open: r } = z({
390
- type: "drawer",
391
- resizable: !0,
392
- content: () => c("div", null, [c("span", null, [e.value])]),
393
- width: t,
394
- footer: () => n.value?.() ?? null,
395
- maskClosable: !0
396
- }), { copy: i, copied: a } = y({ legacy: !0 }), o = (t, n, o) => {
397
- if (!n) return r(t);
398
- let s = () => {
399
- o ? o(e.value) : i(e.value);
400
- };
401
- return r(() => c("div", { style: "display: flex; align-items: center; justify-content: space-between; margin-right: 4px;" }, [g(t), a.value ? c(b, {
402
- quaternary: !0,
403
- size: "tiny",
404
- type: "success"
405
- }, { icon: () => c(D, { size: 18 }, { default: () => [c(d, null, null)] }) }) : c(b, {
406
- quaternary: !0,
407
- size: "tiny",
408
- onClick: s
409
- }, { icon: () => c(D, { size: 16 }, { default: () => [c(u, null, null)] }) })]));
410
- };
411
- return {
412
- 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, {
413
- type: "info",
414
- text: !0,
415
- style: "position: sticky; right: 0; z-index: 2",
416
- onClick: a.showText ? () => a.showText(r) : () => {
417
- 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);
418
- }
419
- }, { default: () => [c(D, { size: 18 }, { default: () => [c(l, null, null)] })] })]),
420
- default: { table: { ellipsis: !1 } }
421
- };
422
- },
423
- date: () => ({
424
- renderer: o("yyyy-MM-dd"),
425
- default: { table: {
426
- width: 140,
427
- align: "center",
428
- sortable: !0
429
- } }
430
- }),
431
- datetime: () => ({
432
- renderer: o("yyyy-MM-dd HH:mm:ss"),
433
- default: { table: {
434
- width: 174,
435
- align: "center",
436
- sortable: !0
437
- } }
438
- }),
439
- dict: () => {
440
- let e, t, n;
441
- return (r, i, { params: a = {} }) => {
442
- if (r == null) return;
443
- let { dictType: o, options: l, multiple: u, statusMap: d } = W(a);
444
- 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) {
445
- if (r = r.toString(), d && r in d) {
446
- let e = d[r] ?? "default";
447
- return [
448
- "primary",
449
- "success",
450
- "warning",
451
- "danger"
452
- ].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 ?? ""])]);
453
- }
454
- return n.get(r)?.[a.labelField || "label"] ?? r ?? "";
455
- }
456
- return r?.map((e) => n.get(e?.toString())?.[a.labelField || "label"] ?? e?.toString() ?? "") ?? "";
457
- };
458
- },
459
- number: () => ({
460
- renderer: (e, t, { params: n = {} }) => {
461
- if (e != null) {
462
- switch (n.percent && (e = Number(e) * 100), "number") {
463
- case typeof n.fixed:
464
- e = e.toFixed(n.fixed);
465
- break;
466
- case typeof n.round:
467
- e = e.toFixed(n.round).replace(/0+$/, "");
468
- break;
469
- case typeof n.precision:
470
- e = e.toPrecision(n.precision);
471
- break;
472
- }
473
- return n?.separator ? Number(e).toLocaleString() : e;
474
- }
475
- },
476
- default: { table: {
477
- width: 100,
478
- align: "right",
479
- sortable: !0
480
- } }
481
- }),
482
- email: () => (e) => c("a", { href: `mailto:${e}` }, [e]),
483
- url: () => (e) => c("a", { href: e }, [e]),
484
- color: () => (e) => c(S, {
485
- value: e,
486
- disabled: !0,
487
- size: "small"
488
- }, null),
489
- image: () => (e, t, { params: n = {} }) => {
490
- let r;
491
- return e ? c(E, {
492
- gap: "8",
493
- wrap: !0
494
- }, U(r = (Array.isArray(e) ? e : n?.multiple ? e.split(",") : [e]).map((e) => a(e)).map((e) => c("img", {
495
- key: e,
496
- src: e,
497
- style: "max-height: 32px; max-width: 100px; object-fit: contain"
498
- }, null))) ? r : { default: () => [r] }) : void 0;
499
- },
500
- file: () => {
501
- let e = I();
502
- return (t, n, { params: i = {} }) => {
503
- let a;
504
- return t ? (n.__file_urls ??= {}, n.__file_urls[e] || r(Array.isArray(t) ? t : i?.multiple ? t.split(",") : [t]).then((t) => {
505
- n.__file_urls[e] = t;
506
- }), c(E, {
507
- gap: "8",
508
- wrap: !0
509
- }, U(a = (n.__file_urls[e] || []).map((e) => c("a", {
510
- key: e.id,
511
- href: e.url,
512
- target: "_blank",
513
- rel: "noreferrer",
514
- style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
515
- }, [e.name]))) ? a : { default: () => [a] })) : void 0;
516
- };
517
- },
518
- dept: () => (t, n, { params: r = {} }) => {
519
- if (t) return c(i, {
520
- value: t,
521
- multiple: r?.multiple,
522
- getDeptsByCode: e
523
- }, null);
524
- },
525
- user: () => {
526
- let e = { style: "padding-block: 0" };
527
- return {
528
- renderer: (e, r, { params: i = {} }) => {
529
- if (e) return c(t, {
530
- value: e,
531
- multiple: i?.multiple,
532
- getUsersByUsername: n
533
- }, null);
534
- },
535
- default: { table: {
536
- width: 150,
537
- ellipsis: !1,
538
- align: "center",
539
- cellProps: () => e
540
- } }
541
- };
542
- }
543
- };
549
+ function X(e) {
550
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !f(e);
544
551
  }
545
- function J() {
546
- 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, {
547
554
  readonly: o,
548
- model: t,
555
+ model: n,
549
556
  items: e,
550
557
  validation: a,
551
- showColon: _(u) ?? !0,
552
- labelWidth: _(d),
553
- labelAlign: _(f),
554
- labelPlacement: _(p),
555
- showRequireMark: _(m),
556
- requireMarkPlacement: _(h),
557
- 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,
558
565
  showAction: !1,
559
566
  onSubmit: r,
560
567
  onReset: i,
561
568
  style: s ? "padding-right: 2rem; padding-top: 1rem" : void 0
562
569
  }, null);
563
570
  }
564
- function Y() {
571
+ function Q() {
565
572
  let e = (e) => typeof e == "number" ? `${e}px` : e, t = {
566
573
  maxHeight: "calc(100vh - 130px)",
567
574
  display: "flex",
568
575
  flexDirection: "column"
569
576
  }, n = { content: !0 };
570
- 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 }) => {
571
578
  let z = s ? () => s : s === null ? null : () => c(E, {
572
579
  justify: "end",
573
580
  gap: "16"
574
- }, { default: () => [P === null ? void 0 : c(b, {
581
+ }, { default: () => [P === null ? void 0 : c(x, {
575
582
  onClick: S,
576
583
  disabled: F,
577
584
  loading: I,
578
585
  style: "min-width: 60px"
579
- }, U(P) ? P : { default: () => [P] }), k === null ? void 0 : c(b, {
586
+ }, X(P) ? P : { default: () => [P] }), k === null ? void 0 : c(x, {
580
587
  type: "primary",
581
588
  onClick: C,
582
589
  disabled: M,
583
590
  loading: N,
584
591
  style: "min-width: 60px"
585
- }, U(k) ? k : { default: () => [k] })] });
592
+ }, X(k) ? k : { default: () => [k] })] });
586
593
  if (r === "dialog") {
587
- let { style: r } = f({ style: {
594
+ let { style: r } = p({ style: {
588
595
  width: e(_ ?? 520),
589
596
  height: e(v)
590
597
  } }, { style: y });
591
- return c(A, f({
598
+ return c(A, p({
592
599
  show: i,
593
600
  preset: "card",
594
601
  title: () => a,
595
602
  maskClosable: g ?? !1,
596
- closeOnEsc: p,
603
+ closeOnEsc: f,
597
604
  closable: m,
598
- onClose: x,
605
+ onClose: b,
599
606
  segmented: n,
600
607
  size: "small",
601
608
  onAfterEnter: O,
602
609
  onAfterLeave: D,
603
- onUpdateShow: x,
610
+ onUpdateShow: b,
604
611
  draggable: d ?? !0,
605
612
  style: r,
606
613
  contentStyle: t
@@ -608,15 +615,15 @@ function Y() {
608
615
  default: () => c(j, {
609
616
  abstract: !0,
610
617
  style: "display: flex; flex-direction: column"
611
- }, U(o) ? o : { default: () => [o] }),
618
+ }, X(o) ? o : { default: () => [o] }),
612
619
  action: z
613
620
  });
614
621
  }
615
622
  let { bodyContentClass: B, bodyContentStyle: V, ...H } = R;
616
- return c(w, f({
623
+ return c(w, p({
617
624
  show: i,
618
625
  trapFocus: !1,
619
- closeOnEsc: p,
626
+ closeOnEsc: f,
620
627
  showMask: h,
621
628
  maskClosable: g,
622
629
  resizable: u,
@@ -624,7 +631,7 @@ function Y() {
624
631
  width: u ? void 0 : _ ?? 440,
625
632
  defaultWidth: u ? _ ?? 440 : void 0,
626
633
  height: v,
627
- onUpdateShow: x,
634
+ onUpdateShow: b,
628
635
  onAfterEnter: O,
629
636
  onAfterLeave: D,
630
637
  style: y
@@ -640,4 +647,4 @@ function Y() {
640
647
  })] });
641
648
  };
642
649
  }
643
- 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 };