|
1
2
|
<template>
<div class="p-4">
|
vben
authored
|
3
4
5
6
7
8
|
<a-alert message="基础示例" class="my-5"></a-alert>
<BasicUpload :maxSize="20" :maxNumber="10" @change="handleChange" :api="uploadApi" />
<a-alert message="嵌入表单,加入表单校验" class="my-5"></a-alert>
<BasicForm @register="register" />
|
|
9
10
11
|
</div>
</template>
<script lang="ts">
|
vben
authored
|
12
|
import { defineComponent } from 'vue';
|
vben
authored
|
13
14
15
|
import { BasicUpload } from '/@/components/Upload';
import { useMessage } from '/@/hooks/web/useMessage';
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
16
|
|
vben
authored
|
17
18
19
20
21
|
import { uploadApi } from '/@/api/sys/upload';
const schemas: FormSchema[] = [
{
field: 'field1',
|
vben
authored
|
22
|
component: 'Upload',
|
vben
authored
|
23
24
25
26
|
label: '字段1',
colProps: {
span: 8,
},
|
vben
authored
|
27
28
29
|
rules: [{ required: true, message: '请选择上传文件' }],
componentProps: {
api: uploadApi,
|
vben
authored
|
30
31
32
|
},
},
];
|
|
33
|
export default defineComponent({
|
vben
authored
|
34
|
components: { BasicUpload, BasicForm },
|
|
35
|
setup() {
|
vben
authored
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
const { createMessage } = useMessage();
const [register] = useForm({
labelWidth: 120,
schemas,
actionColOptions: {
span: 16,
},
});
return {
handleChange: (list: string[]) => {
createMessage.info(`已上传文件${JSON.stringify(list)}`);
},
uploadApi,
register,
};
|
|
51
52
53
|
},
});
</script>
|