Merge pull request 'fix : 修复需求上报文件上传/删除问题' (#298) from dj into master

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/298
This commit is contained in:
2024-06-07 08:46:59 +00:00
4 changed files with 98 additions and 98 deletions

View File

@@ -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 (
<div style={{width: '100%'}}>
{
@@ -88,6 +114,12 @@ const tableConfig = reactive({
</el-button>
))
}
{
row.newFile||props.preview ? <popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'}
perm={['mosr:requirement:del']}
onDelete={() => handleDelete(row)}/>
: ''
}
</div>
)
}
@@ -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
})
</script>

View File

@@ -12,7 +12,7 @@
<script setup lang="jsx">
import {downloadFile, deleteFile} from "@/api/project-demand";
import {ElMessageBox, ElNotification} from "element-plus";
import {ElNotification} from "element-plus";
const props = defineProps({
title: {
@@ -70,9 +70,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 (
<div style={{width: '100%'}}>
{
@@ -85,6 +85,12 @@ const tableConfig = reactive({
</el-button>
))
}
{
row.newFile ? <popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'}
perm={['mosr:requirement:del']}
onDelete={() => handleDelete(row)}/>
: ''
}
</div>
)
}
@@ -132,28 +138,16 @@ const handleDownload = (row) => {
})
}
const handleDelete = (row) => {
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) {
_value.value.splice(_value.value.findIndex((item) => item.id === row.fileId), 1);
}
});
}).catch(() => {
deleteFile(row.fileId).then(res => {
ElNotification({
title: '提示',
message: '用户取消删除! ',
type: 'warning'
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
})
if (res.code === 1000) {
_value.value.splice(_value.value.findIndex((item) => item.id === row.fileId), 1);
}
});
}
watch(() => props.processViewer, (newVal) => {

View File

@@ -16,8 +16,8 @@
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="6" v-if="route.query.id&&formData.specialFund">
<el-form-item label="专项资金" prop="specialFundId" >
<el-col :span="6">
<el-form-item label="专项资金" prop="specialFundId" v-if="route.query.id&&formData.specialFund">
<span>{{ formData.specialFund }}</span>
</el-form-item>
</el-col>
@@ -214,10 +214,12 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="其中申请公司总部科技创新专项资金(元)" prop="specialFundAmount" v-if="!route.query.id&&formData.isSpecialFund">
<el-form-item label="其中申请公司总部科技创新专项资金(元)" prop="specialFundAmount"
v-if="!route.query.id&&formData.isSpecialFund">
<el-input-number v-model="formData.specialFundAmount" placeholder="请输入专项资金" :controls="false"/>
</el-form-item>
<el-form-item label="其中申请公司总部科技创新专项资金(元)" prop="specialFundAmount" v-if="route.query.id&&formData.specialFundAmount">
<el-form-item label="其中申请公司总部科技创新专项资金(元)" prop="specialFundAmount"
v-if="route.query.id&&formData.specialFundAmount">
<el-input-number v-model="formData.specialFundAmount" placeholder="请输入专项资金" :controls="false"/>
</el-form-item>
</el-col>
@@ -278,7 +280,6 @@ const deploymentId = ref()
const specialFundOption = ref([])
const showTable = ref(true)
const otherFileList = ref([])
const file = ref({})
const formData = ref({
isSpecialFund: false,
industryUniversityResearch: '0',
@@ -357,7 +358,6 @@ const compositeParam = (item, type) => {
const getAttachment = (val) => {
console.log('上传文件getAttachment', val)
file.value = compositeParam(val)
formData.value.singleFile = compositeParam(val)
}
const getOtherFile = (val) => {
@@ -370,6 +370,8 @@ const getOtherFile = (val) => {
})
}
const getFileParam = (item) => {
console.log('item', item)
if (item === undefined) return;
return {
fileId: item.fileId,
tag: item.tag
@@ -385,26 +387,21 @@ const handleSubmit = debounce(async (instance) => {
type: 'error'
})
}
let singleFile = {}
if (file.value.fileId !== undefined) {
singleFile = {
fileId: file.value.fileId
}
}
let otherFiles = []
otherFileList.value.forEach(item => {
otherFiles.push(getFileParam(item))
})
if (formData.value.singleFile !== undefined) {
formData.value.singleFile = getFileParam(formData.value.singleFile)
}
let params = {
...formData.value,
// isSpecialFund: formData.value.isSpecialFund ? formData.value.isSpecialFund : false,
deploymentId: deploymentId.value,
fileList: otherFiles,
singleFile: singleFile,
requirementId: route.query.id ? route.query.id : '-1'
}
console.log('params', params, formData.value)
if (JSON.stringify(singleFile) === "{}") {
console.log('params', params)
if (!attachment.value.isSingleFile) {
attachment.value.validate()
ElNotification({
title: '提示',
@@ -415,52 +412,37 @@ const handleSubmit = debounce(async (instance) => {
} else {
attachment.value.clearValidate()
}
// let res = await requirementReported(params)
// ElNotification({
// title: '提示',
// message: res.msg,
// type: res.code === 1000 ? 'success' : 'error'
// })
// if (res.code === 1000) {
// tagsViewStore.delVisitedViews(router.currentRoute.value.path)
// await router.push({
// name: 'Summary'
// })
// }
let res = await requirementReported(params)
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
tagsViewStore.delVisitedViews(router.currentRoute.value.path)
await router.push({
name: 'Summary'
})
}
})
})
const handleResubmit = debounce(() => {
let singleFile = {}
let otherFiles = []
let fileArray
if (name.value === 'Summary/edit') {
singleFile = {
fileId: attachment.value.singleFile?.fileId
}
fileArray = attachment.value.allFileList
} else {
if (file.value.fileId !== undefined) {
singleFile = {
fileId: file.value.fileId
}
}
fileArray = otherFileList.value
}
fileArray.forEach(item => {
otherFiles.push(getFileParam(item))
})
//todo requirementId
let params = {
...formData.value,
// isSpecialFund: formData.value.isSpecialFund ? formData.value.isSpecialFund : false,
deploymentId: deploymentId.value,
fileList: otherFiles,
singleFile: singleFile,
requirementId: route.query.id ? route.query.id : '-1'
}
console.log('重新提交params', params, formData.value)
if (JSON.stringify(singleFile) === "{}") {
if (!attachment.value.isSingleFile) {
attachment.value.validate()
ElNotification({
title: '提示',

View File

@@ -156,6 +156,7 @@ const tableConfig = reactive({
prop: 'oper',
label: '操作',
align: 'center',
fixed:'right',
showOverflowTooltip: false,
currentRender: ({row, index}) => {
let btn = []