|
@ -67,6 +67,8 @@ |
|
|
import FileList from './FileList.vue'; |
|
|
import FileList from './FileList.vue'; |
|
|
import { useI18n } from '@/hooks/web/useI18n'; |
|
|
import { useI18n } from '@/hooks/web/useI18n'; |
|
|
import { get } from 'lodash-es'; |
|
|
import { get } from 'lodash-es'; |
|
|
|
|
|
import { Modal } from 'ant-design-vue'; |
|
|
|
|
|
import { createVNode } from 'vue'; |
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
const props = defineProps({ |
|
|
...basicProps, |
|
|
...basicProps, |
|
@ -74,6 +76,10 @@ |
|
|
type: Array as PropType<string[] | any[]>, |
|
|
type: Array as PropType<string[] | any[]>, |
|
|
default: () => [], |
|
|
default: () => [], |
|
|
}, |
|
|
}, |
|
|
|
|
|
beforeUploadPrompt: { |
|
|
|
|
|
type: String as PropType<string>, |
|
|
|
|
|
default: null, |
|
|
|
|
|
}, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const emit = defineEmits(['change', 'register', 'delete']); |
|
|
const emit = defineEmits(['change', 'register', 'delete']); |
|
@ -124,9 +130,31 @@ |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 上传前校验 |
|
|
// 上传前校验 |
|
|
function beforeUpload(file: File) { |
|
|
async function beforeUpload(file: File) { |
|
|
const { size, name } = file; |
|
|
const { size, name } = file; |
|
|
const { maxSize } = props; |
|
|
const { maxSize, beforeUploadPrompt } = props; |
|
|
|
|
|
if (beforeUploadPrompt) { |
|
|
|
|
|
//弹出确实提示框 |
|
|
|
|
|
try { |
|
|
|
|
|
await new Promise((resolve, reject) => { |
|
|
|
|
|
Modal.confirm({ |
|
|
|
|
|
title: '提醒', |
|
|
|
|
|
content: ( |
|
|
|
|
|
createVNode('div', { style: 'color:red;font-weight: bold;font-size: 22px' }, beforeUploadPrompt) ), |
|
|
|
|
|
onOk() { |
|
|
|
|
|
resolve(true); |
|
|
|
|
|
}, |
|
|
|
|
|
onCancel() { |
|
|
|
|
|
reject(false); |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
// 用户点击了确认,继续执行 |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
// 发生错误或用户取消 |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
// 设置最大值,则判断 |
|
|
// 设置最大值,则判断 |
|
|
if (maxSize && file.size / 1024 / 1024 >= maxSize) { |
|
|
if (maxSize && file.size / 1024 / 1024 >= maxSize) { |
|
|
createMessage.error(t('component.upload.maxSizeMultiple', [maxSize])); |
|
|
createMessage.error(t('component.upload.maxSizeMultiple', [maxSize])); |
|
@ -195,6 +223,7 @@ |
|
|
item.status = UploadResultStatus.SUCCESS; |
|
|
item.status = UploadResultStatus.SUCCESS; |
|
|
// ret为code msg data中的data!!!注意 |
|
|
// ret为code msg data中的data!!!注意 |
|
|
item.response = ret; |
|
|
item.response = ret; |
|
|
|
|
|
console.log('item', item, ret); |
|
|
if (props.resultField) { |
|
|
if (props.resultField) { |
|
|
// 适配预览组件而进行封装 |
|
|
// 适配预览组件而进行封装 |
|
|
item.response = { |
|
|
item.response = { |
|
|