Files
mosr-web/src/views/project-management/implementation/attachment.vue
2024-05-18 17:32:58 +08:00

90 lines
2.1 KiB
Vue

<template>
<fvSearchForm :searchConfig="searchConfig" @search="search"></fvSearchForm>
<el-card style="width: 100%">
<file-upload @getFile="getOtherFile" :showFileList="true"/>
<fvTable style="width: 100%;max-height: 250px" v-if="showTable" :tableConfig="tableConfig"
:data="otherFileList" :isSettingCol="false" :pagination="false">
<template #empty>
<el-empty :image-size="90" description="暂无数据" style="padding: 0"/>
</template>
</fvTable>
</el-card>
</template>
<script setup lang="jsx">
import fvSelect from '@/fvcomponents/fvSelect/index.vue'
import {shallowRef} from "vue";
import {downloadFile} from "@/api/project-demand";
const searchConfig = reactive([
{
label: '标签',
prop: 'collectType',
component: shallowRef(fvSelect),
props: {
placeholder: '请选择标签',
clearable: true,
filterable: true,
}
}
])
const tableConfig = reactive({
columns: [
{
prop: 'index',
type: 'index',
label: '序号',
align: 'center',
width: '80',
},
{
prop: 'originalFileName',
label: '文件名',
align: 'center',
},
{
prop: 'tag',
label: '标签',
align: 'center'
},
{
prop: 'size',
label: '文件大小',
align: 'center',
currentRender: ({row, index}) => (parseInt(row.size / 1024) + 'KB')
},
{
prop: 'oper',
label: '操作',
align: 'center',
currentRender: ({row, index}) => {
return (
<div>
<el-button type="primary" link onClick={() => handleDownload(row)}>下载</el-button>
<el-button type="primary" size="large" link onClick={() => beforeRemove(row)}>删除</el-button>
</div>
)
}
}
]
})
const showTable=ref(true)
const otherFileList = ref([])
const getOtherFile = () => {
}
const handleDownload = (row) => {
downloadFile(row.fileId).then(res => {
const blob = new Blob([res])
let a = document.createElement('a')
a.href=URL.createObjectURL(blob)
a.download = row.originalFileName
a.click()
})
}
</script>
<style scoped>
</style>