vue2 打印数据 以及使用 (2)

news2024/9/23 7:29:52
安装
To install using npm:
 
 
  npm install print-js --save
 
To install using yarn:
 
 
  yarn add print-js

页面效果

 
   <template>
  <div>
    <table width="100%" height="100%" border="1">
      <tr>
        <td colspan="1">1</td>
        <td colspan="1">员工姓名</td>
        <input  v-model="name" style="color: red; width: 100px" />
        <td colspan="3">员工部门</td>
        <input v-model="department" style="color: red; width: 100px" />
      </tr>
    </table>
 
    <table width="100%" height="100%" border="1">
      <tr>
        <td colspan="1">2</td>
        <td colspan="1">所在职位</td>
        <input v-model="position" style="color: red; width: 100px" />
        <td colspan="3">考核吐槽项目</td>
        <input  v-model="message" style="color: red; width: 100px" />
      </tr>
    </table>
 
	<table width="100%" height="100%" border="1">
      <tr>
        <td colspan="1">3</td>
        <td colspan="1">a</td>
        <input type="number" v-model="a" style="color: red; width: 100px" />
		<td colspan="1">*</td>
		<td colspan="1">b</td>
        <input type="number" v-model="b" style="color: red; width: 100px" />
       <td colspan="3">是否满足( > 1593)</td>
        <td colspan="3">{{ this.list }}</td>
      </tr>
    </table>
    <button @click="jsonPrint">打印</button>
  </div>
</template>
   <script lang="ts">
import printJS from "print-js";
export default {
  data() {
    return {
	  fraction: '',       //分数 
	  name: "",           //名字
      department: '',     //部门
      message: "",        //吐槽
      position: "",       //职位
	  a:'',               //分数1
	  b:''                //分数2
    };
  },
  computed: {
	// 计算分数总数
    num() {
      return this.a * this.b ;
    },
	// 改变吐槽展现形式
    reverseMessage() {
      return this.message.split("")
    //   return this.message.split("").reverse().join("");
 
    },
 
	// list  是判断num的满足条件
    list() {
      if (this.num > 1593) {
        return "满足";
      } else {
        return "不满足";
      }
    },
  },
 
  methods: {
    jsonPrint() {
      printJS({
        printable: [], //表格的数据
        header: `<div style="display: flex;flex-direction: column;text-align: center">
						<table border="1" width="100%" height="100%"  >
							<tr>
								<!-- colspan跨n列 -->
								<td colspan="12">学生作业考核评价表</td>
							</tr>
							<tr>
								<td colspan="2">员工姓名</td>
								<td colspan="2" >${this.name}</td>
								<td colspan="1">部门</td>	
								<td colspan="3">${this.department}</td>
								<td colspan="2">所在职位</td>	
								<td colspan="2">${this.position}</td>
							</tr>
							<tr>
								<td colspan="3">考核吐槽项目</td>
								<td colspan="3">${this.reverseMessage}</td>
								<td colspan="1">考核分数</td>
								<td colspan="5"> ${this.num}</td>
							</tr>
							<tr>
								<td colspan="4">考核结果</td>
								<td colspan="8">${this.list}</td>
							</tr>
							</table>
							<table border="1" width="100%" height="100%">
								<tr>
								<td colspan="1">序号</td>
								<td colspan="1">项目</td>
								<td colspan="4">考核标准评分</td>	
								<td colspan="2">自我评分</td>
								<td colspan="2">老师评分</td>	
								<td colspan="3">综合评分</td>
							</tr>
							<tr>
								<td rowspan="4">1</td>
								<td rowspan="4">考勤状况及态度考核</td>
								<td colspan="4">出勤情况:满勤,无请假迟到早退等情况(满分10分)</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
							</tr>
							<tr>
								<td colspan="4">工作积极性:主动承担分内工作,对本人职责范围内的工作无推诿(满分10分)</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
							</tr>
							<tr>
								<td colspan="4">责任意识:本职工作有责任心,及时完成交付的工作,无拖延(满分10分)</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
							</tr>
							<tr>
								<td colspan="4">协作与配合:与上下级,同事工作配合度(满分10分)</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
								<td colspan="2">7</td>
							</tr>
							
							</table>
						
                    </div>`,
        properties: [
          //表头
          // {field: 'id', displayName: '地区', columnSize: `10%`},
          // {field: 'text', displayName: '确认跳闸条数',columnSize: `65%`},
          // {field: 'num', displayName: '误报条数'},
          // {field: 'powerOutageTotalNum', displayName: '跳闸总条数'},
          // {field: 'powerOutageErrorIndex', displayName: '误报指数', columnSize: `10%`},
        ],
        type: "json",
        gridHeaderStyle: "border: 1px solid #000;text-align:center",
        gridStyle: "border: 1px solid #000;text-align:center",
        style:
          " span {color :red ;width: 300px;border: 1px solid #000;	display: flex; }", // 表格样式
      });
    },
  },
};
</script>
   
   <style>
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1079985.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

