feat : 附件处理

This commit is contained in:
clay
2024-06-02 22:36:02 +08:00
parent fb64361c64
commit f6ada88026
5 changed files with 406 additions and 110 deletions

View File

@@ -0,0 +1,10 @@
import request from '@/utils/request.js'
export const searchFileList = (params) => {
return request({
url: `/workflow/mosr/attachment/list`,
method: "get",
params: params
});
};

View File

@@ -3,7 +3,7 @@
<el-form-item label="关键词" prop="name"> <el-form-item label="关键词" prop="name">
<el-input v-model="attachment.name" placeholder="请输入" clearable filterable style="width: 300px"/> <el-input v-model="attachment.name" placeholder="请输入" clearable filterable style="width: 300px"/>
</el-form-item> </el-form-item>
<el-form-item label="标签" prop="tag" v-if="type==='3'"> <el-form-item label="标签" prop="tag" v-if="type==='3'">
<el-select v-model="attachment.tag" placeholder="请选择标签" clearable filterable style="width: 300px"> <el-select v-model="attachment.tag" placeholder="请选择标签" clearable filterable style="width: 300px">
<el-option <el-option
v-for="item in tagsOption" v-for="item in tagsOption"
@@ -15,7 +15,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleSearch" color="#DED0B2">搜索</el-button> <el-button @click="handleSearch" color="#DED0B2">搜索</el-button>
<el-button color="#DED0B2" @click="handleUpload">上传附件</el-button> <el-button v-if="uploadState" color="#DED0B2" @click="handleUpload">上传附件</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-card style="width: 100%"> <el-card style="width: 100%">
@@ -44,9 +44,14 @@ const props = defineProps({
otherFileList: { otherFileList: {
type: Array, type: Array,
default: [] default: []
}, type: { },
type: {
type: String, type: String,
default: '0' default: '0'
},
uploadState:{
type: Boolean,
default: true
} }
}) })
const tagsOption = ref([]) const tagsOption = ref([])
@@ -122,7 +127,7 @@ const handleDownload = (row) => {
}) })
} }
watch(() => props.type, (val) => { watch(() => props.type, (val) => {
console.log('va四川省l',val) console.log('va四川省l', val)
props.type = val props.type = val
if (val === '3') { if (val === '3') {
getTagsOption() getTagsOption()

View File

@@ -1,34 +1,31 @@
<template> <template>
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"> <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
<el-tab-pane label="需求征集" name="0"> <el-tab-pane label="需求征集" name="00">
<search-files-by-tag @search="searchRequirement" @upload="upload" <search-files-by-tag v-if="showTable" @search="searchRequirement" @upload="upload"
:otherFileList="otherFileList"/> :otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="需求上报" name="1"> <el-tab-pane label="需求上报" name="10">
<search-files-by-tag @search="searchReport" @upload="upload" <search-files-by-tag v-if="showTable" @search="searchReport" @upload="upload"
:otherFileList="otherFileList"/> :otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="项目立项" name="2"> <el-tab-pane label="项目立项" name="20">
<search-files-by-tag @search="searchInitiation" @upload="upload" <search-files-by-tag @search="searchInitiation" @upload="upload"
:otherFileList="otherFileList"/> :otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="项目实施" name="3"> <el-tab-pane label="项目实施" name="40">
<search-files-by-tag type="3" @search="searchImplementation" @upload="upload" ref="implementation" <search-files-by-tag type="3" @search="searchImplementation" @upload="upload" ref="implementation"
:otherFileList="otherFileList"/> :otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="项目归档" name="4"> <el-tab-pane label="项目归档" name="50">
<search-files-by-tag @search="searchFiling" @upload="upload" <search-files-by-tag @search="searchFiling" @upload="upload"
:otherFileList="otherFileList"/> :otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</template> </template>
<script setup lang="jsx"> <script setup lang="jsx">
import {searchFileList} from "@/api/project-manage/attachment.js";
import {ElNotification} from "element-plus"; import {ElNotification} from "element-plus";
import {getImplementationAttachment} from "@/api/project-manage";
import {getRequirementAttachment} from "@/api/project-demand";
import {getCollectAttachment} from "@/views/project-demand/summary/api";
import {getFilingAttachment, getInitiationAttachment} from "@/api/project-manage";
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
@@ -36,85 +33,79 @@ const activeName = ref('4')
const attachment = ref({}) const attachment = ref({})
const showTable = ref(true) const showTable = ref(true)
const implementation = ref() const implementation = ref()
const uploadState = ref(true)
const otherFileList = ref([]) const otherFileList = ref([])
const projectId = ref(route.query.id)
const requirementId = ref(route.query.requirementId)
const handleClick = (tab) => { const handleClick = (tab) => {
let name = {} let name = {}
switchSearch(name, tab.index) switchSearch(name, tab.props.name)
} }
const getParams = (param, type) => {
let targetId const switchSearch = (name, index) => {
let params switch (index) {
if (type === 1) { case '00':
targetId = route.query.requirementId searchRequirement({})
params = { break
targetId: targetId, case '10':
...param searchReport({})
} break
} else if (type === 2){ case '20':
targetId = route.query.id searchInitiation({})
if(JSON.stringify(param) !== '{}'){ break
if (param.tag &&!param.name) { case '40':
implementation.value.tagsOption?.forEach(item => { searchImplementation({})
if (item.value === param.tag) { break
param.tag = item.label case '50':
} searchFiling({})
}) break
params = {
targetId: targetId,
tag:param.tag
}
}else if(!param.tag &&param.name){
params = {
targetId: targetId,
...param
}
} else if (!param.tag &&!param.name) {
params = {
targetId: targetId,
}
}
}else {
params = {
targetId: targetId
}
}
}else {
targetId = route.query.id
params = {
targetId: targetId,
...param
}
} }
return params;
} }
const searchRequirement = async (param) => { const searchRequirement = async (param) => {
await search(param) param.targetState = '00'
} param.targetId = projectId.value
const search = async (param, type) => { searchFileList(param).then(res => {
const res = await getRequirementAttachment(getParams(param, type)) changeFileList(res)
changeFileList(res) })
} }
const searchReport = async (param) => { const searchReport = async (param) => {
const res = await getCollectAttachment(getParams(param)) param.targetState = '10'
changeFileList(res) param.targetId = projectId.value
searchFileList(param).then(res => {
changeFileList(res)
})
} }
const searchInitiation = async (param) => { const searchInitiation = async (param) => {
const res = await getInitiationAttachment(getParams(param)) param.targetState = '20'
changeFileList(res) param.targetId = projectId.value
searchFileList(param).then(res => {
changeFileList(res)
})
} }
const searchImplementation = async (param) => { const searchImplementation = async (param) => {
const res = await getImplementationAttachment(getParams(param,2)) param.targetState = '40'
changeFileList(res) param.targetId = projectId.value
searchFileList(param).then(res => {
changeFileList(res)
})
} }
const searchFiling = async (param) => { const searchFiling = async (param) => {
const res = await getFilingAttachment(getParams(param)) param.targetState = '50'
changeFileList(res) param.targetId = projectId.value
searchFileList(param).then(res => {
changeFileList(res)
})
} }
const changeFileList = (res) => { const changeFileList = (res) => {
showTable.value = false showTable.value = false
if (res.code === 1000) { if (res.code === 1000) {
otherFileList.value = res.data otherFileList.value = res.data.fileList
uploadState.value = res.data.upload
nextTick(() => { nextTick(() => {
showTable.value = true showTable.value = true
}) })
@@ -126,16 +117,25 @@ const changeFileList = (res) => {
}) })
} }
} }
onMounted(() => {
if (activeName.value === '4') {
searchFiling({})
}
})
const upload = () => { const upload = () => {
if(activeName.value==='3'){ if (activeName.value === '3') {
router.push({ router.push({
name: 'Implementation/upload', name: 'Implementation/upload',
query: { query: {
id: route.query.id, id: route.query.id,
type:'3' type: '3'
} }
}) })
}else { } else {
router.push({ router.push({
name: switchUpload(activeName.value), name: switchUpload(activeName.value),
query: { query: {
@@ -144,7 +144,7 @@ const upload = () => {
}) })
} }
} }
const switchUpload=(index)=>{ const switchUpload = (index) => {
switch (index) { switch (index) {
case '0': case '0':
return 'Requirement/upload'; return 'Requirement/upload';
@@ -158,33 +158,6 @@ const switchUpload=(index)=>{
return 'Filing/upload'; return 'Filing/upload';
} }
} }
const switchSearch = (name, index) => {
switch (index) {
case '0':
search(name, 1)
break
case '1':
searchReport(name)
break
case '2':
searchInitiation(name)
break
case '3':
searchImplementation(name)
break
case '4':
searchFiling(name)
break
}
}
onMounted(() => {
if (activeName.value === '4') {
let name = {
name: ''
}
searchFiling(name)
}
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -0,0 +1,214 @@
<template>
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
<el-tab-pane label="需求征集" name="0">
<search-files-by-tag @search="searchRequirement" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="需求上报" name="1">
<search-files-by-tag @search="searchReport" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="项目立项" name="2">
<search-files-by-tag @search="searchInitiation" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="项目实施" name="3">
<search-files-by-tag type="3" @search="searchImplementation" @upload="upload" ref="implementation"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="项目归档" name="4">
<search-files-by-tag @search="searchFiling" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
</el-tabs>
</template>
<script setup lang="jsx">
import {ElNotification} from "element-plus";
import {getImplementationAttachment} from "@/api/project-manage";
import {getRequirementAttachment} from "@/api/project-demand";
import {getCollectAttachment} from "@/views/project-demand/summary/api";
import {getFilingAttachment, getInitiationAttachment} from "@/api/project-manage";
const route = useRoute()
const router = useRouter()
const activeName = ref('4')
const attachment = ref({})
const showTable = ref(true)
const implementation = ref()
const otherFileList = ref([])
const handleClick = (tab) => {
let name = {}
switchSearch(name, tab.index)
}
const getParams = (param, type) => {
let targetId
let params
if (type === 1) {
targetId = route.query.requirementId
params = {
targetId: targetId,
...param
}
} else if (type === 2){
targetId = route.query.id
if(JSON.stringify(param) !== '{}'){
if (param.tag &&!param.name) {
implementation.value.tagsOption?.forEach(item => {
if (item.value === param.tag) {
param.tag = item.label
}
})
params = {
targetId: targetId,
tag:param.tag
}
}else if(!param.tag &&param.name){
params = {
targetId: targetId,
...param
}
} else if (!param.tag &&!param.name) {
params = {
targetId: targetId,
}
}
}else {
params = {
targetId: targetId
}
}
}else {
targetId = route.query.id
params = {
targetId: targetId,
...param
}
}
return params;
}
const searchRequirement = async (param) => {
await search(param)
}
const search = async (param, type) => {
const res = await getRequirementAttachment(getParams(param, type))
changeFileList(res)
}
const searchReport = async (param) => {
const res = await getCollectAttachment(getParams(param))
changeFileList(res)
}
const searchInitiation = async (param) => {
const res = await getInitiationAttachment(getParams(param))
changeFileList(res)
}
const searchImplementation = async (param) => {
const res = await getImplementationAttachment(getParams(param,2))
changeFileList(res)
}
const searchFiling = async (param) => {
const res = await getFilingAttachment(getParams(param))
changeFileList(res)
}
const changeFileList = (res) => {
showTable.value = false
if (res.code === 1000) {
otherFileList.value = res.data
nextTick(() => {
showTable.value = true
})
} else {
ElNotification({
title: '提示',
message: res.msg,
type: 'error'
})
}
}
const upload = () => {
if(activeName.value==='3'){
router.push({
name: 'Implementation/upload',
query: {
id: route.query.id,
type:'3'
}
})
}else {
router.push({
name: switchUpload(activeName.value),
query: {
id: route.query.id
}
})
}
}
const switchUpload=(index)=>{
switch (index) {
case '0':
return 'Requirement/upload';
case '1':
return 'Summary/upload';
case '2':
return 'Initiation/upload';
case '3':
return 'Implementation/upload';
case '4':
return 'Filing/upload';
}
}
const switchSearch = (name, index) => {
switch (index) {
case '0':
search(name, 1)
break
case '1':
searchReport(name)
break
case '2':
searchInitiation(name)
break
case '3':
searchImplementation(name)
break
case '4':
searchFiling(name)
break
}
}
onMounted(() => {
if (activeName.value === '4') {
let name = {
name: ''
}
searchFiling(name)
}
})
</script>
<style scoped lang="scss">
:deep(.el-tabs__header) {
margin: 15px 0 30px 0;
}
:deep(.el-tabs__nav-scroll) {
width: 100%;
display: flex;
.el-tabs__nav {
display: flex;
flex: 1;
.el-tabs__item {
flex: 1;
font-size: 16px;
}
.is-active {
color: black;
//background-color: #DED0B2;
}
}
}
</style>

View File

@@ -0,0 +1,94 @@
<template>
<el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
<el-tab-pane label="需求征集" name="00">
<search-files-by-tag @search="searchRequirement" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="需求上报" name="10">
<search-files-by-tag @search="searchReport" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="项目立项" name="20">
<search-files-by-tag @search="searchInitiation" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="项目实施" name="40">
<search-files-by-tag type="3" @search="searchImplementation" @upload="upload" ref="implementation"
:otherFileList="otherFileList"/>
</el-tab-pane>
<el-tab-pane label="项目归档" name="50">
<search-files-by-tag @search="searchFiling" @upload="upload"
:otherFileList="otherFileList"/>
</el-tab-pane>
</el-tabs>
</template>
<script setup lang="jsx">
import {searchFileList} from "@/api/project-manage/attachment.js";
const route = useRoute()
const router = useRouter()
const activeName = ref('4')
const attachment = ref({})
const showTable = ref(true)
const implementation = ref()
const otherFileList = ref([])
const handleClick = (tab) => {
let name = {}
switchSearch(name, tab.index)
}
const switchSearch = (name, index) => {
switch (index) {
case '0':
search(name, 1)
break
case '1':
searchReport(name)
break
case '2':
searchInitiation(name)
break
case '3':
searchImplementation(name)
break
case '4':
searchFiling(name)
break
}
}
onMounted(() => {
if (activeName.value === '4') {
let name = {
name: ''
}
searchFiling(name)
}
})
</script>
<style scoped lang="scss">
:deep(.el-tabs__header) {
margin: 15px 0 30px 0;
}
:deep(.el-tabs__nav-scroll) {
width: 100%;
display: flex;
.el-tabs__nav {
display: flex;
flex: 1;
.el-tabs__item {
flex: 1;
font-size: 16px;
}
.is-active {
color: black;
//background-color: #DED0B2;
}
}
}
</style>