2025-12-03 16:58:06 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
2026-01-23 15:43:22 +08:00
|
|
|
|
|
|
|
|
<!-- 搜索 -->
|
|
|
|
|
<div ref="searchBox" class="mt10">
|
|
|
|
|
<Search :searchArr="searchConfiger" @submit="onSearch" :key="pageData.keyCount" />
|
|
|
|
|
</div>
|
|
|
|
|
<PageTitle :malginLeft="10" :height="35" backgroundColor="#ffff" :marginBottom="5" :marginTop="5">
|
|
|
|
|
<template #left>
|
|
|
|
|
<el-button size="small" type="primary" @click="getDataById('add', '')">
|
2025-12-03 16:58:06 +08:00
|
|
|
<el-icon style="vertical-align: middle">
|
|
|
|
|
<CirclePlus />
|
|
|
|
|
</el-icon>
|
|
|
|
|
<span style="vertical-align: middle">新增</span>
|
|
|
|
|
</el-button>
|
2026-01-23 15:43:22 +08:00
|
|
|
</template>
|
|
|
|
|
</PageTitle>
|
2025-12-03 16:58:06 +08:00
|
|
|
<!-- 表格 -->
|
|
|
|
|
<div class="tabBox">
|
|
|
|
|
<MyTable :tableData="pageData.tableData" :tableColumn="pageData.tableColumn" :tableHeight="pageData.tableHeight"
|
|
|
|
|
:key="pageData.keyCount" :tableConfiger="pageData.tableConfiger" :controlsWidth="pageData.controlsWidth"
|
|
|
|
|
@chooseData="chooseData">
|
|
|
|
|
<template #wjdx="{ row }">
|
|
|
|
|
{{ row.wjdx }}MB
|
|
|
|
|
</template>
|
|
|
|
|
<template #wjlb="{ row }">
|
|
|
|
|
{{ row.wjlb == '01' ? '普通文件' : '定向文件' }}
|
|
|
|
|
</template>
|
|
|
|
|
<!-- 操作 -->
|
|
|
|
|
<template #controls="{ row }">
|
2026-01-23 15:43:22 +08:00
|
|
|
<el-link size="small" type="primary" @click="getDataById('edit', row)">修改</el-link>
|
|
|
|
|
<el-link size="small" type="primary" @click="getDataById('detail', row)">详情</el-link>
|
|
|
|
|
<el-link size="small" type="primary" @click="previewFile(row)"
|
|
|
|
|
v-if="row.wjlx == '.png' || row.wjlx == '.jpg' || row.wjlx == '.jpeg'">预览</el-link>
|
|
|
|
|
<el-link size="small" type="primary" @click="downloadFile(row)">下载</el-link>
|
|
|
|
|
<el-link size="small" type="danger" @click="deleteFile(row)">删除</el-link>
|
2025-12-03 16:58:06 +08:00
|
|
|
</template>
|
|
|
|
|
</MyTable>
|
|
|
|
|
<Pages @changeNo="changeNo" @changeSize="changeSize" :tableHeight="pageData.tableHeight" :pageConfiger="{
|
|
|
|
|
...pageData.pageConfiger,
|
|
|
|
|
total: pageData.total
|
|
|
|
|
}"></Pages>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-23 15:43:22 +08:00
|
|
|
<AddForm ref="addForm" @getList="getList" />
|
2025-12-03 16:58:06 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import PageTitle from "@/components/aboutTable/PageTitle.vue";
|
|
|
|
|
import MyTable from "@/components/aboutTable/MyTable.vue";
|
|
|
|
|
import Pages from "@/components/aboutTable/Pages.vue";
|
|
|
|
|
import Search from "@/components/aboutTable/Search.vue";
|
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
import { qbcjZxsSelectPage } from "@/api/qbcj.js";
|
|
|
|
|
import { reactive, ref, onMounted, getCurrentInstance, watch } from "vue";
|
|
|
|
|
import { getItem } from '@//utils/storage.js'
|
2026-01-23 15:43:22 +08:00
|
|
|
import { deleteWjZzzAddEntity, getWjZzzAddEntity } from '@//api/qbcj.js'
|
2025-12-03 16:58:06 +08:00
|
|
|
import AddForm from "./components/addForm.vue";
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
// const { D_BZ_CJLX, D_GS_XS_LX } = proxy.$dict("D_BZ_CJLX", "D_GS_XS_LX"); //获取字典数据
|
|
|
|
|
const detailDiloag = ref();
|
|
|
|
|
const searchBox = ref(); //搜索框
|
|
|
|
|
const ids = ref([])
|
|
|
|
|
const tableList = ref([]);
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
const { deptBizType, deptLevel } = getItem('deptId')[0]
|
|
|
|
|
const Jb = deptLevel[0] == '2' ? '01' : deptLevel[0] == '3' ? '02' : '03'
|
|
|
|
|
qxkz.deptBizType = deptBizType
|
|
|
|
|
qxkz.deptLevel = Jb
|
|
|
|
|
getRouter()
|
|
|
|
|
tabHeightFn()
|
|
|
|
|
if (route.query.id) {
|
|
|
|
|
detailDiloag.value.init('edit', {
|
|
|
|
|
id: route.query.id
|
|
|
|
|
});
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
getList()
|
|
|
|
|
});
|
|
|
|
|
const chooseData = (val) => {
|
|
|
|
|
ids.value = val.map(item => {
|
|
|
|
|
return item.id
|
|
|
|
|
})
|
|
|
|
|
tableList.value = val
|
|
|
|
|
}
|
|
|
|
|
const qxkz = reactive({
|
|
|
|
|
deptBizType: "",
|
|
|
|
|
deptLevel: ""
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const searchConfiger = ref([
|
2026-01-23 15:43:22 +08:00
|
|
|
{ label: "文件名称", prop: 'wjmc', placeholder: "请输入文件名称", showType: "input" },
|
2025-12-03 16:58:06 +08:00
|
|
|
// { label: "情报来源", prop: 'cjLx', placeholder: "请选择情报来源", showType: "select", options: D_BZ_CJLX },
|
|
|
|
|
// { label: "来源单位", prop: 'ssbmdm', placeholder: "请选择来源单位", showType: "department" }
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const pageData = reactive({
|
|
|
|
|
tableData: [],
|
|
|
|
|
keyCount: 0,
|
|
|
|
|
tableConfiger: {
|
|
|
|
|
rowHieght: 61,
|
|
|
|
|
showSelectType: "checkBox",
|
|
|
|
|
loading: false
|
|
|
|
|
},
|
|
|
|
|
total: 0,
|
|
|
|
|
pageConfiger: {
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
pageCurrent: 1
|
|
|
|
|
},
|
|
|
|
|
controlsWidth: 240,
|
|
|
|
|
tableColumn: [
|
|
|
|
|
{ label: "文件名称", prop: "wjmc" },
|
|
|
|
|
{ label: "文件大小", prop: "wjdx", showSolt: true },
|
|
|
|
|
{ label: "文件类别", prop: "wjlb", showSolt: true },
|
|
|
|
|
{ label: "所属部门", prop: "ssbm" },
|
|
|
|
|
{ label: "文件描述", prop: "qbnr" },
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
const queryFrom = ref({});
|
|
|
|
|
|
|
|
|
|
// 搜索
|
|
|
|
|
const onSearch = (val) => {
|
|
|
|
|
const { lrkssj, zxkssj } = val
|
|
|
|
|
const promes = {
|
|
|
|
|
...val,
|
|
|
|
|
...pageData.pageConfiger,
|
|
|
|
|
lrkssj: lrkssj ? lrkssj[0] : '',
|
|
|
|
|
lrjssj: lrkssj ? lrkssj[1] : '',
|
|
|
|
|
zxkssj: zxkssj ? zxkssj[0] : '',
|
|
|
|
|
zxjssj: zxkssj ? zxkssj[1] : '',
|
|
|
|
|
}
|
|
|
|
|
queryFrom.value = { ...promes }
|
|
|
|
|
pageData.pageConfiger.pageCurrent = 1;
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const changeNo = (val) => {
|
|
|
|
|
pageData.pageConfiger.pageCurrent = val;
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
const changeSize = (val) => {
|
|
|
|
|
pageData.pageConfiger.pageSize = val;
|
|
|
|
|
getList()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取列表
|
|
|
|
|
const getList = () => {
|
|
|
|
|
pageData.tableConfiger.loading = true;
|
2026-01-23 15:43:22 +08:00
|
|
|
let data = { ...pageData.pageConfiger, ...queryFrom.value, wjlb: '01' };
|
2025-12-03 16:58:06 +08:00
|
|
|
getWjZzzAddEntity(data).then(res => {
|
|
|
|
|
pageData.tableData = res.records || [];
|
|
|
|
|
pageData.total = res.total;
|
|
|
|
|
pageData.tableConfiger.loading = false;
|
|
|
|
|
}).catch(() => { pageData.tableConfiger.loading = false; })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 表格高度计算
|
|
|
|
|
const tabHeightFn = () => {
|
2026-01-23 15:43:22 +08:00
|
|
|
pageData.tableHeight = window.innerHeight - searchBox.value.offsetHeight - 270;
|
2025-12-03 16:58:06 +08:00
|
|
|
window.onresize = function () {
|
|
|
|
|
tabHeightFn();
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const routerMate = ref({})
|
|
|
|
|
const getRouter = () => {
|
|
|
|
|
routerMate.value = route.meta
|
|
|
|
|
}
|
|
|
|
|
const addForm = ref(null)
|
|
|
|
|
const getDataById = (type, row) => {
|
2026-01-23 15:43:22 +08:00
|
|
|
addForm.value.init(type, row, '01');
|
2025-12-03 16:58:06 +08:00
|
|
|
}
|
|
|
|
|
const previewFile = (item) => {
|
2026-01-23 15:43:22 +08:00
|
|
|
window.open(item.wjdz);
|
2025-12-03 16:58:06 +08:00
|
|
|
}
|
|
|
|
|
const downloadFile = async (item) => {
|
2026-01-23 15:43:22 +08:00
|
|
|
console.log(item);
|
2025-12-03 16:58:06 +08:00
|
|
|
try {
|
2026-01-23 15:43:22 +08:00
|
|
|
const dataList =JSON.parse(item.wjdz)
|
|
|
|
|
if (dataList.length === 0) {
|
|
|
|
|
proxy.$message.warning('没有文件可下载');
|
|
|
|
|
return;
|
2025-12-03 16:58:06 +08:00
|
|
|
}
|
2026-01-23 15:43:22 +08:00
|
|
|
console.log(dataList);
|
2025-12-03 16:58:06 +08:00
|
|
|
|
2026-01-23 15:43:22 +08:00
|
|
|
const downloadCount = dataList.length;
|
|
|
|
|
let successCount = 0;
|
|
|
|
|
let failCount = 0;
|
2025-12-03 16:58:06 +08:00
|
|
|
|
2026-01-23 15:43:22 +08:00
|
|
|
proxy.$message.info(`开始下载${downloadCount}个文件...`);
|
2025-12-03 16:58:06 +08:00
|
|
|
|
2026-01-23 15:43:22 +08:00
|
|
|
// 并行下载所有文件
|
|
|
|
|
const downloadPromises = dataList.map(async (fileData, index) => {
|
2025-12-03 16:58:06 +08:00
|
|
|
|
2026-01-23 15:43:22 +08:00
|
|
|
try {
|
|
|
|
|
// 使用fetch获取文件内容
|
|
|
|
|
const response = await fetch(fileData.url);
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
throw new Error('文件下载失败');
|
|
|
|
|
}
|
2025-12-03 16:58:06 +08:00
|
|
|
|
2026-01-23 15:43:22 +08:00
|
|
|
// 将响应转换为Blob对象
|
|
|
|
|
const blob = await response.blob();
|
2025-12-03 16:58:06 +08:00
|
|
|
|
2026-01-23 15:43:22 +08:00
|
|
|
// 创建下载链接
|
|
|
|
|
const downloadLink = document.createElement('a');
|
|
|
|
|
downloadLink.href = URL.createObjectURL(blob);
|
|
|
|
|
|
|
|
|
|
// 设置下载文件的名称,避免冲突
|
|
|
|
|
const fileName = dataList.length > 1
|
|
|
|
|
? `${item.wjmc}_${index + 1}`
|
|
|
|
|
: item.wjmc;
|
|
|
|
|
downloadLink.download = fileName;
|
|
|
|
|
|
|
|
|
|
// 触发下载
|
|
|
|
|
document.body.appendChild(downloadLink);
|
|
|
|
|
downloadLink.click();
|
|
|
|
|
|
|
|
|
|
// 清理
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
document.body.removeChild(downloadLink);
|
|
|
|
|
URL.revokeObjectURL(downloadLink.href);
|
|
|
|
|
}, 100);
|
|
|
|
|
|
|
|
|
|
successCount++;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(`文件${index + 1}下载失败:`, error);
|
|
|
|
|
failCount++;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 等待所有下载完成
|
|
|
|
|
await Promise.all(downloadPromises);
|
|
|
|
|
|
|
|
|
|
// 显示下载结果
|
|
|
|
|
if (failCount === 0) {
|
|
|
|
|
proxy.$message.success(`成功下载${successCount}个文件`);
|
|
|
|
|
} else if (successCount === 0) {
|
|
|
|
|
proxy.$message.error(`所有${failCount}个文件下载失败`);
|
|
|
|
|
} else {
|
|
|
|
|
proxy.$message.warning(`成功下载${successCount}个文件,失败${failCount}个文件`);
|
|
|
|
|
}
|
2025-12-03 16:58:06 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('文件下载失败:', error);
|
|
|
|
|
proxy.$message.error('文件下载失败,请稍后重试');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const deleteFile = (row) => {
|
|
|
|
|
proxy.$confirm('确定删除选中文件吗?', '提示', {
|
|
|
|
|
confirmButtonText: '确定',
|
|
|
|
|
cancelButtonText: '取消',
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
2026-01-23 15:43:22 +08:00
|
|
|
deleteWjZzzAddEntity({ ids: [row.id] }).then(res => {
|
2025-12-03 16:58:06 +08:00
|
|
|
proxy.$message.success('删除成功');
|
|
|
|
|
getList();
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
proxy.$message.error('删除失败');
|
|
|
|
|
});
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
proxy.$message.info('已取消删除');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.label-pop {
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
|
position: absolute;
|
|
|
|
|
content: '*';
|
|
|
|
|
top: 0;
|
|
|
|
|
left: -7px;
|
|
|
|
|
color: red;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.el-loading-mask {
|
|
|
|
|
background: rgba(0, 0, 0, 0.5) !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:v-deep .el-dialog {
|
|
|
|
|
width: 90% !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.zdy-model-dialogs {
|
|
|
|
|
/* background-color: rgb(50, 148, 214); */
|
|
|
|
|
background: url("~@/assets/images/bg46.png") no-repeat center center;
|
|
|
|
|
background-size: 100% 100%;
|
|
|
|
|
padding: 8px 10px;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
pointer-events: auto !important;
|
|
|
|
|
height: calc(100% - 50px);
|
|
|
|
|
overflow: auto;
|
|
|
|
|
}
|
|
|
|
|
</style>
|