Auto Commit

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