@ithinkdt/ui 4.0.0-19 → 4.0.0-200
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/auto-imports.js +1 -1
- package/dist/components-BoVUU6GJ.js +1736 -0
- package/dist/components.js +5 -0
- package/dist/directives-DUuJW647.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/{src → esm}/components.d.ts +63 -17
- package/esm/components.js +1 -0
- package/{src → esm}/design.d.ts +9 -0
- package/esm/directives.js +1 -0
- package/esm/index.js +1 -0
- package/{src → esm}/page.d.ts +43 -26
- package/esm/page.js +1 -0
- package/esm/use-style.js +1 -0
- package/locale.d.ts +4 -0
- package/package.json +31 -28
- package/unocss-preset.d.ts +5 -0
- package/unocss-preset.js +163 -0
- package/src/components/Checkboxes.jsx +0 -130
- package/src/components/DataActions.jsx +0 -105
- package/src/components/DataCustom.jsx +0 -172
- package/src/components/DataFilter.jsx +0 -113
- package/src/components/DataForm.jsx +0 -264
- package/src/components/DataLocaleInput.jsx +0 -121
- package/src/components/DataPagination.jsx +0 -62
- package/src/components/DataSelection.jsx +0 -57
- package/src/components/DataTable.jsx +0 -255
- package/src/components/Radios.jsx +0 -134
- package/src/components/UserDept.jsx +0 -643
- package/src/components/assets.jsx +0 -274
- package/src/components/index.js +0 -11
- package/src/design/Account.jsx +0 -152
- package/src/design/Appearance.jsx +0 -89
- package/src/design/Breadcrumb.jsx +0 -67
- package/src/design/Fullscreen.jsx +0 -65
- package/src/design/Language.jsx +0 -45
- package/src/design/Layout.jsx +0 -241
- package/src/design/Logo.jsx +0 -92
- package/src/design/Menu.jsx +0 -133
- package/src/design/MultiTabs.jsx +0 -501
- package/src/design/Notification.jsx +0 -311
- package/src/design/common.jsx +0 -21
- package/src/design/index.js +0 -10
- package/src/directives/index.js +0 -2
- package/src/directives/spin.js +0 -181
- package/src/directives/tooltip.jsx +0 -121
- package/src/index.js +0 -18
- package/src/page.jsx +0 -628
- package/src/use-i18n.js +0 -8
- package/src/use-style.js +0 -58
- package/src/utils.js +0 -20
- package/unocss.d.ts +0 -5
- package/unocss.js +0 -95
- /package/{src → esm}/directives.d.ts +0 -0
- /package/{src → esm}/index.d.ts +0 -0
- /package/{src → esm}/use-style.d.ts +0 -0
package/src/page.jsx
DELETED
|
@@ -1,628 +0,0 @@
|
|
|
1
|
-
import { format } from 'date-fns'
|
|
2
|
-
import {
|
|
3
|
-
NButton, NCheckbox, NColorPicker, NDatePicker, NDrawer, NDrawerContent, NFlex, NInput,
|
|
4
|
-
NInputNumber, NModal, NScrollbar, NSelect, NText, NUpload,
|
|
5
|
-
useMessage,
|
|
6
|
-
} from 'ithinkdt-ui'
|
|
7
|
-
import { defineComponent, h, mergeProps, unref } from 'vue'
|
|
8
|
-
|
|
9
|
-
import { useDict, useDictMap } from '@ithinkdt/common/dict'
|
|
10
|
-
|
|
11
|
-
import { DataForm, DtDeptRender, DtUserDept, DtUserRender, NCheckboxes, NRadios } from './components'
|
|
12
|
-
import { useI18n } from './use-i18n.js'
|
|
13
|
-
|
|
14
|
-
const mapProps = (props) => {
|
|
15
|
-
return Object.fromEntries(Object.entries(props || {}).map(([prop, value]) => [prop, unref(value)]))
|
|
16
|
-
}
|
|
17
|
-
export function createPageFormHelper({
|
|
18
|
-
getUserGroups, getUsersByGroup, getUsersByDept, getUsersByUsername, uploadFile,
|
|
19
|
-
}) {
|
|
20
|
-
const SimpleUpload = defineComponent({
|
|
21
|
-
name: 'SimpleUpload',
|
|
22
|
-
props: {
|
|
23
|
-
type: { type: String, default: 'file' }, // file | image
|
|
24
|
-
multiple: { type: Boolean, default: false },
|
|
25
|
-
max: { type: Number, default: undefined },
|
|
26
|
-
accept: { type: String, default: undefined },
|
|
27
|
-
maxSize: { type: Number, default: undefined }, // MB
|
|
28
|
-
disabled: { type: Boolean, default: undefined },
|
|
29
|
-
fileList: { type: Array, default: () => [] },
|
|
30
|
-
onUpdateFileList: { type: [Array, Function] },
|
|
31
|
-
},
|
|
32
|
-
setup(props, { slots }) {
|
|
33
|
-
const { t } = useI18n()
|
|
34
|
-
|
|
35
|
-
const message = useMessage()
|
|
36
|
-
const customRequest = computed(() => props.customRequest || (
|
|
37
|
-
async ({ file, onProgress, onFinish, onError }) => {
|
|
38
|
-
uploadFile(file, percent => onProgress({ percent }))
|
|
39
|
-
.then((id) => {
|
|
40
|
-
file.file.fileId = id
|
|
41
|
-
onFinish()
|
|
42
|
-
}).catch((error) => {
|
|
43
|
-
message.success(error.message)
|
|
44
|
-
onError(error)
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
))
|
|
48
|
-
return () => {
|
|
49
|
-
const { type, onUpdateFileList, ...props0 } = props
|
|
50
|
-
return (
|
|
51
|
-
<NUpload
|
|
52
|
-
{...props0}
|
|
53
|
-
onFinish={({ file, event }) => {
|
|
54
|
-
props0.onFinish?.({ file, event })
|
|
55
|
-
return {
|
|
56
|
-
...file,
|
|
57
|
-
id: file.file.fileId,
|
|
58
|
-
}
|
|
59
|
-
}}
|
|
60
|
-
customRequest={customRequest.value}
|
|
61
|
-
listType={type === 'image' ? 'image-card' : 'text'}
|
|
62
|
-
accept={props0.accept ?? type === 'image' ? 'image/*' : undefined}
|
|
63
|
-
onUpdate:fileList={onUpdateFileList}
|
|
64
|
-
>
|
|
65
|
-
{{
|
|
66
|
-
default: () => <NButton disabled={props.disabled}>{t('common.page.form.selectFileText')}</NButton>,
|
|
67
|
-
...slots,
|
|
68
|
-
}}
|
|
69
|
-
</NUpload>
|
|
70
|
-
)
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
input: () => (
|
|
77
|
-
{ slots, props },
|
|
78
|
-
{ modelValue, 'onUpdate:modelValue': onUpdateValue, required, readonly, ...params },
|
|
79
|
-
) => {
|
|
80
|
-
if (readonly) return <NText depth={2} style="line-height: 1.25">{modelValue ?? ''}</NText>
|
|
81
|
-
|
|
82
|
-
props = mapProps(props)
|
|
83
|
-
return h(NInput, {
|
|
84
|
-
'clearable': true,
|
|
85
|
-
...props,
|
|
86
|
-
...params,
|
|
87
|
-
'value': modelValue,
|
|
88
|
-
'onUpdate:value': onUpdateValue,
|
|
89
|
-
}, slots)
|
|
90
|
-
},
|
|
91
|
-
number: () => (
|
|
92
|
-
{ slots, props },
|
|
93
|
-
{ modelValue, 'onUpdate:modelValue': onUpdateValue, required, readonly, ...params },
|
|
94
|
-
) => {
|
|
95
|
-
if (readonly) return <NText depth={2} style="line-height: 1.25">{modelValue ?? ''}</NText>
|
|
96
|
-
props = mapProps(props)
|
|
97
|
-
return h(NInputNumber, {
|
|
98
|
-
'clearable': true,
|
|
99
|
-
...props,
|
|
100
|
-
...params,
|
|
101
|
-
'value': modelValue,
|
|
102
|
-
'onUpdate:value': onUpdateValue,
|
|
103
|
-
}, slots)
|
|
104
|
-
},
|
|
105
|
-
select: () => {
|
|
106
|
-
let dictType0, options0
|
|
107
|
-
return (
|
|
108
|
-
{ slots, props: props0 },
|
|
109
|
-
{ modelValue, 'onUpdate:modelValue': onUpdateValue, required, readonly, ...params },
|
|
110
|
-
) => {
|
|
111
|
-
const { dictType, options, ...props } = mapProps(props0)
|
|
112
|
-
if (options) {
|
|
113
|
-
options0 = options
|
|
114
|
-
} else {
|
|
115
|
-
if (dictType0 !== dictType) {
|
|
116
|
-
dictType0 = dictType
|
|
117
|
-
if (!options0 && dictType0) {
|
|
118
|
-
options0 = useDict(dictType0)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
if (readonly) {
|
|
123
|
-
if (props.multiple) {
|
|
124
|
-
const items = modelValue ? options0?.filter(item => modelValue.includes(item[props.valueField || 'value'])) : []
|
|
125
|
-
return (
|
|
126
|
-
<NText depth={2} style="line-height: 1.25">
|
|
127
|
-
{
|
|
128
|
-
items.map((it, i, arr) => {
|
|
129
|
-
const vn = props.renderLabel ? props.renderLabel(it) ?? '' : it[props.labelField || 'label'] ?? ''
|
|
130
|
-
return (
|
|
131
|
-
<span key={it[props.valueField || 'value']}>
|
|
132
|
-
{vn}
|
|
133
|
-
{i < arr.length - 1 ? ', ' : ''}
|
|
134
|
-
</span>
|
|
135
|
-
)
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
</NText>
|
|
139
|
-
)
|
|
140
|
-
} else {
|
|
141
|
-
const it = options0?.find(item => item[props.valueField || 'value'] === modelValue)
|
|
142
|
-
return <NText depth={2} style="line-height: 1.25">{it ? props.renderLabel ? props.renderLabel(it) ?? '' : it[props.labelField || 'label'] ?? '' : ''}</NText>
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return h(NSelect, {
|
|
147
|
-
'clearable': true,
|
|
148
|
-
'loading': options0?.loading,
|
|
149
|
-
...props,
|
|
150
|
-
'options': unref(options0),
|
|
151
|
-
...params,
|
|
152
|
-
'value': modelValue,
|
|
153
|
-
'onUpdate:value': onUpdateValue,
|
|
154
|
-
}, slots)
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
checkbox: () => (
|
|
158
|
-
{ slots, props },
|
|
159
|
-
{ modelValue, 'onUpdate:modelValue': onUpdateValue, required, readonly, ...params },
|
|
160
|
-
) => {
|
|
161
|
-
props = mapProps(props)
|
|
162
|
-
if (readonly) {
|
|
163
|
-
let content
|
|
164
|
-
if (modelValue === (props.checkedValue ?? true)) {
|
|
165
|
-
content = slots?.checked
|
|
166
|
-
? slots.checked()
|
|
167
|
-
: <NCheckbox checked />
|
|
168
|
-
} else {
|
|
169
|
-
content = slots?.unchecked ? slots.unchecked() : <NCheckbox disabled />
|
|
170
|
-
}
|
|
171
|
-
return <NText depth={2} style="line-height: 1.25">{content}</NText>
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return h(NCheckbox, {
|
|
175
|
-
...props,
|
|
176
|
-
...params,
|
|
177
|
-
'checked': modelValue,
|
|
178
|
-
'onUpdate:checked': onUpdateValue,
|
|
179
|
-
}, slots)
|
|
180
|
-
},
|
|
181
|
-
checkboxes: () => {
|
|
182
|
-
let dictType0, options0
|
|
183
|
-
return (
|
|
184
|
-
{ props: props0 },
|
|
185
|
-
{ modelValue, required, readonly, ...params },
|
|
186
|
-
) => {
|
|
187
|
-
const { dictType, options, ...props } = mapProps(props0)
|
|
188
|
-
if (options) {
|
|
189
|
-
options0 = options
|
|
190
|
-
} else {
|
|
191
|
-
if (dictType0 !== dictType) {
|
|
192
|
-
dictType0 = dictType
|
|
193
|
-
if (!options0 && dictType0) {
|
|
194
|
-
options0 = useDict(dictType0)
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
if (readonly) {
|
|
199
|
-
const items = options0?.filter(item => modelValue.includes(item[props.valueField ?? 'value']))
|
|
200
|
-
return (
|
|
201
|
-
<NText depth={2} style="line-height: 2.4">
|
|
202
|
-
{
|
|
203
|
-
items.map((it, i, arr) => {
|
|
204
|
-
const vn = it[props.labelField ?? 'label'] ?? ''
|
|
205
|
-
return (
|
|
206
|
-
<span key={it[props.valueField ?? 'value']}>
|
|
207
|
-
{vn}
|
|
208
|
-
{i < arr.length - 1 ? ', ' : ''}
|
|
209
|
-
</span>
|
|
210
|
-
)
|
|
211
|
-
})
|
|
212
|
-
}
|
|
213
|
-
</NText>
|
|
214
|
-
)
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return h(NCheckboxes,
|
|
218
|
-
{
|
|
219
|
-
...props,
|
|
220
|
-
...params,
|
|
221
|
-
options: options0,
|
|
222
|
-
modelValue,
|
|
223
|
-
},
|
|
224
|
-
)
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
radios: () => {
|
|
228
|
-
let dictType0, options0
|
|
229
|
-
return (
|
|
230
|
-
{ props: props0 },
|
|
231
|
-
{ modelValue, required, readonly, ...params },
|
|
232
|
-
) => {
|
|
233
|
-
const { dictType, options, ...props } = mapProps(props0)
|
|
234
|
-
if (options) {
|
|
235
|
-
options0 = options
|
|
236
|
-
} else {
|
|
237
|
-
if (dictType0 !== dictType) {
|
|
238
|
-
dictType0 = dictType
|
|
239
|
-
if (!options0 && dictType0) {
|
|
240
|
-
options0 = useDict(dictType0)
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (readonly) {
|
|
246
|
-
const it = options0?.find(item => item[props.valueField ?? 'value'] === modelValue)
|
|
247
|
-
return <NText depth={2} style="line-height: 1.25">{it?.[props.labelField ?? 'label'] ?? ''}</NText>
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
return h(
|
|
251
|
-
NRadios,
|
|
252
|
-
{
|
|
253
|
-
...props,
|
|
254
|
-
...params,
|
|
255
|
-
options: options0,
|
|
256
|
-
modelValue,
|
|
257
|
-
},
|
|
258
|
-
)
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
datepicker: () => (
|
|
262
|
-
{ slots, props },
|
|
263
|
-
{ modelValue, 'onUpdate:modelValue': onUpdateValue, required, readonly, ...params },
|
|
264
|
-
) => {
|
|
265
|
-
const { type = 'date', format: formatter = type.startsWith('datetime') ? 'yyyy-MM-dd HH:mm:ss' : 'yyyy-MM-dd', ...props2 } = mapProps(props)
|
|
266
|
-
if (readonly) {
|
|
267
|
-
if (type.endsWith('range')) {
|
|
268
|
-
return (
|
|
269
|
-
<NText depth={2} style="line-height: 1.25">
|
|
270
|
-
{modelValue
|
|
271
|
-
? `${modelValue[0] ? format(modelValue[0], formatter) : ''
|
|
272
|
-
} ~ ${modelValue[1] ? format(modelValue[1], formatter) : ''}`
|
|
273
|
-
: ''}
|
|
274
|
-
</NText>
|
|
275
|
-
)
|
|
276
|
-
}
|
|
277
|
-
return (
|
|
278
|
-
<NText depth={2} style="line-height: 1.25">
|
|
279
|
-
{modelValue ? format(modelValue, formatter) : ''}
|
|
280
|
-
</NText>
|
|
281
|
-
)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return h(NDatePicker, {
|
|
285
|
-
'clearable': true,
|
|
286
|
-
...props2,
|
|
287
|
-
...params,
|
|
288
|
-
type,
|
|
289
|
-
'format': formatter,
|
|
290
|
-
'value': modelValue,
|
|
291
|
-
'onUpdate:value': onUpdateValue,
|
|
292
|
-
}, slots)
|
|
293
|
-
},
|
|
294
|
-
file: () => {
|
|
295
|
-
return (
|
|
296
|
-
{ slots, props },
|
|
297
|
-
{ modelValue, 'onUpdate:modelValue': onUpdateValue, required, readonly, ...params },
|
|
298
|
-
) => {
|
|
299
|
-
props = mapProps(props)
|
|
300
|
-
if (readonly) {
|
|
301
|
-
if (modelValue.length === 0) return
|
|
302
|
-
return (
|
|
303
|
-
<NFlex gap="8" wrap>
|
|
304
|
-
{modelValue.map(it => (
|
|
305
|
-
<a
|
|
306
|
-
key={it.id}
|
|
307
|
-
href={it.url}
|
|
308
|
-
target="_blank"
|
|
309
|
-
rel="noreferrer"
|
|
310
|
-
style="max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
311
|
-
>
|
|
312
|
-
{it.name}
|
|
313
|
-
</a>
|
|
314
|
-
))}
|
|
315
|
-
</NFlex>
|
|
316
|
-
)
|
|
317
|
-
}
|
|
318
|
-
return h(SimpleUpload, {
|
|
319
|
-
...props,
|
|
320
|
-
...params,
|
|
321
|
-
fileList: modelValue,
|
|
322
|
-
onUpdateFileList: onUpdateValue,
|
|
323
|
-
}, slots)
|
|
324
|
-
}
|
|
325
|
-
},
|
|
326
|
-
user: () => {
|
|
327
|
-
let users, groups, depts
|
|
328
|
-
return (
|
|
329
|
-
{ slots, props: props0 },
|
|
330
|
-
{ modelValue, 'onUpdate:modelValue': onUpdateValue, required, readonly, ...params },
|
|
331
|
-
) => {
|
|
332
|
-
const props = mapProps(props0)
|
|
333
|
-
if (!users) {
|
|
334
|
-
users = shallowRef([])
|
|
335
|
-
getUsersByUsername().then((res) => {
|
|
336
|
-
users.value = res
|
|
337
|
-
})
|
|
338
|
-
getUserGroups().then((res) => {
|
|
339
|
-
groups.value = res
|
|
340
|
-
})
|
|
341
|
-
getDeptsByCode().then((res) => {
|
|
342
|
-
depts.value = res
|
|
343
|
-
})
|
|
344
|
-
}
|
|
345
|
-
if (readonly) {
|
|
346
|
-
return <DtUserRender value={modelValue} multiple={props.multiple} getUsersByUsername={getUsersByUsername} />
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
return h(DtUserDept, {
|
|
350
|
-
'type': 'user',
|
|
351
|
-
'users': users.value,
|
|
352
|
-
'depts': depts.value,
|
|
353
|
-
'groups': groups.value,
|
|
354
|
-
getUsersByDept,
|
|
355
|
-
getUsersByGroup,
|
|
356
|
-
...props,
|
|
357
|
-
...params,
|
|
358
|
-
modelValue,
|
|
359
|
-
'onUpdate:modelValue': onUpdateValue,
|
|
360
|
-
}, slots)
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export function createPageTableHelper({ getDeptsByCode, getUsersByUsername, getFileInfos, previewFileUrl }) {
|
|
367
|
-
const getFormatter = (defaultFormatter) => {
|
|
368
|
-
return () => (value, record, index, params) => {
|
|
369
|
-
if (value === undefined || value === null) return
|
|
370
|
-
return format(value, params.formatter ?? defaultFormatter)
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
const IDot = (props = {}) => (
|
|
375
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 32 32" {...props}>
|
|
376
|
-
{/* Icon from Carbon by IBM - undefined */}
|
|
377
|
-
<circle cx="16" cy="16" r="8" fill="currentColor" />
|
|
378
|
-
</svg>
|
|
379
|
-
)
|
|
380
|
-
|
|
381
|
-
return {
|
|
382
|
-
date: getFormatter('yyyy-MM-dd'),
|
|
383
|
-
datetime: getFormatter('yyyy-MM-dd HH:mm:ss'),
|
|
384
|
-
dict: () => {
|
|
385
|
-
let dictType0, options0, optionMap
|
|
386
|
-
return (value, record, index, params) => {
|
|
387
|
-
if (value === undefined || value === null) return
|
|
388
|
-
const { dictType, options, multiple, statusMap } = mapProps(params)
|
|
389
|
-
if (options) {
|
|
390
|
-
if (options0 !== options) {
|
|
391
|
-
options0 = options
|
|
392
|
-
optionMap = new Map(options.map(op => [op[params.valueField || 'value'], op]))
|
|
393
|
-
}
|
|
394
|
-
} else {
|
|
395
|
-
if (dictType0 !== dictType) {
|
|
396
|
-
dictType0 = dictType
|
|
397
|
-
if (!optionMap && dictType0) {
|
|
398
|
-
optionMap = useDictMap(dictType0)
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
if (!multiple) {
|
|
403
|
-
value = value.toString()
|
|
404
|
-
if (statusMap && value in statusMap) {
|
|
405
|
-
let status = statusMap[value] ?? 'default'
|
|
406
|
-
if (['primary', 'success', 'warning', 'danger'].includes(status)) {
|
|
407
|
-
status = `var(--color-${status})`
|
|
408
|
-
}
|
|
409
|
-
return (
|
|
410
|
-
<span style="position: relative; padding-left: 1.25em">
|
|
411
|
-
<IDot style={`color: ${status}; position: absolute;left: 0; top: 1.5px`} />
|
|
412
|
-
<span>{optionMap.get(value?.toString())?.[params.labelField || 'label'] ?? ''}</span>
|
|
413
|
-
</span>
|
|
414
|
-
)
|
|
415
|
-
}
|
|
416
|
-
return optionMap.get(value)?.[params.labelField || 'label'] ?? ''
|
|
417
|
-
}
|
|
418
|
-
return value?.map(it => optionMap.get(it.toString())?.[params.labelField || 'label']) ?? ''
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
number: () => {
|
|
422
|
-
return (value, record, index, params) => {
|
|
423
|
-
if (value === undefined || value === null) return
|
|
424
|
-
if (params.percent) {
|
|
425
|
-
value = Number(value) * 100
|
|
426
|
-
}
|
|
427
|
-
switch ('number') {
|
|
428
|
-
case typeof params.fixed: {
|
|
429
|
-
value = value.toFixed(params.fixed)
|
|
430
|
-
break
|
|
431
|
-
}
|
|
432
|
-
case typeof params.round: {
|
|
433
|
-
value = value.toFixed(params.round).replace(/0+$/, '')
|
|
434
|
-
break
|
|
435
|
-
}
|
|
436
|
-
case typeof params.precision: {
|
|
437
|
-
value = value.toPrecision(params.precision)
|
|
438
|
-
break
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
return params?.separator ? Number(value).toLocaleString() : value
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
email: () => {
|
|
445
|
-
return (value) => {
|
|
446
|
-
return <a href={`mailto:${value}`}>{value}</a>
|
|
447
|
-
}
|
|
448
|
-
},
|
|
449
|
-
url: () => {
|
|
450
|
-
return (value) => {
|
|
451
|
-
return <a href={value}>{value}</a>
|
|
452
|
-
}
|
|
453
|
-
},
|
|
454
|
-
color: () => {
|
|
455
|
-
return (value) => {
|
|
456
|
-
return <NColorPicker value={value} disabled size="small" />
|
|
457
|
-
}
|
|
458
|
-
},
|
|
459
|
-
image: () => {
|
|
460
|
-
return (value, record, index, params) => {
|
|
461
|
-
if (!value) return
|
|
462
|
-
const urls = (Array.isArray(value) ? value : (params?.multiple ? value.split(',') : [value]))
|
|
463
|
-
.map(id => previewFileUrl(id))
|
|
464
|
-
return (
|
|
465
|
-
<NFlex gap="8" wrap>
|
|
466
|
-
{urls.map(url => (
|
|
467
|
-
<img key={url} src={url} style="max-height: 32px; max-width: 100px; object-fit: contain" />
|
|
468
|
-
))}
|
|
469
|
-
</NFlex>
|
|
470
|
-
)
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
file: () => {
|
|
474
|
-
const key = nanoid()
|
|
475
|
-
return (value, record, index, params) => {
|
|
476
|
-
if (!value) return
|
|
477
|
-
record.__file_urls ??= {}
|
|
478
|
-
if (!record.__file_urls[key]) {
|
|
479
|
-
getFileInfos(Array.isArray(value) ? value : (params?.multiple ? value.split(',') : [value]))
|
|
480
|
-
.then((infos) => {
|
|
481
|
-
record.__file_urls[key] = infos
|
|
482
|
-
})
|
|
483
|
-
}
|
|
484
|
-
const infos = record.__file_urls[key] || []
|
|
485
|
-
|
|
486
|
-
return (
|
|
487
|
-
<NFlex gap="8" wrap>
|
|
488
|
-
{infos.map(it => (
|
|
489
|
-
<a
|
|
490
|
-
key={it.id}
|
|
491
|
-
href={it.url}
|
|
492
|
-
target="_blank"
|
|
493
|
-
rel="noreferrer"
|
|
494
|
-
style="max-width: 100px; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; display: inline-block"
|
|
495
|
-
>
|
|
496
|
-
{it.name}
|
|
497
|
-
</a>
|
|
498
|
-
))}
|
|
499
|
-
</NFlex>
|
|
500
|
-
)
|
|
501
|
-
}
|
|
502
|
-
},
|
|
503
|
-
dept: () => {
|
|
504
|
-
return (value, record, index, params) => {
|
|
505
|
-
if (!value) return
|
|
506
|
-
return <DtDeptRender value={value} multiple={params?.multiple} getDeptsByCode={getDeptsByCode} />
|
|
507
|
-
}
|
|
508
|
-
},
|
|
509
|
-
user: () => {
|
|
510
|
-
return (value, record, index, params) => {
|
|
511
|
-
if (!value) return
|
|
512
|
-
return <DtUserRender value={value} multiple={params?.multiple} getUsersByUsername={getUsersByUsername} />
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
export function createFormHelper() {
|
|
519
|
-
return () => ({ items, model, handleSubmit, reset, validation, readonly, inModal, showColon }) => {
|
|
520
|
-
return (
|
|
521
|
-
<DataForm
|
|
522
|
-
readonly={readonly}
|
|
523
|
-
model={model}
|
|
524
|
-
items={items}
|
|
525
|
-
validation={validation}
|
|
526
|
-
showColon={unref(showColon) ?? true}
|
|
527
|
-
showAction={false}
|
|
528
|
-
onSubmit={handleSubmit}
|
|
529
|
-
onRest={reset}
|
|
530
|
-
style={inModal ? 'padding-right: 2rem; padding-top: 1rem' : undefined}
|
|
531
|
-
/>
|
|
532
|
-
)
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
export function createModalHelper() {
|
|
537
|
-
const formatLength = (length) => {
|
|
538
|
-
if (typeof length === 'number') {
|
|
539
|
-
return `${length}px`
|
|
540
|
-
}
|
|
541
|
-
return length
|
|
542
|
-
}
|
|
543
|
-
const contentStyle0 = {
|
|
544
|
-
maxHeight: 'calc(100vh - 130px)',
|
|
545
|
-
display: 'flex',
|
|
546
|
-
flexDirection: 'column',
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
const segmented = { content: true }
|
|
550
|
-
return () => ({
|
|
551
|
-
type = 'dialog', visible, title, content, footer, placement, resizable, draggable, closeOnEsc, closable,
|
|
552
|
-
showMask, maskClosable, width, height, style, onClose, onCancel, onConfirm, onAfterClose, onAfterOpen,
|
|
553
|
-
confirmText, confirmDisabled, confirmLoading, cancelText, cancelDisabled, cancelLoading, nativeScrollbar, ...options
|
|
554
|
-
}) => {
|
|
555
|
-
const footer0 = footer
|
|
556
|
-
? () => footer
|
|
557
|
-
: footer === null
|
|
558
|
-
? () => null
|
|
559
|
-
: () => (
|
|
560
|
-
<NFlex justify="end" gap="16">
|
|
561
|
-
{cancelText === null ? undefined : <NButton onClick={onCancel} disabled={cancelDisabled} loading={cancelLoading} style="min-width: 60px">{cancelText}</NButton>}
|
|
562
|
-
{confirmText === null ? undefined : <NButton type="primary" onClick={onConfirm} disabled={confirmDisabled} loading={confirmLoading} style="min-width: 60px">{confirmText}</NButton>}
|
|
563
|
-
</NFlex>
|
|
564
|
-
)
|
|
565
|
-
if (type === 'dialog') {
|
|
566
|
-
const { style: style0 } = mergeProps(
|
|
567
|
-
{ style: { width: formatLength(width ?? 520), height: formatLength(height) } },
|
|
568
|
-
{ style },
|
|
569
|
-
)
|
|
570
|
-
return (
|
|
571
|
-
<NModal
|
|
572
|
-
show={visible}
|
|
573
|
-
preset="card"
|
|
574
|
-
title={() => title}
|
|
575
|
-
maskClosable={maskClosable ?? false}
|
|
576
|
-
closeOnEsc={closeOnEsc}
|
|
577
|
-
closable={closable}
|
|
578
|
-
onClose={onClose}
|
|
579
|
-
segmented={segmented}
|
|
580
|
-
size="small"
|
|
581
|
-
onAfterEnter={onAfterOpen}
|
|
582
|
-
onAfterLeave={onAfterClose}
|
|
583
|
-
onUpdateShow={onClose}
|
|
584
|
-
draggable={draggable ?? true}
|
|
585
|
-
style={style0}
|
|
586
|
-
contentStyle={contentStyle0}
|
|
587
|
-
{...options}
|
|
588
|
-
>
|
|
589
|
-
{{
|
|
590
|
-
default: () => (
|
|
591
|
-
<NScrollbar abstract style="display: flex; flex-direction: column">
|
|
592
|
-
{content}
|
|
593
|
-
</NScrollbar>
|
|
594
|
-
),
|
|
595
|
-
action: footer0,
|
|
596
|
-
}}
|
|
597
|
-
</NModal>
|
|
598
|
-
)
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
return (
|
|
602
|
-
<NDrawer
|
|
603
|
-
show={visible}
|
|
604
|
-
trapFocus={false}
|
|
605
|
-
closeOnEsc={closeOnEsc}
|
|
606
|
-
showMask={showMask}
|
|
607
|
-
maskClosable={maskClosable}
|
|
608
|
-
resizable={resizable}
|
|
609
|
-
placement={placement}
|
|
610
|
-
width={width ?? 440}
|
|
611
|
-
height={height}
|
|
612
|
-
onUpdateShow={onClose}
|
|
613
|
-
onAfterEnter={onAfterOpen}
|
|
614
|
-
onAfterLeave={onAfterClose}
|
|
615
|
-
style={style}
|
|
616
|
-
{...options}
|
|
617
|
-
>
|
|
618
|
-
<NDrawerContent closable={closable} nativeScrollbar={nativeScrollbar ?? false}>
|
|
619
|
-
{{
|
|
620
|
-
default: () => content,
|
|
621
|
-
header: () => title,
|
|
622
|
-
footer: footer0,
|
|
623
|
-
}}
|
|
624
|
-
</NDrawerContent>
|
|
625
|
-
</NDrawer>
|
|
626
|
-
)
|
|
627
|
-
}
|
|
628
|
-
}
|
package/src/use-i18n.js
DELETED
package/src/use-style.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { useMergedClsPrefix } from 'ithinkdt-ui/es/_mixins/use-config'
|
|
2
|
-
import _useStyle from 'ithinkdt-ui/es/_mixins/use-style'
|
|
3
|
-
|
|
4
|
-
export { c, cB, cE, cM } from 'ithinkdt-ui/es/_utils/cssr/index'
|
|
5
|
-
|
|
6
|
-
export { useMergedClsPrefix as useClsPrefix }
|
|
7
|
-
|
|
8
|
-
export default function useStyle(mountId, style, clsPrefix, styleIsolate) {
|
|
9
|
-
clsPrefix ??= useMergedClsPrefix()
|
|
10
|
-
_useStyle(mountId, style, clsPrefix, styleIsolate)
|
|
11
|
-
return clsPrefix
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const fullWidth = {
|
|
15
|
-
width: '100%',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const fullHeight = {
|
|
19
|
-
height: '100%',
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const fullWH = {
|
|
23
|
-
...fullWidth,
|
|
24
|
-
...fullHeight,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const flex = {
|
|
28
|
-
display: 'flex',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const flexDirCol = {
|
|
32
|
-
...flex,
|
|
33
|
-
flexDirection: 'column',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const flexAlignCenter = {
|
|
37
|
-
...flex,
|
|
38
|
-
alignItems: 'center',
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const flexJustifyCenter = {
|
|
42
|
-
...flex,
|
|
43
|
-
justifyContent: 'center',
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const flexJustifySB = {
|
|
47
|
-
...flex,
|
|
48
|
-
justifyContent: 'space-between',
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const flexCenter = {
|
|
52
|
-
...flexAlignCenter,
|
|
53
|
-
...flexJustifyCenter,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const flexGap = (gap) => {
|
|
57
|
-
return { ...flex, gap }
|
|
58
|
-
}
|