From 12db4164d0785d465754a2ff6dc269dc80269f96 Mon Sep 17 00:00:00 2001
From: odjbin <1042039504@qq.com>
Date: Sat, 29 Jun 2024 12:05:10 +0800
Subject: [PATCH] =?UTF-8?q?fix=20:=20=E5=8D=95=E6=96=87=E4=BB=B6=E5=92=8C?=
=?UTF-8?q?=E5=A4=9A=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=A0=B7=E5=BC=8F?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/AttachmentUpload.vue | 55 ++++++++++++++++-------------
src/components/FileUpload.vue | 10 ++++--
vite.config.js | 32 ++++++++---------
3 files changed, 53 insertions(+), 44 deletions(-)
diff --git a/src/components/AttachmentUpload.vue b/src/components/AttachmentUpload.vue
index 8b8b53f..9742001 100644
--- a/src/components/AttachmentUpload.vue
+++ b/src/components/AttachmentUpload.vue
@@ -1,5 +1,5 @@
-
+
@@ -12,29 +12,29 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -81,7 +81,7 @@ const props = defineProps({
},
labelPosition: {
type: String,
- default:''
+ default: ''
}
})
const emit = defineEmits(["getAttachment", "getOtherFile"])
@@ -209,6 +209,7 @@ const singleTableConfig = reactive({
}
]
})
+const fileUploadRef=ref()
const rules = reactive({
attachment: [{required: true, message: '请上传附件', trigger: ['blur', 'change']}],
})
@@ -216,8 +217,9 @@ const applyForm = ref()
const singleFile = ref(props.formData.singleFile)
const isSingleFile = ref(false)
const allFileList = ref([])
+const deleteFileVal = ref({})
const singleFileList = ref([])
-if(props.formData.fileList !== null && props.formData.fileList?.length > 0){
+if (props.formData.fileList !== null && props.formData.fileList?.length > 0) {
allFileList.value = props.formData.fileList
}
watch(() => props.showTable, (newVal) => {
@@ -259,7 +261,7 @@ watch(() => props.formData.singleFile, (newVal) => {
watch(() => isSingleFile.value, (newVal) => {
isSingleFile.value = newVal
}, {deep: true})
-const handleDelete = (row,type) => {
+const handleDelete = (row, type) => {
deleteFile(row.fileId).then(res => {
ElNotification({
title: '提示',
@@ -267,21 +269,24 @@ const handleDelete = (row,type) => {
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
- if(type==='single'){
+ if (type === 'single') {
singleFileList.value.splice(singleFileList.value.findIndex((item) => item.id === row.fileId), 1);
isSingleFile.value = false
- }else {
+ } else {
allFileList.value.splice(allFileList.value.findIndex((item) => item.id === row.fileId), 1);
}
}
});
}
const handleSingleDelete = (row) => {
- handleDelete(row,'single')
+ console.log('row',row)
+ // fileUploadRef.value.handleRemove(deleteFileVal.value.id)
+ handleDelete(row, 'single')
}
const getAttachment = (val) => {
- console.log('getAttachment',val)
+ console.log('getAttachment', val)
isSingleFile.value = true
+ // deleteFileVal.value=val
emit('getAttachment', val)
}
const getOtherFile = (val) => {
diff --git a/src/components/FileUpload.vue b/src/components/FileUpload.vue
index 2a6a16d..52df26b 100644
--- a/src/components/FileUpload.vue
+++ b/src/components/FileUpload.vue
@@ -44,10 +44,12 @@ const props = defineProps({
showFileList: {
type: Boolean,
default: false
- }, disabled: {
+ },
+ disabled: {
type: Boolean,
default: false
- }, multiple: {
+ },
+ multiple: {
type: Boolean,
default: true
}
@@ -98,7 +100,9 @@ const uploadError = () => {
type: 'error'
})
}
-
+defineExpose({
+ handleRemove
+})