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> <template>
<el-form :model="attachment" inline> <div v-loading="_value">
<el-form-item label="名称" prop="fileName"> <el-form :model="attachment" inline>
<el-input v-model="attachment.fileName" placeholder="请输入附件名称查询" clearable filterable style="width: 300px"/> <el-form-item label="名称" prop="fileName">
</el-form-item> <el-input v-model="attachment.fileName" placeholder="请输入附件名称查询" clearable filterable style="width: 300px"/>
<el-form-item label="标签" prop="tag" v-if="type==='40'"> </el-form-item>
<el-select v-model="attachment.tag" placeholder="请选择标签" clearable filterable style="width: 300px"> <el-form-item label="标签" prop="tag" v-if="type==='40'">
<el-option <el-select v-model="attachment.tag" placeholder="请选择标签" clearable filterable style="width: 300px">
v-for="item in tagsOption" <el-option
:key="item.value" v-for="item in tagsOption"
:label="item.label" :key="item.value"
:value="item.value" :label="item.label"
/> :value="item.value"
</el-select> />
</el-form-item> </el-select>
<el-form-item> </el-form-item>
<el-button @click="handleSearch" color="#DED0B2">搜索</el-button> <el-form-item>
<el-button v-if="uploadState" color="#DED0B2" @click="handleUpload">上传附件</el-button> <el-button @click="handleSearch" color="#DED0B2">搜索</el-button>
</el-form-item> <el-button @click="handleReset">重置</el-button>
</el-form> <el-button v-if="uploadState" color="#DED0B2" @click="handleUpload">上传附件</el-button>
<el-card style="width: 100%"> </el-form-item>
<fvTable style="width: 100%;max-height: 250px" v-if="showTable" :tableConfig="tableConfig" </el-form>
:data="fileList" :isSettingCol="false" :pagination="false"> <el-card style="width: 100%">
<template #empty> <fvTable style="width: 100%;max-height: 250px" v-if="showTable" :tableConfig="tableConfig"
<el-empty :image-size="90" description="暂无数据" style="padding: 0"/> :data="fileList" :isSettingCol="false" :pagination="false">
</template> <template #empty>
</fvTable> <el-empty :image-size="90" description="暂无数据" style="padding: 0"/>
</el-card> </template>
</fvTable>
</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,
@@ -46,7 +50,11 @@ const props = defineProps({
type: String, type: String,
default: '00' default: '00'
}, },
uploadState:{ uploadState: {
type: Boolean,
default: true
},
loading: {
type: Boolean, type: Boolean,
default: true default: true
} }
@@ -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 handleClick = (tab) => { const paneList=ref([
switchSearch(tab.props.name) {
} label:'需求征集',
name:'00'
const switchSearch = (index) => { },
switch (index) { {
case '00': label:'需求上报',
searchRequirement({}) name:'10'
break },
case '10': {
searchReport({}) label:'项目立项',
break name:'20'
case '20': },
searchInitiation({}) {
break label:'项目实施',
case '40': name:'40'
searchImplementation({}) },
break {
case '50': label:'项目归档',
searchFiling({}) name:'50'
break
} }
])
const handleClick = (tab) => {
activeName.value=tab.props.name
loading.value=true
search({})
} }
const searchRequirement = async (param) => { const search = async (param) => {
param.targetState = '00' param.targetState = activeName.value
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({