fix : 修复附件上传组件bug

This commit is contained in:
2024-05-18 22:08:08 +08:00
parent e4e7444aff
commit b7ebd66729
3 changed files with 67 additions and 76 deletions

View File

@@ -11,8 +11,8 @@
</el-row>
</el-form>
<AttachmentUpload label="项目验收附件" :showTable="showTable" :otherFileList="otherFileList"
@deleteOtherFile="deleteOtherFile" @download="downloadOtherFile" @getAttachment="getAttachment"
@getOtherFile="getOtherFile" :showFileList="true" @deleteFile="deleteAttachment"/>
@getAttachment="getAttachment"
@getOtherFile="getOtherFile" :showFileList="true"/>
<div class="oper-page-btn">
<el-button color="#DED0B2" @click="handleSubmit(applyForm)">提交</el-button>
</div>
@@ -20,15 +20,16 @@
</template>
<script setup lang="jsx">
import {ElMessage, ElMessageBox} from "element-plus";
import {deleteFile,downloadFile} from "@/api/project-demand";
const formData = ref({})
const fileList = ref(null)
const applyForm = ref()
const showTable = ref(true)
const otherFileList = ref([])
const compositeParam = (item) => {
let tag=''
if(!formData.value.collectType&&router.currentRoute.value.name==='Implementation/check'){
tag='项目实施'
}
return {
fileId: item.id,
size: item.size,
@@ -36,17 +37,13 @@ const compositeParam = (item) => {
fileType: item.fileType,
url: item.url,
processNodeTag: null,
tag: formData.value.collectType
tag: tag
}
}
const getAttachment = (val) => {
console.log('上传文件getAttachment', val)
showTable.value = false
let fileObj = compositeParam(val)
fileList.value.push(fileObj)
nextTick(() => {
showTable.value = true
})
// fileList.value.push(fileObj)
}
const getOtherFile = (val) => {
console.log('上传文件getOtherFile', val)
@@ -57,39 +54,8 @@ const getOtherFile = (val) => {
showTable.value = true
})
}
const deleteAttachment = (val) => {
deleteFile(val).then(res => {
if (res.code === 1000) {
ElMessage.success("删除成功");
}
});
}
const deleteOtherFile = (row) => {
ElMessageBox.confirm(`确认删除名称为${row.originalFileName}的表格吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteFile(row.fileId).then(res => {
if (res.code === 1000) {
ElMessage.success("删除成功");
otherFileList.value.splice(otherFileList.value.findIndex((item) => item.id === row.fileId), 1);
}
});
}).catch(() => {
ElMessage.warning("用户取消删除! ");
})
}
const downloadOtherFile = (row) => {
downloadFile(row.fileId).then(res => {
const blob = new Blob([res])
let a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = row.originalFileName
a.click()
})
}
const handleSubmit = (instance) => {
if (!instance) return
instance.validate(async (valid) => {

View File

@@ -150,7 +150,7 @@ const tableConfig = reactive({
} else if (row.state === '4') {
btn.push({label: '台账', func: () => handleStandingBook(row), type: 'primary'})
btn.push({label: '附件', func: () => handleAttachment(row), type: 'primary'})
btn.push({label: '分摊', func: () => handleShare(row), type: 'primary'})
btn.push({label: '查看分摊', func: () => handleShare(row), type: 'primary'})
}
return (
<div style={{width: '100%'}}>