@otwb/ui 2.0.0
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/README.md +1 -0
- package/auto-imports.d.ts +15 -0
- package/auto-imports.js +34 -0
- package/dist/components-mcRUKEL_.js +1650 -0
- package/dist/components.js +5 -0
- package/dist/directives-CRvPGywW.js +183 -0
- package/dist/directives.js +3 -0
- package/dist/index.js +1224 -0
- package/dist/page.js +519 -0
- package/dist/use-i18n-Dx7V4KrY.js +6 -0
- package/dist/use-style-DcT-1dj4.js +29 -0
- package/dist/use-style.js +2 -0
- package/esm/components.d.ts +448 -0
- package/esm/components.js +1 -0
- package/esm/design.d.ts +243 -0
- package/esm/directives.d.ts +42 -0
- package/esm/directives.js +1 -0
- package/esm/index.d.ts +19 -0
- package/esm/index.js +1 -0
- package/esm/page.d.ts +170 -0
- package/esm/page.js +1 -0
- package/esm/use-style.d.ts +10 -0
- package/esm/use-style.js +1 -0
- package/locale.d.ts +78 -0
- package/package.json +99 -0
- package/unocss-preset.d.ts +5 -0
- package/unocss-preset.js +94 -0
package/dist/page.js
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
import { n as useI18n } from "./use-i18n-Dx7V4KrY.js";
|
|
2
|
+
import "./directives-CRvPGywW.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-mcRUKEL_.js";
|
|
5
|
+
import { computed, createVNode, defineComponent, h, isVNode, mergeProps, ref, shallowRef, unref } from "vue";
|
|
6
|
+
import { until } from "@vueuse/core";
|
|
7
|
+
import { NButton, NCheckbox, NColorPicker, NDatePicker, NDrawer, NDrawerContent, NFlex, NInput, NInputNumber, NModal, NScrollbar, NSelect, NText, NUpload, useMessage } from "ithinkdt-ui";
|
|
8
|
+
import { format } from "date-fns";
|
|
9
|
+
import { useFormItem } from "ithinkdt-ui/es/_mixins";
|
|
10
|
+
import { useDict, useDictMap } from "@otwb/common/dict";
|
|
11
|
+
function _isSlot(n) {
|
|
12
|
+
return typeof n == "function" || Object.prototype.toString.call(n) === "[object Object]" && !isVNode(n);
|
|
13
|
+
}
|
|
14
|
+
var mapProps = (n) => Object.fromEntries(Object.entries(n || {}).map(([n, c]) => [n, unref(c)])), SimpleUpload = /* @__PURE__ */ defineComponent({
|
|
15
|
+
name: "SimpleUpload",
|
|
16
|
+
props: {
|
|
17
|
+
type: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: "file"
|
|
20
|
+
},
|
|
21
|
+
size: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: "medium"
|
|
24
|
+
},
|
|
25
|
+
multiple: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: !1
|
|
28
|
+
},
|
|
29
|
+
max: {
|
|
30
|
+
type: Number,
|
|
31
|
+
default: void 0
|
|
32
|
+
},
|
|
33
|
+
accept: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: void 0
|
|
36
|
+
},
|
|
37
|
+
maxSize: {
|
|
38
|
+
type: Number,
|
|
39
|
+
default: void 0
|
|
40
|
+
},
|
|
41
|
+
disabled: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: void 0
|
|
44
|
+
},
|
|
45
|
+
fileList: {
|
|
46
|
+
type: Array,
|
|
47
|
+
default: () => []
|
|
48
|
+
},
|
|
49
|
+
onUpdateFileList: { type: [Array, Function] },
|
|
50
|
+
uploadFile: { type: Function }
|
|
51
|
+
},
|
|
52
|
+
setup(c, { slots: l, expose: u }) {
|
|
53
|
+
let { t: d } = useI18n();
|
|
54
|
+
SimpleUpload.t = d;
|
|
55
|
+
let f = useFormItem(c), p = useMessage(), g = computed(() => c.customRequest || (({ file: 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);
|
|
60
|
+
});
|
|
61
|
+
})), _ = ref();
|
|
62
|
+
u({ submit() {
|
|
63
|
+
return until(_).toBeTruthy().then((n) => n.submit());
|
|
64
|
+
} });
|
|
65
|
+
let v = (n) => {
|
|
66
|
+
c.onUpdateFileList?.(n), nextTick(() => f.nTriggerFormChange());
|
|
67
|
+
};
|
|
68
|
+
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
|
|
76
|
+
}), {
|
|
77
|
+
default: () => {
|
|
78
|
+
let n;
|
|
79
|
+
return createVNode(NButton, {
|
|
80
|
+
disabled: f.mergedDisabledRef.value,
|
|
81
|
+
size: f.mergedSizeRef.value
|
|
82
|
+
}, _isSlot(n = d("common.page.form.selectFileText")) ? n : { default: () => [n] });
|
|
83
|
+
},
|
|
84
|
+
...l
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
function createPageFormHelper({ getUserGroups: n, getUsersByGroup: d, getDeptsByCode: p, getUsersByDept: m, getUsersByUsername: g, uploadFile: v, getFileInfos: y }) {
|
|
90
|
+
return {
|
|
91
|
+
input: () => ({ slots: n, props: c }, { modelValue: l, "onUpdate:modelValue": u, required: d, readonly: f,...p }) => f ? createVNode(NText, {
|
|
92
|
+
depth: 2,
|
|
93
|
+
style: "line-height: 1.25"
|
|
94
|
+
}, { default: () => [l ?? ""] }) : (c = mapProps(c), h(NInput, {
|
|
95
|
+
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)),
|
|
111
|
+
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;
|
|
117
|
+
return createVNode(NText, {
|
|
118
|
+
depth: 2,
|
|
119
|
+
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] });
|
|
124
|
+
} else {
|
|
125
|
+
let n = c?.find((n) => n[b.valueField || "value"] === d);
|
|
126
|
+
return createVNode(NText, {
|
|
127
|
+
depth: 2,
|
|
128
|
+
style: "line-height: 1.25"
|
|
129
|
+
}, { default: () => [n ? b.renderLabel ? b.renderLabel(n) ?? "" : n[b.labelField || "label"] ?? "" : d ?? ""] });
|
|
130
|
+
}
|
|
131
|
+
return h(NSelect, {
|
|
132
|
+
clearable: !0,
|
|
133
|
+
loading: c?.loading,
|
|
134
|
+
...b,
|
|
135
|
+
options: unref(c),
|
|
136
|
+
...g,
|
|
137
|
+
value: d,
|
|
138
|
+
"onUpdate:value": f
|
|
139
|
+
}, l);
|
|
140
|
+
};
|
|
141
|
+
},
|
|
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, {
|
|
146
|
+
depth: 2,
|
|
147
|
+
style: "line-height: 1.25"
|
|
148
|
+
}, _isSlot(u) ? u : { default: () => [u] });
|
|
149
|
+
}
|
|
150
|
+
return h(NCheckbox, {
|
|
151
|
+
...c,
|
|
152
|
+
...p,
|
|
153
|
+
checked: l,
|
|
154
|
+
"onUpdate:checked": u
|
|
155
|
+
}, n);
|
|
156
|
+
},
|
|
157
|
+
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;
|
|
163
|
+
return createVNode(NText, {
|
|
164
|
+
depth: 2,
|
|
165
|
+
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] });
|
|
170
|
+
}
|
|
171
|
+
return h(NCheckboxes, {
|
|
172
|
+
...y,
|
|
173
|
+
...m,
|
|
174
|
+
options: c,
|
|
175
|
+
modelValue: d
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
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);
|
|
185
|
+
return createVNode(NText, {
|
|
186
|
+
depth: 2,
|
|
187
|
+
style: "line-height: 1.25"
|
|
188
|
+
}, { default: () => [n ? n[y.labelField ?? "label"] ?? "" : d ?? ""] });
|
|
189
|
+
}
|
|
190
|
+
return h(NRadios, {
|
|
191
|
+
...y,
|
|
192
|
+
...m,
|
|
193
|
+
options: l,
|
|
194
|
+
modelValue: d
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
},
|
|
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, {
|
|
201
|
+
depth: 2,
|
|
202
|
+
style: "line-height: 1.25"
|
|
203
|
+
}, { default: () => [l ? `${l[0] ? format(l[0], g) : ""} ~ ${l[1] ? format(l[1], g) : ""}` : ""] }) : createVNode(NText, {
|
|
204
|
+
depth: 2,
|
|
205
|
+
style: "line-height: 1.25"
|
|
206
|
+
}, { default: () => [l ? format(l, g) : ""] }) : h(NDatePicker, {
|
|
207
|
+
clearable: !0,
|
|
208
|
+
...v,
|
|
209
|
+
...p,
|
|
210
|
+
type: m,
|
|
211
|
+
format: g,
|
|
212
|
+
value: l,
|
|
213
|
+
"onUpdate:value": u
|
|
214
|
+
}, n);
|
|
215
|
+
},
|
|
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;
|
|
219
|
+
return console.warn("[file] 原则上此组建不应该显示在详情中"), fileList.value.length === 0 ? void 0 : createVNode(NFlex, {
|
|
220
|
+
gap: "8",
|
|
221
|
+
vertical: !0
|
|
222
|
+
}, _isSlot(n = l.map((n) => createVNode("a", {
|
|
223
|
+
key: n.id,
|
|
224
|
+
href: n.url,
|
|
225
|
+
target: "_blank",
|
|
226
|
+
rel: "noreferrer",
|
|
227
|
+
style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
228
|
+
}, [n.name]))) ? n : { default: () => [n] });
|
|
229
|
+
}
|
|
230
|
+
return h(SimpleUpload, {
|
|
231
|
+
...c,
|
|
232
|
+
...p,
|
|
233
|
+
defaultUpload: !1,
|
|
234
|
+
uploadFile: v,
|
|
235
|
+
fileList: l,
|
|
236
|
+
onUpdateFileList: u
|
|
237
|
+
}, n);
|
|
238
|
+
},
|
|
239
|
+
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);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}, p;
|
|
251
|
+
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, {
|
|
257
|
+
gap: "8",
|
|
258
|
+
vertical: !0,
|
|
259
|
+
style: "padding: 6px 0"
|
|
260
|
+
}, _isSlot(n = u.value.map((n) => createVNode("a", {
|
|
261
|
+
key: n.id,
|
|
262
|
+
href: n.url,
|
|
263
|
+
target: "_blank",
|
|
264
|
+
rel: "noreferrer",
|
|
265
|
+
title: n.name,
|
|
266
|
+
download: n.name,
|
|
267
|
+
style: "max-width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
268
|
+
}, [n.name]))) ? n : { default: () => [n] });
|
|
269
|
+
}
|
|
270
|
+
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);
|
|
279
|
+
}
|
|
280
|
+
}, d);
|
|
281
|
+
},
|
|
282
|
+
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");
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
},
|
|
287
|
+
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
|
|
301
|
+
}, null) : h(DtUserDept, {
|
|
302
|
+
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);
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}
|
|
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({
|
|
321
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
322
|
+
width: "1em",
|
|
323
|
+
height: "1em",
|
|
324
|
+
viewBox: "0 0 32 32"
|
|
325
|
+
}, n), [createVNode("circle", {
|
|
326
|
+
cx: "16",
|
|
327
|
+
cy: "16",
|
|
328
|
+
r: "8",
|
|
329
|
+
fill: "currentColor"
|
|
330
|
+
}, null)]);
|
|
331
|
+
return {
|
|
332
|
+
date: d("yyyy-MM-dd"),
|
|
333
|
+
datetime: d("yyyy-MM-dd HH:mm:ss"),
|
|
334
|
+
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";
|
|
342
|
+
return [
|
|
343
|
+
"primary",
|
|
344
|
+
"success",
|
|
345
|
+
"warning",
|
|
346
|
+
"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"] ?? ""])]);
|
|
348
|
+
}
|
|
349
|
+
return l.get(u)?.[p.labelField || "label"] ?? "";
|
|
350
|
+
}
|
|
351
|
+
return u?.map((n) => l.get(n.toString())?.[p.labelField || "label"]) ?? "";
|
|
352
|
+
};
|
|
353
|
+
},
|
|
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);
|
|
359
|
+
break;
|
|
360
|
+
case typeof u.round:
|
|
361
|
+
n = n.toFixed(u.round).replace(/0+$/, "");
|
|
362
|
+
break;
|
|
363
|
+
case typeof u.precision:
|
|
364
|
+
n = n.toPrecision(u.precision);
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
return u?.separator ? Number(n).toLocaleString() : n;
|
|
368
|
+
}
|
|
369
|
+
},
|
|
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,
|
|
374
|
+
disabled: !0,
|
|
375
|
+
size: "small"
|
|
376
|
+
}, null),
|
|
377
|
+
image: () => (n, c, l, d) => {
|
|
378
|
+
let f;
|
|
379
|
+
return n ? createVNode(NFlex, {
|
|
380
|
+
gap: "8",
|
|
381
|
+
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,
|
|
385
|
+
style: "max-height: 32px; max-width: 100px; object-fit: contain"
|
|
386
|
+
}, null))) ? f : { default: () => [f] }) : void 0;
|
|
387
|
+
},
|
|
388
|
+
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;
|
|
394
|
+
}), createVNode(NFlex, {
|
|
395
|
+
gap: "8",
|
|
396
|
+
wrap: !0
|
|
397
|
+
}, _isSlot(p = (u.__file_urls[n] || []).map((n) => createVNode("a", {
|
|
398
|
+
key: n.id,
|
|
399
|
+
href: n.url,
|
|
400
|
+
target: "_blank",
|
|
401
|
+
rel: "noreferrer",
|
|
402
|
+
style: "max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
403
|
+
}, [n.name]))) ? p : { default: () => [p] })) : void 0;
|
|
404
|
+
};
|
|
405
|
+
},
|
|
406
|
+
dept: () => (c, l, u, d) => {
|
|
407
|
+
if (c) return createVNode(DtDeptRender, {
|
|
408
|
+
value: c,
|
|
409
|
+
multiple: d?.multiple,
|
|
410
|
+
getDeptsByCode: n
|
|
411
|
+
}, null);
|
|
412
|
+
},
|
|
413
|
+
user: () => (n, l, u, d) => {
|
|
414
|
+
if (n) return createVNode(DtUserRender, {
|
|
415
|
+
value: n,
|
|
416
|
+
multiple: d?.multiple,
|
|
417
|
+
getUsersByUsername: c
|
|
418
|
+
}, null);
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
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,
|
|
435
|
+
showAction: !1,
|
|
436
|
+
onSubmit: l,
|
|
437
|
+
onRest: u,
|
|
438
|
+
style: m ? "padding-right: 2rem; padding-top: 1rem" : void 0
|
|
439
|
+
}, null);
|
|
440
|
+
}
|
|
441
|
+
function createModalHelper() {
|
|
442
|
+
let n = (n) => typeof n == "number" ? `${n}px` : n, c = {
|
|
443
|
+
maxHeight: "calc(100vh - 130px)",
|
|
444
|
+
display: "flex",
|
|
445
|
+
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, {
|
|
449
|
+
justify: "end",
|
|
450
|
+
gap: "16"
|
|
451
|
+
}, { default: () => [I === null ? void 0 : createVNode(NButton, {
|
|
452
|
+
onClick: k,
|
|
453
|
+
disabled: L,
|
|
454
|
+
loading: R,
|
|
455
|
+
style: "min-width: 60px"
|
|
456
|
+
}, _isSlot(I) ? I : { default: () => [I] }), N === null ? void 0 : createVNode(NButton, {
|
|
457
|
+
type: "primary",
|
|
458
|
+
onClick: A,
|
|
459
|
+
disabled: P,
|
|
460
|
+
loading: F,
|
|
461
|
+
style: "min-width: 60px"
|
|
462
|
+
}, _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 });
|
|
468
|
+
return createVNode(NModal, mergeProps({
|
|
469
|
+
show: d,
|
|
470
|
+
preset: "card",
|
|
471
|
+
title: () => f,
|
|
472
|
+
maskClosable: C ?? !1,
|
|
473
|
+
closeOnEsc: b,
|
|
474
|
+
closable: x,
|
|
475
|
+
onClose: O,
|
|
476
|
+
segmented: l,
|
|
477
|
+
size: "small",
|
|
478
|
+
onAfterEnter: M,
|
|
479
|
+
onAfterLeave: j,
|
|
480
|
+
onUpdateShow: O,
|
|
481
|
+
draggable: v ?? !0,
|
|
482
|
+
style: u,
|
|
483
|
+
contentStyle: c
|
|
484
|
+
}, B), {
|
|
485
|
+
default: () => createVNode(NScrollbar, {
|
|
486
|
+
abstract: !0,
|
|
487
|
+
style: "display: flex; flex-direction: column"
|
|
488
|
+
}, _isSlot(p) ? p : { default: () => [p] }),
|
|
489
|
+
action: V
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
let { bodyContentClass: H, bodyContentStyle: U,...W } = B;
|
|
493
|
+
return createVNode(NDrawer, mergeProps({
|
|
494
|
+
show: d,
|
|
495
|
+
trapFocus: !1,
|
|
496
|
+
closeOnEsc: b,
|
|
497
|
+
showMask: S,
|
|
498
|
+
maskClosable: C,
|
|
499
|
+
resizable: _,
|
|
500
|
+
placement: g,
|
|
501
|
+
width: T ?? 440,
|
|
502
|
+
height: E,
|
|
503
|
+
onUpdateShow: O,
|
|
504
|
+
onAfterEnter: M,
|
|
505
|
+
onAfterLeave: j,
|
|
506
|
+
style: D
|
|
507
|
+
}, W), { default: () => [createVNode(NDrawerContent, {
|
|
508
|
+
closable: x,
|
|
509
|
+
nativeScrollbar: z ?? !1,
|
|
510
|
+
bodyContentClass: H,
|
|
511
|
+
bodyContentStyle: U
|
|
512
|
+
}, {
|
|
513
|
+
default: () => p,
|
|
514
|
+
header: () => f,
|
|
515
|
+
footer: V
|
|
516
|
+
})] });
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
export { createFormHelper, createModalHelper, createPageFormHelper, createPageTableHelper };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useMergedClsPrefix } from "ithinkdt-ui/es/_mixins/use-config";
|
|
2
|
+
import _useStyle from "ithinkdt-ui/es/_mixins/use-style";
|
|
3
|
+
import { c, cB, cE, cM } from "ithinkdt-ui/es/_utils/cssr/index";
|
|
4
|
+
function useStyle(m, h, g, _) {
|
|
5
|
+
return g ??= useMergedClsPrefix(), _useStyle(m, h, g, _), g;
|
|
6
|
+
}
|
|
7
|
+
const fullWidth = { width: "100%" }, fullHeight = { height: "100%" }, fullWH = {
|
|
8
|
+
...fullWidth,
|
|
9
|
+
...fullHeight
|
|
10
|
+
}, flex = { display: "flex" }, flexDirCol = {
|
|
11
|
+
...flex,
|
|
12
|
+
flexDirection: "column"
|
|
13
|
+
}, flexAlignCenter = {
|
|
14
|
+
...flex,
|
|
15
|
+
alignItems: "center"
|
|
16
|
+
}, flexJustifyCenter = {
|
|
17
|
+
...flex,
|
|
18
|
+
justifyContent: "center"
|
|
19
|
+
}, flexJustifySB = {
|
|
20
|
+
...flex,
|
|
21
|
+
justifyContent: "space-between"
|
|
22
|
+
}, flexCenter = {
|
|
23
|
+
...flexAlignCenter,
|
|
24
|
+
...flexJustifyCenter
|
|
25
|
+
}, flexGap = (e) => ({
|
|
26
|
+
...flex,
|
|
27
|
+
gap: e
|
|
28
|
+
});
|
|
29
|
+
export { flex as a, flexDirCol as c, flexJustifySB as d, fullHeight as f, useStyle as g, useMergedClsPrefix as h, cM as i, flexGap as l, fullWidth as m, cB as n, flexAlignCenter as o, fullWH as p, cE as r, flexCenter as s, c as t, flexJustifyCenter as u };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as flex, c as flexDirCol, d as flexJustifySB, f as fullHeight, g as useStyle, h as useMergedClsPrefix, i as cM, l as flexGap, m as fullWidth, n as cB, o as flexAlignCenter, p as fullWH, r as cE, s as flexCenter, t as c, u as flexJustifyCenter } from "./use-style-DcT-1dj4.js";
|
|
2
|
+
export { c, cB, cE, cM, useStyle as default, flex, flexAlignCenter, flexCenter, flexDirCol, flexGap, flexJustifyCenter, flexJustifySB, fullHeight, fullWH, fullWidth, useMergedClsPrefix as useClsPrefix };
|