From 3730b756ae508ed57e64dfc2895748ada6db5876 Mon Sep 17 00:00:00 2001 From: yuntian001 <479820787@qq.com> Date: Thu, 15 Sep 2022 08:47:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=89=93=E5=8C=85?= =?UTF-8?q?=E5=90=8E=E6=89=93=E5=8D=B0=E6=A0=B7=E5=BC=8F=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/meTable/hooks/print.ts | 40 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/components/meTable/hooks/print.ts b/src/components/meTable/hooks/print.ts index 69bb52ec..a2fd82e3 100644 --- a/src/components/meTable/hooks/print.ts +++ b/src/components/meTable/hooks/print.ts @@ -3,14 +3,14 @@ export function getExportBlobByContent(content: string, type = 'text/html') { return new Blob([content], { type: `${type};charset=utf-8;` }); } -export function createHtmlPage(content: string, title = '', style: string[] = []): string { - const styleString = style.join(`\n`); +export function createHtmlPage(content: string, title = '', head: string[] = []): string { + const headString = head.join(`\n`); return [ '', '', '', `${title}`, - ``, + `${headString}`, '', `${content}`, '', @@ -41,8 +41,8 @@ function afterPrintEvent() { requestAnimationFrame(removePrintFrame); } -export function handlePrint(content: string, title = '', style: string[] = [], type = 'text/html'): void { - content = createHtmlPage(content, title, style); +export function handlePrint(content: string, title = '', head: string[] = [], type = 'text/html'): void { + content = createHtmlPage(content, title, head); const blob = getExportBlobByContent(content, type); removePrintFrame(); printFrame = createFrame(); @@ -56,23 +56,35 @@ export function handlePrint(content: string, title = '', style: string[] = [], t printFrame.src = URL.createObjectURL(blob); } -export default async (elTable: ELTable, title = '', style: string[] = []) => { - style.unshift(`.el-table{ +export default async (elTable: ELTable, title = '', head: string[] = []) => { + head.unshift(``); + head.unshift( + '', + ); + head.unshift( + '', + ); const index = elTable.getSelectionIndexs(); if (index.length) { - style.push( - 'tbody>tr:not(' + + head.push( + '', ); } - handlePrint(elTable.$el.outerHTML, title, style); + handlePrint(elTable.$el.outerHTML, title, head); };