@ithinkdt/ui 4.0.0-700 → 4.0.0-800

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