首页 > 其他分享 >vue2 vue-print-nb

vue2 vue-print-nb

时间:2024-03-20 16:58:45浏览次数:17  
标签:none vue val bottom border nb print printData

一、安装插件

1、npm install vue-print-nb --save

二、引入Vue项目

在main.js中添加-- 全局挂载     import Print from 'vue-print-nb'     Vue.use(Print)

 三、前端代码

一、操作项中的打印按钮
<span title="打印"> <svg-icon icon-class="printer" class="svgicon" @click="showPrinterDialog(scope.row)" /> </span>
二、打印组件
  <!-- 打印内容 -->     <itemPrint :itemData="showPrinterParams.itemData" :showPrinterDialogClick="showPrinterParams.showPrinterDialogClick"></itemPrint>   三、参数定义   showPrinterParams: {         itemData: {},         showPrinterDialogClick: ''       }, 四、 打开打印页面     showPrinterDialog(row) {       this.showPrinterParams.itemData = row       this.showPrinterParams.showPrinterDialogClick = Math.random() + ''     } 五、引入打印组件 import itemPrint from '@/views/lawcase/task_manager/task_transfer/item_transfer_print'   components: {     itemPrint   },

四、打印页面代码

<template>
  <el-dialog width="60%"  :visible.sync="visible" >
    <div id="print-tag" >
      <!--标题 -->
      <h2 class="title"> 流转通知单</h2>
      <div class="timeShow">
        通知时间:<span class="space">    年    月    日 </span>
      </div>
      <div class="printCls">
        <div class="tableCls">
          <div>
            <div><span>原案件名称/编号</span> <span> {{ printData.original }} </span></div>
            <div><span>原移交单位</span> <span> {{printData.orgName}} </span></div>
            <div><span>流转去向</span> <span class="right-none"> {{printData.targetOrg}}</span></div>
          </div>
          <div>
            <div><span>现案件名称/编号</span> <span>{{printData.caseInfo}}</span></div>
            <div><span>流转方式</span> <span style="text-decoration:underline">随案移交 </span></div>
            <div><span>流转时间</span> <span  class="right-none">{{printData.changeTime}}</span></div>
          </div>
          <div>
            <div><span ><span class="itemTop">物品名称:{{printData.itemName}}</span></span> <span> <span class="itemTop">合计数量:{{printData.itemNum}}</span></span></div>
            <div><span>特征备注</span><span class="right-none"></span></div>
            <div><span class="right-none"></span> <span class="right-none"></span></div>
          </div>
          <div>
            <div><span>移交人</span>   <span></span></div>
            <div><span>移交时间</span>  <span></span></div>
            <div><span>联系电话</span>  <span  class="right-none"></span></div>
          </div>
          <div>
            <div><span>接收人</span>   <span></span></div>
            <div><span>接收时间</span>  <span></span></div>
            <div><span>联系电话</span>  <span  class="right-none"></span></div>
          </div>
          <div>
            <div><span class="vertical"><span class="itemTop">保管单位:</span></span> <span>负责人:</span></div>
            <div><span class="vertical">首次入库时间</span><span class="vertical"></span> </div>
            <div><span class="vertical">联系电话</span><span  class="right-none"></span></div>
          </div>
          <div>
            <div><span class="vertical"></span> <span class="bottom-none">经手人:</span></div>
            <div><span class="vertical"></span><span class="vertical"></span> </div>
            <div><span class="vertical"></span><span  class="right-bottom-none"></span></div>
          </div>
        </div>
      </div>
      <div class="printBottom">此通知单一式三份</div>
    </div>
    <div slot="footer">
      <el-button  @click="handleCancel"> 关闭 </el-button>
      <el-button type="primary"  @click="handlePrint" v-print="printContent"> 打印 </el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    itemData: {
      type: Object,
      default: {}
    },
    showPrinterDialogClick: {
      type: String,
      default: ''
    },
  },
  watch: {
    // 点击父组件储位时,显示选择储位
    showPrinterDialogClick(val) {
      this.visible = true
    },
    itemData(val) {
      this.printData = val
      let name = val.originalName;
      if(name !=null){
         // 原案件名称/编号
          this.printData.original =val.originalName+"/"+val.originalCode
          // 原单位
          this.printData.orgName = this.getDeptName(val.originalOrg)
          // 流转去向
          this.printData.targetOrg =this.getDeptName(val.orgUuid)
          // 案件名称/编号
          this.printData.caseInfo = val.caseName+"/"+val.caseCode
          this.printData.changeTime = this.$publicjs.fullDate(val.changeTime)
      }else{
          this.printData.original =val.caseName+"/"+val.caseCode
          // 原单位
          this.printData.orgName = this.getDeptName(val.orgUuid)
      }
    }
  },
  data() {
    return {
      visible:false,
      showTreeDialog: false,
      printData: {},
      printContent: {
        id: 'print-tag',
        // preview: true, // 预览工具是否启用
        // previewTitle: '储能服务费结算单', // 预览页面的标题
        popTitle: '通知单', // 打印页面的页眉
        extraCss: "https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.compat.css, https://cdn.bootcdn.net/ajax/libs/hover.css/2.3.1/css/hover-min.css",
        extraHead: '<meta http-equiv="Content-Language"content="zh-cn"/>',
        previewBeforeOpenCallback() {},
        previewOpenCallback() {},
        beforeOpenCallback(vue) {
          vue.printLoading= true;
        },
        openCallback(vue) {
          vue.printLoading=false
        },
        closeCallback() {},
        clickMounted(vue) {}
      },
    }
  },
  methods: {
     handlePrint(){

     },
     // 关闭
     handleCancel(){
       this.visible = false;
     },
     // 根据组织编号得到组织名称
     getDeptName(id) {
      return this.$publicjs.getDeptName(id);
     },
  }
}
</script>
<style lang="less" scoped>
.title{
  text-align:center;
  margin-bottom:5px;
}
.timeShow{
  margin-left:10px;
}
// 年月日的空格
.space{
  word-spacing:40px;
}
.itemTop{
 margin-left:-20px; 
}
.printCls{
  border:1px solid #999;
  }
  .tableCls{
    & > div{
      display:flex;
      & > div{
        flex: 1;
        display: flex;
        & > span {
          flex:1;
          padding:25px;
          border: 1px solid #999;
          border-top:none;
          border-left: none;
        }
        .right-none{
          border-right: none;
        }
        .right-bottom-none{
          border-right: none;
          border-bottom: none;
        }
        .bottom-none{
          border-bottom: none;
        }
        .style-none{
          border-right: none;
          border-left: none;
        }
        .vertical{
          border-top:none;
          border-bottom: none;
        }
      }
    }
  }
  .printBottom{
    text-align:center;
    margin-top:10px;
  }
