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('导出失败') + } +} +