Auto Commit

上级 036b1d55
<template> <template>
<div> <div>
<a-button type="primary" style="margin: 10px 0;" :loading="state.exportLoading" @click="onExport"> <a-button type="primary" style="margin: 10px 0;" :loading="state.exportLoading" @click="onExport">
导出 </a-button> 导出Excel </a-button>
</div> </div>
</template> </template>
<script setup> <script setup>
......
...@@ -85,7 +85,7 @@ onMounted(() => { ...@@ -85,7 +85,7 @@ onMounted(() => {
} }
document.addEventListener('keydown', (e) => { document.addEventListener('keydown', (e) => {
console.log(e, 'e') console.log(e, 'e')
if (e.ctrlKey && e.keyCode === 79) { if (e.ctrlKey && e.keyCode === 89) {
console.log('Ctrl+y'); console.log('Ctrl+y');
onSearch() onSearch()
} }
......
...@@ -3,7 +3,6 @@ const base64 = s => window.btoa(unescape(encodeURIComponent(s))); ...@@ -3,7 +3,6 @@ const base64 = s => window.btoa(unescape(encodeURIComponent(s)));
const tableToExcel = async (jsonData) => { const tableToExcel = async (jsonData) => {
return new Promise(resolve => { return new Promise(resolve => {
try { try {
console.log('start', jsonData)
let str = '<tr>' let str = '<tr>'
Object.keys(jsonData[0]).forEach(name => { Object.keys(jsonData[0]).forEach(name => {
const tdStr = `<td>${name}</td>` const tdStr = `<td>${name}</td>`
...@@ -18,8 +17,10 @@ const tableToExcel = async (jsonData) => { ...@@ -18,8 +17,10 @@ const tableToExcel = async (jsonData) => {
} }
str += '</tr>'; str += '</tr>';
} }
const currentTime = new Date()
const fileSuffix = currentTime.valueOf()
// Worksheet名 // Worksheet名
const worksheet = '用户质量分' const worksheet = '用户质量分' + fileSuffix
const uri = 'data:application/vnd.ms-excel;base64,'; const uri = 'data:application/vnd.ms-excel;base64,';
// 下载的表格模板数据 // 下载的表格模板数据
const template = `<html xmlns:o="urn:schemas-microsoft-com:office:office" const template = `<html xmlns:o="urn:schemas-microsoft-com:office:office"
...@@ -31,13 +32,12 @@ const tableToExcel = async (jsonData) => { ...@@ -31,13 +32,12 @@ const tableToExcel = async (jsonData) => {
</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--> </x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]-->
<meta charset='utf-8' /> <meta charset='utf-8' />
</head><body><table>${str}</table></body></html>`; </head><body><table>${str}</table></body></html>`;
console.log('str', str)
// 下载模板 // 下载模板
window.location.href = uri + base64(template); window.location.href = uri + base64(template);
resolve(true) resolve(true)
} }
catch (r) { catch (r) {
console.log(r, 'r') console.log(r, 'html excel')
resolve(false) resolve(false)
} }
}) })
...@@ -51,7 +51,7 @@ export const exportExcelFunc = async (tableData) => { ...@@ -51,7 +51,7 @@ export const exportExcelFunc = async (tableData) => {
resolve(true) resolve(true)
} }
catch (r) { catch (r) {
console.log(r, 'r') console.log(r, 'exportExcelFunc')
resolve(false) resolve(false)
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册