fix : 重新提交全流程初步完成

This commit is contained in:
2024-05-20 23:01:53 +08:00
parent 6c80652416
commit 3270aeef06
12 changed files with 280 additions and 189 deletions

View File

@@ -3,10 +3,13 @@
<el-row>
<el-col :span="24">
<el-form-item :label="label" prop="attachment">
<template v-if="preview">
<el-button type="primary" link @click="handleDownload(singleFile)" style="font-size: 18px">{{ singleFile?.originalFileName }}</el-button>
<template v-if="preview&&JSON.stringify(singleFile) !== '{}'&&JSON.stringify(singleFile)!=='null'">
<el-button type="primary" link @click="handleDownload(singleFile)" style="font-size: 18px">
{{ singleFile?.originalFileName }}
</el-button>
<el-button type="danger" link @click="deleteOtherFile(singleFile,1)">删除</el-button>
</template>
<template v-else>
<template v-else-if="!preview||JSON.stringify(singleFile) === '{}'||singleFile==null">
<file-upload @getFile="getAttachment" :showFileList="showFileList" :maxSize="0" @delete="deleteAttachment"/>
</template>
</el-form-item>
@@ -31,7 +34,7 @@
<script setup lang="jsx">
import FileUpload from '@/components/FileUpload.vue'
import {deleteFile, downloadFile} from "../api/project-demand";
import {ElMessage, ElMessageBox} from "element-plus";
import {ElMessage, ElMessageBox, ElNotification} from "element-plus";
const emit = defineEmits(["getAttachment", "getOtherFile"])
const formData = ref({})
@@ -77,11 +80,11 @@ const tableConfig = reactive({
]
})
const rules = reactive({
attachment: [{required: true, message: '请上传附件', trigger: ['blur','change']}],
attachment: [{required: true, message: '请上传附件', trigger: ['blur', 'change']}],
})
const applyForm=ref()
const singleFile=ref()
const allFileList=ref([])
const applyForm = ref()
const singleFile = ref()
const allFileList = ref([])
const props = defineProps({
showFileList: {
type: Boolean,
@@ -95,10 +98,10 @@ const props = defineProps({
}, preview: {
type: Boolean,
default: false
},otherFileList: {
}, otherFileList: {
type: Array,
default: []
},formData: {
}, formData: {
type: Array,
default: []
}
@@ -107,16 +110,19 @@ watch(() => props.showTable, (newVal) => {
props.showTable = newVal
}, {deep: true})
watch(() => props.otherFileList, (newVal) => {
newVal.forEach(item=>{
newVal.forEach(item => {
allFileList.value.push(item)
})
}, {deep: true})
watch(() => props.formData.fileList, (newVal) => {
newVal.forEach(item=>{
allFileList.value.push(item)
})
if (props.preview) {
newVal.forEach(item => {
allFileList.value.push(item)
})
}
}, {deep: true})
watch(() => props.formData.singleFile, (newVal) => {
// singleFile.value = {}
singleFile.value = newVal
}, {deep: true})
const getAttachment = (val) => {
@@ -132,20 +138,32 @@ const deleteAttachment = (val) => {
}
});
}
const deleteOtherFile = (row) => {
const deleteOtherFile = (row, type) => {
ElMessageBox.confirm(`确认删除名称为${row.originalFileName}的表格吗?`, '系统提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteFile(row.fileId).then(res => {
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
ElMessage.success("删除成功");
props.otherFileList.splice(props.otherFileList.findIndex((item) => item.id === row.fileId), 1);
if (type === 1) {
singleFile.value = {}
} else {
props.otherFileList.splice(props.otherFileList.findIndex((item) => item.id === row.fileId), 1);
}
}
});
}).catch(() => {
ElMessage.warning("用户取消删除! ");
ElNotification({
title: '提示',
message: "用户取消删除! ",
type: 'warning'
})
})
}
const handleDownload = (row) => {
@@ -158,10 +176,10 @@ const handleDownload = (row) => {
})
}
defineExpose({
validate(){
validate() {
return applyForm.value.validate()
},
clearValidate(){
clearValidate() {
return applyForm.value.clearValidate()
},
allFileList,