fix: 移除拖拽组件,全局注册ProModal替换默认AModal
This commit is contained in:
@@ -35,19 +35,22 @@ const props = defineProps({
|
||||
|
||||
/**弹框关闭事件 */
|
||||
function fnModalClose() {
|
||||
if(props.loading) return
|
||||
if (props.loading) return;
|
||||
emit('close');
|
||||
}
|
||||
|
||||
/**上传前检查或转换压缩 */
|
||||
function fnBeforeUpload(file: FileType) {
|
||||
if (props.loading) return false;
|
||||
// 检查文件大小
|
||||
if (props.size > 0) {
|
||||
// 检查文件大小
|
||||
if (props.size > 0) {
|
||||
const fileSize = file.size;
|
||||
const isLtM = fileSize / 1024 / 1024 < props.size;
|
||||
if (!isLtM) {
|
||||
message.error(`${t('components.UploadModal.allowFilter')} ${props.size}MB`, 3);
|
||||
message.error(
|
||||
`${t('components.UploadModal.allowFilter')} ${props.size}MB`,
|
||||
3
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -56,7 +59,10 @@ function fnBeforeUpload(file: FileType) {
|
||||
const fileName = file.name;
|
||||
const isAllowType = props.ext.some(v => fileName.endsWith(v));
|
||||
if (!isAllowType) {
|
||||
message.error(`${t('components.UploadModal.onlyAllow')} ${props.ext.join('、')}`, 3);
|
||||
message.error(
|
||||
`${t('components.UploadModal.onlyAllow')} ${props.ext.join('、')}`,
|
||||
3
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -65,13 +71,14 @@ function fnBeforeUpload(file: FileType) {
|
||||
|
||||
/**上传请求发出 */
|
||||
function fnUpload(up: UploadRequestOption) {
|
||||
emit('upload', up.file)
|
||||
emit('upload', up.file);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-modal
|
||||
width="500px"
|
||||
<ProModal
|
||||
:drag="true"
|
||||
:destroyOnClose="true"
|
||||
:title="props.title"
|
||||
:visible="props.visible"
|
||||
:keyboard="false"
|
||||
@@ -93,20 +100,26 @@ function fnUpload(up: UploadRequestOption) {
|
||||
<p class="ant-upload-drag-icon">
|
||||
<inbox-outlined></inbox-outlined>
|
||||
</p>
|
||||
<p class="ant-upload-text">{{t('components.UploadModal.uploadTip')}}</p>
|
||||
<p class="ant-upload-text">
|
||||
{{ t('components.UploadModal.uploadTip') }}
|
||||
</p>
|
||||
<p class="ant-upload-hint">
|
||||
<div v-if="props.size > 0">
|
||||
{{t('components.UploadModal.allowSize')}} {{ props.size }} MB
|
||||
</div>
|
||||
<div v-if="props.ext.length > 0">
|
||||
{{t('components.UploadModal.allowFormat')}} {{ props.ext.join('、') }}
|
||||
|
||||
</div>
|
||||
<template v-if="props.size > 0">
|
||||
<div>
|
||||
{{ t('components.UploadModal.allowSize') }} {{ props.size }} MB
|
||||
</div>
|
||||
</template>
|
||||
<template v-if="props.ext.length > 0">
|
||||
<div>
|
||||
{{ t('components.UploadModal.allowFormat') }}
|
||||
{{ props.ext.join('、') }}
|
||||
</div>
|
||||
</template>
|
||||
</p>
|
||||
</a-upload-dragger>
|
||||
<slot></slot>
|
||||
</a-space>
|
||||
</a-modal>
|
||||
</ProModal>
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user