fix : 修改为一个文件上传入口, 阶段变更增加变更状态,修复项目实施显示

This commit is contained in:
2024-08-27 22:28:52 +08:00
parent a1a3c0ac9f
commit 50504f4e94
9 changed files with 252 additions and 214 deletions

View File

@@ -1,28 +1,28 @@
<template>
<el-form :model="formData" ref="applyForm" :rules="rules" :label-position="labelPosition" style="margin-left: 5px">
<el-row>
<!-- <el-col :span="24">-->
<!-- <el-form-item :label="label" prop="attachment" >-->
<!-- <template v-if="preview">-->
<!-- <file-upload @getFile="getAttachment" :multiple="false"-->
<!-- :disabled="singleFileArray?.length>0?true:false" title="如需修改需求申请书附件,请先删除文件再上传!"/>-->
<!-- <fvTable style="width: 100%;max-height: 80px;" height="80" v-if="singleFileArray?.length>0"-->
<!-- :tableConfig="editSingleTableConfig"-->
<!-- :data="singleFileArray" :isSettingCol="false" :pagination="false">-->
<!-- </fvTable>-->
<!-- </template>-->
<!-- <template v-else-if="!preview">-->
<!-- <file-upload @getFile="getAttachment" :multiple="false"-->
<!-- :disabled="isSingleFile"/>-->
<!-- <fvTable style="width: 100%;max-height: 80px;" v-if="showSingleTable" height="80"-->
<!-- :tableConfig="singleTableConfig"-->
<!-- :data="_singleFileValue" :isSettingCol="false" :pagination="false">-->
<!-- </fvTable>-->
<!-- </template>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<el-col :span="24">
<el-form-item :label="label" prop="attachment" >
<template v-if="preview">
<file-upload @getFile="getAttachment" :multiple="false"
:disabled="singleFileArray?.length>0?true:false" title="如需修改需求申请书附件,请先删除文件再上传!"/>
<fvTable style="width: 100%;max-height: 80px;" height="80" v-if="singleFileArray?.length>0"
:tableConfig="editSingleTableConfig"
:data="singleFileArray" :isSettingCol="false" :pagination="false">
</fvTable>
</template>
<template v-else-if="!preview">
<file-upload @getFile="getAttachment" :multiple="false"
:disabled="isSingleFile"/>
<fvTable style="width: 100%;max-height: 80px;" v-if="showSingleTable" height="80"
:tableConfig="singleTableConfig"
:data="_singleFileValue" :isSettingCol="false" :pagination="false">
</fvTable>
</template>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="其他文件" :label-width="tag==='需求上报'?120:106">
<el-form-item :label="label" prop="" required>
<file-upload @getFile="getOtherFile"/>
<fvTable style="width: 100%;max-height: 160px;" v-if="showTable" height="160" :tableConfig="tableConfig"
:data="allFileList" :isSettingCol="false" :pagination="false">
@@ -240,11 +240,12 @@ const editSingleTableConfig = reactive({
})
const singleFileArray = ref([])
const rules = reactive({
attachment: [{required: true, message: '请上传附件', trigger: ['blur', 'change']}],
// attachment: [{required: true, message: '请上传附件', trigger: ['blur', 'change']}],
})
const applyForm = ref()
const singleFile = ref({})
const isSingleFile = ref(false)
const isHaveOneFile = ref(false)
const allFileList = ref([])
if (localStorage.getItem('singleFile')) {
singleFileArray.value.push(JSON.parse(localStorage.getItem('singleFile')))
@@ -276,16 +277,18 @@ const _otherFileListValue = computed({
}
})
if (_otherFileListValue.value && _otherFileListValue.value.length > 0) {
isHaveOneFile.value=true
_otherFileListValue.value.forEach(item => {
allFileList.value.push(item)
})
}
watch(() => props.showSingleTable, (newVal) => {
props.showSingleTable = newVal
}, {deep: true})
// watch(() => props.showSingleTable, (newVal) => {
// props.showSingleTable = newVal
// }, {deep: true})
watch(() => props.formData.fileList, (newVal) => {
if (props.preview) {
newVal?.forEach(item => {
isHaveOneFile.value=true
allFileList.value.push(item)
})
}
@@ -329,6 +332,9 @@ watch(() => props.showTable, (newVal) => {
watch(() => isSingleFile.value, (newVal) => {
isSingleFile.value = newVal
}, {deep: true})
watch(() => isHaveOneFile.value, (newVal) => {
isHaveOneFile.value = newVal
}, {deep: true})
// watch(() => singleFile.value, (newVal) => {
// singleFile.value = newVal
// }, {deep: true})
@@ -364,6 +370,7 @@ const handleDelete = (row, type) => {
_singleFileValue.value.splice(_singleFileValue.value.findIndex((item) => item.fileId === row.fileId), 1);
isSingleFile.value = false
} else {
isHaveOneFile.value=false
allFileList.value.splice(allFileList.value.findIndex((item) => item.fileId === row.fileId), 1);
}
}
@@ -373,7 +380,6 @@ const handleSingleDelete = (row) => {
handleDelete(row, 'single')
}
const getAttachment = (val) => {
// console.log('getAttachment', val)
isSingleFile.value = true
emit('getAttachment', val)
}
@@ -394,6 +400,7 @@ const getOtherFile = (val) => {
} else {
allFileList.value = _otherFileListValue.value
}
isHaveOneFile.value=true
emit('getOtherFile', val)
}
const deleteAttachment = (val) => {
@@ -458,7 +465,8 @@ defineExpose({
},
allFileList,
singleFile,
isSingleFile
isSingleFile,
isHaveOneFile,
})
</script>