Merge pull request 'fix : 修复项目实施附件接口' (#240) from dj into master

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/240
This commit is contained in:
2024-05-28 10:00:57 +00:00
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" :before-remove="beforeRemove"
:on-remove="handleRemove" :on-remove="handleRemove"
> >
<el-button color="#DED0B2" :loading="loading">上传文件</el-button> <el-button color="#DED0B2" :loading="loading" :disabled="disabled">上传文件</el-button>
</el-upload> </el-upload>
</template> </template>
@@ -26,7 +26,6 @@ const uploadFileUrl = ref(baseURL + "/workflow/process/file/upload")
const headers = reactive({ const headers = reactive({
authorization: getToken() authorization: getToken()
}) })
const disabled = ref(false)
const loading = ref(false) const loading = ref(false)
const showTable = ref(false) const showTable = ref(false)
const uploadParams = ref({}) const uploadParams = ref({})
@@ -44,6 +43,9 @@ const props = defineProps({
showFileList: { showFileList: {
type: Boolean, type: Boolean,
default: false default: false
},disabled: {
type: Boolean,
default: false
} }
}) })

View File

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