fix : 修复项目归档中附件上传问题

This commit is contained in:
2024-06-05 11:40:31 +08:00
parent d676868cf7
commit ca64562059
4 changed files with 93 additions and 117 deletions

View File

@@ -1,4 +1,5 @@
<template> <template>
<div v-loading="_value">
<el-form :model="attachment" inline> <el-form :model="attachment" inline>
<el-form-item label="名称" prop="fileName"> <el-form-item label="名称" prop="fileName">
<el-input v-model="attachment.fileName" placeholder="请输入附件名称查询" clearable filterable style="width: 300px"/> <el-input v-model="attachment.fileName" placeholder="请输入附件名称查询" clearable filterable style="width: 300px"/>
@@ -15,6 +16,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 @click="handleReset">重置</el-button>
<el-button v-if="uploadState" 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>
@@ -26,17 +28,19 @@
</template> </template>
</fvTable> </fvTable>
</el-card> </el-card>
</div>
</template> </template>
<script setup lang="jsx"> <script setup lang="jsx">
import {downloadFile} from "@/api/project-demand"; import {downloadFile} from "@/api/project-demand";
import {ElNotification} from "element-plus"; import {ElNotification} from "element-plus";
import {getTags} from "@/api/project-manage"; import {getTags} from "@/api/project-manage";
import {computed} from "vue";
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const attachment = reactive({}) const attachment = reactive({})
const emit = defineEmits(['search']) const emit = defineEmits(['search','update:modelValue'])
const props = defineProps({ const props = defineProps({
fileList: { fileList: {
type: Array, type: Array,
@@ -49,6 +53,10 @@ const props = defineProps({
uploadState: { uploadState: {
type: Boolean, type: Boolean,
default: true default: true
},
loading: {
type: Boolean,
default: true
} }
}) })
const tagsOption = ref([]) const tagsOption = ref([])
@@ -91,6 +99,14 @@ const tableConfig = reactive({
] ]
}) })
const showTable = ref(true) const showTable = ref(true)
const _value = computed({
get() {
return props.loading || ""
},
set(value) {
emit('update:modelValue', value)
}
})
const getTagsOption = () => { const getTagsOption = () => {
if (!route.query.id) return if (!route.query.id) return
getTags(route.query.id).then(res => { getTags(route.query.id).then(res => {
@@ -108,6 +124,11 @@ const getTagsOption = () => {
const handleSearch = () => { const handleSearch = () => {
emit('search', attachment) emit('search', attachment)
} }
const handleReset=()=>{
attachment.fileName=''
attachment.tag=''
emit('search', {})
}
const handleUpload = () => { const handleUpload = () => {
emit('upload') emit('upload')
} }

View File

@@ -1,24 +1,8 @@
<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="00"> <el-tab-pane v-for="item in paneList" :label="item.label" :name="item.name">
<search-files-by-tag @search="searchRequirement" @upload="upload" <search-files-by-tag @search="search" @upload="upload" :type="item.name==='40'?'40':''"
:otherFileList="otherFileList" :uploadState="uploadState"/> :fileList="fileList" :uploadState="uploadState" v-model:loading="loading"/>
</el-tab-pane>
<el-tab-pane label="需求上报" name="10">
<search-files-by-tag @search="searchReport" @upload="upload"
:otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane>
<el-tab-pane label="项目立项" name="20">
<search-files-by-tag @search="searchInitiation" @upload="upload"
:otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane>
<el-tab-pane label="项目实施" name="40">
<search-files-by-tag type="40" @search="searchImplementation" @upload="upload" ref="implementation"
:otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane>
<el-tab-pane label="项目归档" name="50">
<search-files-by-tag @search="searchFiling" @upload="upload"
:otherFileList="otherFileList" :uploadState="uploadState"/>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</template> </template>
@@ -31,78 +15,52 @@ const route = useRoute()
const router = useRouter() const router = useRouter()
const activeName = ref('50') const activeName = ref('50')
const attachment = ref({}) const attachment = ref({})
const implementation = ref() const loading = ref(false)
const uploadState = ref(true) const uploadState = ref(true)
const otherFileList = ref([]) const fileList = ref([])
const projectId = ref(route.query.id) const projectId = ref(route.query.id)
const requirementId = ref(route.query.requirementId) const requirementId = ref(route.query.requirementId)
const paneList=ref([
{
label:'需求征集',
name:'00'
},
{
label:'需求上报',
name:'10'
},
{
label:'项目立项',
name:'20'
},
{
label:'项目实施',
name:'40'
},
{
label:'项目归档',
name:'50'
}
])
const handleClick = (tab) => { const handleClick = (tab) => {
switchSearch(tab.props.name) activeName.value=tab.props.name
loading.value=true
search({})
} }
const switchSearch = (index) => { const search = async (param) => {
switch (index) { param.targetState = activeName.value
case '00':
searchRequirement({})
break
case '10':
searchReport({})
break
case '20':
searchInitiation({})
break
case '40':
searchImplementation({})
break
case '50':
searchFiling({})
break
}
}
const searchRequirement = async (param) => {
param.targetState = '00'
param.targetId = projectId.value param.targetId = projectId.value
searchFileList(param).then(res => { searchFileList(param).then(res => {
loading.value=false
changeFileList(res) changeFileList(res)
}) })
} }
const searchReport = async (param) => {
param.targetState = '10'
param.targetId = projectId.value
searchFileList(param).then(res => {
changeFileList(res)
})
}
const searchInitiation = async (param) => {
param.targetState = '20'
param.targetId = projectId.value
searchFileList(param).then(res => {
changeFileList(res)
})
}
const searchImplementation = async (param) => {
param.targetState = '40'
param.targetId = projectId.value
console.log('param',param)
searchFileList(param).then(res => {
changeFileList(res)
})
}
const searchFiling = async (param) => {
param.targetState = '50'
param.targetId = projectId.value
searchFileList(param).then(res => {
changeFileList(res)
})
}
const changeFileList = (res) => { const changeFileList = (res) => {
if (res.code === 1000) { if (res.code === 1000) {
otherFileList.value = res.data.fileList fileList.value = res.data.fileList
uploadState.value = res.data.upload uploadState.value = res.data.upload
} else { } else {
ElNotification({ ElNotification({
@@ -113,14 +71,6 @@ const changeFileList = (res) => {
} }
} }
onMounted(() => {
if (activeName.value === '50') {
searchFiling({})
}
})
const upload = () => { const upload = () => {
if (activeName.value === '40') { if (activeName.value === '40') {
router.push({ router.push({
@@ -140,6 +90,12 @@ const upload = () => {
}) })
} }
} }
onMounted(() => {
if (activeName.value === '50') {
search({})
}
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -97,7 +97,7 @@ const getTagsOption = () => {
const handleSearch = () => { const handleSearch = () => {
let params = { let params = {
targetId: route.query.id, targetId: route.query.id,
targetState: "30" targetState: "40"
} }
if (attachment.tag) { if (attachment.tag) {
tagsOption.value.forEach(item => { tagsOption.value.forEach(item => {

View File

@@ -139,8 +139,7 @@ const handleSubmit = async (instance) => {
let params = { let params = {
fileList: fileList.value, fileList: fileList.value,
projectId: route.query.id, projectId: route.query.id,
tag: formData.value.tagName, targetState: "40"
targetState: "30"
} }
let res = await uploadFileList(params) let res = await uploadFileList(params)
ElNotification({ ElNotification({