| | |
| | | // 大小限制(MB) |
| | | fileSize: propTypes.number.def(200), |
| | | // 文件类型, 例如['png', 'jpg', 'jpeg'] |
| | | fileType: propTypes.array.def(["doc","docx","xlsx", "xls", "ppt", "txt", "pdf"]), |
| | | fileType: propTypes.array.def(['doc', 'docx', 'xlsx', 'xls', 'ppt', 'txt', 'pdf', 'mp3', 'mp4', 'mov', 'png', 'jpg', 'jpeg', 'zip', 'rar', '7z']), |
| | | // 是否显示提示 |
| | | isShowTip: propTypes.bool.def(true), |
| | | }); |
| | |
| | | // 上传前校检格式和大小 |
| | | const handleBeforeUpload = (file: any) => { |
| | | // 校检文件类型 |
| | | // if (props.fileType.length) { |
| | | // const fileName = file.name.split('.'); |
| | | // const fileExt = fileName[fileName.length - 1]; |
| | | // const isTypeOk = props.fileType.indexOf(fileExt) >= 0; |
| | | // if (!isTypeOk) { |
| | | // proxy?.$modal.msgError(`文件格式不正确, 请上传${props.fileType.join("/")}格式文件!`); |
| | | // return false; |
| | | // } |
| | | // } |
| | | if (props.fileType.length) { |
| | | const fileName = file.name.split('.'); |
| | | const fileExt = fileName[fileName.length - 1]; |
| | | const isTypeOk = props.fileType.indexOf(fileExt) >= 0; |
| | | if (!isTypeOk) { |
| | | proxy?.$modal.msgError(`文件格式不正确, 请上传${props.fileType.join("/")}格式文件!`); |
| | | return false; |
| | | } |
| | | } |
| | | // 校检文件大小 |
| | | if (props.fileSize) { |
| | | const isLt = file.size / 1024 / 1024 < props.fileSize; |