当前位置: 首页 > wzjs >正文

海安网站设计建设银行网站

海安网站设计,建设银行网站,嵌入式软件开发技术,网站建设风险控制1. 安装依赖 首先,我们需要安装docx库,以便在前端生成Word文档。可以通过以下命令进行安装: npm install docx 2. 实现导出功能 2.1 初始化文档 使用docx库创建一个新的文档实例,并定义文档的结构和内容。我们使用Document、…

1. 安装依赖

首先,我们需要安装docx库,以便在前端生成Word文档。可以通过以下命令进行安装:

npm install docx

2. 实现导出功能

2.1 初始化文档

使用docx库创建一个新的文档实例,并定义文档的结构和内容。我们使用Document、Paragraph和TextRun等类来构建文档。

const doc = new Document({sections: [{properties: {},children: [new Paragraph({children: [new TextRun({ text: `id:${proposalDetail.value.pid}【这里填写自己要的信息哈】`, size: 24 })],spacing: { after: 200 },alignment: 'right', // 右对齐}),new Paragraph({children: [new TextRun({text: "详情信息",bold: true,size: 32,}),],spacing: { after: 400 },}),// 其他信息...],}],
});

     每个信息都使用Paragraph和TextRun进行格式化。总之就是要添加什么,就new 一个 Paragraph或者是TextPath(看代码就知道啥意思了)

2.2 生成并下载文档

使用Packer.toBlob方法将文档转换为Blob对象,并使用file-saver库的saveAs方法下载文档。

const blob = await Packer.toBlob(doc);
saveAs(blob, `${proposalDetail.value.pid || '详情'}.docx`);
2.3完整代码(以我的实现为例)
// 下载提案内容为Word文档
const download = async () => {try {isDownloading.value = true// 创建文档const doc = new Document({sections: [{properties: {},children: [new Paragraph({children: [new TextRun({ text: `提案号:${proposalDetail.value.pid}`, size: 24 })],spacing: { after: 200 },alignment: 'right',}),new Paragraph({children: [new TextRun({text: "提案详情",bold: true,size: 32,}),],spacing: { after: 400 },}),// 基本信息new Paragraph({children: [new TextRun({ text: `案由:${proposalDetail.value.caseReason}`, size: 24 })],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: `提案人:${proposalDetail.value.proposer}`, size: 24 })],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: `联名人:${proposalDetail.value.signers || '无'}`, size: 24 })],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: `提案人地区:${proposalDetail.value.proposerRegion}`, size: 24 })],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: `提案类型:${proposalDetail.value.proposalType}`, size: 24 })],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: `提交时间:${formatDateTime(proposalDetail.value.submitTime)}`, size: 24 })],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: `是否愿意公示:${proposalDetail.value.isPublic ? '是' : '否'}`, size: 24 })],spacing: { after: 400 },}),// 提案内容new Paragraph({children: [new TextRun({text: "提案内容:",bold: true,size: 24,}),],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: proposalDetail.value.proposalContent, size: 24 })],spacing: { after: 400 },}),// 处理结果new Paragraph({children: [new TextRun({text: "处理结果:",bold: true,size: 24,}),],spacing: { after: 200 },}),new Paragraph({children: [new TextRun({ text: proposalDetail.value.handingResult || '暂无处理结果', size: 24 })],spacing: { after: 400 },}),// 添加处理状态部分new Paragraph({children: [new TextRun({text: "处理状态:",bold: true,size: 24,}),],spacing: { after: 200 },}),// 添加所有状态阶段...getStatusInfo.value.filter(stage => !stage.isHidden).map(stage =>new Paragraph({children: [new TextRun({text: `${stage.label}—— `,size: 24}),new TextRun({text: getStatusText(stage),size: 24,color: stage.isRejected ? 'FF0000' : // 红色stage.isProcessing ? '409EFF' : // 蓝色!stage.time ? '909399' : '333333' // 灰色或黑色})],spacing: { after: 200 },}))],}],})// 生成文档const blob = await Packer.toBlob(doc)saveAs(blob, `提案${proposalDetail.value.pid || '详情'}.docx`)ElMessage.success('提案内容已保存为Word文档')} catch (error) {console.error('生成Word文档失败:', error)ElMessage.error('生成Word文档失败,请重试')} finally {isDownloading.value = false}
}

3. 用户界面

在用户界面中,我们使用Element Plus的按钮组件来触发导出功能。按钮的文本会根据导出状态进行更新,提供良好的用户体验。

<el-button type="danger" @click="download" :loading="isDownloading" class="action-button">{{ isDownloading ? '正在生成...' : '详情导出Word' }}
</el-button>

4. 实现效果


文章转载自:

http://RU7yOch7.wjfzp.cn
http://Jsbkdydh.wjfzp.cn
http://r37l9ohq.wjfzp.cn
http://Cahn3DZd.wjfzp.cn
http://3gau70cf.wjfzp.cn
http://twYGl16n.wjfzp.cn
http://rAZdyEzM.wjfzp.cn
http://2e7FrUfB.wjfzp.cn
http://6gnquDOo.wjfzp.cn
http://tCro3sQW.wjfzp.cn
http://oGMCcE7y.wjfzp.cn
http://r1tELtbN.wjfzp.cn
http://GC4UkC6p.wjfzp.cn
http://wHT5mC45.wjfzp.cn
http://bhYKCQLp.wjfzp.cn
http://GljC357E.wjfzp.cn
http://OVJCW8hf.wjfzp.cn
http://WSERBlJf.wjfzp.cn
http://SeD9rjHI.wjfzp.cn
http://X3P7qedn.wjfzp.cn
http://P0QijlFw.wjfzp.cn
http://TiqrUbex.wjfzp.cn
http://Iu8EIc5w.wjfzp.cn
http://CStXwNCy.wjfzp.cn
http://umyu6gB0.wjfzp.cn
http://RiCyVyy5.wjfzp.cn
http://xp8oqXUf.wjfzp.cn
http://6B1O80v6.wjfzp.cn
http://5GD9w1y4.wjfzp.cn
http://AHt34uz7.wjfzp.cn
http://www.dtcms.com/wzjs/682788.html

相关文章:

  • 品牌网站建设费用要多少网站优化公司服务
  • 制作一个网站流程网站开发工作平时做什么
  • 网站框架是怎么做的个人网站空间收费
  • 简单网站建设培训中心手工制作风筝
  • 工作做ppt课件的网站wordpress显示目录结构
  • 广东省住房建设部网站手机兼职做什么好
  • 做视频的网站花瓣设计网站官网入口
  • 长沙seo优化价格济南 网站优化
  • 彭水网站建设推广简单网页制作图片
  • 郑州seo网站推广重庆发布微信公众号
  • 张家港做英文网站网站开发是网站后台开发吗
  • 怎么样做问卷网站企业型网站网址
  • 建设酒店网站ppt模板购物节优惠卷网站怎么做
  • 微信开发网站苏州网站建设招聘
  • 郑州汉狮做网站多少钱微信小程序开发费用一览表
  • 龙华做棋牌网站建设多少钱创意产品
  • 移动网站视频主持人网石家庄科技网站
  • 西安网站seo 优帮云wordpress swf
  • 网站自己做服务器如何做网站毕业设计
  • 国内扁平化网站欣赏c# 网站开发实例教程
  • 诀窍的网站织梦资源下载站网站模板
  • 电子商务网站建设有哪些流程图wordpress建什么站
  • 网站开发任务需求书阀门行业网站怎么做
  • 温州本地网站淘客wordpress数据
  • 高校二级网站建设方案游戏网站建设需要多少钱
  • 揭阳装修网站建设越城网站建设公司
  • 建设银行信用卡网站显示余额开启wordpress多站点
  • 怎样申请做自己的网站电子书网站用dz还是wordpress
  • 网站设计流程大致分为几个阶段做外贸哪些网站比较好
  • 优秀的个人博客网站北京网站开发教师招聘