Commit be2b8a7e175033dace7a521ab26cd319c5cfdea6
1 parent
99303a99
feat: integrate upload components into form by default
Showing
5 changed files
with
15 additions
and
15 deletions
CHANGELOG.zh_CN.md
src/components/Form/src/FormItem.tsx
... | ... | @@ -158,7 +158,7 @@ export default defineComponent({ |
158 | 158 | ) { |
159 | 159 | rule.type = 'object'; |
160 | 160 | } |
161 | - if (component.includes('RangePicker')) { | |
161 | + if (component.includes('RangePicker') || component.includes('Upload')) { | |
162 | 162 | rule.type = 'array'; |
163 | 163 | } |
164 | 164 | if (component.includes('InputNumber')) { | ... | ... |
src/components/Form/src/componentMap.ts
... | ... | @@ -18,6 +18,7 @@ import { |
18 | 18 | TreeSelect, |
19 | 19 | } from 'ant-design-vue'; |
20 | 20 | import RadioButtonGroup from './components/RadioButtonGroup.vue'; |
21 | +import { BasicUpload } from '/@/components/Upload'; | |
21 | 22 | |
22 | 23 | const componentMap = new Map<ComponentType, any>(); |
23 | 24 | |
... | ... | @@ -48,6 +49,8 @@ componentMap.set('RangePicker', DatePicker.RangePicker); |
48 | 49 | componentMap.set('WeekPicker', DatePicker.WeekPicker); |
49 | 50 | componentMap.set('TimePicker', TimePicker); |
50 | 51 | |
52 | +componentMap.set('Upload', BasicUpload); | |
53 | + | |
51 | 54 | export function add(compName: ComponentType, component: Component) { |
52 | 55 | componentMap.set(compName, component); |
53 | 56 | } | ... | ... |
src/components/Upload/src/data.tsx
1 | +import type { BasicColumn, ActionItem } from '/@/components/Table'; | |
2 | + | |
3 | +import { FileItem, PreviewFileItem, UploadResultStatus } from './types'; | |
1 | 4 | import { checkImgType, isImgTypeByName } from './utils'; |
2 | 5 | import { Progress, Tag } from 'ant-design-vue'; |
3 | -import { FileItem, PreviewFileItem, UploadResultStatus } from './types'; | |
4 | -import { BasicColumn, ActionItem, TableAction } from '/@/components/Table/index'; | |
6 | + | |
7 | +import TableAction from '/@/components/Table/src/components/TableAction'; | |
5 | 8 | |
6 | 9 | // 文件上传列表 |
7 | 10 | export function createTableColumns(): BasicColumn[] { | ... | ... |
src/views/demo/comp/upload/index.vue
... | ... | @@ -9,31 +9,24 @@ |
9 | 9 | </div> |
10 | 10 | </template> |
11 | 11 | <script lang="ts"> |
12 | - import { defineComponent, h } from 'vue'; | |
12 | + import { defineComponent } from 'vue'; | |
13 | 13 | import { BasicUpload } from '/@/components/Upload'; |
14 | 14 | import { useMessage } from '/@/hooks/web/useMessage'; |
15 | 15 | import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; |
16 | 16 | |
17 | 17 | import { uploadApi } from '/@/api/sys/upload'; |
18 | - // import { Alert } from 'ant-design-vue'; | |
19 | 18 | |
20 | 19 | const schemas: FormSchema[] = [ |
21 | 20 | { |
22 | 21 | field: 'field1', |
23 | - component: 'Input', | |
22 | + component: 'Upload', | |
24 | 23 | label: '字段1', |
25 | 24 | colProps: { |
26 | 25 | span: 8, |
27 | 26 | }, |
28 | - rules: [{ required: true, type: 'array', message: '请选择上传文件' }], | |
29 | - render: ({ model, field }) => { | |
30 | - return h(BasicUpload, { | |
31 | - value: model[field], | |
32 | - api: uploadApi, | |
33 | - onChange: (val: string[]) => { | |
34 | - model[field] = val; | |
35 | - }, | |
36 | - }); | |
27 | + rules: [{ required: true, message: '请选择上传文件' }], | |
28 | + componentProps: { | |
29 | + api: uploadApi, | |
37 | 30 | }, |
38 | 31 | }, |
39 | 32 | ]; | ... | ... |