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"
style="margin-left: 15px;margin-bottom: -18px"></fvForm>
<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"
style="margin-left: 15px;margin-top: -10px">
<el-tab-pane name="all" :closable="false" label="全部">
@@ -43,15 +29,12 @@
</el-tab-pane>
</el-tabs>
<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"/>
<el-button color="#DED0B2" @click="handleEditTag" v-if="activeName!='all'&&activeName!='plus'&&!isDefault"
style="margin-left: 10px;">编辑
</el-button>
</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"
:data="fileList" :isSettingCol="false" :pagination="false">
<template #empty>
@@ -94,6 +77,7 @@ const tagsViewStore = useTagsView()
const route = useRoute()
const router = useRouter()
const fileList = ref([])
const allFileList = ref([])
const activeName = ref('all')
const tagNameShow = ref(false)
const showInput = ref(false)
@@ -366,32 +350,6 @@ const tagsOption = ref([])
const fileParam = ref({
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({
columns: [
{
@@ -428,8 +386,11 @@ const tableConfig = reactive({
return (
<div>
<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>
)
}
@@ -449,9 +410,76 @@ const filePreviewParam = ref({
})
const filePreviewShow = 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 = () => {
fileParam.value.tagName = getTagName(activeName.value)
if(otherAttachmentList.value&&otherAttachmentList.value.length>0){
if(fileList.value&&fileList.value.length>0){
ElNotification({
title: '提示',
message: '该标签下存在文件,不能编辑标签。如需编辑标签,请先删除该标签下的所有文件。',
@@ -463,7 +491,7 @@ const handleEditTag = () => {
isEdit.value = true
}
const tabRemove = async (val) => {
if(otherAttachmentList.value&&otherAttachmentList.value.length>0){
if(fileList.value&&fileList.value.length>0){
ElNotification({
title: '提示',
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 defaultArray=tagsOption.value.filter(item1=>item1.tagId==item.props.name)
if(defaultArray&&defaultArray.length>0){
@@ -527,20 +528,28 @@ const handleTabClick = (item) => {
isEdit.value = false
fileParam.value.tagName = ''
}
const fileArray=JSON.parse(localStorage.getItem('implementFile'))
if (item.props.name != 'plus') {
if (item.props.name == 'all') {
changeFileList('all')
fileList.value=fileArray
getOldFileList('all')
} 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')){
fileList.value=JSON.parse(localStorage.getItem('implementFile'))
allFileList.value=JSON.parse(localStorage.getItem('implementFile'))
}
const changeImplementFile=()=>{
localStorage.setItem('implementFile', JSON.stringify(fileList.value))
localStorage.setItem('implementFile', JSON.stringify(allFileList.value))
}
const clickToPreview=(row)=>{
@@ -638,6 +647,8 @@ const getTagsOption = () => {
getTagList(route.query.projectId).then(res => {
if (res.code === 1000) {
tagsOption.value = res.data.rows
console.log("🚀 ~ file: res.data.rows ", res.data.rows)
tagsOption.value?.forEach((tag, index) => {
tagsOption.value[index].isClose =1
})
@@ -692,7 +703,7 @@ const compositeParam = (item) => {
fileType: item.fileType,
url: item.url,
newFile: true,
tag: fileParam.value.tagName,
tag: getTagName(activeName.value) || '项目实施',
}
}
const getFile = (val) => {
@@ -700,24 +711,17 @@ const getFile = (val) => {
showTable.value = false
let fileObj = compositeParam(val)
fileList.value.push(fileObj)
allFileList.value.push(fileObj)
nextTick(() => {
showTable.value = true
})
changeImplementFile()
}
const handleSubmit = async (instance) => {
if (!instance) return
instance.validate(async (valid) => {
if (!valid) {
ElNotification({
title: '提示',
message: '请完善数据,再提交!',
type: 'error'
})
return;
}
const files=JSON.parse(localStorage.getItem('implementFile'))
let params = {
fileList: fileList.value,
fileList: files,
projectId: route.query.projectId,
targetState: "30"
}
@@ -761,9 +765,9 @@ const handleSubmit = async (instance) => {
}
localStorage.removeItem('implementFile')
}
})
}
getTagsOption()
getOldFileList('all')
</script>
<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>