From b4a5c36fb0b76fa0d834185bb2e6ce404cd4214b Mon Sep 17 00:00:00 2001 From: qsh <> Date: Tue, 3 Jun 2025 14:38:38 +0800 Subject: [PATCH] sc --- src/utils/index.ts | 27 +++++++++++++++++++ src/views/OKR/Analysis/index.vue | 7 +++++ .../Management/Components/DialogOkrInfo.vue | 6 ++--- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index a8696e1..db00de1 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -220,3 +220,30 @@ export const removeNullField = (obj: Object) => { } return obj } + +import * as XLSX from 'xlsx' +import * as FileSaver from 'file-saver' +export const exportTableWithVue = (domId: any, fileName: String) => { + // const XLSX = require('xlsx') + // 使用 this.$nextTick 是在dom元素都渲染完成之后再执行 + // this.$nextTick(function () { + // 设置导出的内容是否只做解析,不进行格式转换 false:要解析, true:不解析 + const xlsxParam = { raw: true } + const wb = XLSX.utils.table_to_book(document.querySelector(domId), xlsxParam) + + const wbout = XLSX.write(wb, { + bookType: 'xlsx', + bookSST: true, + type: 'array' + }) + try { + // 下载保存文件 + FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), `${fileName}.xlsx`) + } catch (e) { + if (typeof console !== 'undefined') { + console.log(e, wbout) + } + } + return wbout + // }); +} diff --git a/src/views/OKR/Analysis/index.vue b/src/views/OKR/Analysis/index.vue index 3bed8cf..527a952 100644 --- a/src/views/OKR/Analysis/index.vue +++ b/src/views/OKR/Analysis/index.vue @@ -12,6 +12,7 @@ @change="nodeChange" />
+ 导出 diff --git a/src/views/OKR/Management/Components/DialogOkrInfo.vue b/src/views/OKR/Management/Components/DialogOkrInfo.vue index e999d29..102e920 100644 --- a/src/views/OKR/Management/Components/DialogOkrInfo.vue +++ b/src/views/OKR/Management/Components/DialogOkrInfo.vue @@ -449,7 +449,7 @@ function resetForm() { startTime: undefined, endTime: undefined, executor: [], - dataScope: 1 + dataScope: 2 } } @@ -464,7 +464,7 @@ function addObjective() { objectiveName: '', executor: [], keyResults: [], - dataScope: 1 + dataScope: 2 }) } @@ -495,7 +495,7 @@ function removeKR(oIdx, krIdx) { } function addChildNode() { - childNodeList.value.push({ dataScope: 1 }) + childNodeList.value.push({ dataScope: 2 }) } function removeChildNode(idx) {