fix : 修复项目实施附件接口

This commit is contained in:
2024-05-28 18:00:42 +08:00
parent dd406e4ba6
commit be367ead6e
3 changed files with 74 additions and 28 deletions

View File

@@ -100,3 +100,14 @@ export const getProjectConclusionProcess = () => {
});
};
//文件查询
export const searchFile = (targetId,tag) => {
return request({
url: '/workflow/process/file/query',
method: "get",
params:{
targetId:targetId,
tag:tag
}
});
};

View File

@@ -14,7 +14,7 @@
:before-remove="beforeRemove"
:on-remove="handleRemove"
>
<el-button color="#DED0B2" :loading="loading">上传文件</el-button>
<el-button color="#DED0B2" :loading="loading" :disabled="disabled">上传文件</el-button>
</el-upload>
</template>
@@ -26,7 +26,6 @@ const uploadFileUrl = ref(baseURL + "/workflow/process/file/upload")
const headers = reactive({
authorization: getToken()
})
const disabled = ref(false)
const loading = ref(false)
const showTable = ref(false)
const uploadParams = ref({})
@@ -44,6 +43,9 @@ const props = defineProps({
showFileList: {
type: Boolean,
default: false
},disabled: {
type: Boolean,
default: false
}
})

View File

@@ -1,19 +1,20 @@
<template>
<el-form :model="attachment" inline class="query-form" ref="queryForm">
<el-form :model="attachment" inline class="query-form" ref="queryForm" rules="rules">
<el-form-item label="标签" prop="tag">
<el-select v-model="attachment.tag" placeholder="请选择标签" clearable filterable style="width: 200px">
<el-option
v-for="item in tagsOption"
:key="item.value"
:label="item.label"
:value="item.value"
:key="item.label"
:label="item.value"
:value="item.label"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleSearch" color="#DED0B2" >搜索</el-button>
<el-button @click="handleUpload" color="#DED0B2" >上传附件</el-button>
<!-- <file-upload @getFile="getFile" :showFileList="true"/>-->
<el-button @click="handleSearch(queryForm)" color="#DED0B2">搜索</el-button>
<el-button color="#DED0B2" :disabled="!attachment.tag" style="padding: 0" title="请先选择标签再上传附件!">
<file-upload @getFile="getFile" :disabled="!attachment.tag"/>
</el-button>
</el-form-item>
</el-form>
<el-card style="width: 100%">
@@ -28,15 +29,18 @@
<script setup lang="jsx">
import {downloadFile} from "@/api/project-demand";
import {getImplementationAttachment} from "@/api/project-manage";
import {getImplementationAttachment,searchFile} from "@/api/project-manage";
import {ElNotification} from "element-plus";
const route = useRoute()
const router = useRouter()
const attachment=reactive({
tag:''
const attachment = reactive({
tag: ''
})
const rules = reactive({
tag: [{required: true, message: '请选择标签', trigger: 'blur'}]
})
const queryForm = ref()
const tagsOption = ref([])
const tableConfig = reactive({
columns: [
@@ -77,39 +81,68 @@ const tableConfig = reactive({
}
]
})
const showTable=ref(true)
const showTable = ref(true)
const otherFileList = ref([])
const getTagsOption = (id=route.query.id) => {
if(!route.query.id) return
const compositeParam = (item) => {
return {
fileId: item.id,
size: item.size,
originalFileName: item.originalFilename,
fileType: item.fileType,
url: item.url,
tag: attachment.tag,
}
}
const getFile = (val) => {
console.log('上传文件', val)
showTable.value = false
let fileObj = compositeParam(val)
otherFileList.value.push(fileObj)
nextTick(() => {
showTable.value = true
})
}
const getTagsOption = (id = route.query.id) => {
if (!route.query.id) return
getImplementationAttachment(id).then(res => {
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if(res.code === 1000) {
if (res.code === 1000) {
tagsOption.value = res.data
}
})
}
const handleSearch = () => {
console.log('attachment.tag',attachment.tag)
// getTagsOption()
}
const handleUpload=()=>{
router.push({
name: 'Implementation/upload',
query: {
id: route.query.id
}
const handleSearch = (instance) => {
if (!instance) return
instance.validate(async (valid) => {
if (!valid) return
let tagName = ''
tagsOption.value.forEach(item => {
if (item.label === attachment.tag) {
tagName = item.value
}
})
searchFile(route.query.id, tagName).then(res => {
showTable.value = false
if (res.code === 1000) {
otherFileList.value = res.data
nextTick(() => {
showTable.value = true
})
}
})
})
}
const handleDownload = (row) => {
downloadFile(row.fileId).then(res => {
const blob = new Blob([res])
let a = document.createElement('a')
a.href=URL.createObjectURL(blob)
a.href = URL.createObjectURL(blob)
a.download = row.originalFileName
a.click()
})