@ithinkdt/ui 4.0.0-601 → 4.0.0-700

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,17 @@
1
- import { n as useI18n } from "./use-i18n-Dx7V4KrY.js";
2
- import "./use-style-D9hLG26i.js";
3
- import "./directives-8VsgmCuO.js";
4
- import { a as DtUserRender, h as DataForm, i as DtUserDept, r as DtDeptRender, s as NRadios, x as NCheckboxes } from "./components-CDuTve1u.js";
5
- import { computed, createVNode, defineComponent, h, isVNode, mergeProps, ref, shallowRef, unref } from "vue";
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";
3
+ import { computed, createVNode, defineComponent, h, isVNode, mergeProps, nextTick, ref, shallowRef, unref } from "vue";
6
4
  import { until } from "@vueuse/core";
7
5
  import { NButton, NCheckbox, NColorPicker, NDatePicker, NDrawer, NDrawerContent, NFlex, NInput, NInputNumber, NModal, NScrollbar, NSelect, NText, NUpload, useMessage } from "ithinkdt-ui";
6
+ import { nanoid } from "nanoid";
8
7
  import { format } from "date-fns";
9
8
  import { useFormItem } from "ithinkdt-ui/es/_mixins";
10
9
  import { isNullish } from "@ithinkdt/common";
11
10
  import { useDict, useDictMap } from "@ithinkdt/common/dict";
12
- function _isSlot(r) {
13
- return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !isVNode(r);
11
+ function _isSlot(a) {
12
+ return typeof a == "function" || Object.prototype.toString.call(a) === "[object Object]" && !isVNode(a);
14
13
  }
15
- var mapProps = (r) => Object.fromEntries(Object.entries(r || {}).map(([r, a]) => [r, unref(a)])), SimpleUpload = /* @__PURE__ */ defineComponent({
14
+ var mapProps = (a) => Object.fromEntries(Object.entries(a || {}).map(([a, c]) => [a, unref(c)])), SimpleUpload = /* @__PURE__ */ defineComponent({
16
15
  name: "SimpleUpload",
17
16
  props: {
18
17
  type: {
@@ -50,496 +49,496 @@ var mapProps = (r) => Object.fromEntries(Object.entries(r || {}).map(([r, a]) =>
50
49
  onUpdateFileList: { type: [Array, Function] },
51
50
  uploadFile: { type: Function }
52
51
  },
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);
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);
61
60
  });
62
- })), p = ref();
63
- s({ submit() {
64
- return until(p).toBeTruthy().then((r) => r.submit());
61
+ })), _ = ref();
62
+ u({ submit() {
63
+ return until(_).toBeTruthy().then((a) => a.submit());
65
64
  } });
66
- let m = (r) => {
67
- a.onUpdateFileList?.(r), nextTick(() => l.nTriggerFormChange());
65
+ let v = (a) => {
66
+ c.onUpdateFileList?.(a), nextTick(() => f.nTriggerFormChange());
68
67
  };
69
68
  return () => {
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
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
77
76
  }), {
78
- default: r === "image" ? void 0 : () => {
79
- let r;
77
+ default: a === "image" ? void 0 : () => {
78
+ let a;
80
79
  return createVNode(NButton, {
81
- disabled: l.mergedDisabledRef.value,
82
- size: l.mergedSizeRef.value
83
- }, _isSlot(r = c("common.page.form.selectFileText")) ? r : { default: () => [r] });
80
+ disabled: f.mergedDisabledRef.value,
81
+ size: f.mergedSizeRef.value
82
+ }, _isSlot(a = d("common.page.form.selectFileText")) ? a : { default: () => [a] });
84
83
  },
85
- ...o
84
+ ...l
86
85
  });
87
86
  };
88
87
  }
