From 42fea1853d235e576ec15dd6f87f250af9fdea31 Mon Sep 17 00:00:00 2001
From: odjbin <1042039504@qq.com>
Date: Fri, 7 Jun 2024 16:46:44 +0800
Subject: [PATCH] =?UTF-8?q?fix=20:=20=E4=BF=AE=E5=A4=8D=E9=9C=80=E6=B1=82?=
=?UTF-8?q?=E4=B8=8A=E6=8A=A5=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0/?=
=?UTF-8?q?=E5=88=A0=E9=99=A4=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/AttachmentUpload.vue | 85 ++++++++++++-------
.../DetailComponent/FileComponent.vue | 40 ++++-----
src/views/project-demand/summary/add.vue | 70 ++++++---------
src/views/project-demand/summary/index.vue | 1 +
4 files changed, 98 insertions(+), 98 deletions(-)
diff --git a/src/components/AttachmentUpload.vue b/src/components/AttachmentUpload.vue
index aa5ed37..81ebf81 100644
--- a/src/components/AttachmentUpload.vue
+++ b/src/components/AttachmentUpload.vue
@@ -37,6 +37,32 @@ import FileUpload from '@/components/FileUpload.vue'
import {deleteFile, downloadFile} from "@/api/project-demand";
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
+const props = defineProps({
+ showFileList: {
+ type: Boolean,
+ default: false
+ },
+ label: {
+ type: String,
+ default: '项目附件'
+ },
+ showTable: {
+ type: Boolean,
+ default: true
+ },
+ preview: {
+ type: Boolean,
+ default: false
+ },
+ otherFileList: {
+ type: Array,
+ default: []
+ },
+ formData: {
+ type: Array,
+ default: []
+ }
+})
const emit = defineEmits(["getAttachment", "getOtherFile"])
const formData = ref({})
const tableConfig = reactive({
@@ -72,9 +98,9 @@ const tableConfig = reactive({
currentRender: ({row, index}) => {
let btn = []
btn.push({label: '下载', func: () => handleDownload(row), type: 'primary'})
- if (row.newFile){
- btn.push({label: '删除', func: () => handleDelete(row), type: 'primary'})
- }
+ // if (row.newFile){
+ // btn.push({label: '删除', func: () => handleDelete(row), type: 'primary'})
+ // }
return (
{
@@ -88,6 +114,12 @@ const tableConfig = reactive({
))
}
+ {
+ row.newFile||props.preview ?
handleDelete(row)}/>
+ : ''
+ }
)
}
@@ -101,39 +133,13 @@ const applyForm = ref()
const singleFile = ref()
const isSingleFile = ref(false)
const allFileList = ref([])
-const props = defineProps({
- showFileList: {
- type: Boolean,
- default: false
- },
- label: {
- type: String,
- default: '项目附件'
- },
- showTable: {
- type: Boolean,
- default: true
- },
- preview: {
- type: Boolean,
- default: false
- },
- otherFileList: {
- type: Array,
- default: []
- },
- formData: {
- type: Array,
- default: []
- }
-})
watch(() => props.showTable, (newVal) => {
props.showTable = newVal
}, {deep: true})
watch(() => props.otherFileList, (newVal) => {
console.log('newotherFileList', newVal)
if (props.preview) {
- if (props.formData.fileList.length===0) {
+ if (props.formData.fileList===null||props.formData.fileList.length===0) {
allFileList.value = newVal
} else {
newVal?.forEach(item => {
@@ -156,6 +162,21 @@ watch(() => props.formData.singleFile, (newVal) => {
console.log('singleFile', newVal)
singleFile.value = newVal
}, {deep: true})
+watch(() => isSingleFile.value, (newVal) => {
+ isSingleFile.value = newVal
+}, {deep: true})
+const handleDelete = (row) => {
+ deleteFile(row.fileId).then(res => {
+ ElNotification({
+ title: '提示',
+ message: res.msg,
+ type: res.code === 1000 ? 'success' : 'error'
+ })
+ if (res.code === 1000) {
+ allFileList.value.splice(allFileList.value.findIndex((item) => item.id === row.fileId), 1);
+ }
+ });
+}
const getAttachment = (val) => {
isSingleFile.value = true
emit('getAttachment', val)
@@ -172,6 +193,7 @@ const deleteAttachment = (val) => {
type: 'success'
})
isSingleFile.value = false
+ singleFile.value={}
}
});
}
@@ -221,7 +243,8 @@ defineExpose({
return applyForm.value.clearValidate()
},
allFileList,
- singleFile
+ singleFile,
+ isSingleFile
})
diff --git a/src/components/DetailComponent/FileComponent.vue b/src/components/DetailComponent/FileComponent.vue
index 9ae988a..f4a1374 100644
--- a/src/components/DetailComponent/FileComponent.vue
+++ b/src/components/DetailComponent/FileComponent.vue
@@ -12,7 +12,7 @@