@ithinkdt/ui 4.0.0-405 → 4.0.0-406
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 +146 -137
- package/esm/page.d.ts +3 -1
- package/package.json +1 -1
package/dist/page.js
CHANGED
|
@@ -9,10 +9,10 @@ import { format } from "date-fns";
|
|
|
9
9
|
import { useFormItem } from "ithinkdt-ui/es/_mixins";
|
|
10
10
|
import { isNullish } from "@ithinkdt/common";
|
|
11
11
|
import { useDict, useDictMap } from "@ithinkdt/common/dict";
|
|
12
|
-
function _isSlot(
|
|
13
|
-
return typeof
|
|
12
|
+
function _isSlot(e) {
|
|
13
|
+
return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !isVNode(e);
|
|
14
14
|
}
|
|
15
|
-
var mapProps = (
|
|
15
|
+
var mapProps = (e) => Object.fromEntries(Object.entries(e || {}).map(([e, a]) => [e, unref(a)])), SimpleUpload = /* @__PURE__ */ defineComponent({
|
|
16
16
|
name: "SimpleUpload",
|
|
17
17
|
props: {
|
|
18
18
|
type: {
|
|
@@ -53,44 +53,44 @@ var mapProps = (r) => Object.fromEntries(Object.entries(r || {}).map(([r, a]) =>
|
|
|
53
53
|
setup(a, { slots: o, expose: s }) {
|
|
54
54
|
let { t: c } = useI18n();
|
|
55
55
|
SimpleUpload.t = c;
|
|
56
|
-
let l = useFormItem(a), u = useMessage(), f = computed(() => a.customRequest || (({ file:
|
|
57
|
-
a.uploadFile(
|
|
58
|
-
|
|
59
|
-
}).catch((
|
|
60
|
-
u.error(
|
|
56
|
+
let l = useFormItem(a), u = useMessage(), f = computed(() => a.customRequest || (({ file: e, onProgress: o, onFinish: s, onError: c }) => {
|
|
57
|
+
a.uploadFile(e.file, (e) => o({ percent: e })).then((a) => {
|
|
58
|
+
e.file.fileId = a, s();
|
|
59
|
+
}).catch((e) => {
|
|
60
|
+
u.error(e.message), c(e);
|
|
61
61
|
});
|
|
62
62
|
})), p = ref();
|
|
63
63
|
s({ submit() {
|
|
64
|
-
return until(p).toBeTruthy().then((
|
|
64
|
+
return until(p).toBeTruthy().then((e) => e.submit());
|
|
65
65
|
} });
|
|
66
|
-
let m = (
|
|
67
|
-
a.onUpdateFileList?.(
|
|
66
|
+
let m = (e) => {
|
|
67
|
+
a.onUpdateFileList?.(e), nextTick(() => l.nTriggerFormChange());
|
|
68
68
|
};
|
|
69
69
|
return () => {
|
|
70
|
-
let { type:
|
|
70
|
+
let { type: e, onUpdateFileList: s, ...u } = a;
|
|
71
71
|
return createVNode(NUpload, mergeProps(u, {
|
|
72
72
|
ref: p,
|
|
73
73
|
customRequest: f.value,
|
|
74
|
-
listType:
|
|
75
|
-
accept: u.accept ??
|
|
74
|
+
listType: e === "image" ? "image-card" : "text",
|
|
75
|
+
accept: u.accept ?? e === "image" ? "image/*" : void 0,
|
|
76
76
|
"onUpdate:fileList": m
|
|
77
77
|
}), {
|
|
78
|
-
default:
|
|
79
|
-
let
|
|
78
|
+
default: e === "image" ? void 0 : () => {
|
|
79
|
+
let e;
|
|
80
80
|
return createVNode(NButton, {
|
|
81
81
|
disabled: l.mergedDisabledRef.value,
|
|
82
82
|
size: l.mergedSizeRef.value
|
|
83
|
-
}, _isSlot(
|
|
83
|
+
}, _isSlot(e = c("common.page.form.selectFileText")) ? e : { default: () => [e] });
|
|
84
84
|
},
|
|
85
85
|
...o
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
-
function createPageFormHelper({ getUserGroups:
|
|
91
|
-
let _ = (
|
|
90
|
+
function createPageFormHelper({ getUserGroups: e, getUsersByGroup: s, getDeptsByCode: l, getUsersByDept: d, getUsersByUsername: f, uploadFile: m, getFileInfos: g }) {
|
|
91
|
+
let _ = (e) => e, x = (e) => isNullish(e) ? e : String(e), C = (e) => isNullish(e) ? e : Number(e);
|
|
92
92
|
return {
|
|
93
|
-
input: () => ({ slots:
|
|
93
|
+
input: () => ({ slots: e, props: a }, { modelValue: o, "onUpdate:modelValue": s, required: c, readonly: l, ...u }) => l ? createVNode(NText, {
|
|
94
94
|
depth: 2,
|
|
95
95
|
style: "line-height: 1.25"
|
|
96
96
|
}, { default: () => [o ?? ""] }) : (a = mapProps(a), h(NInput, {
|
|
@@ -99,41 +99,50 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
99
99
|
...u,
|
|
100
100
|
value: o,
|
|
101
101
|
"onUpdate:value": s
|
|
102
|
-
},
|
|
103
|
-
number: () =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
}, e)),
|
|
103
|
+
number: () => {
|
|
104
|
+
let e, 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 e = l, m === "string" && !a && (a = (a, ...o) => {
|
|
112
|
+
e(x(a), ...o);
|
|
113
|
+
}), h(NInputNumber, {
|
|
114
|
+
clearable: !0,
|
|
115
|
+
...g,
|
|
116
|
+
...f,
|
|
117
|
+
value: _,
|
|
118
|
+
"onUpdate:value": m === "string" ? a : e
|
|
119
|
+
}, o);
|
|
120
|
+
};
|
|
121
|
+
},
|
|
113
122
|
select: () => {
|
|
114
|
-
let
|
|
123
|
+
let e, a, o, s, c;
|
|
115
124
|
return ({ slots: l, props: u }, { modelValue: d, "onUpdate:modelValue": f, required: m, readonly: g, ...v }) => {
|
|
116
|
-
let { dictType: b, options: S, valueType: w = "string", ...T } = mapProps(u), E = w === "number" ?
|
|
117
|
-
S ? a = S :
|
|
125
|
+
let { dictType: b, options: S, valueType: w = "string", ...T } = mapProps(u), E = w === "number" ? x : _;
|
|
126
|
+
S ? a = S : e !== b && (e = b, !a && e && (a = useDict(e)));
|
|
118
127
|
let D = T.multiple ? d?.map(E) : E(d);
|
|
119
128
|
if (g) if (T.multiple) {
|
|
120
|
-
let
|
|
129
|
+
let e;
|
|
121
130
|
return createVNode(NText, {
|
|
122
131
|
depth: 2,
|
|
123
132
|
style: "line-height: 1.25"
|
|
124
|
-
}, _isSlot(
|
|
125
|
-
let s =
|
|
126
|
-
return createVNode("span", { key:
|
|
127
|
-
})) ?
|
|
133
|
+
}, _isSlot(e = (D?.map((e) => a?.find((a) => a[T.valueField || "value"] === e)) ?? []).map((e, a, o) => {
|
|
134
|
+
let s = e ? T.renderLabel ? T.renderLabel(e) ?? "" : e[T.labelField || "label"] ?? "" : D[a] ?? "";
|
|
135
|
+
return createVNode("span", { key: e ? e[T.valueField || "value"] : D[a] ?? "" }, [s, a < o.length - 1 ? ", " : ""]);
|
|
136
|
+
})) ? e : { default: () => [e] });
|
|
128
137
|
} else {
|
|
129
|
-
let
|
|
138
|
+
let e = a?.find((e) => e[T.valueField || "value"] === D);
|
|
130
139
|
return createVNode(NText, {
|
|
131
140
|
depth: 2,
|
|
132
141
|
style: "line-height: 1.25"
|
|
133
|
-
}, { default: () => [
|
|
142
|
+
}, { default: () => [e ? T.renderLabel ? T.renderLabel(e) ?? "" : e[T.labelField || "label"] ?? "" : D ?? ""] });
|
|
134
143
|
}
|
|
135
|
-
return s = T.multiple, o = f, w === "number" && !c && (c = (
|
|
136
|
-
o(s ?
|
|
144
|
+
return s = T.multiple, o = f, w === "number" && !c && (c = (e, ...a) => {
|
|
145
|
+
o(s ? e?.map(C) : C(e), ...a);
|
|
137
146
|
}), h(NSelect, {
|
|
138
147
|
clearable: !0,
|
|
139
148
|
loading: a?.loading,
|
|
@@ -145,10 +154,10 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
145
154
|
}, l);
|
|
146
155
|
};
|
|
147
156
|
},
|
|
148
|
-
checkbox: () => ({ slots:
|
|
157
|
+
checkbox: () => ({ slots: e, props: a }, { modelValue: o, "onUpdate:modelValue": s, required: c, readonly: l, ...u }) => {
|
|
149
158
|
if (a = mapProps(a), l) {
|
|
150
159
|
let s;
|
|
151
|
-
return s = o === (a.checkedValue ?? !0) ?
|
|
160
|
+
return s = o === (a.checkedValue ?? !0) ? e?.checked ? e.checked() : createVNode(NCheckbox, { checked: !0 }, null) : e?.unchecked ? e.unchecked() : createVNode(NCheckbox, { disabled: !0 }, null), createVNode(NText, {
|
|
152
161
|
depth: 2,
|
|
153
162
|
style: "line-height: 1.25"
|
|
154
163
|
}, _isSlot(s) ? s : { default: () => [s] });
|
|
@@ -158,26 +167,26 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
158
167
|
...u,
|
|
159
168
|
checked: o,
|
|
160
169
|
"onUpdate:checked": s
|
|
161
|
-
},
|
|
170
|
+
}, e);
|
|
162
171
|
},
|
|
163
172
|
checkboxes: () => {
|
|
164
|
-
let
|
|
173
|
+
let e, a, s, c;
|
|
165
174
|
return ({ props: l }, { modelValue: u, "onUpdate:modelValue": d, required: f, readonly: m, ...g }) => {
|
|
166
|
-
let { dictType: v, options: y, valueType: b = "string", ...S } = mapProps(l), w = b === "number" ?
|
|
167
|
-
y ? a = y :
|
|
175
|
+
let { dictType: v, options: y, valueType: b = "string", ...S } = mapProps(l), w = b === "number" ? x : _;
|
|
176
|
+
y ? a = y : e !== v && (e = v, !a && e && (a = useDict(e)));
|
|
168
177
|
let T = u?.map(w) ?? [];
|
|
169
178
|
if (m) {
|
|
170
|
-
let
|
|
179
|
+
let e;
|
|
171
180
|
return createVNode(NText, {
|
|
172
181
|
depth: 2,
|
|
173
182
|
style: "line-height: 2.4"
|
|
174
|
-
}, _isSlot(
|
|
175
|
-
let s =
|
|
176
|
-
return createVNode("span", { key:
|
|
177
|
-
})) ?
|
|
183
|
+
}, _isSlot(e = (T?.map((e) => a?.find((a) => a[S.valueField || "value"] === e)) ?? []).map((e, a, o) => {
|
|
184
|
+
let s = e ? e[S.labelField ?? "label"] ?? "" : T[a] ?? "";
|
|
185
|
+
return createVNode("span", { key: e ? e[S.valueField ?? "value"] : T[a] ?? "" }, [s, a < o.length - 1 ? ", " : ""]);
|
|
186
|
+
})) ? e : { default: () => [e] });
|
|
178
187
|
}
|
|
179
|
-
return s = d, b === "number" && !c && (c = (
|
|
180
|
-
s(multiple0 ?
|
|
188
|
+
return s = d, b === "number" && !c && (c = (e, ...a) => {
|
|
189
|
+
s(multiple0 ? e?.map(C) : C(e), ...a);
|
|
181
190
|
}), h(NCheckboxes, {
|
|
182
191
|
...S,
|
|
183
192
|
...g,
|
|
@@ -188,20 +197,20 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
188
197
|
};
|
|
189
198
|
},
|
|
190
199
|
radios: () => {
|
|
191
|
-
let
|
|
200
|
+
let e, a, o, s;
|
|
192
201
|
return ({ props: c }, { modelValue: l, "onUpdate:modelValue": d, required: f, readonly: m, ...g }) => {
|
|
193
|
-
let { dictType: v, options: y, valueType: b = "string", ...S } = mapProps(c), w = b === "number" ?
|
|
194
|
-
y ? a = y :
|
|
202
|
+
let { dictType: v, options: y, valueType: b = "string", ...S } = mapProps(c), w = b === "number" ? x : _;
|
|
203
|
+
y ? a = y : e !== v && (e = v, !a && e && (a = useDict(e)));
|
|
195
204
|
let T = w(l);
|
|
196
205
|
if (m) {
|
|
197
|
-
let
|
|
206
|
+
let e = a?.find((e) => e[S.valueField ?? "value"] === T);
|
|
198
207
|
return createVNode(NText, {
|
|
199
208
|
depth: 2,
|
|
200
209
|
style: "line-height: 1.25"
|
|
201
|
-
}, { default: () => [
|
|
210
|
+
}, { default: () => [e ? e[S.labelField ?? "label"] ?? "" : T ?? ""] });
|
|
202
211
|
}
|
|
203
|
-
return o = d, b === "number" && !s && (s = (
|
|
204
|
-
o(C(
|
|
212
|
+
return o = d, b === "number" && !s && (s = (e, ...a) => {
|
|
213
|
+
o(C(e), ...a);
|
|
205
214
|
}), h(NRadios, {
|
|
206
215
|
...S,
|
|
207
216
|
...g,
|
|
@@ -211,7 +220,7 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
211
220
|
});
|
|
212
221
|
};
|
|
213
222
|
},
|
|
214
|
-
datepicker: () => ({ slots:
|
|
223
|
+
datepicker: () => ({ slots: e, props: a }, { modelValue: o, "onUpdate:modelValue": s, required: c, readonly: l, ...u }) => {
|
|
215
224
|
let { type: d = "date", format: f = d.startsWith("datetime") ? "yyyy-MM-dd HH:mm:ss" : "yyyy-MM-dd", ...m } = mapProps(a);
|
|
216
225
|
return l ? d.endsWith("range") ? createVNode(NText, {
|
|
217
226
|
depth: 2,
|
|
@@ -229,21 +238,21 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
229
238
|
format: f,
|
|
230
239
|
value: o,
|
|
231
240
|
"onUpdate:value": s
|
|
232
|
-
},
|
|
241
|
+
}, e);
|
|
233
242
|
},
|
|
234
|
-
file: () => ({ slots:
|
|
243
|
+
file: () => ({ slots: e, props: a }, { modelValue: o, "onUpdate:modelValue": s, required: c, readonly: l, ...u }) => {
|
|
235
244
|
if (a = mapProps(a), l) {
|
|
236
|
-
let
|
|
245
|
+
let e;
|
|
237
246
|
return console.warn("[file] 原则上此组建不应该显示在详情中"), fileList.value.length === 0 ? void 0 : createVNode(NFlex, {
|
|
238
247
|
gap: "8",
|
|
239
248
|
vertical: !0
|
|
240
|
-
}, _isSlot(
|
|
241
|
-
key:
|
|
242
|
-
href:
|
|
249
|
+
}, _isSlot(e = o.map((e) => createVNode("a", {
|
|
250
|
+
key: e.id,
|
|
251
|
+
href: e.url,
|
|
243
252
|
target: "_blank",
|
|
244
253
|
rel: "noreferrer",
|
|
245
254
|
style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
246
|
-
}, [
|
|
255
|
+
}, [e.name]))) ? e : { default: () => [e] });
|
|
247
256
|
}
|
|
248
257
|
return h(SimpleUpload, {
|
|
249
258
|
...a,
|
|
@@ -252,53 +261,53 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
252
261
|
uploadFile: m,
|
|
253
262
|
fileList: o,
|
|
254
263
|
onUpdateFileList: s
|
|
255
|
-
},
|
|
264
|
+
}, e);
|
|
256
265
|
},
|
|
257
266
|
upload: () => {
|
|
258
|
-
let
|
|
267
|
+
let e = null, a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = shallowRef([]), c = 0, l = (e) => {
|
|
259
268
|
let a = ++c;
|
|
260
|
-
s.value =
|
|
261
|
-
let l =
|
|
269
|
+
s.value = e.map((e) => o.get(e)).filter(Boolean);
|
|
270
|
+
let l = e.filter((e) => !o.has(e));
|
|
262
271
|
Promise.resolve(l.length > 0 ? g(l) : []).then((l) => {
|
|
263
272
|
if (a === c) {
|
|
264
|
-
s.value =
|
|
265
|
-
for (let
|
|
273
|
+
s.value = e.map((e) => o.get(e) || l.find((a) => a.id === e)), o.clear();
|
|
274
|
+
for (let e of s.value) o.set(e.id, e);
|
|
266
275
|
}
|
|
267
276
|
});
|
|
268
277
|
}, u;
|
|
269
278
|
return {
|
|
270
279
|
renderer: ({ slots: c, props: d }, { modelValue: f, "onUpdate:modelValue": g, required: _, readonly: y, ...b }) => {
|
|
271
280
|
let x = mapProps(d);
|
|
272
|
-
if (u = x.ref ??= shallowRef(),
|
|
273
|
-
let
|
|
281
|
+
if (u = x.ref ??= shallowRef(), e !== f && (e = f, l(f?.split(",") ?? [])), y) {
|
|
282
|
+
let e;
|
|
274
283
|
return s.value.length === 0 ? void 0 : createVNode(NFlex, {
|
|
275
284
|
gap: "8",
|
|
276
285
|
vertical: !0,
|
|
277
286
|
style: "padding: 6px 0"
|
|
278
|
-
}, _isSlot(
|
|
279
|
-
key:
|
|
280
|
-
href:
|
|
287
|
+
}, _isSlot(e = s.value.map((e) => createVNode("a", {
|
|
288
|
+
key: e.id,
|
|
289
|
+
href: e.url,
|
|
281
290
|
target: "_blank",
|
|
282
291
|
rel: "noreferrer",
|
|
283
|
-
title:
|
|
284
|
-
download:
|
|
292
|
+
title: e.name,
|
|
293
|
+
download: e.name,
|
|
285
294
|
style: "max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
286
|
-
}, [
|
|
295
|
+
}, [e.name]))) ? e : { default: () => [e] });
|
|
287
296
|
}
|
|
288
297
|
return h(SimpleUpload, {
|
|
289
298
|
...x,
|
|
290
299
|
...b,
|
|
291
300
|
uploadFile: m,
|
|
292
301
|
fileList: s.value,
|
|
293
|
-
onUpdateFileList: (
|
|
302
|
+
onUpdateFileList: (e = []) => {
|
|
294
303
|
o.clear();
|
|
295
|
-
for (let s of
|
|
296
|
-
s.value =
|
|
304
|
+
for (let s of e) 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 = e, g(s.value.map((e) => a.get(e.id) || e.id).join(",") || null);
|
|
297
306
|
}
|
|
298
307
|
}, c);
|
|
299
308
|
},
|
|
300
309
|
beforeSubmit: async () => {
|
|
301
|
-
if (await u?.value?.submit(), await until(s).toMatch((
|
|
310
|
+
if (await u?.value?.submit(), await until(s).toMatch((e) => e.every((e) => !["pending", "uploading"].includes(e.status))), s.value.some((e) => e.status === "error")) return SimpleUpload.t("common.page.form.validate.fileErrorMessage");
|
|
302
311
|
}
|
|
303
312
|
};
|
|
304
313
|
},
|
|
@@ -306,12 +315,12 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
306
315
|
let o, u, m;
|
|
307
316
|
return ({ slots: g, props: _ }, { modelValue: y, "onUpdate:modelValue": b, required: x, readonly: S, ...C }) => {
|
|
308
317
|
let w = mapProps(_);
|
|
309
|
-
return o || (o = shallowRef([]), u = shallowRef([]), m = shallowRef([]), f().then((
|
|
310
|
-
o.value =
|
|
311
|
-
}),
|
|
312
|
-
u.value =
|
|
313
|
-
}), l().then((
|
|
314
|
-
m.value =
|
|
318
|
+
return o || (o = shallowRef([]), u = shallowRef([]), m = shallowRef([]), f().then((e) => {
|
|
319
|
+
o.value = e;
|
|
320
|
+
}), e().then((e) => {
|
|
321
|
+
u.value = e;
|
|
322
|
+
}), l().then((e) => {
|
|
323
|
+
m.value = e;
|
|
315
324
|
})), S ? createVNode(DtUserRender, {
|
|
316
325
|
value: y,
|
|
317
326
|
multiple: w.multiple,
|
|
@@ -332,15 +341,15 @@ function createPageFormHelper({ getUserGroups: r, getUsersByGroup: s, getDeptsBy
|
|
|
332
341
|
}
|
|
333
342
|
};
|
|
334
343
|
}
|
|
335
|
-
function createPageTableHelper({ getDeptsByCode:
|
|
336
|
-
let u = (
|
|
337
|
-
if (a != null) return format(a, c.formatter ??
|
|
338
|
-
}, d = (
|
|
344
|
+
function createPageTableHelper({ getDeptsByCode: e, getUsersByUsername: o, getFileInfos: s, previewFileUrl: c }) {
|
|
345
|
+
let u = (e) => () => (a, o, s, c) => {
|
|
346
|
+
if (a != null) return format(a, c.formatter ?? e);
|
|
347
|
+
}, d = (e = {}) => createVNode("svg", mergeProps({
|
|
339
348
|
xmlns: "http://www.w3.org/2000/svg",
|
|
340
349
|
width: "1em",
|
|
341
350
|
height: "1em",
|
|
342
351
|
viewBox: "0 0 32 32"
|
|
343
|
-
},
|
|
352
|
+
}, e), [createVNode("circle", {
|
|
344
353
|
cx: "16",
|
|
345
354
|
cy: "16",
|
|
346
355
|
r: "8",
|
|
@@ -350,87 +359,87 @@ function createPageTableHelper({ getDeptsByCode: r, getUsersByUsername: o, getFi
|
|
|
350
359
|
date: u("yyyy-MM-dd"),
|
|
351
360
|
datetime: u("yyyy-MM-dd HH:mm:ss"),
|
|
352
361
|
dict: () => {
|
|
353
|
-
let
|
|
362
|
+
let e, a, o;
|
|
354
363
|
return (s, c, l, u) => {
|
|
355
364
|
if (s == null) return;
|
|
356
365
|
let { dictType: f, options: p, multiple: m, statusMap: g } = mapProps(u);
|
|
357
|
-
if (p ? a !== p && (a = p, o = new Map(p.map((
|
|
366
|
+
if (p ? a !== p && (a = p, o = new Map(p.map((e) => [e[u.valueField || "value"], e]))) : e !== f && (e = f, !o && e && (o = useDictMap(e))), !m) {
|
|
358
367
|
if (s = s.toString(), g && s in g) {
|
|
359
|
-
let
|
|
368
|
+
let e = g[s] ?? "default";
|
|
360
369
|
return [
|
|
361
370
|
"primary",
|
|
362
371
|
"success",
|
|
363
372
|
"warning",
|
|
364
373
|
"danger"
|
|
365
|
-
].includes(
|
|
374
|
+
].includes(e) && (e = `var(--color-${e})`), createVNode("span", { style: "position: relative; padding-left: 1.25em" }, [createVNode(d, { style: `color: ${e}; position: absolute;left: 0; top: 1.5px` }, null), createVNode("span", null, [o.get(s)?.[u.labelField || "label"] ?? s ?? ""])]);
|
|
366
375
|
}
|
|
367
376
|
return o.get(s)?.[u.labelField || "label"] ?? s ?? "";
|
|
368
377
|
}
|
|
369
|
-
return s?.map((
|
|
378
|
+
return s?.map((e) => o.get(e?.toString())?.[u.labelField || "label"] ?? e?.toString() ?? "") ?? "";
|
|
370
379
|
};
|
|
371
380
|
},
|
|
372
|
-
number: () => (
|
|
373
|
-
if (
|
|
374
|
-
switch (s.percent && (
|
|
381
|
+
number: () => (e, a, o, s) => {
|
|
382
|
+
if (e != null) {
|
|
383
|
+
switch (s.percent && (e = Number(e) * 100), "number") {
|
|
375
384
|
case typeof s.fixed:
|
|
376
|
-
|
|
385
|
+
e = e.toFixed(s.fixed);
|
|
377
386
|
break;
|
|
378
387
|
case typeof s.round:
|
|
379
|
-
|
|
388
|
+
e = e.toFixed(s.round).replace(/0+$/, "");
|
|
380
389
|
break;
|
|
381
390
|
case typeof s.precision:
|
|
382
|
-
|
|
391
|
+
e = e.toPrecision(s.precision);
|
|
383
392
|
break;
|
|
384
393
|
}
|
|
385
|
-
return s?.separator ? Number(
|
|
394
|
+
return s?.separator ? Number(e).toLocaleString() : e;
|
|
386
395
|
}
|
|
387
396
|
},
|
|
388
|
-
email: () => (
|
|
389
|
-
url: () => (
|
|
390
|
-
color: () => (
|
|
391
|
-
value:
|
|
397
|
+
email: () => (e) => createVNode("a", { href: `mailto:${e}` }, [e]),
|
|
398
|
+
url: () => (e) => createVNode("a", { href: e }, [e]),
|
|
399
|
+
color: () => (e) => createVNode(NColorPicker, {
|
|
400
|
+
value: e,
|
|
392
401
|
disabled: !0,
|
|
393
402
|
size: "small"
|
|
394
403
|
}, null),
|
|
395
|
-
image: () => (
|
|
404
|
+
image: () => (e, a, o, s) => {
|
|
396
405
|
let l;
|
|
397
|
-
return
|
|
406
|
+
return e ? createVNode(NFlex, {
|
|
398
407
|
gap: "8",
|
|
399
408
|
wrap: !0
|
|
400
|
-
}, _isSlot(l = (Array.isArray(
|
|
401
|
-
key:
|
|
402
|
-
src:
|
|
409
|
+
}, _isSlot(l = (Array.isArray(e) ? e : s?.multiple ? e.split(",") : [e]).map((e) => c(e)).map((e) => createVNode("img", {
|
|
410
|
+
key: e,
|
|
411
|
+
src: e,
|
|
403
412
|
style: "max-height: 32px; max-width: 100px; object-fit: contain"
|
|
404
413
|
}, null))) ? l : { default: () => [l] }) : void 0;
|
|
405
414
|
},
|
|
406
415
|
file: () => {
|
|
407
|
-
let
|
|
416
|
+
let e = nanoid();
|
|
408
417
|
return (a, o, c, l) => {
|
|
409
418
|
let u;
|
|
410
|
-
return a ? (o.__file_urls ??= {}, o.__file_urls[
|
|
411
|
-
o.__file_urls[
|
|
419
|
+
return a ? (o.__file_urls ??= {}, o.__file_urls[e] || s(Array.isArray(a) ? a : l?.multiple ? a.split(",") : [a]).then((a) => {
|
|
420
|
+
o.__file_urls[e] = a;
|
|
412
421
|
}), createVNode(NFlex, {
|
|
413
422
|
gap: "8",
|
|
414
423
|
wrap: !0
|
|
415
|
-
}, _isSlot(u = (o.__file_urls[
|
|
416
|
-
key:
|
|
417
|
-
href:
|
|
424
|
+
}, _isSlot(u = (o.__file_urls[e] || []).map((e) => createVNode("a", {
|
|
425
|
+
key: e.id,
|
|
426
|
+
href: e.url,
|
|
418
427
|
target: "_blank",
|
|
419
428
|
rel: "noreferrer",
|
|
420
429
|
style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
421
|
-
}, [
|
|
430
|
+
}, [e.name]))) ? u : { default: () => [u] })) : void 0;
|
|
422
431
|
};
|
|
423
432
|
},
|
|
424
433
|
dept: () => (a, o, s, c) => {
|
|
425
434
|
if (a) return createVNode(DtDeptRender, {
|
|
426
435
|
value: a,
|
|
427
436
|
multiple: c?.multiple,
|
|
428
|
-
getDeptsByCode:
|
|
437
|
+
getDeptsByCode: e
|
|
429
438
|
}, null);
|
|
430
439
|
},
|
|
431
|
-
user: () => (
|
|
432
|
-
if (
|
|
433
|
-
value:
|
|
440
|
+
user: () => (e, s, c, l) => {
|
|
441
|
+
if (e) return createVNode(DtUserRender, {
|
|
442
|
+
value: e,
|
|
434
443
|
multiple: l?.multiple,
|
|
435
444
|
getUsersByUsername: o
|
|
436
445
|
}, null);
|
|
@@ -438,10 +447,10 @@ function createPageTableHelper({ getDeptsByCode: r, getUsersByUsername: o, getFi
|
|
|
438
447
|
};
|
|
439
448
|
}
|
|
440
449
|
function createFormHelper() {
|
|
441
|
-
return () => ({ items:
|
|
450
|
+
return () => ({ items: e, model: a, handleSubmit: o, reset: c, validation: l, readonly: u, inModal: d, showFeedback: f, showColon: p, labelWidth: m, labelAlign: g, labelPlacement: _, showRequireMark: v, requireMarkPlacement: b }) => createVNode(DataForm, {
|
|
442
451
|
readonly: u,
|
|
443
452
|
model: a,
|
|
444
|
-
items:
|
|
453
|
+
items: e,
|
|
445
454
|
validation: l,
|
|
446
455
|
showColon: unref(p) ?? !0,
|
|
447
456
|
labelWidth: unref(m),
|
|
@@ -457,7 +466,7 @@ function createFormHelper() {
|
|
|
457
466
|
}, null);
|
|
458
467
|
}
|
|
459
468
|
function createModalHelper() {
|
|
460
|
-
let
|
|
469
|
+
let e = (e) => typeof e == "number" ? `${e}px` : e, a = {
|
|
461
470
|
maxHeight: "calc(100vh - 130px)",
|
|
462
471
|
display: "flex",
|
|
463
472
|
flexDirection: "column"
|
|
@@ -480,8 +489,8 @@ function createModalHelper() {
|
|
|
480
489
|
}, _isSlot(N) ? N : { default: () => [N] })] });
|
|
481
490
|
if (s === "dialog") {
|
|
482
491
|
let { style: s } = mergeProps({ style: {
|
|
483
|
-
width:
|
|
484
|
-
height:
|
|
492
|
+
width: e(S ?? 520),
|
|
493
|
+
height: e(C)
|
|
485
494
|
} }, { style: w });
|
|
486
495
|
return createVNode(NModal, mergeProps({
|
|
487
496
|
show: c,
|
package/esm/page.d.ts
CHANGED
|
@@ -26,7 +26,9 @@ declare module '@ithinkdt/page' {
|
|
|
26
26
|
inputSlots?: InputSlots
|
|
27
27
|
}
|
|
28
28
|
number: {
|
|
29
|
-
numberProps?: ShallowMaybeRef<Omit<InputNumberProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps
|
|
29
|
+
numberProps?: ShallowMaybeRef<Omit<InputNumberProps, 'value' | 'onUpdate:value' | 'disabled'>> & PublicProps & {
|
|
30
|
+
valueType?: 'string' | 'number' | undefined
|
|
31
|
+
}
|
|
30
32
|
numberSlots?: InputNumberSlots
|
|
31
33
|
}
|
|
32
34
|
select: {
|