89
88
  });
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);
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);
92
91
  return {
93
- input: () => ({ slots: r, props: a }, { modelValue: o, "onUpdate:modelValue": s, required: c, readonly: l,...u }) => l ? createVNode(NText, {
92
+ input: () => ({ slots: a, props: c }, { modelValue: l, "onUpdate:modelValue": u, required: d, readonly: f, ...p }) => f ? createVNode(NText, {
94
93
  depth: 2,
95
94
  style: "line-height: 1.25"
96
- }, { default: () => [o ?? ""] }) : (a = mapProps(a), h(NInput, {
95
+ }, { default: () => [l ?? ""] }) : (c = mapProps(c), h(NInput, {
97
96
  clearable: !0,
98
- ...a,
99
- ...u,
100
- value: o,
101
- "onUpdate:value": s
102
- }, r)),
97
+ ...c,
98
+ ...p,
99
+ value: l,
100
+ "onUpdate:value": u
101
+ }, a)),
103
102
  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, {
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, {
107
106
  depth: 2,
108
107
  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);
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);
113
112
  }), h(NInputNumber, {
114
113
  clearable: !0,
114
+ ...y,
115
115
  ...g,
116
- ...f,
117
- value: _,
118
- "onUpdate:value": m === "string" ? a : r
119
- }, o);
116
+ value: b,
117
+ "onUpdate:value": v === "string" ? c : a
118
+ }, l);
120
119
  };
121
120
  },
122
121
  select: () => {
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;
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;
130
129
  return createVNode(NText, {
131
130
  depth: 2,
132
131
  style: "line-height: 1.25"
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] });
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] });
137
136
  } else {
138
- let r = a?.find((r) => r[T.valueField || "value"] === D);
137
+ let a = c?.find((a) => a[O.valueField || "value"] === A);
139
138
  return createVNode(NText, {
140
139
  depth: 2,
141
140
  style: "line-height: 1.25"
142
- }, { default: () => [r ? T.renderLabel ? T.renderLabel(r) ?? "" : r[T.labelField || "label"] ?? "" : D ?? ""] });
141
+ }, { default: () => [a ? O.renderLabel ? O.renderLabel(a) ?? "" : a[O.labelField || "label"] ?? "" : A ?? ""] });
143
142
  }
144
- return s = T.multiple, o = f, w === "number" && !c && (c = (r, ...a) => {
145
- o(s ? r?.map(C) : C(r), ...a);
143
+ return u = O.multiple, l = g, D === "number" && !d && (d = (a, ...c) => {
144
+ l(u ? a?.map(T) : T(a), ...c);
146
145
  }), h(NSelect, {
147
146
  clearable: !0,
148
- loading: a?.loading,
149
- ...T,
150
- options: unref(a),
151
- ...v,
152
- value: D,
153
- "onUpdate:value": w === "number" ? c : o
154
- }, l);
147
+ loading: c?.loading,
148
+ ...O,
149
+ options: unref(c),
150
+ ...S,
151
+ value: A,
152
+ "onUpdate:value": D === "number" ? d : l
153
+ }, f);
155
154
  };
156
155
  },
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, {
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, {
161
160
  depth: 2,
162
161
  style: "line-height: 1.25"
163
- }, _isSlot(s) ? s : { default: () => [s] });
162
+ }, _isSlot(u) ? u : { default: () => [u] });
164
163
  }
165
164
  return h(NCheckbox, {
166
- ...a,
167
- ...u,
168
- checked: o,
169
- "onUpdate:checked": s
170
- }, r);
165
+ ...c,
166
+ ...p,
167
+ checked: l,
168
+ "onUpdate:checked": u
169
+ }, a);
171
170
  },
172
171
  checkboxes: () => {
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;
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;
180
179
  return createVNode(NText, {
181
180
  depth: 2,
182
181
  style: "line-height: 2.4"
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] });
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] });
187
186
  }
188
- return o = d, b === "number" && !s && (s = (r, ...a) => {
189
- o(multiple0 ? r?.map(C) : C(r), ...a);
187
+ return l = m, w === "number" && !u && (u = (a, ...c) => {
188
+ l(a?.map(T), ...c);
190
189
  }), h(NCheckboxes, {
191
- ...S,
192
- ...g,
193
- options: a,
194
- modelValue: T,
195
- "onUpdate:modelValue": b === "number" ? s : o
190
+ ...E,
191
+ ...y,
192
+ options: c,
193
+ modelValue: O,
194
+ "onUpdate:modelValue": w === "number" ? u : l
196
195
  });
197
196
  };
198
197
  },
199
198
  radios: () => {
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);
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);
207
206
  return createVNode(NText, {
208
207
  depth: 2,
209
208
  style: "line-height: 1.25"
210
- }, { default: () => [r ? r[S.labelField ?? "label"] ?? "" : T ?? ""] });
209
+ }, { default: () => [a ? a[E.labelField ?? "label"] ?? "" : O ?? ""] });
211
210
  }
