feat(project-manage): 新增项目附件标签功能
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
<!-- <el-button color="#DED0B2" @click="handleUpload">上传附件</el-button>-->
|
||||
<file-upload v-if="!isLineBtn&&uploadState" @getFile="getFile"/>
|
||||
|
||||
<el-button color="#DED0B2" @click="handleEditTag" v-if="activeName!='all'" style="margin-left: 10px;">编辑
|
||||
<el-button color="#DED0B2" @click="handleEditTag" v-if="activeName!='all'&&activeName!='plus'" style="margin-left: 10px;">编辑
|
||||
</el-button>
|
||||
</div>
|
||||
<fvTable style="width: 100%;min-height:311px;max-height: 311px" v-if="showAttachmentTable" height="311"
|
||||
@@ -127,9 +127,9 @@ const executeTableConfig = reactive({
|
||||
<div>
|
||||
<el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button>
|
||||
{
|
||||
row.newFile ?
|
||||
<popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'}
|
||||
onDelete={() => deleteSingleFile(row)}/> : ''
|
||||
uploadState.value ?
|
||||
<popover-delete name={row.originalFileName} type={'文件'} btnType={'danger'}
|
||||
onDelete={() => deleteSingleFile(row)}/>:''
|
||||
}
|
||||
</div>
|
||||
)
|
||||
@@ -137,6 +137,7 @@ const executeTableConfig = reactive({
|
||||
}
|
||||
]
|
||||
})
|
||||
// row.newFile ?: ''
|
||||
const otherAttachmentList = ref([])
|
||||
|
||||
const filePreviewParam = ref({
|
||||
@@ -159,6 +160,8 @@ const deleteSingleFile = (row) => {
|
||||
})
|
||||
if (res.code === 1000) {
|
||||
otherAttachmentList.value.splice(otherAttachmentList.value.findIndex((item) => item.fileId === row.fileId), 1);
|
||||
getAttachmentList()
|
||||
activeName.value = 'all'
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -176,6 +179,9 @@ const changeTag = async () => {
|
||||
projectId: route.query.projectId,
|
||||
fileTag: fileParam.value.tagName
|
||||
})
|
||||
getAttachmentList()
|
||||
fileParam.value.tagName = ''
|
||||
activeName.value = 'all'
|
||||
}
|
||||
ElNotification({
|
||||
title: '提示',
|
||||
@@ -188,11 +194,9 @@ const changeTag = async () => {
|
||||
// label: fileParam.value.tagName
|
||||
// })
|
||||
tagNameShow.value = false;
|
||||
fileParam.value.tagName = ''
|
||||
activeName.value = 'all'
|
||||
}
|
||||
const tabRemove = async (val) => {
|
||||
ElMessageBox.confirm(`确认删除名称为${getFileName(val)}的标签吗?`, '系统提示', {
|
||||
ElMessageBox.confirm(`确认删除名称为${getTagName(val)}的标签吗?`, '系统提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
@@ -205,15 +209,16 @@ const tabRemove = async (val) => {
|
||||
})
|
||||
if (res.code === 1000) {
|
||||
getTagsOption()
|
||||
otherAttachmentList.value = allFiles.value
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleEditTag = () => {
|
||||
tagNameShow.value = true
|
||||
fileParam.value.tagName = getFileName(activeName.value)
|
||||
fileParam.value.tagName = getTagName(activeName.value)
|
||||
isEdit.value = true
|
||||
}
|
||||
const getFileName = (name) => {
|
||||
const getTagName = (name) => {
|
||||
const tagArray = tagsOption.value.filter((item1) => item1.tagId == name)
|
||||
let tagName = ''
|
||||
if (tagArray && tagArray.length > 0) {
|
||||
@@ -227,16 +232,17 @@ const handleTabClick = (item) => {
|
||||
isEdit.value = false
|
||||
}
|
||||
if (item.props.name != 'plus') {
|
||||
if (item.props.name == 'all') {
|
||||
otherAttachmentList.value = allFiles.value
|
||||
} else {
|
||||
otherAttachmentList.value = allFiles.value.filter(item1 => item1.tag == getFileName(item.props.name))
|
||||
}
|
||||
changeFileList(getTagName(item.props.name))
|
||||
// if (item.props.name == 'all') {
|
||||
// otherAttachmentList.value = allFiles.value
|
||||
// } else {
|
||||
// otherAttachmentList.value = allFiles.value.filter(item1 => item1.tag == getTagName(item.props.name))
|
||||
// }
|
||||
}
|
||||
showAttachmentTable.value = false
|
||||
nextTick(() => {
|
||||
showAttachmentTable.value = true
|
||||
})
|
||||
// showAttachmentTable.value = false
|
||||
// nextTick(() => {
|
||||
// showAttachmentTable.value = true
|
||||
// })
|
||||
}
|
||||
const compositeParam = (item) => {
|
||||
return {
|
||||
@@ -246,7 +252,7 @@ const compositeParam = (item) => {
|
||||
fileType: item.fileType,
|
||||
url: item.url,
|
||||
newFile: true,
|
||||
tag: activeName.value,
|
||||
tag: getTagName(activeName.value),
|
||||
}
|
||||
}
|
||||
const getFile = (val) => {
|
||||
@@ -264,11 +270,14 @@ const handleSubmit = async (list) => {
|
||||
targetState: "30"
|
||||
}
|
||||
let res = await uploadFileList(params)
|
||||
// ElNotification({
|
||||
// title: '提示',
|
||||
// message: res.msg,
|
||||
// type: res.code === 1000 ? 'success' : 'error'
|
||||
// })
|
||||
if(res.code !== 1000){
|
||||
ElNotification({
|
||||
title: '提示',
|
||||
message: res.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
getTagsOption()
|
||||
}
|
||||
const clickToPreview = (row) => {
|
||||
filePreviewShow.value = false
|
||||
@@ -281,12 +290,29 @@ const clickToPreview = (row) => {
|
||||
filePreviewShow.value = true
|
||||
})
|
||||
}
|
||||
const handleSearch = () => {
|
||||
const changeFileList=(tag)=>{
|
||||
showAttachmentTable.value = false
|
||||
let params = {
|
||||
targetId: route.query.projectId,
|
||||
targetState: "30",
|
||||
tag:tag
|
||||
}
|
||||
searchImplementationFileList(params).then(res => {
|
||||
if (res.code === 1000) {
|
||||
otherAttachmentList.value = res.data.fileList
|
||||
nextTick(() => {
|
||||
showAttachmentTable.value = true
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
const getAttachmentList = () => {
|
||||
const loading = ElLoading.service({fullscreen: true})
|
||||
let params = {
|
||||
targetId: route.query.projectId,
|
||||
targetState: "30"
|
||||
}
|
||||
showAttachmentTable.value = false
|
||||
if (attachmentParam.tag) {
|
||||
tagsOption.value.forEach(item => {
|
||||
if (item.value === attachmentParam.tag) {
|
||||
@@ -296,7 +322,6 @@ const handleSearch = () => {
|
||||
params.tag = attachmentParam.tag
|
||||
}
|
||||
searchImplementationFileList(params).then(res => {
|
||||
showAttachmentTable.value = false
|
||||
if (res.code === 1000) {
|
||||
// otherAttachmentList.value = res.data.fileList
|
||||
otherAttachmentList.value = res.data.fileList
|
||||
@@ -322,19 +347,12 @@ const getTagsOption = () => {
|
||||
if (!route.query.projectId) return
|
||||
getTagList(route.query.projectId).then(res => {
|
||||
if (res.code === 1000) {
|
||||
res.data.rows[0].isClose = 1
|
||||
tagsOption.value = res.data.rows
|
||||
otherAttachmentList.value.forEach(item => {
|
||||
tagsOption.value.forEach(tag => {
|
||||
// console.log(tag.fileTag,item.tag)
|
||||
if (tag.fileTag == item.tag) {
|
||||
tag.isClose = 0
|
||||
} else {
|
||||
tag.isClose = 1
|
||||
}
|
||||
})
|
||||
tagsOption.value.forEach((tag, index) => {
|
||||
const filterArray = otherAttachmentList.value.filter(item => tag.fileTag == item.tag)
|
||||
tagsOption.value[index].isClose = filterArray.length > 0 ? 0 : 1
|
||||
})
|
||||
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
|
||||
} else {
|
||||
ElNotification({
|
||||
@@ -356,9 +374,9 @@ const handleUpload = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
handleSearch()
|
||||
getAttachmentList()
|
||||
onActivated(() => {
|
||||
handleSearch()
|
||||
getAttachmentList()
|
||||
})
|
||||
</script>
|
||||
<style lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user