This commit is contained in:
2026-01-26 18:03:42 +08:00
parent df187151d6
commit 5a651a1f90

View File

@ -1,25 +1,27 @@
<template> <template>
<div> <div>
<!-- 搜索 -->
<div ref="searchBox" class="mt10"> <div ref="searchBox" class="mt10">
<Search :searchArr="searchConfiger" @submit="onSearch" :key="pageData.keyCount" /> <Search :searchArr="searchConfiger" @submit="onSearch" :key="pageData.keyCount" />
</div> </div>
<PageTitle :malginLeft="10" :height="35" backgroundColor="#ffff" :marginBottom="5" :marginTop="5"> <PageTitle :malginLeft="10" :height="35" backgroundColor="#ffff" :marginBottom="5" :marginTop="5">
<template #left> <template #left>
<el-button size="small" type="primary" @click="getDataById('add', '')"> <el-button size="small" type="primary" @click="getDataById('add', '')">
<el-icon style="vertical-align: middle"> <el-icon style="vertical-align: middle"><CirclePlus /></el-icon>
<CirclePlus />
</el-icon>
<span style="vertical-align: middle">新增</span> <span style="vertical-align: middle">新增</span>
</el-button> </el-button>
</template> </template>
</PageTitle> </PageTitle>
<!-- 表格 --> <!-- 表格 -->
<div class="tabBox"> <div class="tabBox">
<MyTable :tableData="pageData.tableData" :tableColumn="pageData.tableColumn" :tableHeight="pageData.tableHeight" <MyTable
:key="pageData.keyCount" :tableConfiger="pageData.tableConfiger" :controlsWidth="pageData.controlsWidth" :tableData="pageData.tableData"
@chooseData="chooseData"> :tableColumn="pageData.tableColumn"
:tableHeight="pageData.tableHeight"
:key="pageData.keyCount"
:tableConfiger="pageData.tableConfiger"
:controlsWidth="pageData.controlsWidth"
@chooseData="chooseData"
>
<template #wjdx="{ row }"> <template #wjdx="{ row }">
{{ row.wjdx }}MB {{ row.wjdx }}MB
</template> </template>
@ -30,16 +32,17 @@
<template #controls="{ row }"> <template #controls="{ row }">
<el-link size="small" type="primary" @click="getDataById('edit', row)">修改</el-link> <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="getDataById('detail', row)">详情</el-link>
<el-link size="small" type="primary" @click="previewFile(row)" <el-link size="small" type="primary" @click="previewFile(row)" v-if="row.wjlx == '.png' || row.wjlx == '.jpg' || row.wjlx == '.jpeg'">预览</el-link>
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="primary" @click="downloadFile(row)">下载</el-link>
<el-link size="small" type="danger" @click="deleteFile(row)">删除</el-link> <el-link size="small" type="danger" @click="deleteFile(row)">删除</el-link>
</template> </template>
</MyTable> </MyTable>
<Pages @changeNo="changeNo" @changeSize="changeSize" :tableHeight="pageData.tableHeight" :pageConfiger="{ <Pages
...pageData.pageConfiger, @changeNo="changeNo"
total: pageData.total @changeSize="changeSize"
}"></Pages> :tableHeight="pageData.tableHeight"
:pageConfiger="{ ...pageData.pageConfiger, total: pageData.total }"
/>
</div> </div>
</div> </div>
<AddForm ref="addForm" @getList="getList" /> <AddForm ref="addForm" @getList="getList" />
@ -51,43 +54,20 @@ import MyTable from "@/components/aboutTable/MyTable.vue";
import Pages from "@/components/aboutTable/Pages.vue"; import Pages from "@/components/aboutTable/Pages.vue";
import Search from "@/components/aboutTable/Search.vue"; import Search from "@/components/aboutTable/Search.vue";
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { qbcjZxsSelectPage } from "@/api/qbcj.js"; import { reactive, ref, onMounted, getCurrentInstance } from "vue";
import { reactive, ref, onMounted, getCurrentInstance, watch } from "vue";
import { getItem } from '@//utils/storage.js' import { getItem } from '@//utils/storage.js'
import { deleteWjZzzAddEntity, getWjZzzAddEntity } from '@//api/qbcj.js' import { deleteWjZzzAddEntity, getWjZzzAddEntity } from '@//api/qbcj.js'
import AddForm from "./components/addForm.vue"; import AddForm from "./components/addForm.vue";
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
// const { D_BZ_CJLX, D_GS_XS_LX } = proxy.$dict("D_BZ_CJLX", "D_GS_XS_LX"); //获取字典数据
const detailDiloag = ref(); const detailDiloag = ref();
const searchBox = ref(); //搜索框 const searchBox = ref(); //搜索框
const ids = ref([]) const ids = ref([])
const tableList = 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({ const qxkz = reactive({
deptBizType: "", deptBizType: "",
deptLevel: "" deptLevel: ""
}) })
const searchConfiger = ref([ const searchConfiger = ref([
{ label: "文件名称", prop: 'wjmc', placeholder: "请输入文件名称", showType: "input" }, { label: "文件名称", prop: 'wjmc', placeholder: "请输入文件名称", showType: "input" },
// { label: "情报来源", prop: 'cjLx', placeholder: "请选择情报来源", showType: "select", options: D_BZ_CJLX }, // { label: "情报来源", prop: 'cjLx', placeholder: "请选择情报来源", showType: "select", options: D_BZ_CJLX },
@ -117,6 +97,26 @@ const pageData = reactive({
] ]
}); });
const queryFrom = ref({}); const queryFrom = ref({});
const addForm = ref(null)
const route = useRoute()
const routerMate = ref({})
onMounted(() => {
const { deptBizType, deptLevel } = getItem('deptId')[0]
qxkz.deptBizType = deptBizType
qxkz.deptLevel = deptLevel[0] == '2' ? '01' : deptLevel[0] == '3' ? '02' : '03'
routerMate.value = route.meta;
getList()
tabHeightFn()
if (route.query.id) return detailDiloag.value.init('edit', { id: route.query.id });
});
const chooseData = (val) => {
if(Array.isArray(val)){
ids.value = val.map(item => item.id)
tableList.value = val
}
}
// 搜索 // 搜索
const onSearch = (val) => { const onSearch = (val) => {
@ -162,67 +162,46 @@ const tabHeightFn = () => {
tabHeightFn(); tabHeightFn();
}; };
}; };
const route = useRoute()
const routerMate = ref({})
const getRouter = () => {
routerMate.value = route.meta
}
const addForm = ref(null)
const getDataById = (type, row) => { const getDataById = (type, row) => {
addForm.value.init(type, row, '01'); addForm.value.init(type, row, '01');
} }
const previewFile = (item) => { const previewFile = (item) => {
window.open(item.wjdz); window.open(item.wjdz);
} }
const downloadFile = async (item) => { const downloadFile = async (item) => {
console.log(item);
try { try {
const dataList =JSON.parse(item.wjdz) const dataList =JSON.parse(item.wjdz)
if (dataList.length === 0) { if (dataList.length === 0) return proxy.$message.warning('没有文件可下载');
proxy.$message.warning('没有文件可下载');
return;
}
console.log(dataList);
const downloadCount = dataList.length; const downloadCount = dataList.length;
let successCount = 0; let successCount = 0;
let failCount = 0; let failCount = 0;
proxy.$message.info(`开始下载${downloadCount}个文件...`); proxy.$message.info(`开始下载${downloadCount}个文件...`);
// 并行下载所有文件 // 并行下载所有文件
const downloadPromises = dataList.map(async (fileData, index) => { const downloadPromises = dataList.map(async (fileData, index) => {
try { try {
// 使用fetch获取文件内容 // 使用fetch获取文件内容
const response = await fetch(fileData.url); const response = await fetch(fileData.url);
if (!response.ok) { if (!response.ok) throw new Error('文件下载失败');
throw new Error('文件下载失败');
}
// 将响应转换为Blob对象 // 将响应转换为Blob对象
const blob = await response.blob(); const blob = await response.blob();
// 创建下载链接 // 创建下载链接
const downloadLink = document.createElement('a'); const downloadLink = document.createElement('a');
downloadLink.href = URL.createObjectURL(blob); downloadLink.href = URL.createObjectURL(blob);
// 设置下载文件的名称,避免冲突 // 设置下载文件的名称,避免冲突
const fileName = dataList.length > 1 const fileName = dataList.length > 1 ? `${item.wjmc}_${index + 1}` : item.wjmc;
? `${item.wjmc}_${index + 1}`
: item.wjmc;
downloadLink.download = fileName; downloadLink.download = fileName;
// 触发下载 // 触发下载
document.body.appendChild(downloadLink); document.body.appendChild(downloadLink);
downloadLink.click(); downloadLink.click();
// 清理 // 清理
setTimeout(() => { setTimeout(() => {
document.body.removeChild(downloadLink); document.body.removeChild(downloadLink);
URL.revokeObjectURL(downloadLink.href); URL.revokeObjectURL(downloadLink.href);
}, 100); }, 100);
successCount++; successCount++;
} catch (error) { } catch (error) {
console.error(`文件${index + 1}下载失败:`, error); console.error(`文件${index + 1}下载失败:`, error);
@ -246,12 +225,9 @@ console.log(dataList);
proxy.$message.error('文件下载失败,请稍后重试'); proxy.$message.error('文件下载失败,请稍后重试');
} }
} }
const deleteFile = (row) => { const deleteFile = (row) => {
proxy.$confirm('确定删除选中文件吗?', '提示', { proxy.$confirm('确定删除选中文件吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteWjZzzAddEntity({ ids: [row.id] }).then(res => { deleteWjZzzAddEntity({ ids: [row.id] }).then(res => {
proxy.$message.success('删除成功'); proxy.$message.success('删除成功');
getList(); getList();