-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(upload->previewColumns): Adapt functions && chore upload demo (#…
…3799) * feat(upload->previewColumns): add function capability with delete fileList * chore(upload->demo): split file && add previewColumns fn demo * type(upload): optional handleRemove * type(upload): remove optional handleRemove * feat(upload->previewCol): add enhanceing handleAdd && handleDownload * chore(upload->preview): remove previewColumns
- Loading branch information
1 parent
17f5b1b
commit 29ef0d3
Showing
8 changed files
with
377 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<template> | ||
|
||
<Alert message="基础示例" /> | ||
<BasicUpload | ||
:maxSize="20" | ||
:maxNumber="10" | ||
@change="handleChange" | ||
:api="uploadApi" | ||
class="my-5" | ||
:accept="['image/*']" | ||
/> | ||
|
||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { BasicUpload } from '@/components/Upload'; | ||
import { uploadApi } from '@/api/sys/upload'; | ||
import { useMessage } from '@/hooks/web/useMessage'; | ||
const { createMessage } = useMessage(); | ||
import { Alert } from 'ant-design-vue'; | ||
function handleChange(list: string[]) { | ||
createMessage.success(`已上传文件${JSON.stringify(list)}`); | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<Alert message="嵌入表单,加入表单校验" /> | ||
<BasicForm @register="registerValiate" class="my-5" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { uploadApi } from '@/api/sys/upload'; | ||
import { useMessage } from '@/hooks/web/useMessage'; | ||
const { createMessage } = useMessage(); | ||
import { BasicForm, FormSchema, useForm } from '@/components/Form'; | ||
import { Alert } from 'ant-design-vue'; | ||
const schemasValiate: FormSchema[] = [ | ||
{ | ||
field: 'field1', | ||
component: 'Upload', | ||
label: '字段1', | ||
rules: [{ required: true, message: '请选择上传文件' }], | ||
componentProps: { | ||
api: uploadApi, | ||
}, | ||
}, | ||
{ | ||
field: 'field2', | ||
component: 'ImageUpload', | ||
label: '字段2(ImageUpload)', | ||
colProps: { | ||
span: 8, | ||
}, | ||
componentProps: { | ||
api: uploadApi, | ||
}, | ||
}, | ||
]; | ||
const [registerValiate, { getFieldsValue: getFieldsValueValiate, validate }] = useForm({ | ||
labelWidth: 160, | ||
schemas: schemasValiate, | ||
actionColOptions: { | ||
span: 18, | ||
}, | ||
submitFunc: () => { | ||
return new Promise((resolve) => { | ||
validate() | ||
.then(() => { | ||
resolve(); | ||
console.log(getFieldsValueValiate()); | ||
createMessage.success(`请到控制台查看结果`); | ||
}) | ||
.catch(() => { | ||
createMessage.error(`请输入必填项`); | ||
}); | ||
}); | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<template> | ||
<Alert message="嵌入表单,加入resultFiled自定义返回值" /> | ||
<BasicForm @register="registerCustom" class="my-5" /> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { uploadApi } from '@/api/sys/upload'; | ||
import { useMessage } from '@/hooks/web/useMessage'; | ||
const { createMessage } = useMessage(); | ||
import { BasicForm, FormSchema, useForm } from '@/components/Form'; | ||
import { Alert } from 'ant-design-vue'; | ||
const schemasCustom: FormSchema[] = [ | ||
{ | ||
field: 'field3', | ||
component: 'Upload', | ||
label: '字段3', | ||
componentProps: { | ||
resultField: 'data3.url', | ||
api: (file, progress) => { | ||
return new Promise((resolve) => { | ||
uploadApi(file, progress).then((uploadApiResponse) => { | ||
resolve({ | ||
code: 200, | ||
data3: { | ||
url: uploadApiResponse.data.url, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}, | ||
}, | ||
}, | ||
{ | ||
field: 'field4', | ||
component: 'ImageUpload', | ||
label: '字段4(ImageUpload)', | ||
colProps: { | ||
span: 8, | ||
}, | ||
componentProps: { | ||
resultField: 'data4.url', | ||
api: (file, progress) => { | ||
return new Promise((resolve) => { | ||
uploadApi(file, progress).then((uploadApiResponse) => { | ||
resolve({ | ||
code: 200, | ||
data4: { | ||
url: uploadApiResponse.data.url, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}, | ||
}, | ||
}, | ||
]; | ||
const [registerCustom, { getFieldsValue: getFieldsValueCustom }] = useForm({ | ||
labelWidth: 160, | ||
schemas: schemasCustom, | ||
actionColOptions: { | ||
span: 18, | ||
}, | ||
submitFunc: () => { | ||
return new Promise((resolve) => { | ||
console.log(getFieldsValueCustom()); | ||
resolve(); | ||
createMessage.success(`请到控制台查看结果`); | ||
}); | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped></style> |
Oops, something went wrong.