前后尝试了 两个插件 vue-print-nb、vue-easy-print ,都不行。最后选择了 print-js。

不多说了,贴整个代码

<template><div class="table-data"><div class="search-box"><el-row><el-col :span="24"><div class="grid-content bg-purple"><el-row><el-col :span="20"><div class="block"><el-date-picker size="mini" type="daterange" v-model="selectDate" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @change="searchPay"></el-date-picker></div></el-col><el-col :span="2"><el-button type="primary" icon="el-icon-printer" size="mini" @click="printDemo">打印</el-button></el-col></el-row></div></el-col></el-row></div><div ><el-table v-loading="loading" element-loading-text="拼命加载中" :data="tableData" border stripe style="width:100%" class="table-box-print"><el-table-column width="200" label="缴费日期" prop="payDate" align="center" sortable></el-table-column><el-table-column fit label="缴费方式" prop="payWay" align="center" sortable></el-table-column><el-table-column fit label="缴费笔数" prop="count" align="center"></el-table-column><el-table-column fit label="实缴金额" prop="courseTotal" align="center"></el-table-column></el-table><el-divider></el-divider><el-row><el-col :span="2" :offset="10"><el-tag size="mini">缴费数:</el-tag></el-col><el-col :span="5"><el-input size="mini" v-model="count" :disabled="true"></el-input></el-col><el-col :span="2"><el-tag size="mini">缴费总额:</el-tag></el-col><el-col :span="5"><el-input size="mini" v-model="totalFee" :disabled="true"></el-input></el-col></el-row></div></div></template><script lang="ts">import {Component,Vue,Provide} from "vue-property-decorator";import {State,Getter,Mutation,Action} from "vuex-class";import print from 'print-js';@Component({components: {print}})export default class PayRecordPrintByPayWay extends Vue {@Getter("user") getUser: any;@Provide() selectDate: any = "";@Provide() tHeight: number = document.body.offsetHeight - 100;@Provide() tableData: any = []; // 表格数据@Provide() printData: any = []; // 表格数据@Provide() page: number = 1; // 当前page@Provide() size: number = 50; // 请求数据的个数 默认5@Provide() total: number = 0; // 总数据条数@Provide() count: number = 0; // 总数据条数@Provide() totalFee: number = 0; // 总数据条数@Provide() loading: boolean = true;test() {console.log(this.selectDate);console.log(this.selectDate[0]);console.log(this.selectDate[1]);this.searchPay();}created() {this.loading = false;}handleSizeChange(val: number): void {this.size = val;this.page = 1;//this.searchVal ? this.loadSearchData() : this.loadData();}handleCurrentChange(val: number): void {this.page = val;//this.searchVal ? this.loadSearchData() : this.loadData();}/**查询缴费记录*/searchPay() {if (this.selectDate.length < 2) {return;}let data: any = {beginDate: this.selectDate[0],endDate: this.selectDate[1],};(this as any).$axios.post("/student/searchPayRecordWithPayWay", data).then((res: any) => {if (res.data.state == "error") {this.$message({message: res.data.msg,type: res.data.state,duration: 3000});}this.tableData = res.data.list;this.printData = res.data.list;this.total = res.data.total;if (this.total > 0) {for (let i = 0; i < this.total; i++) {this.totalFee = this.totalFee + Number(this.tableData[i].courseTotal);this.count = this.count+ Number(this.tableData[i].count);}}this.printData.push({payWay: '合计',count: this.count ,courseTotal:this.totalFee,payDate:"------"})this.loading = false;});}printDemo() {print({printable: this.printData,//table header//field someJSONdata对应的字段 displayName 打印表格显示的字段properties: [{field: 'payDate',displayName: '缴费日期',columnSize: 1},{field: 'payWay',displayName: '缴费方式',columnSize: 1},{field: 'count',displayName: '缴费笔数',columnSize: 1}, {field: 'courseTotal',displayName: '实缴金额',columnSize: 1}],// 头部样式// gridHeaderStyle: "border: 1px solid lightgray;white-space:nowrap; ",// //表格样式// gridStyle: "border: 1px solid lightgray;white-space:nowrap; ",gridHeaderStyle: 'color: red; border: 1px solid #3971A5;',gridStyle: 'border: 1px solid #3971A5; text-align:center; font-size: 8px;',header: '<h3 class="custom-h3">缴费方式统计表</h3>',// scanStyles: false,// style: style,//打印类型type: "json"});}}</script><style lang="scss">.table-box-print {font-size: 8px;th {padding: 0 !important;height: 20px;}td {padding: 0 !important;height: 20px;}}.pages {background: #fff;margin-top: 10px;padding: 10px 10px;text-align: right;height: 50px;box-sizing: border-box;}.table-data {.el-input {width: 200px;margin-right: 10px;}.search-box {background: #fff;margin-bottom: 10px;padding: 10px 10px;border-radius: 4px;height: 50px;box-sizing: border-box;.el-input {width: 100px;margin-right: 10px;}}}</style>

vue print-js 解决 打印分页问题相关推荐

  1. vue使用print.js实现打印功能,以及添加打印机

    print.js 一个javascript库,可以实现打印功能 github地址 github地址: https://github.com/crabbly/print.js 官网地址 https:// ...

  2. vue封装打印插件print.js实现打印组件功能

    代码 插件地址:https://github.com/xyl66/vuePlugs_printjs 1. 打印插件属性方法 定义-print.js // 打印类属性.方法定义 /* eslint-di ...

  3. Print.js实现打印pdf,HTML,图片(可设置样式可分页)

    目录 一.安装及引入Print.js 二.介绍 三.常用配置 四.具体使用 一.安装及引入Print.js 1.安装 npm install print-js --save //or yarn add ...

  4. 前端使用print.js实现打印

    前言 项目中经常会用到前端调用浏览器打印的功能,也经常会遇到一些问题,写这篇文章是为了更好的梳理一下相关内容.下面的内容基于vue. 如果需要用到前端生成二维码可以看我的这篇文章:在vue项目中使用q ...

  5. vue+element-ui+js页面打印(打印elementui的table)

    前端调用浏览器打印功能,实现纯前端vue+element-ui+js打印页面功能 1.效果展示 2.封装成公共函数 3.在.vue文件中引入并使用"printExcel"函数 1. ...

  6. vue项目使用Print.js插件实现PDF文件打印

    一,Print.js介绍 Print.js主要是为了帮助我们在应用程序中直接打印PDF文件,而不需要离开界面,也不需要使用嵌入.对于用户不需要打开或下载PDF文件的特殊情况,只需要打印即可. 例如,当 ...

  7. vue使用print.js打印插件

    任务:解决vue页面局部打印功能 print.js插件,可以打印 html.pdf.json数据 官网:https://printjs.crabbly.com/ 一个整理的很好的讲解:https:// ...

  8. vue @media print使用js插入打印页不同尺寸打印,可自定义尺寸大小,打印机配置

    业务需求 在开发时,遇到需求打印时既能切换A4纸张,又能切换成凭证纸张.而使用 @media 设置尺寸后,影响所有页面,无法实现打印多尺寸的问题. 打印技术 使用浏览器自带的 print 打印技术 打 ...

  9. jquery打印html页面自动分页,前端实现指定位置分页、多页打印功能(jquery.print.js)...

    1. 分类 原生打印,window.print() 实现 插件实现,很多种,我这里选择的是 jquery.print.js 优缺点 原生打印的好处就不多说了,简单方便,全屏打印,如果对打印功能没有什么 ...

最新文章

  1. 缺陷检测 | PCB AOI质量检测之自动定位核选取算法
  2. 张新波 | 十面埋伏 - 论大数据风控技术体系的构建
  3. openstack安装rabbitmq-server消息队列时出现错误
  4. python制作表白神器_python制作exe可执行表白神器-Go语言中文社区
  5. c#中.clear()作用_清单 .Clear()方法以及C#中的示例
  6. IDC:2017年中国网络安全市场分析与2018年预测
  7. golang后端php前端,Golang如何接收前端的参数
  8. python如何向字典添加新键?
  9. oracle是否启用dataguard,启动和关闭data guard的步骤
  10. mysql 分类计数器,MYSQL计数器类型业务的优化
  11. SQLServer中一个多用户自动生成编号的过程
  12. 隔离 docker 容器中的用户-------分享链接
  13. 学习Java的9张思维导图
  14. 【iPod转换精灵V10.2 官方最新版】强大的视频转换功能
  15. 【深度学习】CRNN 文字识别端对端模型 CTC损失
  16. 基于时空图卷积网络预测交通流
  17. 解读swarm最新资讯,主网8.2号开始产BZZ
  18. 手机电源键失灵无法开机的有效土方法
  19. 意识理论综述:众多竞争的意识理论如何相互关联?
  20. php自助旅游网站平台

热门文章

  1. Linux远程桌面的选择
  2. 抖音xgorgon和设备注册算法
  3. Cesium-通过Shader添加圆形扩散效果
  4. 三维图像高斯金字塔matlab,图像拼接中 高斯金字塔的建立 matlab程序详细解释 现金奖励...
  5. 性能优化(四)长图优化,仿微博加载长图方式
  6. 有线电视CATV、iptv、ott-tv区别
  7. 考研日语线上笔记(四):中级日语语法总结20课(1~10)
  8. 【天宇分析】寻找圣杯:区块链域名与钱包的价值
  9. Linux远程桌面的设计总结,windows / Linux 远程桌面访问全面总结 / 共享文件
  10. 如何进行CMDB数据运营?