软件列表导出功能开发
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
<d-button variant="solid" color="secondary" @click="clear">清空</d-button>
|
||||
</div>
|
||||
<div class="left-btn">
|
||||
<d-button v-if="isLogin" class="output-btn" icon="icon-share" variant="text">导出</d-button>
|
||||
<d-button v-if="isLogin" class="output-btn" icon="icon-share" variant="text" @click="exportResult">导出</d-button>
|
||||
<span v-if="isLogin" style="height: 14px" class="split"></span>
|
||||
<TableSetting :columns="columns" @setDefult="setDefult" :show-column-list="showColumnList" @update:show-column-list="updateShowColumnList"/>
|
||||
</div>
|
||||
@@ -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('导出失败')
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user