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,42 +1,46 @@
<template>
<el-form :model="attachment" inline>
<el-form-item label="名称" prop="fileName">
<el-input v-model="attachment.fileName" placeholder="请输入附件名称查询" clearable filterable style="width: 300px"/>
</el-form-item>
<el-form-item label="标签" prop="tag" v-if="type==='40'">
<el-select v-model="attachment.tag" placeholder="请选择标签" clearable filterable style="width: 300px">
<el-option
v-for="item in tagsOption"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleSearch" color="#DED0B2">搜索</el-button>
<el-button v-if="uploadState" color="#DED0B2" @click="handleUpload">上传附件</el-button>
</el-form-item>
</el-form>
<el-card style="width: 100%">
<fvTable style="width: 100%;max-height: 250px" v-if="showTable" :tableConfig="tableConfig"
:data="fileList" :isSettingCol="false" :pagination="false">
<template #empty>
<el-empty :image-size="90" description="暂无数据" style="padding: 0"/>
</template>
</fvTable>
</el-card>
<div v-loading="_value">
<el-form :model="attachment" inline>
<el-form-item label="名称" prop="fileName">
<el-input v-model="attachment.fileName" placeholder="请输入附件名称查询" clearable filterable style="width: 300px"/>
</el-form-item>
<el-form-item label="标签" prop="tag" v-if="type==='40'">
<el-select v-model="attachment.tag" placeholder="请选择标签" clearable filterable style="width: 300px">
<el-option
v-for="item in tagsOption"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<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-form-item>
</el-form>
<el-card style="width: 100%">
<fvTable style="width: 100%;max-height: 250px" v-if="showTable" :tableConfig="tableConfig"
:data="fileList" :isSettingCol="false" :pagination="false">
<template #empty>
<el-empty :image-size="90" description="暂无数据" style="padding: 0"/>
</template>
</fvTable>
</el-card>
</div>
</template>
<script setup lang="jsx">
import {downloadFile} from "@/api/project-demand";
import {ElNotification} from "element-plus";
import {getTags} from "@/api/project-manage";
import {computed} from "vue";
const route = useRoute()
const router = useRouter()
const attachment = reactive({})
const emit = defineEmits(['search'])
const emit = defineEmits(['search','update:modelValue'])
const props = defineProps({
fileList: {
type: Array,
@@ -46,7 +50,11 @@ const props = defineProps({
type: String,
default: '00'
},
uploadState:{
uploadState: {
type: Boolean,
default: true
},
loading: {
type: Boolean,
default: true
}
@@ -91,6 +99,14 @@ const tableConfig = reactive({
]
})
const showTable = ref(true)
const _value = computed({
get() {
return props.loading || ""
},
set(value) {
emit('update:modelValue', value)
}
})
const getTagsOption = () => {
if (!route.query.id) return
getTags(route.query.id).then(res => {
@@ -108,6 +124,11 @@ const getTagsOption = () => {
const handleSearch = () => {
emit('search', attachment)
}
const handleReset=()=>{
attachment.fileName=''
attachment.tag=''
emit('search', {})
}
const handleUpload = () => {
emit('upload')
}

View File

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

View File

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

View File

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