fix(upload): 取消fileupload组件的自动隐藏和提示功能,修改成用户可自定义配置 (#95)
This commit is contained in:
parent
5248bec3cc
commit
e62130ef17
|
|
@ -1,6 +1,8 @@
|
|||
<template>
|
||||
<tiny-file-upload :action="action" :limit="limit" @exceed="handleExceed" multiple>
|
||||
<tiny-button type="primary">点击上传</tiny-button>
|
||||
<tiny-file-upload :action="action" :limit="limit" @exceed="handleExceed" multiple is-hidden>
|
||||
<tiny-button type="primary">
|
||||
点击上传
|
||||
</tiny-button>
|
||||
</tiny-file-upload>
|
||||
</template>
|
||||
|
||||
|
|
|
|||
|
|
@ -56,17 +56,9 @@ export const getFormData = ({ constants, state, parent, props }) => ({ formData,
|
|||
|
||||
export const uploadFiles = ({ state, constants, Modal, props, t }) => (files) => {
|
||||
const { limit, fileList } = props
|
||||
if (limit) {
|
||||
const fileCount = fileList.length + files.length
|
||||
if (fileCount > limit) {
|
||||
props.onExceed && props.onExceed(files, fileList)
|
||||
return
|
||||
} else if (fileCount === limit) {
|
||||
Modal.message({
|
||||
message: `${t('ui.upload.limitUploadFileNumber')}:${limit}`,
|
||||
status: 'info'
|
||||
})
|
||||
}
|
||||
if (limit && fileList.length + files.length > limit) {
|
||||
props.onExceed && props.onExceed(files, fileList)
|
||||
return
|
||||
}
|
||||
|
||||
let postFiles = Array.prototype.slice.call(files)
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@ export default defineComponent({
|
|||
'isFolderTitle',
|
||||
'plugin',
|
||||
'listOption',
|
||||
'maxNameLength'
|
||||
'maxNameLength',
|
||||
'isHidden'
|
||||
],
|
||||
setup(props, context) {
|
||||
return setup({ props, context, renderless, api, extendOptions: { Modal } })
|
||||
|
|
@ -209,7 +210,8 @@ export default defineComponent({
|
|||
onPreview: preview,
|
||||
httpRequest,
|
||||
isFolder,
|
||||
edmToken
|
||||
edmToken,
|
||||
isHidden: this.isHidden
|
||||
},
|
||||
ref: 'upload-inner'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,11 @@ export default defineComponent({
|
|||
onSuccess: Function,
|
||||
size: String,
|
||||
type: String,
|
||||
withCredentials: Boolean
|
||||
withCredentials: Boolean,
|
||||
isHidden: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
setup(props, context) {
|
||||
return setup({
|
||||
|
|
@ -94,12 +98,13 @@ export default defineComponent({
|
|||
name,
|
||||
uploadFiles,
|
||||
fileList,
|
||||
limit
|
||||
limit,
|
||||
isHidden
|
||||
} = this
|
||||
|
||||
const defaultSlot = (this.slots.default && this.slots.default()) || []
|
||||
|
||||
const hidden = fileList.length >= limit
|
||||
const hidden = isHidden && fileList.length >= limit
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
Loading…
Reference in New Issue