gi-component 0.0.14 → 0.0.15
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/package.json
CHANGED
|
@@ -116,7 +116,8 @@ export function createDialog() {
|
|
|
116
116
|
...options,
|
|
117
117
|
content: () => h(DialogContent, { type: 'error', content: options.content as string }),
|
|
118
118
|
simple: true,
|
|
119
|
-
style: { maxWidth: '420px', ...options.style }
|
|
119
|
+
style: { maxWidth: '420px', ...options.style },
|
|
120
|
+
lockScroll: false
|
|
120
121
|
})
|
|
121
122
|
}
|
|
122
123
|
}
|
|
@@ -194,6 +194,36 @@ onMounted(() => {
|
|
|
194
194
|
loadDictData()
|
|
195
195
|
})
|
|
196
196
|
|
|
197
|
+
/** 获取占位文本 */
|
|
198
|
+
const getPlaceholder = (item: FormColumnItem) => {
|
|
199
|
+
if (!item.type) return undefined
|
|
200
|
+
if (['input', 'input-number', 'input-tag'].includes(item.type)) {
|
|
201
|
+
return `请输入${item.label}`
|
|
202
|
+
}
|
|
203
|
+
if (['textarea'].includes(item.type)) {
|
|
204
|
+
return `请填写${item.label}`
|
|
205
|
+
}
|
|
206
|
+
if (
|
|
207
|
+
[
|
|
208
|
+
'select',
|
|
209
|
+
'select-v2',
|
|
210
|
+
'tree-select',
|
|
211
|
+
'cascader',
|
|
212
|
+
'time-select',
|
|
213
|
+
'input-search'
|
|
214
|
+
].includes(item.type)
|
|
215
|
+
) {
|
|
216
|
+
return `请选择${item.label}`
|
|
217
|
+
}
|
|
218
|
+
if (['date-picker'].includes(item.type)) {
|
|
219
|
+
return `请选择日期`
|
|
220
|
+
}
|
|
221
|
+
if (['time-picker'].includes(item.type)) {
|
|
222
|
+
return `请选择时间`
|
|
223
|
+
}
|
|
224
|
+
return undefined
|
|
225
|
+
}
|
|
226
|
+
|
|
197
227
|
// 组件的默认props配置
|
|
198
228
|
function getComponentBindProps(item: FormColumnItem) {
|
|
199
229
|
// 获取默认配置
|
|
@@ -263,36 +293,6 @@ const CompMap: Record<Exclude<FormColumnType, 'slot'>, any> = {
|
|
|
263
293
|
|
|
264
294
|
const formRef = ref<FormInstance>()
|
|
265
295
|
|
|
266
|
-
/** 获取占位文本 */
|
|
267
|
-
const getPlaceholder = (item: FormColumnItem) => {
|
|
268
|
-
if (!item.type) return undefined
|
|
269
|
-
if (['input', 'input-number', 'input-tag'].includes(item.type)) {
|
|
270
|
-
return `请输入${item.label}`
|
|
271
|
-
}
|
|
272
|
-
if (['textarea'].includes(item.type)) {
|
|
273
|
-
return `请填写${item.label}`
|
|
274
|
-
}
|
|
275
|
-
if (
|
|
276
|
-
[
|
|
277
|
-
'select',
|
|
278
|
-
'select-v2',
|
|
279
|
-
'tree-select',
|
|
280
|
-
'cascader',
|
|
281
|
-
'time-select',
|
|
282
|
-
'input-search'
|
|
283
|
-
].includes(item.type)
|
|
284
|
-
) {
|
|
285
|
-
return `请选择${item.label}`
|
|
286
|
-
}
|
|
287
|
-
if (['date-picker'].includes(item.type)) {
|
|
288
|
-
return `请选择日期`
|
|
289
|
-
}
|
|
290
|
-
if (['time-picker'].includes(item.type)) {
|
|
291
|
-
return `请选择时间`
|
|
292
|
-
}
|
|
293
|
-
return undefined
|
|
294
|
-
}
|
|
295
|
-
|
|
296
296
|
/** 表单项校验规则 */
|
|
297
297
|
function getFormItemRules(item: FormColumnItem) {
|
|
298
298
|
if (item.required) {
|
|
@@ -332,9 +332,10 @@ function isDisabled(item: FormColumnItem) {
|
|
|
332
332
|
|
|
333
333
|
/** 表单数据更新 */
|
|
334
334
|
function updateModelValue(value: any, item: FormColumnItem) {
|
|
335
|
+
const val = item?.format ? item.format(value) : value
|
|
335
336
|
emit(
|
|
336
337
|
'update:modelValue',
|
|
337
|
-
Object.assign(props.modelValue, { [item.field]:
|
|
338
|
+
Object.assign(props.modelValue, { [item.field]: val })
|
|
338
339
|
)
|
|
339
340
|
}
|
|
340
341
|
|
|
@@ -7,30 +7,30 @@ import type { InputSearchInstance } from '../../input-search'
|
|
|
7
7
|
|
|
8
8
|
export type FormColumnType
|
|
9
9
|
= | 'input'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
| 'textarea'
|
|
11
|
+
| 'input-number'
|
|
12
|
+
| 'input-tag'
|
|
13
|
+
| 'input-search'
|
|
14
|
+
| 'select'
|
|
15
|
+
| 'select-v2'
|
|
16
|
+
| 'tree-select'
|
|
17
|
+
| 'cascader'
|
|
18
|
+
| 'slider'
|
|
19
|
+
| 'switch'
|
|
20
|
+
| 'rate'
|
|
21
|
+
| 'checkbox-group'
|
|
22
|
+
| 'checkbox'
|
|
23
|
+
| 'radio-group'
|
|
24
|
+
| 'radio'
|
|
25
|
+
| 'date-picker'
|
|
26
|
+
| 'time-picker'
|
|
27
|
+
| 'time-select'
|
|
28
|
+
| 'color-picker'
|
|
29
|
+
| 'transfer'
|
|
30
|
+
| 'autocomplete'
|
|
31
|
+
| 'upload'
|
|
32
|
+
| 'title'
|
|
33
|
+
| 'slot'
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* 表单列属性类型,根据组件类型使用对应的属性类型
|
|
@@ -69,6 +69,7 @@ export interface FormColumnItem<F = any> {
|
|
|
69
69
|
slotName?: string
|
|
70
70
|
slots?: FormColumnSlots
|
|
71
71
|
extra?: string | (() => VNode) // 右侧额外内容
|
|
72
|
+
format?: (value: string) => string | number
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
export interface FormProps extends Partial<ElFormProps> {
|