<template>
|
<div class="app-container">
|
<div style="margin-bottom: 10px">
|
<el-button
|
type="primary"
|
plain
|
icon="Plus"
|
@click="openDialog('add',{})"
|
>新增</el-button>
|
<span style="font-size: 15px;color: #ed5565;margin-left: 15px">补录今年1-6月的历史项目</span>
|
</div>
|
|
<!-- 表格数据 -->
|
<el-table v-loading="loading" :data="dataList" :border="true">
|
<el-table-column label="项目名称" prop="name" align="center" width="180" />
|
<el-table-column label="项目时间" prop="filingDate" align="center" :show-overflow-tooltip="true" />
|
<el-table-column label="报告撰写人" prop="writer" align="center" :show-overflow-tooltip="true" />
|
<el-table-column label="报告审批人" prop="reviewer" align="center" width="200" />
|
<el-table-column label="报告扫描件" align="center" >
|
<template #default="scope">
|
<div v-for="(item,index) in scope.row.files" :key="index">
|
<span style="color: #1890ff;cursor: pointer" @click="showFile(item)">{{item.originName}}</span>
|
</div>
|
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
|
<template #default="scope">
|
<el-button link type="primary" @click="openDialog('review',scope.row)" >查看</el-button>
|
<el-button link type="primary" @click="openDialog('edit',scope.row)" >编辑</el-button>
|
<el-button link type="danger" @click="handleDelete(scope.row)" >删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<div class="pag-container">
|
<el-pagination
|
v-model:current-page="data.queryParams.pageNum"
|
v-model:page-size="data.queryParams.pageSize"
|
:page-sizes="[10,15,20,25]"
|
layout="total, sizes, prev, pager, next, jumper"
|
:total="total"
|
@size-change="handleSizeChange"
|
@current-change="handleCurrentChange"
|
/>
|
</div>
|
<suppleDialog ref="dRef" @getList="getList"></suppleDialog>
|
</div>
|
</template>
|
|
<script setup>
|
import {getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue";
|
import suppleDialog from './components/supplemenrtDialog.vue'
|
import {ElMessage, ElMessageBox} from "element-plus";
|
import {delSupplement, getSupplementList} from "@/api/backManage/supplement";
|
import axios from "axios";
|
import {getToken} from "@/utils/auth";
|
const { proxy } = getCurrentInstance();
|
const loading = ref(false);
|
const dRef = ref();
|
const data = reactive({
|
queryParams: {
|
pageNum: 1,
|
pageSize: 10,
|
},
|
total: 0,
|
dataList: []
|
});
|
|
const { queryParams, total, dataList } = toRefs(data);
|
|
onMounted(() => {
|
getList();
|
});
|
const getList = async () => {
|
loading.value = true;
|
const res = await getSupplementList(data.queryParams);
|
if(res.code === 200){
|
dataList.value = res.data.list.map(item => {
|
return {
|
...item,
|
filingDate: item.filingDate.substring(0,10),
|
files: item.files.map(f => {
|
return {
|
...f,
|
type:f.originName.substring(f.originName.lastIndexOf(".") + 1)
|
}
|
})
|
}
|
})
|
console.log("dataList.value",dataList.value)
|
total.value = res.data.total
|
}else{
|
ElMessage.warning(res.message)
|
}
|
loading.value = false;
|
}
|
const handleSizeChange = (val) => {
|
data.queryParams.pageNum = 1
|
data.queryParams.pageSize = val
|
getList()
|
}
|
const handleCurrentChange = (val) => {
|
data.queryParams.pageNum = val
|
getList()
|
}
|
|
const openDialog = (type, value) => {
|
dRef.value.openDialog(type, value);
|
}
|
|
const handleDelete = (val) => {
|
ElMessageBox.confirm(
|
'确定删除此条数据?',
|
'提示',
|
{
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning',
|
})
|
.then( async() => {
|
const res = await delSupplement(val);
|
if(res.code === 200){
|
ElMessage({
|
type: 'success',
|
message: '删除成功'
|
});
|
await getList();
|
}else{
|
ElMessage.warning(res.message)
|
}
|
})
|
}
|
const showFile = (file) => {
|
let path = "";
|
if(file.path){
|
path = file.path
|
}else {
|
path = file.response.data.path
|
|
}
|
const url = import.meta.env.VITE_APP_BASE_API + '/' + path
|
axios.get( url,{
|
headers:
|
{
|
'Content-Type': 'application/json',
|
'Authorization':getToken(),
|
},
|
responseType: 'blob'
|
}
|
).then(res=>{
|
if (res) {
|
const link = document.createElement('a')
|
let blob = new Blob([res.data],{type: res.data.type})
|
link.style.display = "none";
|
link.href = URL.createObjectURL(blob); // 创建URL
|
link.setAttribute("download", file.originName);
|
document.body.appendChild(link);
|
link.click();
|
document.body.removeChild(link);
|
} else {
|
this.$message.error('获取文件失败')
|
}
|
})
|
}
|
|
</script>
|
<style lang="scss">
|
.pag-container{
|
float: right;
|
margin-top: 10px;
|
}
|
</style>
|