From 4aab9ad97f34eed8d6115f2abab59db45132c081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=B0=91=E5=BA=B7?= Date: Thu, 20 Mar 2025 20:57:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E5=88=97=E8=A1=A8=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Jyh/Search/Components/OssQuery.vue | 45 +++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/views/Jyh/Search/Components/OssQuery.vue b/src/views/Jyh/Search/Components/OssQuery.vue index 6572e65..0e0d814 100644 --- a/src/views/Jyh/Search/Components/OssQuery.vue +++ b/src/views/Jyh/Search/Components/OssQuery.vue @@ -69,7 +69,7 @@ 清空
- 导出 + 导出
@@ -181,6 +181,7 @@ import CountryModal from './CountryModal.vue' import OrgModal from './OrgModal.vue' import NoData from '@/components/NoData/NoData.vue'; import { useAccountStore } from '@/stores/user'; +import * as XLSX from "xlsx" const { formatTime } = useTimeFormat(); import { releasePage, searchLanguageList } from '@/api/jyh'; import { useTimeFormat } from '@/utils/hooks/useTimeFormat'; @@ -197,6 +198,7 @@ const { isLogin } = storeToRefs(userInfo); const tableKey = ref(0); const countryVisible = ref(false); const orgVisible = ref(false); +const allTableData = ref([]); const tableData = ref([]); const languageList = ref([]); const globalInfo = useGlobalInfoStore(); @@ -429,6 +431,7 @@ const getReleaseList = async() => { size: pager.value.pageSize }); if (!error && data) { + allTableData.value = data.data.records tableData.value = data.data.records; pager.value.total = data.data.total; @@ -460,6 +463,46 @@ onMounted(async() => { // ...query // }; // }); + +const exportResult = () => { + + if (!allTableData.value.length) { + Message.info('暂无结果'); + return; + } + + const exportData = allTableData.value.map(item => { + let res = {} + columns.value.forEach(col => { + + if (col.key === 'validStatus') { + res[col.label] = validStatusMap[item[col.key]] ? validStatusMap[item[col.key]] : ''; + } else { + res[col.label] = item[col.key] ? item[col.key] : ''; + } + }) + return res + }) + + try { + const workSheet = XLSX.utils.json_to_sheet(exportData); + const workBook: any = { Sheets: { '校验结果': workSheet}, SheetNames: ['校验结果']}; + const excelBuffer = XLSX.write(workBook, { bookType: 'xlsx', type: 'array'}); + + const link = document.createElement('a'); + const blob = new Blob([excelBuffer]); + link.setAttribute('href', window.URL.createObjectURL(blob)); + link.setAttribute('download', '软件存在及可信校验结果.xlsx'); + link.style.visibility = 'hidden'; + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); + Message.success('导出成功') + } catch { + Message.error('导出失败') + } +} +