添加 docx

dev
suixy 2 months ago
parent e7c11cd38f
commit 4ce05b1fdd

@ -1,6 +1,6 @@
{
"$schema": "https://json.schemastore.org/package",
"name": "经营管理系统",
"name": "hwBm",
"version": "5.5.0-2.5.0",
"description": "海威经营管理信息化系统",
"author": "LionLi",
@ -28,6 +28,7 @@
"await-to-js": "3.0.0",
"axios": "1.8.4",
"crypto-js": "4.2.0",
"docx": "^9.5.1",
"echarts": "5.6.0",
"element-plus": "2.9.8",
"file-saver": "2.0.5",

@ -26,6 +26,11 @@ import Layout from '@/layout/index.vue';
// 公共路由
export const constantRoutes: RouteRecordRaw[] = [
{
path: '/contract',
component: () => import('@/views/contract/index.vue'),
hidden: true
},
{
path: '/redirect',
component: Layout,

@ -0,0 +1,40 @@
<template>
<div>123</div>
</template>
<script setup>
import { Document, Packer, Paragraph, TextRun } from 'docx';
//
const doc = new Document({
sections: [
{
properties: {},
children: [
new Paragraph({
text: 'Hello World',
heading: 'Heading1'
}),
new Paragraph({
text: 'This is a simple DOCX file created using DOCX.js.'
})
]
}
]
});
const download = async (doc) => {
const blob = await Packer.toBlob(doc);
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'document.docx';
// Click the link to download the file
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
// download(doc)
</script>
<style scoped></style>
Loading…
Cancel
Save