feat : 文件下载组件删除功能

This commit is contained in:
2024-05-18 19:54:58 +08:00
parent 6009885c09
commit 0732acf8c7
3 changed files with 44 additions and 35 deletions

View File

@@ -10,13 +10,13 @@
</el-col>
<el-col :span="24">
<el-form-item label="项目验收附件" prop="attachment">
<file-upload @getFile="getAttachment" :showFileList="true"/>
<file-upload @getFile="getAttachment" :showFileList="true" @delete="handleDelete"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="其他文件">
<el-card style="width: 100%">
<file-upload @getFile="getOtherFile" :showFileList="true"/>
<file-upload @getFile="getOtherFile" :showFileList="false" />
<fvTable style="width: 100%;max-height: 250px" v-if="showTable" :tableConfig="tableConfig"
:data="otherFileList" :isSettingCol="false" :pagination="false">
<template #empty>
@@ -36,6 +36,8 @@
<script setup lang="jsx">
import FileUpload from "@/components/FileUpload.vue";
import {ElMessage} from "element-plus";
import {deleteFile} from "@/api/project-demand";
const formData = ref({})
const rules = reactive({
@@ -99,30 +101,22 @@ const compositeParam = (item) => {
}
const getAttachment = (val) => {
console.log('上传文件', val)
showTable.value = false
nextTick(() => {
showTable.value = true
})
let fileObj = {}
let newFileArray = []
if (route.query.isAdd === undefined) {
val.forEach(item => {
fileObj = compositeParam(item)
newFileArray.push(fileObj)
formData.value.fileList.push(fileObj)
})
fileList.value = formData.value.fileList
} else {
val.forEach(item => {
fileObj = compositeParam(item)
newFileArray.push(fileObj)
})
formData.value.fileList = newFileArray
fileList.value = newFileArray
}
// showTable.value = false
// let fileObj = compositeParam(val)
// formData.value.fileList.push(fileObj)
// nextTick(() => {
// showTable.value = true
// })
}
const getOtherFile = () => {
}
const handleDelete=(val)=>{
deleteFile(val).then(res => {
if (res.code === 1000) {
ElMessage.success("删除成功");
}
});
}
const handleSubmit = (instance) => {
if (!instance) return