</style>

六、结果展示

 

标签:none,vue,val,bottom,border,nb,print,printData
From: https://www.cnblogs.com/flyShare/p/18085561

相关文章

  • pinia——vue3的状态管理工具
    简介Pinia是Vue的专属状态管理库,它允许你跨组件或页面共享状态。主要优点Vue2和Vue3都支持,这让我们同时使用Vue2和Vue3的小伙伴都能很快上手。pinia中只有state、getter、action,抛弃了Vuex中的Mutation,Vuex中mutation一直都不太受小伙伴们的待见,pinia直接抛弃它了,这无疑......
  • VsCode中高效书写Vue3代码的插件
    Vue-Official(原Volar)就是原先的Volar,现已弃用。Vue-Official提供的功能:语法高亮:Vue-Official扩展可以为Vue单文件组件(.vue文件)中的HTML、CSS和JavaScript部分提供语法高亮,使代码更易于阅读和编写。代码片段:Vue-Official扩展提供了丰富的Vue.js相关的......
  • 【Vue3】组件通信以及各种方式的对比
    方式一:props「父」向「子」组件发送数据父组件:定义需要传递给子组件的数据,并使用v-bind指令将其绑定到子组件的props上。<template><child-component:message="parentMessage"/></template><scriptsetup>importChildComponentfrom'./ChildComponent.......
  • vue3 项目接入keycloak
    之前都是vue2项目接入keycloak,网上表较多资料参考,vue3得比较少记录一下。这个前端项目是jetlinks社区版。引入了 dsb-norge/vue-keycloak-js插件, https://github.com/dsb-norge/vue-keycloak-js,还是要看官方得文档、示例。1.官方提供得示例比较全,我需要得是vue3typescri......
  • vue的vite、vue-cli、create-vue的区别
     脚手架:创建项目,选择性安装需要的插件,指定统一的风格,生成demo。构建项目:建立项目的运行环境,需要手动安装插件。 vue-cli【官网:https://cli.vuejs.org/zh/index.html】VueCLI的包名称由vue-cli改成了@vue/clivue-cli是Vue早期推出的一款脚手架,使用webpack......
  • 基于Java的校园电商物流云平台(Vue.js+SpringBoot)
    目录一、摘要1.1项目介绍1.2项目录屏二、功能模块2.1数据中心模块2.2商品数据模块2.3快递公司模块2.4物流订单模块三、系统设计3.1用例设计3.2数据库设计3.2.1商品表3.2.2快递公司表3.2.3物流订单表四、系统展示五、核心代码5.1查询商品5.2查询快递公......
  • 基于Java的医院门诊预约挂号系统(Vue.js+SpringBoot)
    目录一、摘要1.1项目介绍1.2项目录屏二、功能模块2.1功能性需求2.1.1数据中心模块2.1.2科室医生档案模块2.1.3预约挂号模块2.1.4医院时政模块2.2可行性分析2.2.1可靠性2.2.2易用性2.2.3维护性三、数据库设计3.1用户表3.2科室档案表3.3医生档案表3.4......
  • 基于Java的考研专业课程管理系统(Vue.js+SpringBoot)
    目录一、摘要1.1项目介绍1.2项目录屏二、功能模块2.1数据中心模块2.2考研高校模块2.3高校教师管理模块2.4考研专业模块2.5考研政策模块三、系统设计3.1用例设计3.2数据库设计3.2.1考研高校表3.2.2高校教师表3.2.3考研专业表3.2.4考研政策表四、系统展......
  • java毕设安卓基于vue的历史博物馆APP(开题+源码)
    本系统(程序+源码)带文档lw万字以上 文末可获取一份本项目的java源码和数据库参考。系统程序文件列表开题报告内容研究背景随着信息技术的飞速发展,移动互联网已经成为现代人生活不可或缺的一部分。智能手机普及率的提升,使得移动应用(APP)成为连接用户与服务的重要桥梁。历史......
  • JAVA实战开源项目:高校大学生创业管理系统(Vue+SpringBoot)
    目录一、摘要1.1项目介绍1.2项目录屏二、功能模块2.1系统公告模块2.2创业项目模块2.3创业社团模块2.4政府政策模块2.5创业比赛模块三、系统设计3.1用例设计3.2数据库设计3.2.1系统公告表3.2.2创业项目表3.2.3创业社团表3.2.4政策表四、系统展示五、核......