212
- return o = d, b === "number" && !s && (s = (r, ...a) => {
213
- o(C(r), ...a);
211
+ return l = m, w === "number" && !u && (u = (a, ...c) => {
212
+ l(T(a), ...c);
214
213
  }), h(NRadios, {
215
- ...S,
216
- ...g,
217
- options: a,
218
- modelValue: T,
219
- "onUpdate:modelValue": b === "number" ? s : o
214
+ ...E,
215
+ ...y,
216
+ options: c,
217
+ modelValue: O,
218
+ "onUpdate:modelValue": w === "number" ? u : l
220
219
  });
221
220
  };
222
221
  },
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, {
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, {
226
225
  depth: 2,
227
226
  style: "line-height: 1.25"
228
- }, { default: () => [o ? `${o[0] ? format(o[0], f) : ""} ~ ${o[1] ? format(o[1], f) : ""}` : ""] }) : createVNode(NText, {
227
+ }, { default: () => [l ? `${l[0] ? format(l[0], g) : ""} ~ ${l[1] ? format(l[1], g) : ""}` : ""] }) : createVNode(NText, {
229
228
  depth: 2,
230
229
  style: "line-height: 1.25"
231
- }, { default: () => [o ? format(o, f) : ""] }) : h(NDatePicker, {
230
+ }, { default: () => [l ? format(l, g) : ""] }) : h(NDatePicker, {
232
231
  actions: null,
233
232
  updateValueOnClose: !0,
234
233
  clearable: !0,
235
- ...m,
236
- ...u,
237
- type: d,
238
- format: f,
239
- value: o,
240
- "onUpdate:value": s
241
- }, r);
234
+ ...v,
235
+ ...p,
236
+ type: m,
237
+ format: g,
238
+ value: l,
239
+ "onUpdate:value": u
240
+ }, a);
242
241
  },
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;
246
- return console.warn("[file] 原则上此组建不应该显示在详情中"), fileList.value.length === 0 ? void 0 : createVNode(NFlex, {
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, {
247
246
  gap: "8",
248
247
  vertical: !0
249
- }, _isSlot(r = o.map((r) => createVNode("a", {
250
- key: r.id,
251
- href: r.url,
248
+ }, _isSlot(a = l.map((a) => createVNode("a", {
249
+ key: a.id,
250
+ href: a.url,
252
251
  target: "_blank",
253
252
  rel: "noreferrer",
254
253
  style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
255
- }, [r.name]))) ? r : { default: () => [r] });
254
+ }, [a.name]))) ? a : { default: () => [a] }) : void 0;
256
255
  }
257
256
  return h(SimpleUpload, {
258
- ...a,
259
- ...u,
257
+ ...c,
258
+ ...p,
260
259
  defaultUpload: !1,
261
- uploadFile: m,
262
- fileList: o,
263
- onUpdateFileList: s
264
- }, r);
260
+ uploadFile: v,
261
+ fileList: l,
262
+ onUpdateFileList: u
263
+ }, a);
265
264
  },
266
265
  upload: () => {
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);
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);
275
274
  }
276
275
  });
277
- }, u;
276
+ }, p;
278
277
  return {
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, {
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, {
284
283
  gap: "8",
285
284
  vertical: !0,
286
285
  style: "padding: 6px 0"
287
- }, _isSlot(r = s.value.map((r) => createVNode("a", {
288
- key: r.id,
289
- href: r.url,
286
+ }, _isSlot(a = u.value.map((a) => createVNode("a", {
287
+ key: a.id,
288
+ href: a.url,
290
289
  target: "_blank",
291
290
  rel: "noreferrer",
292
- title: r.name,
293
- download: r.name,
291
+ title: a.name,
292
+ download: a.name,
294
293
  style: "max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
295
- }, [r.name]))) ? r : { default: () => [r] });
294
+ }, [a.name]))) ? a : { default: () => [a] });
296
295
  }
297
296
  return h(SimpleUpload, {
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);
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);
306
305
  }
307
- }, c);
306
+ }, d);
308
307
  },
309
308
  beforeSubmit: async () => {
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");
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");
311
310
  }
312
311
  };
313
312
  },
314
313
  user: () => {
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
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
328
327
  }, null) : h(DtUserDept, {
329
328
  type: "user",
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);
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);
340
339
  };
341
340
  }
342
341
  };
