h5内嵌h5

news/2024/11/19 9:30:57/

1.基本介绍:

用于某些打印环境

2.逻辑说明:

将h5内嵌在h5 ,利用v-html

3.具体实现:

      <div class="box" ref="content" @click="toPrint"><div v-html="html"></div></div>
    getHTML() {const info = this.dailyList;this.printList = this.dailyList.charges;this.printList = this.arrayChunk(this.printList, Math.ceil(this.printList.length / 1));function genderFilter(value) {if (value == 'M') return '男';else if (value == 'F') return '女';}console.log('打印列表=>', this.printList);let top = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title><style>body{padding: 0;margin: 0;font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","微软雅黑",Arial,sans-serif;}.tie{width: 1%;border-left: 2px dashed #000;border-right: 2px dashed #000;padding: 0 10px;margin-right: 10px;font-weight: bold;}#top{display: flex;flex-wrap: wrap;justify-content: space-between;border: 1px solid #000;}#top div{width: 24%;text-align: left;margin-bottom: 10px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;padding-left: 3px;}.container{max-width: 1920px;min-width: 1024px;text-align: center;margin: 0 auto;/*min-height: 100vh;*/font-size: 22px;}section{flex: 1;display: flex;}section .con{width: 99%;height:380px;overflow: auto;}.tabcon{display: flex;}header,section,footer{text-align: center;}header{/*display: flex;*/align-items: baseline;justify-content: center;text-align: center;}header .title {font-size: 30px;font-weight: 700;margin: 0 0 25px 0;}ul{display: flex;list-style: none;justify-content: flex-start;padding-left: 5px;}ul li{width: 20%;text-align: left;padding: 0 10px;}ul li span{display: inline-block;padding-left: 5px;}ul li p {display: inline-block;margin: 0;width: 80px;}.xiaoji {display: flex;justify-content: flex-end;width: 98.8%;border: 1px solid #000;padding-bottom: 5px;}.money {display: flex;justify-content: space-between;}.admin {/*display: flex;justify-content: flex-end;*/float:right;margin-top:10px;border:none}.admin div {margin-top: 5px;margin-right: 20px;}footer div div {/* width: 33.333333%; */margin-top: 5px;margin-right: 20px;}.table {width: 100%;text-align: center;font-size: 16px;}.table tr td {height: 20px;}/* table:nth-last-child(2) tr:nth-last-child(1) td:nth-last-child(1) {border-right: 1px solid #000;}table:nth-child(2) tr:nth-child(1) td:nth-child(4) {border-right: none;}table:nth-last-child(1) tr td:nth-last-child(1) {/* border-right: 1px solid #000;*/}table:nth-last-child(1) tr:nth-last-child(1) td:nth-last-child(n-4) {border-bottom: 1px solid #000;}table:nth-child(3) tr:nth-child(1) td:nth-last-child(n-4) {border-bottom: none;} */.textLeft {text-align: left;}.textRight {text-align: right;}.table tr th {padding: 7px 7px;height: 50px;font-size: 22px;}.table:nth-last-child(1) tr th:nth-last-child(1) {/* border-right: 1px solid #000;*/}.table tr td{padding: 5px 5px;word-wrap: break-word;}.table tbody tr:hover{background:#F2F6FC;}h2{letter-spacing:5px;margin-bottom: 0;}.zhenduan {display: flex;justify-content: space-between;border-left: 1px solid #000;border-right: 1px solid #000;}.zhenduan div {padding: 6px;}.loginTime,.userInfo{display:flex;justify-content: space-evenly;font-size:16px;margin: 10px 0;}.loginTime p, .userInfo p{text-align: left;margin: 0;width: 17%;}.item_name {font-weight: bold;}.disable{background-color:#ccc;// color:red}</style></head>`;let mid = `<body><div class="container"><header><div class="title">${this.hosName}病人费用住院清单</div></header><div class="loginTime"><p><span class="item_name">姓&emsp;&emsp;名:</span>${info.patient_name}</p><p><span class="item_name">年&emsp;&emsp;龄:</span>${info.age}</p><p><span class="item_name">性&emsp;&emsp;别:</span>${genderFilter(info.gender)}</p><p><span class="item_name">住&ensp;院&ensp;号:</span>${info.medical_no}</p><p><span class="item_name">床&emsp;&emsp;号:</span>${info.bed_no}号床</p></div><div class="userInfo"><p><span class="item_name">科&emsp;&emsp;室:</span>${info.in_dept}</p><p><span class="item_name">入院日期:</span>${this.$moment(info.in_date).format('YYYY-MM-DD')}</p><p><span class="item_name">住院天数:</span>${info.in_days}天</p><p><span class="item_name">出院日期:</span>${info.out_date || '暂无出院日期'}</p><p><span class="item_name">费用累计:</span>${moneyFormat(info.total_charge, 3)}</p></div><section><div class="con"><div class="tabcon">`;let mid2 = `${(() => {let result = '';this.printList.forEach((item) => {result += `<table border=1  class="table" width="100%" cellspacing="0" cellpadding="0" style="table-layout:fixed"><thead><tr><th>费用日期</th><th style="width: 30%;">项目名称</th><th>项目单价</th><th>项目数量</th><th>项目规格</th><th>项目金额</th></tr></thead><tbody>${(() => {let result = '';item.forEach((v, i) => {result += `<tr><td>${this.$moment(this.date).format('YYYY-MM-DD') || v.charge_time}</td><td>${v.item_name}</td><td>${moneyFormat(v.price)}</td><td>${this.$options.filters['countFormat'](v.quantity)}</td><td>${v.unit}</td><td>${moneyFormat(v.amount)}</td></tr>`;});return result;})(item)}</tbody></table></div></div></section>`;});return result;})()}`;let btn = `<div class="admin" ><button id='print' ref='print' :disabled="printDisabled" class="btn admin"}"  @click="goPrint">打印</button></div>`;let bot = `</div></div></body></html>`;let tmp = top + mid + mid2 + bot;// let tmp = top + mid + mid2 + btn + bot;this.html = tmp;// console.log(this.html);return tmp;},


http://www.ppmy.cn/news/161784.html

相关文章

html,h4,h5的区别,(转)H5和H4的对比听感

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 下午光顾了北京惠威体验店。入手X4&#xff0c;感觉非常excellent&#xff01;一直犹豫在H5和X4之间&#xff0c;是因为之前完全是通过网上的评测和其他发烧友的转述来对这两款箱子进行对比。直到今天了解庐山真面目后才有了分晓。…

H5Audio音频案例

效果图: 代码: html: <div class"audio-wrapper clearfix"> <audio src"../images/en_01.mp3" loop"loop" id"audio"> </audio> <div class"audio-left" id"audioPlayer"> <img cla…

HTML之H5

一、新增标签 1、网页结构语义化标签&#xff08;8个&#xff09;&#xff1a; header&#xff0c;用于展示介绍性内容或是辅助导航 nav&#xff0c;网页导航栏 section&#xff0c;类似于一篇文章独立的章节&#xff0c;是article的一部分&#xff08;个人理解&#xf…

微信H5支付(V3)

最近在做一个涉及支付的项目&#xff0c;其中对支付模块的内容涉及的比较多&#xff0c;记录一点心得。如果有错误&#xff0c;希望各位大佬斧正。 这个支付项目涉及H5端的微信支付、支付宝支付、建行支付、会员卡充值&#xff08;现金&#xff09;等四部分内容。我将在下面的…

微信支付之H5支付

先看下H5支付的官方描述吧&#xff1a; H5支付是指商户在微信客户端外的移动端网页展示商品或服务&#xff0c;用户在前述页面确认使用微信支付时&#xff0c;商户发起本服务呼起微信客户端进行支付。 主要用于触屏版的手机浏览器请求微信支付的场景。可以方便的从外部浏览器…

微信H5支付概述

最近有项目接入微信H5支付&#xff0c;所以在这里大概总结下。 首先&#xff0c;需要微信公众号是服务认证号&#xff0c;然后申请开通微信H5支付【微信H5支付申请由原来的微信公众号平台迁移到商户平台&#xff0c;需要在商户平台申请开通】&#xff0c;开通后会收到邮件&…

web:H5和小程序的区别

web&#xff1a;H5和小程序的区别 H5和小程序的区别 H5和小程序不具备可比性&#xff0c;只是很多移动端的场景下&#xff0c;两种选择都能实现产品的大部分功能。最近几年&#xff0c;小程序的兴起&#xff0c;让人们理解他等同于H5&#xff0c;其实不然。 关于小程序与H5&…

微信公众号h5页面支付(MWEB)

/*** 官微-分期支付接口(h5页面支付)** param request* param response*/SuppressWarnings("unchecked")ResponseBodyRequestMapping(value "/wxWapPrePayH5", method RequestMethod.POST)public Map<String, Object> wxWapPrePayH5(HttpServletRe…