feat : 项目归档-实施附件

This commit is contained in:
dj
2025-04-27 14:28:59 +08:00
parent f1b81d86a2
commit c27162f918

View File

@@ -4,20 +4,6 @@
<fvForm :schema="schema" @getInstance="(e)=>baseForm = e" label-position="left" label-width="left" <fvForm :schema="schema" @getInstance="(e)=>baseForm = e" label-position="left" label-width="left"
style="margin-left: 15px;margin-bottom: -18px"></fvForm> style="margin-left: 15px;margin-bottom: -18px"></fvForm>
<baseTitle title="项目实施-上传附件" ></baseTitle> <baseTitle title="项目实施-上传附件" ></baseTitle>
<!-- <el-form :model="fileParam" ref="tagForm" label-width="auto">-->
<!-- <el-form-item label="标签名称" prop="tagName" style="margin-left: 15px;">-->
<!-- <el-input v-model="fileParam.tagName" placeholder="请输入标签名称" style="width: 300px;margin-right: 10px" v-if="showInput" clearable/>-->
<!-- <el-select v-model="fileParam.tagName" placeholder="请选择标签名称" clearable filterable style="width: 300px;margin-right: 10px" v-else>-->
<!-- <el-option-->
<!-- v-for="item in tagsOption"-->
<!-- :key="item.value"-->
<!-- :label="item.label"-->
<!-- :value="item.value"-->
<!-- />-->
<!-- </el-select>-->
<!-- <el-button type="primary" link @click="changeInput">{{ showInput ? '选择' : '输入' }}</el-button>-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleTabClick" @tab-remove="tabRemove" <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleTabClick" @tab-remove="tabRemove"
style="margin-left: 15px;margin-top: -10px"> style="margin-left: 15px;margin-top: -10px">
<el-tab-pane name="all" :closable="false" label="全部"> <el-tab-pane name="all" :closable="false" label="全部">
@@ -43,15 +29,12 @@
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
<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>-->
<file-upload v-if="activeName!='plus'&&activeName!='all'" @getFile="getFile"/> <file-upload v-if="activeName!='plus'&&activeName!='all'" @getFile="getFile"/>
<el-button color="#DED0B2" @click="handleEditTag" v-if="activeName!='all'&&activeName!='plus'&&!isDefault" <el-button color="#DED0B2" @click="handleEditTag" v-if="activeName!='all'&&activeName!='plus'&&!isDefault"
style="margin-left: 10px;">编辑 style="margin-left: 10px;">编辑
</el-button> </el-button>
</div> </div>
<!-- <baseTitle title="其他文件"></baseTitle>-->
<!-- <file-upload @getFile="getFile" :disabled="!fileParam.tagName" :title="!fileParam.tagName?'请先选择/输入标签!':''" style="margin-left: 15px"/>-->
<fvTable style="width: 100%;max-height: 318px;" v-if="showTable" height="318" :tableConfig="tableConfig" <fvTable style="width: 100%;max-height: 318px;" v-if="showTable" height="318" :tableConfig="tableConfig"
:data="fileList" :isSettingCol="false" :pagination="false"> :data="fileList" :isSettingCol="false" :pagination="false">
<template #empty> <template #empty>
@@ -94,6 +77,7 @@ const tagsViewStore = useTagsView()
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const fileList = ref([]) const fileList = ref([])
const allFileList = ref([])
const activeName = ref('all') const activeName = ref('all')
const tagNameShow = ref(false) const tagNameShow = ref(false)
const showInput = ref(false) const showInput = ref(false)
@@ -366,32 +350,6 @@ const tagsOption = ref([])
const fileParam = ref({ const fileParam = ref({
tagName: '' tagName: ''
}) })
const changeTag = async () => {
let res = null
if (isEdit.value) {
res = await updateTag({
tagId: activeName.value,
fileTag: fileParam.value.tagName,
projectId: route.query.projectId,
})
changeFileList(fileParam.value.tagName,true)
} else {
res = await addTag({
projectId: route.query.projectId,
fileTag: fileParam.value.tagName
})
getAttachmentList()
fileParam.value.tagName = ''
activeName.value = 'all'
}
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
tagNameShow.value = false;
}
const tableConfig = reactive({ const tableConfig = reactive({
columns: [ columns: [
{ {
@@ -428,8 +386,11 @@ const tableConfig = reactive({
return ( return (
<div> <div>
<el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button> <el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button>
<popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'} {
onDelete={() => handleDelete(row)}/> row.oldType ? null : <popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'}
onDelete={() => handleDelete(row)}/>
}
</div> </div>
) )
} }
@@ -449,9 +410,76 @@ const filePreviewParam = ref({
}) })
const filePreviewShow = ref(false) const filePreviewShow = ref(false)
const isEdit = ref(false) const isEdit = ref(false)
const changeTag = async () => {
let res = null
if (isEdit.value) {
res = await updateTag({
tagId: activeName.value,
fileTag: fileParam.value.tagName,
projectId: route.query.projectId,
})
} else {
res = await addTag({
projectId: route.query.projectId,
fileTag: fileParam.value.tagName
})
fileParam.value.tagName = ''
activeName.value = 'all'
}
getTagsOption()
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
tagNameShow.value = false;
}
const getOldFileList = (tag,flag) => {
let params = {}
if (tag == 'all') {
params = {
targetId: route.query.projectId,
targetState: "30",
}
} else {
params = {
targetId: route.query.projectId,
targetState: "30",
tag: getTagName(activeName.value)
}
}
showTable.value = false
searchImplementationFileList(params).then(res => {
if (res.code === 1000) {
if(tag == 'all'){
res.data.fileList?.forEach(item=>{
item.oldType=true
fileList.value.push(item)
})
}else{
console.log("🚀 ~ file:'res.data.fileList ",res.data.fileList )
res.data.fileList?.forEach(item=>{
item.oldType=true
if(getTagName(activeName.value)==item.tag){
fileList.value.push(item)
}
})
console.log("🚀 ~ file:'fileList.value ",fileList.value)
}
if(flag){
getTagsOption(flag)
}
nextTick(() => {
showTable.value = true
})
changeImplementFile()
}
})
}
const handleEditTag = () => { const handleEditTag = () => {
fileParam.value.tagName = getTagName(activeName.value) fileParam.value.tagName = getTagName(activeName.value)
if(otherAttachmentList.value&&otherAttachmentList.value.length>0){ if(fileList.value&&fileList.value.length>0){
ElNotification({ ElNotification({
title: '提示', title: '提示',
message: '该标签下存在文件,不能编辑标签。如需编辑标签,请先删除该标签下的所有文件。', message: '该标签下存在文件,不能编辑标签。如需编辑标签,请先删除该标签下的所有文件。',
@@ -463,7 +491,7 @@ const handleEditTag = () => {
isEdit.value = true isEdit.value = true
} }
const tabRemove = async (val) => { const tabRemove = async (val) => {
if(otherAttachmentList.value&&otherAttachmentList.value.length>0){ if(fileList.value&&fileList.value.length>0){
ElNotification({ ElNotification({
title: '提示', title: '提示',
message: '该标签下存在文件,不能删除标签。如需删除标签,请先删除该标签下的所有文件。', message: '该标签下存在文件,不能删除标签。如需删除标签,请先删除该标签下的所有文件。',
@@ -488,33 +516,6 @@ const tabRemove = async (val) => {
}) })
} }
const changeFileList = (tag,flag) => {
let params = {}
if (tag == 'all') {
params = {
targetId: route.query.projectId,
targetState: "30",
}
} else {
params = {
targetId: route.query.projectId,
targetState: "30",
tag: tag
}
}
searchImplementationFileList(params).then(res => {
if (res.code === 1000) {
if(tag == 'all'&&flag){
allFiles.value = res.data.fileList
}else{
otherAttachmentList.value = res.data.fileList
}
if(flag){
getTagsOption(flag)
}
}
})
}
const handleTabClick = (item) => { const handleTabClick = (item) => {
const defaultArray=tagsOption.value.filter(item1=>item1.tagId==item.props.name) const defaultArray=tagsOption.value.filter(item1=>item1.tagId==item.props.name)
if(defaultArray&&defaultArray.length>0){ if(defaultArray&&defaultArray.length>0){
@@ -527,20 +528,28 @@ const handleTabClick = (item) => {
isEdit.value = false isEdit.value = false
fileParam.value.tagName = '' fileParam.value.tagName = ''
} }
const fileArray=JSON.parse(localStorage.getItem('implementFile'))
if (item.props.name != 'plus') { if (item.props.name != 'plus') {
if (item.props.name == 'all') { if (item.props.name == 'all') {
changeFileList('all') fileList.value=fileArray
getOldFileList('all')
} else { } else {
changeFileList(getTagName(item.props.name)) fileList.value=fileArray.filter(item1 => item1.tag == getTagName(item.props.name))
getOldFileList()
showTable.value = false
nextTick(() => {
showTable.value = true
})
} }
} }
} }
if(localStorage.getItem('implementFile')){ if(localStorage.getItem('implementFile')){
fileList.value=JSON.parse(localStorage.getItem('implementFile')) fileList.value=JSON.parse(localStorage.getItem('implementFile'))
allFileList.value=JSON.parse(localStorage.getItem('implementFile'))
} }
const changeImplementFile=()=>{ const changeImplementFile=()=>{
localStorage.setItem('implementFile', JSON.stringify(fileList.value)) localStorage.setItem('implementFile', JSON.stringify(allFileList.value))
} }
const clickToPreview=(row)=>{ const clickToPreview=(row)=>{
@@ -638,6 +647,8 @@ const getTagsOption = () => {
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
console.log("🚀 ~ file: res.data.rows ", res.data.rows)
tagsOption.value?.forEach((tag, index) => { tagsOption.value?.forEach((tag, index) => {
tagsOption.value[index].isClose =1 tagsOption.value[index].isClose =1
}) })
@@ -692,7 +703,7 @@ const compositeParam = (item) => {
fileType: item.fileType, fileType: item.fileType,
url: item.url, url: item.url,
newFile: true, newFile: true,
tag: fileParam.value.tagName, tag: getTagName(activeName.value) || '项目实施',
} }
} }
const getFile = (val) => { const getFile = (val) => {
@@ -700,24 +711,17 @@ const getFile = (val) => {
showTable.value = false showTable.value = false
let fileObj = compositeParam(val) let fileObj = compositeParam(val)
fileList.value.push(fileObj) fileList.value.push(fileObj)
allFileList.value.push(fileObj)
nextTick(() => { nextTick(() => {
showTable.value = true showTable.value = true
}) })
changeImplementFile() changeImplementFile()
} }
const handleSubmit = async (instance) => { const handleSubmit = async (instance) => {
if (!instance) return const files=JSON.parse(localStorage.getItem('implementFile'))
instance.validate(async (valid) => {
if (!valid) {
ElNotification({
title: '提示',
message: '请完善数据,再提交!',
type: 'error'
})
return;
}
let params = { let params = {
fileList: fileList.value, fileList: files,
projectId: route.query.projectId, projectId: route.query.projectId,
targetState: "30" targetState: "30"
} }
@@ -761,9 +765,9 @@ const handleSubmit = async (instance) => {
} }
localStorage.removeItem('implementFile') localStorage.removeItem('implementFile')
} }
})
} }
getTagsOption() getTagsOption()
getOldFileList('all')
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -786,4 +790,12 @@ getTagsOption()
} }
} }
} }
:deep(.el-tabs__item.is-active) {
color: #BEA266;
}
:deep(.el-tabs__active-bar) {
background-color: #BEA266;
}
</style> </style>