这个问题该怎么办?求解决
该如何解决呢? 该怎么解决呢?<div><br></div> 大概原因是什么呢? 有没有人在 这种大概是什么类型的问题<div><br></div> 请贴出你的打印js代码,或者 ,演示页面,我们这边帮你测一下! 好的,稍后<div><br></div>这是打印的代码
<template><div>
<div
id="time"
style="
width: 100%;
height: 100%;
background-color: white;
color: black;
font: 50px bolder '微软雅黑';
margin: auto;
text-align: center;
z-index: 1;
"
>
{{ nowDate }}
</div>
<div
id="num"
style="
width: 100%;
height: 100%;
background-color: white;
color: black;
font: 50px bolder '微软雅黑';
margin: auto;
text-align: center;
z-index: 1;
"
>
距离下次打印还有:{{ time }}秒
</div>
<div
id="warn"
style="
width: 100%;
height: 100%;
background-color: white;
color: red;
font: 50px bolder '微软雅黑';
margin: auto;
text-align: center;
z-index: 1;
"
>
(物流平台)此页面不可以关闭,顺丰快递单打印中.......
</div>
<div
style="
width: 100%;
height: 100%;
background-color: white;
color: green;
font: 50px bolder '微软雅黑';
margin: auto;
text-align: center;
z-index: 1;
"
>
<span style="font-size: 30px"
>温馨提示:系统待打印顺丰快递面单数:{{ testone }}
<input
type="text"
id="expressNumber"
value=""
readonly="readonly"
style="width: 60px; font-size: 22px; border: none; outline: none"
/></span>
</div>
<div
id="page1"
style="
width: 100%;
height: 100%;
background-color: white;
color: black;
margin: auto;
text-align: center;
z-index: 1;
"
>
<img :src="userAvatarSrc" width="368" height="552" />
</div>
<!-- <img src="src/assets/123.jpg" alt=""> -->
</div>
</template>
<script >
import Axios from 'axios'
// import {getJCP} from '../../utils/jcpfree.js';
import { getJCP } from '../../utils/jcp-vue1.js'
// import api from '@common/api'
// import test from '../../common/test'
// import api from '../../common/myapi'
export default {
data() {
return {
nowDate: '',
time: 5,
url1: 'http://10.10.100.61:8080/jeecg-boot/sf/logisticsSignMessage/autoPrintSF',
url2: 'http://10.10.100.61:8080/jeecg-boot/sf/logisticsSignMessage/updataStatus',
url3: 'http://10.10.100.61:8080/jeecg-boot/sf/logisticsSignMessage/getExpressNumber',
// url1: 'http://v3642d0100.zicp.vip/jeecg-boot/sf/logisticsSignMessage/autoPrintSF',
// url2: 'http://v3642d0100.zicp.vip/jeecg-boot/sf/logisticsSignMessage/updataStatus',
// url3: 'http://v3642d0100.zicp.vip/jeecg-boot/sf/logisticsSignMessage/getExpressNumber',
time1: null,
time2: null,
flag: false,
testone: 0,
datas: '',
userAvatarSrc: '',
how: '无对话框直接打印',
expressNo: '',
}
},
methods: {
// 设置页面倒计时--3
countDown() {
// this.time;
if (this.time > 0) {
this.time = this.time - 1
if (this.time == 0) {
this.autoPrint()
// this.doPrint()
// this.updatestatus()
}
if (this.time == 4) {
this.getExpressNumber()
// this.expressDocument();
}
} else {
this.time = 5 //倒计时为0进入的页面
}
},
doPrint123() {
this.doPrint()
this.getExpressNumber()
//打印完之后统计未打印面单书,并在页面上进行展示。
this.updatestatus()
},
//打印
doPrint() {
const my = this
console.log(this.flag)
if (this.flag) {
console.log('----------------expressNo------------------')
console.log(my.expressNo)
if (my.expressNo != null && my.expressNo != '') {
var printer = 'SF'
var myDoc = {
settings: {
printer: printer, // 设置选中的打印机
},
documents: document, // 打印页面(div)们在本文档中
copyrights: '杰创软件拥有版权 [url]www.jatools.com[/url]', // 版权声明必须
}
//设置打印边距
myDoc.settings.marginRight = 1
myDoc.settings.marginLeft = 1
myDoc.settings.marginBottom = 1
myDoc.settings.marginTop = 1
var jcp = getJCP()
console.log('-------jcp-----')
console.log(jcp)
// 调用打印方法
jcp.print(myDoc, false) // 不弹出对话框打印
// if (this.how == '打印预览'){
// jcp.printPreview(myDoc, false);
// }else if (this.how == '弹出打印机选择对话框打印') {
// jcp.print(myDoc, true);
// } else{
// }
//打印完毕之后清除打印文档。
this.userAvatarSrc = ''
}
}else{
window.reload();
}
},
updatestatus() {
Axios({
method: 'post',
// url: api.updataStatus,
url: this.url2,
params: {
expressNo: this.expressNo,
},
})
.then((res) => {
// this.list1 = res.data.data.recordes;
if ('OK' == res.data) {
console.log('修改订单状态成功' + expressNo)
}
})
},
getversion() {
const my = this
getJCP().getVersion(function (result) {
if (my.time1 == null) {
// 倒计时
my.time1 = setInterval(my.countDown, 1000)
}
if (result != null && result != '' && result != undefined) {
my.flag = true
// this.time2= setInterval(my.doPrint, 3000);
setTimeout(my.doPrint123, 3000)
}else{
window.reload();
}
})
},
autoPrint() {
var datas
//该URL表示去查找快递订单表中 快寄状态为0快递公司为顺丰的所有快递单号。 返回快递单号字符串
Axios({
method: 'post',
// url: api.autoPrintSF,
url: this.url1,
params: {},
})
.then((res) => {
// this.list1 = res.data.data.recordes;
if (res.data == '' || res.data == null || res.data == '""') {
return false
} else {
//取掉快寄订单串首尾端的双引号
this.datas = res.data
if (this.datas != null && this.datas != '') {
// this.userAvatarSrc="src/assets/123.jpg"
this.userAvatarSrc = this.datas.pictureAddress
if (this.userAvatarSrc != null) {
console.log('打印订单数')
this.expressNo = this.datas.mailNumber
this.getversion()
}
} else {
this.userAvatarSrc = ''
return false
}
}
})
.catch(() => {
console.log('超过时间没有响应,清空页面')
this.userAvatarSrc = ''
})
},
getExpressNumber() {
Axios({
method: 'post',
// url: api.getExpressNumber,
url: this.url3,
params: {},
}).then((res) => {
this.testone = res.data
})
},
currentTime() {
setInterval(this.formatDate, 500)
},
formatDate() {
let date = new Date()
let year = date.getFullYear() // 年
let month = date.getMonth() + 1 // 月
let day = date.getDate() // 日
let week = date.getDay() // 星期
let weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
let hour = date.getHours() // 时
hour = hour < 10 ? '0' + hour : hour // 如果只有一位,则前面补零
let minute = date.getMinutes() // 分
minute = minute < 10 ? '0' + minute : minute // 如果只有一位,则前面补零
let second = date.getSeconds() // 秒
second = second < 10 ? '0' + second : second // 如果只有一位,则前面补零
this.nowDate = `${year}/${month}/${day} ${hour}:${minute}:${second} ${weekArr[week]}`
},
},
mounted() {
this.getExpressNumber()
this.getversion()
//客户端关闭页面时做到提示功能。
window.onbeforeunload = function (e) {
e = e || window.event
// 兼容IE8和Firefox 4之前的版本
if (e) {
e.returnValue = '亲:打印正在进行中,请勿关闭此页面!'
}
// Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
return '亲:打印正在进行中,请勿关闭此页面!'
}
//页面入口--1
this.currentTime()
},
beforeDestroy() {
if (this.formatDate) {
clearInterval(this.formatDate) // 在Vue实例销毁前,清除我们的定时器
}
clearInterval(this.time1)
this.time1 = null
},
}
</script>
<style>
</style>
在压缩包里面
在压缩包里面 请与我们客服联系,QQ:1020527890页:
[1]