|
@@ -18,6 +18,8 @@
|
|
|
:auto-upload="false"
|
|
:auto-upload="false"
|
|
|
:before-upload="beforeUpload"
|
|
:before-upload="beforeUpload"
|
|
|
:on-success="handleUploadSuccess"
|
|
:on-success="handleUploadSuccess"
|
|
|
|
|
+ :on-exceed="handleExceed"
|
|
|
|
|
+ :limit="1"
|
|
|
style="width: 384px; height: 192px; border-radius: 8px"
|
|
style="width: 384px; height: 192px; border-radius: 8px"
|
|
|
>
|
|
>
|
|
|
<el-icon class="el-icon--upload" style="width: 33px; height: 42px"><Document /></el-icon>
|
|
<el-icon class="el-icon--upload" style="width: 33px; height: 42px"><Document /></el-icon>
|
|
@@ -101,7 +103,8 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { Close, Document, CircleCheck, Warning } from '@element-plus/icons-vue';
|
|
import { Close, Document, CircleCheck, Warning } from '@element-plus/icons-vue';
|
|
|
import { ref } from 'vue';
|
|
import { ref } from 'vue';
|
|
|
- import type { UploadInstance } from 'element-plus';
|
|
|
|
|
|
|
+ import { genFileId, ElMessage } from 'element-plus';
|
|
|
|
|
+ import type { UploadInstance, UploadProps, UploadRawFile } from 'element-plus';
|
|
|
import { downloadByUrl } from '@/utils/file/download';
|
|
import { downloadByUrl } from '@/utils/file/download';
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
import { useUserStore } from '@/store/modules/user';
|
|
|
import { onMounted } from 'vue';
|
|
import { onMounted } from 'vue';
|
|
@@ -156,6 +159,10 @@
|
|
|
const isExcel = /\.(xlsx|xls)$/.test(file.name.toLowerCase());
|
|
const isExcel = /\.(xlsx|xls)$/.test(file.name.toLowerCase());
|
|
|
if (!isExcel) {
|
|
if (!isExcel) {
|
|
|
// 提示用户选择正确的文件类型
|
|
// 提示用户选择正确的文件类型
|
|
|
|
|
+ ElMessage({
|
|
|
|
|
+ message: '仅支持上传.xlsx .xls格式文件',
|
|
|
|
|
+ type: 'error',
|
|
|
|
|
+ });
|
|
|
return false; // 阻止上传
|
|
return false; // 阻止上传
|
|
|
}
|
|
}
|
|
|
return true; // 允许上传
|
|
return true; // 允许上传
|
|
@@ -190,6 +197,13 @@
|
|
|
emits('change');
|
|
emits('change');
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const handleExceed: UploadProps['onExceed'] = (files) => {
|
|
|
|
|
+ upload.value!.clearFiles();
|
|
|
|
|
+ const file = files[0] as UploadRawFile;
|
|
|
|
|
+ file.uid = genFileId();
|
|
|
|
|
+ upload.value!.handleStart(file);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
//对话框
|
|
//对话框
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|