fix : 修复项目实施附件上传功能

This commit is contained in:
dj
2025-04-09 10:58:26 +08:00
parent d3b12bd64c
commit f3d9ff44a3

View File

@@ -30,7 +30,7 @@
</el-row> </el-row>
<div style="margin-top:10px;margin-bottom: 8px;margin-left: 15px;display: flex"> <div style="margin-top:10px;margin-bottom: 8px;margin-left: 15px;display: flex">
<!-- <el-button color="#DED0B2" @click="handleUpload">上传附件</el-button>--> <!-- <el-button color="#DED0B2" @click="handleUpload">上传附件</el-button>-->
<file-upload v-if="!isLineBtn&&uploadState" @getFile="getFile"/> <file-upload v-if="!isLineBtn&&uploadState&&activeName!='plus'" @getFile="getFile"/>
<el-button color="#DED0B2" @click="handleEditTag" v-if="activeName!='all'&&activeName!='plus'&&uploadState" <el-button color="#DED0B2" @click="handleEditTag" v-if="activeName!='all'&&activeName!='plus'&&uploadState"
style="margin-left: 10px;">编辑 style="margin-left: 10px;">编辑
@@ -46,7 +46,7 @@
<file-preview ref="filePreviewRef" :fullscreen="false" v-if="filePreviewShow" :fileName="filePreviewParam.fileName" <file-preview ref="filePreviewRef" :fullscreen="false" v-if="filePreviewShow" :fileName="filePreviewParam.fileName"
:fileUrl="filePreviewParam.fileUrl" :fileUrl="filePreviewParam.fileUrl"
:fileType="filePreviewParam.fileType"/> :fileType="filePreviewParam.fileType"/>
<el-dialog v-model="tagNameShow" center width="450" top="450px"> <el-dialog v-model="tagNameShow" center width="450" top="40vh">
<div style="display: flex;align-items: center">标签 <div style="display: flex;align-items: center">标签
<el-input v-model="fileParam.tagName" placeholder="请输入标签名称" style="width: 335px;" clearable/> <el-input v-model="fileParam.tagName" placeholder="请输入标签名称" style="width: 335px;" clearable/>
</div> </div>
@@ -63,6 +63,7 @@ import {addTag, delTag, getTagList, getTags, updateTag} from "@/api/project-mana
import {ElLoading, ElMessageBox, ElNotification} from "element-plus"; import {ElLoading, ElMessageBox, ElNotification} from "element-plus";
import {searchImplementationFileList, uploadFileList} from "@/api/project-manage/attachment"; import {searchImplementationFileList, uploadFileList} from "@/api/project-manage/attachment";
import {deleteFile, downloadFile} from "@/api/project-demand"; import {deleteFile, downloadFile} from "@/api/project-demand";
import {nextTick, onActivated} from "vue";
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
@@ -184,11 +185,13 @@ const changeTag = async () => {
fileTag: fileParam.value.tagName, fileTag: fileParam.value.tagName,
projectId: route.query.projectId, projectId: route.query.projectId,
}) })
changeFileList(fileParam.value.tagName,true)
} else { } else {
res = await addTag({ res = await addTag({
projectId: route.query.projectId, projectId: route.query.projectId,
fileTag: fileParam.value.tagName fileTag: fileParam.value.tagName
}) })
getAttachmentList() getAttachmentList()
fileParam.value.tagName = '' fileParam.value.tagName = ''
activeName.value = 'all' activeName.value = 'all'
@@ -198,11 +201,6 @@ const changeTag = async () => {
message: res.msg, message: res.msg,
type: res.code === 1000 ? 'success' : 'error' type: res.code === 1000 ? 'success' : 'error'
}) })
getTagsOption()
// tagsOption.value.push({
// value: fileParam.value.tagName,
// label: fileParam.value.tagName
// })
tagNameShow.value = false; tagNameShow.value = false;
} }
const tabRemove = async (val) => { const tabRemove = async (val) => {
@@ -240,6 +238,7 @@ const handleTabClick = (item) => {
tagNameShow.value = item.props.name == 'plus'; tagNameShow.value = item.props.name == 'plus';
if (item.props.name == 'plus') { if (item.props.name == 'plus') {
isEdit.value = false isEdit.value = false
fileParam.value.tagName = ''
} }
if (item.props.name != 'plus') { if (item.props.name != 'plus') {
if (item.props.name == 'all') { if (item.props.name == 'all') {
@@ -295,7 +294,7 @@ const handleSubmit = async (list) => {
otherAttachmentList.value.push(item) otherAttachmentList.value.push(item)
}) })
} }
getTagsOption() changeFileList('all',true)
} }
const clickToPreview = (row) => { const clickToPreview = (row) => {
filePreviewShow.value = false filePreviewShow.value = false
@@ -308,7 +307,7 @@ const clickToPreview = (row) => {
filePreviewShow.value = true filePreviewShow.value = true
}) })
} }
const changeFileList = (tag) => { const changeFileList = (tag,flag) => {
let params = {} let params = {}
if (tag == 'all') { if (tag == 'all') {
params = { params = {
@@ -326,7 +325,14 @@ const changeFileList = (tag) => {
searchImplementationFileList(params).then(res => { searchImplementationFileList(params).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
otherAttachmentList.value = res.data.fileList if(tag == 'all'&&flag){
allFiles.value = res.data.fileList
}else{
otherAttachmentList.value = res.data.fileList
}
if(flag){
getTagsOption(flag)
}
nextTick(() => { nextTick(() => {
showAttachmentTable.value = true showAttachmentTable.value = true
}) })
@@ -340,14 +346,6 @@ const getAttachmentList = () => {
targetState: "30" targetState: "30"
} }
showAttachmentTable.value = false showAttachmentTable.value = false
if (attachmentParam.tag) {
tagsOption.value.forEach(item => {
if (item.value === attachmentParam.tag) {
attachmentParam.tag = item.label
}
})
params.tag = attachmentParam.tag
}
searchImplementationFileList(params).then(res => { searchImplementationFileList(params).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
// otherAttachmentList.value = res.data.fileList // otherAttachmentList.value = res.data.fileList
@@ -370,15 +368,27 @@ const getAttachmentList = () => {
} }
}) })
} }
const getTagsOption = () => { const getTagsOption = (flag) => {
if (!route.query.projectId) return if (!route.query.projectId) return
getTagList(route.query.projectId).then(res => { getTagList(route.query.projectId).then(res => {
if (res.code === 1000) { if (res.code === 1000) {
tagsOption.value = res.data.rows tagsOption.value = res.data.rows
let list=[]
if(flag){
list= allFiles.value
}else{
list=otherAttachmentList.value
}
tagsOption.value.forEach((tag, index) => { tagsOption.value.forEach((tag, index) => {
const filterArray = otherAttachmentList.value.filter(item => tag.fileTag == item.tag) const filterArray = list.filter(item => tag.fileTag == item.tag)
console.log("🚀 ~ file:filterArray ", filterArray)
tagsOption.value[index].isClose = filterArray.length > 0 ? 0 : 1 tagsOption.value[index].isClose = filterArray.length > 0 ? 0 : 1
}) })
console.log("🚀 otherAttachmentList.value", allFiles.value)
console.log("🚀 ~ file:\tagsOption.value ", tagsOption.value)
// if (!res.data.rows || res.data.rows.length == 0) return; // if (!res.data.rows || res.data.rows.length == 0) return;
// activeName.value=res.data.rows[0].tagId // activeName.value=res.data.rows[0].tagId
} else { } else {