@ithinkdt/ui 4.0.0-54 → 4.0.0-600

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