python图片处理:添加背景文生图(2)

文生图3.0&#xff1a;添加背景图片 3个回车文生图꧂写在前面&#xff1a;肉麻的话꧁ 哈哈&#xff0c;我明白了&#xff01;请允许我再试一次以幽默的方式来重新描述文本&#xff1a; 亲爱的主人大大&#xff0c;你是超级棒的&#xff01;如果你不想处理枯燥的代码&#xff0…

前端TypeScript学习day03-TS高级类型

(创作不易&#xff0c;感谢有你&#xff0c;你的支持&#xff0c;就是我前行的最大动力&#xff0c;如果看完对你有帮助&#xff0c;请留下您的足迹&#xff09; 目录 TypeScript 高级类型 class 类 class继承 extends implements 类成员可见性 public protected …

c语言终点站--文件操作

前言&#xff1a; 为什么要学习文件操作呢&#xff1f;想要知道这个问题&#xff0c;我们就需要先了解什么是数据的可持久化。 那么什么是数据的可持久化呢&#xff1f;数据的可持久化就是把内存中的数据对象永久的保存在电脑的磁盘文件中&#xff0c;将程序数据在持久状态和…

mysql面试题40:列值为null或者空字符串时,查询是否会用到索引?

该文章专注于面试,面试只要回答关键点即可,不需要对框架有非常深入的回答,如果你想应付面试,是足够了,抓住关键点 面试官:列值为null或者空字符串时,查询是否会用到索引? 当列的值为NULL时,查询可能会使用索引,但具体是否使用索引取决于数据库的优化器和查询条件。…

点向行列连边的网络流图优化成行列连边的二分图:CF1592F2

https://www.luogu.com.cn/problem/CF1592F2 做完F1&#xff0c;然后用1的结论来思考。 场上推了几个性质。首先op4的操作行列必然两两不同&#xff0c;所以op4最多 max ⁡ ( n , m ) \max(n,m) max(n,m) 次。然后手玩发现只有除 ( n , m ) (n,m) (n,m) 的三个格子都为1&am…

ChatGPT 是如何产生心智的? | 京东云技术团队

一、前言 - ChatGPT真的产生心智了吗&#xff1f; 来自斯坦福大学的最新研究结论&#xff0c;一经发出就造成了学术圈的轰动&#xff0c;“原本认为是人类独有的心智理论&#xff08;Theory of Mind&#xff0c;ToM&#xff09;&#xff0c;已经出现在ChatGPT背后的AI模型上”…

芯科蓝牙BG27开发笔记10-BG27样板调试

样板使用了1.5V电源&#xff0c;boost升压到1.8V供MCU使用&#xff0c;因此IO通信的电平需要注意&#xff1a; 不能使用常用的5V、3.3V的jlink进行调试&#xff0c;类似的uart通信也一样。 BRD4001A底板的jlink如何使用&#xff1f; 参考开发板套件的说明文档《ug551-brd4194…

purr map walk 学习教程 完整版教程学习

Function reference • purrrhttps://purrr.tidyverse.org/reference/index.htmlMap over multiple input simultaneously (in "parallel") — pmap • purrr 11 Other purrr functions | Functional Programming (stanford.edu) 关注微信&#xff1a;生信小博士 1…

【解决问题思路分析】记录hutool默认使用服务端上次返回cookie的问题解决思路

背景&#xff1a; 本服务需要调用第三方接口获取数据&#xff0c;首先调用public-key接口获取公钥&#xff0c;然后用公钥加密密码&#xff0c;将用户名和密码传入/ticket接口&#xff0c;获取Cookie和response body中的token。 排查思路 由于是调用第三方接口出现问题&…

OnlyOffice文档服务器安装及集成使用

OnlyOffice文档服务器安装及集成使用 一、安装1.使用docker安装2.开启防火墙3.配置4.访问测试 二、应用集成1.前端集成(React)(1).安装onlyoffice/document-editor-react(2).使用 ONLYOFFICE 文档 React 组件 2.后台集成(Java)(1) getFile接口(2) callback接口(3) getFile接口和…

SpringBoot拦截器实现

1.定义一个拦截器类&#xff0c;实现HandlerInterceptor接口 创建一个Interceptor类实现HandlerInterceptor接口&#xff0c;重写preHandle()&#xff0c;postHandle()&#xff0c;afterCompletion() 三个方法 如下代码&#xff0c;我们就创建了一个Spring的拦截器 /*** auth…

战神引擎传奇假设教程

战神引擎传奇假设教程 --------------------------------------------------------------------------------------------------- 传奇这款游戏可以说是一代人的回忆&#xff0c;特别是8090后&#xff0c;传奇对他们有着许许多多的难忘的回忆&#xff0c; 随着时代的发展&…

typora常用偏好设置

启用自动保存 关闭拼写检查 插入图片的设置 将图片保存在当前文件夹内 换行设置 关闭换行符的显示功能

LeetCode【155】最小栈

题目&#xff1a; 代码&#xff1a; class MinStack {Deque<Integer> xStack;Deque<Integer> minStack;public MinStack() {xStack new LinkedList<Integer>();minStack new LinkedList<Integer>();minStack.push(Integer.MAX_VALUE);}public voi…

Sub-1G射频收发器soc芯片 UM2080F32 低功耗 32 位 IoTP

UM2080F32是基于 ARM Cortex M0 内核的超低功耗、高性能的、单片集成 (G)FSK/OOK 无线收发机的 32 位SOC 芯片。 UM2080F32 工作于200MHz~960MHz 范围内&#xff0c;支持灵活可设的数据包格式&#xff0c;支持自动应答和自动重发功能&#xff0c;支持跳频操作&#xff0c;支持 …

48 路径总和 III

路经总和 III 题目规定了寻路方向&#xff08;不能折返&#xff0c;是单源向下探路&#xff0c;符合DFS&#xff09;模板1 题解1 DFS更好理解题意的版本 题解2 前缀和&#xff08;重点记忆&#xff09;前缀和 由根结点到当前结点的路径上所有节点的和(不含当前结点) 给定一个二…

面试官:谈谈 Go 内存逃逸机制

大家好&#xff0c;我是木川 一、概念 在一段程序中&#xff0c;每一个函数都会有自己的内存区域存放自己的局部变量、返回地址等&#xff0c;这些内存会由编译器在栈中进行分配&#xff0c;每一个函数都会分配一个栈桢&#xff0c;在函数运行结束后进行销毁&#xff0c;但是有…

【开发日记】Docker搭建Maven私服

文章目录 前言1、拉取镜像2、创建本地目录3、启动容器4、访问5、上传依赖6、项目配置私服 前言 Maven私服是一种特殊的远程仓库&#xff0c;它是架设在局域网内的仓库服务&#xff0c;用来代理位于外部的远程仓库&#xff08;中央仓库、其他远程公共仓库&#xff09;。 在公司…

操作系统实验一:计算机资源信 息分析(Windows 2学时)

一、实验目的 通过实验使学生进一步了解操作系统使用的计算机软硬件环境,掌握进程、线程、内存、文件等基本概念,获得某计算机中的软硬件资源信息。基本能达到下列具体的目标: 掌握获取的计算机硬件信息的方法。掌握获取计算机安装的操作系统信息的方法,分析安装的操作系统…

mybatis逆向工程

目录 第一章、mybatis逆向工程1.1&#xff09;Generator.xml配置文件1.2&#xff09;pom文件中添加mybatis代码自动生成插件1.3&#xff09;双击红色选中命令&#xff0c;生成相关文件</font>1.4&#xff09;成功生成mapper和model&#xff0c;加上注解 友情提醒 先看文…