343
342
  }
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({
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({
348
347
  xmlns: "http://www.w3.org/2000/svg",
349
348
  width: "1em",
350
349
  height: "1em",
351
350
  viewBox: "0 0 32 32"
352
- }, r), [createVNode("circle", {
351
+ }, a), [createVNode("circle", {
353
352
  cx: "16",
354
353
  cy: "16",
355
354
  r: "8",
356
355
  fill: "currentColor"
357
356
  }, null)]);
358
357
  return {
359
- date: u("yyyy-MM-dd"),
360
- datetime: u("yyyy-MM-dd HH:mm:ss"),
358
+ date: p("yyyy-MM-dd"),
359
+ datetime: p("yyyy-MM-dd HH:mm:ss"),
361
360
  dict: () => {
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";
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";
369
368
  return [
370
369
  "primary",
371
370
  "success",
372
371
  "warning",
373
372
  "danger"
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 ?? ""])]);
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 ?? ""])]);
375
374
  }
376
- return o.get(s)?.[l.labelField || "label"] ?? s ?? "";
375
+ return l.get(u)?.[f.labelField || "label"] ?? u ?? "";
377
376
  }
378
- return s?.map((r) => o.get(r?.toString())?.[l.labelField || "label"] ?? r?.toString() ?? "") ?? "";
377
+ return u?.map((a) => l.get(a?.toString())?.[f.labelField || "label"] ?? a?.toString() ?? "") ?? "";
379
378
  };
380
379
  },
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);
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);
386
385
  break;
387
- case typeof o.round:
388
- r = r.toFixed(o.round).replace(/0+$/, "");
386
+ case typeof l.round:
387
+ a = a.toFixed(l.round).replace(/0+$/, "");
389
388
  break;
390
- case typeof o.precision:
391
- r = r.toPrecision(o.precision);
389
+ case typeof l.precision:
390
+ a = a.toPrecision(l.precision);
392
391
  break;
393
392
  }
394
- return o?.separator ? Number(r).toLocaleString() : r;
393
+ return l?.separator ? Number(a).toLocaleString() : a;
395
394
  }
396
395
  },
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,
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,
401
400
  disabled: !0,
402
401
  size: "small"
403
402
  }, null),
404
- image: () => (r, a, { params: o = {} }) => {
405
- let s;
406
- return r ? createVNode(NFlex, {
403
+ image: () => (a, c, { params: l = {} }) => {
404
+ let u;
405
+ return a ? createVNode(NFlex, {
407
406
  gap: "8",
408
407
  wrap: !0
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,
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,
412
411
  style: "max-height: 32px; max-width: 100px; object-fit: contain"
413
- }, null))) ? s : { default: () => [s] }) : void 0;
412
+ }, null))) ? u : { default: () => [u] }) : void 0;
414
413
  },
415
414
  file: () => {
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;
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;
421
420
  }), createVNode(NFlex, {
422
421
  gap: "8",
423
422
  wrap: !0
424
- }, _isSlot(l = (o.__file_urls[r] || []).map((r) => createVNode("a", {
425
- key: r.id,
426
- href: r.url,
423
+ }, _isSlot(f = (l.__file_urls[a] || []).map((a) => createVNode("a", {
424
+ key: a.id,
425
+ href: a.url,
427
426
  target: "_blank",
428
427
  rel: "noreferrer",
429
428
  style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
430
- }, [r.name]))) ? l : { default: () => [l] })) : void 0;
429
+ }, [a.name]))) ? f : { default: () => [f] })) : void 0;
431
430
  };
432
431
  },
