|
@@ -1026,11 +1026,24 @@
|
|
:limit="1"
|
|
:limit="1"
|
|
:on-exceed="handleExceed"
|
|
:on-exceed="handleExceed"
|
|
:before-upload="beforeUpload"
|
|
:before-upload="beforeUpload"
|
|
- :on-progress="handleProgress"
|
|
|
|
|
|
+ :show-file-list="false"
|
|
|
|
+ :on-change="handleChange"
|
|
>
|
|
>
|
|
<div class="mt-24px text-black">将文件拖动到此处,<span class="text-blue">或点击上传</span></div>
|
|
<div class="mt-24px text-black">将文件拖动到此处,<span class="text-blue">或点击上传</span></div>
|
|
<div class="mt-8px text-12px">支持的文件格式:.xls,.xlsx</div>
|
|
<div class="mt-8px text-12px">支持的文件格式:.xls,.xlsx</div>
|
|
</el-upload>
|
|
</el-upload>
|
|
|
|
+ <!-- 自定义文件列表 -->
|
|
|
|
+ <div v-if="fileList.length > 0" class="upload-file-list mt-4">
|
|
|
|
+ <div v-for="file in fileList" :key="file.uid" class="mb-2 flex items-center justify-between border rounded p-2">
|
|
|
|
+ <div class="flex items-center">
|
|
|
|
+ <HcIcon name="file-excel" class="mr-2 text-green-500" />
|
|
|
|
+ <span>{{ file.name }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ <el-button type="danger" link @click="handleRemove(file)">
|
|
|
|
+ <HcIcon name="delete" />
|
|
|
|
+ </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
<div class="text-right">
|
|
<div class="text-right">
|
|
<el-button hc-btn type="success" :loading="downLoadTemplateLoading" @click="downLoadTemplate">
|
|
<el-button hc-btn type="success" :loading="downLoadTemplateLoading" @click="downLoadTemplate">
|
|
<HcIcon name="download-2" />
|
|
<HcIcon name="download-2" />
|
|
@@ -2661,17 +2674,17 @@ const beforeUpload = (file) => {
|
|
}
|
|
}
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
-// 添加进度条处理函数
|
|
|
|
-// 添加进度条处理函数
|
|
|
|
-const handleProgress = (event, file) => {
|
|
|
|
- // 控制上传进度最大显示99%
|
|
|
|
- if (event.percent >= 99) {
|
|
|
|
- file.percentage = 99
|
|
|
|
- } else {
|
|
|
|
- file.percentage = event.percent
|
|
|
|
- }
|
|
|
|
|
|
+// 添加以下数据和方法
|
|
|
|
+const fileList = ref([])
|
|
|
|
+
|
|
|
|
+const handleChange = (file, files) => {
|
|
|
|
+ fileList.value = [file] // 由于限制为1个文件,直接替换
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const handleRemove = (file) => {
|
|
|
|
+ fileList.value = fileList.value.filter(item => item.uid !== file.uid)
|
|
|
|
+ dialogUploadRef.value?.clearFiles()
|
|
}
|
|
}
|
|
-// 添加进度条处理函数
|
|
|
|
|
|
|
|
const handleExceed = (files) => {
|
|
const handleExceed = (files) => {
|
|
dialogUploadRef.value.clearFiles()
|
|
dialogUploadRef.value.clearFiles()
|
|
@@ -2686,11 +2699,7 @@ const handleSuccess = (res) => {
|
|
confirmLoading.value = false
|
|
confirmLoading.value = false
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
window.$message.success(res.msg || '上传成功')
|
|
window.$message.success(res.msg || '上传成功')
|
|
- // 上传成功时才显示100%
|
|
|
|
- const uploadFiles = dialogUploadRef.value?.uploadFiles || []
|
|
|
|
- uploadFiles.forEach(file => {
|
|
|
|
- file.percentage = 100
|
|
|
|
- })
|
|
|
|
|
|
+
|
|
|
|
|
|
divisionImportDialog.value = false
|
|
divisionImportDialog.value = false
|
|
|
|
|