433
- dept: () => (a, o, { params: s = {} }) => {
434
- if (a) return createVNode(DtDeptRender, {
435
- value: a,
436
- multiple: s?.multiple,
437
- getDeptsByCode: r
432
+ dept: () => (c, l, { params: u = {} }) => {
433
+ if (c) return createVNode(DtDeptRender, {
434
+ value: c,
435
+ multiple: u?.multiple,
436
+ getDeptsByCode: a
438
437
  }, null);
439
438
  },
440
- user: () => (r, s, { params: c = {} }) => {
441
- if (r) return createVNode(DtUserRender, {
442
- value: r,
443
- multiple: c?.multiple,
444
- getUsersByUsername: o
439
+ user: () => (a, u, { params: d = {} }) => {
440
+ if (a) return createVNode(DtUserRender, {
441
+ value: a,
442
+ multiple: d?.multiple,
443
+ getUsersByUsername: l
445
444
  }, null);
446
445
  }
447
446
  };
448
447
  }
449
448
  function createFormHelper() {
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,
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,
462
461
  showAction: !1,
463
- onSubmit: s,
464
- onRest: c,
465
- style: d ? "padding-right: 2rem; padding-top: 1rem" : void 0
462
+ onSubmit: u,
463
+ onRest: d,
464
+ style: m ? "padding-right: 2rem; padding-top: 1rem" : void 0
466
465
  }, null);
467
466
  }
468
467
  function createModalHelper() {
469
- let r = (r) => typeof r == "number" ? `${r}px` : r, a = {
468
+ let a = (a) => typeof a == "number" ? `${a}px` : a, c = {
470
469
  maxHeight: "calc(100vh - 130px)",
471
470
  display: "flex",
472
471
  flexDirection: "column"
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, {
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, {
476
475
  justify: "end",
477
476
  gap: "16"
478
- }, { default: () => [I === null ? void 0 : createVNode(NButton, {
479
- onClick: k,
480
- disabled: L,
481
- loading: R,
477
+ }, { default: () => [R === null ? void 0 : createVNode(NButton, {
478
+ onClick: j,
479
+ disabled: z,
480
+ loading: B,
482
481
  style: "min-width: 60px"
483
- }, _isSlot(I) ? I : { default: () => [I] }), N === null ? void 0 : createVNode(NButton, {
482
+ }, _isSlot(R) ? R : { default: () => [R] }), F === null ? void 0 : createVNode(NButton, {
484
483
  type: "primary",
485
- onClick: A,
486
- disabled: P,
487
- loading: F,
484
+ onClick: M,
485
+ disabled: I,
486
+ loading: L,
488
487
  style: "min-width: 60px"
489
- }, _isSlot(N) ? N : { default: () => [N] })] });
490
- if (s === "dialog") {
491
- let { style: s } = mergeProps({ style: {
492
- width: r(S ?? 520),
493
- height: r(C)
494
- } }, { style: w });
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 });
495
494
  return createVNode(NModal, mergeProps({
496
- show: c,
495
+ show: d,
497
496
  preset: "card",
498
- title: () => l,
499
- maskClosable: b ?? !1,
500
- closeOnEsc: _,
501
- closable: v,
497
+ title: () => f,
498
+ maskClosable: C ?? !1,
499
+ closeOnEsc: b,
500
+ closable: x,
502
501
  onClose: O,
503
- segmented: o,
502
+ segmented: l,
504
503
  size: "small",
505
- onAfterEnter: M,
506
- onAfterLeave: j,
504
+ onAfterEnter: P,
505
+ onAfterLeave: N,
507
506
  onUpdateShow: O,
508
- draggable: m ?? !0,
509
- style: s,
510
- contentStyle: a
511
- }, B), {
507
+ draggable: v ?? !0,
508
+ style: u,
509
+ contentStyle: c
510
+ }, H), {
512
511
  default: () => createVNode(NScrollbar, {
513
512
  abstract: !0,
514
513
  style: "display: flex; flex-direction: column"
515
- }, _isSlot(u) ? u : { default: () => [u] }),
516
- action: V
514
+ }, _isSlot(p) ? p : { default: () => [p] }),
515
+ action: U
517
516
  });
518
517
  }
519
- let { bodyContentClass: H, bodyContentStyle: U,...W } = B;
518
+ let { bodyContentClass: W, bodyContentStyle: G, ...K } = H;
520
519
  return createVNode(NDrawer, mergeProps({
521
- show: c,
520
+ show: d,
522
521
  trapFocus: !1,
523
- closeOnEsc: _,
524
- showMask: y,
525
- maskClosable: b,
526
- resizable: p,
527
- placement: f,
528
- width: S ?? 440,
529
- height: C,
522
+ closeOnEsc: b,
523
+ showMask: S,
524
+ maskClosable: C,
525
+ resizable: _,
526
+ placement: g,
527
+ width: w ?? 440,
528
+ height: E,
530
529
  onUpdateShow: O,
531
- onAfterEnter: M,
532
- onAfterLeave: j,
533
- style: w
534
- }, W), { default: () => [createVNode(NDrawerContent, {
535
- closable: v,
536
- nativeScrollbar: z ?? !1,
537
- bodyContentClass: H,
538
- bodyContentStyle: U
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
539
538
  }, {
540
- default: () => u,
541
- header: () => l,
542
- footer: V
539
+ default: () => p,
540
+ header: () => f,
541
+ footer: U
543
542
  })] });
544
543
  };
545
544
  }