This commit is contained in:
liuyp 2024-05-29 21:26:31 +08:00
commit bd4e0b4c10
7 changed files with 209 additions and 171 deletions

View File

@ -98,6 +98,7 @@
"vue-meta": "2.4.0",
"vue-okr-tree": "^1.0.17",
"vue-pdf": "^4.2.0",
"vue-pdf-signature": "^4.2.7",
"vue-print-nb": "^1.7.5",
"vue-property-decorator": "^9.1.2",
"vue-router": "3.4.9",

View File

@ -9,14 +9,14 @@ export function listEmisWaybill(query) {
})
}
// 查询运单列表详细
export function getInfoByBillCode(billCode) {
return request({
url: '/emis/emisWaybill/getInfoByBillCode',
method: 'get',
params: {billCode: billCode}
})
}
// 查询运单详细
// export function getInfoByBillCode(billCode) {
// return request({
// url: '/emis/emisWaybill/getInfoByBillCode',
// method: 'get',
// params: {billCode: billCode}
// })
// }
export function getWaybillDetail(billCode) {
return request({

View File

@ -1,89 +1,13 @@
<template>
<div id="container">
<div class="tools">
<!-- <el-button type="text" @click="FirstPage()">
<el-tooltip class="item" effect="light" content="第一页" placement="top">
<i class="el-icon-d-arrow-left"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="changePdfPage(0)">
<el-tooltip class="item" effect="light" content="上一页" placement="top">
<i class="el-icon-arrow-left"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="changePdfPage(1)">
<el-tooltip class="item" effect="light" content="下一页" placement="top">
<i class="el-icon-arrow-right"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="lastPage()">
<el-tooltip class="item" effect="light" content="最后一页" placement="top">
<i class="el-icon-d-arrow-right"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="setIsExit()" v-show="!isExit" style="margin-right:10px;">
<el-tooltip class="item" effect="light" content="页码选择" placement="top">
<i class="el-icon-setting"></i>
</el-tooltip>
</el-button>
<el-tooltip class="item" effect="light" content="页码选择" placement="top" v-show="isExit">
<el-select v-model="value" placeholder="请选择" @change="pageSelect" size="mini">
<el-option v-for="item in pageCount" :key="item" :label="'第 '+item+' 页'" :value="item"></el-option>
</el-select>
</el-tooltip>
<el-button type="text" @click="scaleD()">
<el-tooltip class="item" effect="light" content="放大" placement="top">
<i class="el-icon-zoom-in"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="scaleX()">
<el-tooltip class="item" effect="light" content="缩小" placement="top">
<i class="el-icon-zoom-out"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="clock()">
<el-tooltip class="item" effect="light" content="顺时针旋转" placement="top">
<i class="el-icon-refresh-right"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="counterClock()">
<el-tooltip class="item" effect="light" content="逆时针旋转" placement="top">
<i class="el-icon-refresh-left"></i>
</el-tooltip>
</el-button> -->
<div style="width:100%;text-align: right;">
<el-button type="text" @click="downPDF">
<el-tooltip class="item" effect="light" content="下载" placement="top">
<i class="el-icon-download"></i>
</el-tooltip>
</el-button>
<el-button type="text" @click="printPDF">
<el-tooltip class="item" effect="light" content="打印" placement="top">
<i class="el-icon-printer"></i>
</el-tooltip>
</el-button>
<el-button title="下载" type="primary" icon="el-icon-download" @click="downPDF">下载</el-button>
<el-button title="打印" type="primary" icon="el-icon-printer" @click="printPDF">打印</el-button>
</div>
<!-- <p class="total">
<el-tooltip class="item" effect="light" content="当前页" placement="top">
<b style="color:#F56C6C;cursor:pointer;">{{ currentPage }}</b> </el-tooltip>&nbsp;/&nbsp;
<el-tooltip class="item" effect="light" content="总页数" placement="top">
<b style="color:#67C23A;cursor:pointer;">{{ pageCount }}</b></el-tooltip>
</p> -->
</div>
<div class="main">
<div class="pdfview">
<pdf
v-for="i in pageCount" :key="i"
ref="pdf" id="pdf"
:page="i"
:src="pdfLoadUrl"
style="width: 100%;margin-bottom: 10px;"
@num-pages="currentPage=$event">
</pdf>
</div>
<!-- <pdf ref="pdf" id="pdf" :src="src" :page="currentPage" :rotate="pageRotate" @num-pages="pageCount = $event" @page-loaded="currentPage = $event" @loaded="loadPdfHandler"></pdf> -->
<iframe style="width: 100%; height: 100%;" :src="pdfLoadUrl" frameborder="0"></iframe>
</div>
</div>
</template>
@ -126,7 +50,9 @@ export default {
pdfUrl(newVal) {
console.log(this.pdfUrl)
if(this.pdfUrl){
this.src=this.pdfUrl;
// this.src=this.pdfUrl;
this.pdfLoadUrl='/static/pdfjs/4.2.67/web/viewer.html?file=' + encodeURIComponent(this.pdfUrl)
console.log(this.pdfLoadUrl)
}
},
},
@ -253,9 +179,10 @@ export default {
.tools {
display: flex;
background: #e1e1e1;
width: 100%;
z-index:9999;
z-index: 9999;
position: absolute;
top: 20px;
right: 30px;
}
.total {

View File

@ -64,6 +64,12 @@ class TanexPrinterSdk {
// 默认打印机
defaultPrinter = null;
defaultTplCode = null;
isSendSetToken=false;
isSendGetTpl=false;
isSendGetPrinter=false;
// 标识:是否连接成功 , 记录重试的次数,重新连接尝试的次数
connected = false;
printerIsRead = false;
@ -130,29 +136,13 @@ class TanexPrinterSdk {
return this.defaultPrinter;
}
// 获取pdf链接
getPdfUrl(ydSn,tplName,printerName){
return this.HTTP_GET_PDF + '?ydSn=' + ydSn+"&tplName="+tplName+"&printerName="+printerName;
}
// 下载PDF文件
// downPdfFile(ydSn,tplName,printerName){
// let link = document.createElement('a');
// link.style.display = 'none';
// link.href = this.HTTP_GET_PDF + '?ydSn=' + ydSn+"&tplName="+tplName+"&printerName="+printerName;
// // window.open(link.href, '_blank');
// document.body.appendChild(link);
// link.click();
// }
// 批量获取PDF文件
batchGetPDF(tplName,printerName,orderList,callback){
if(tplName&&printerName&&orderList&&orderList.length>0){
batchGetPDF(tplCode,printerName,orderList,callback){
if(tplCode&&printerName&&orderList&&orderList.length>0){
this.setOnBatchGetPDF(callback);
// 超时计算
this.sendBatchGetPDFCMD(tplName,printerName,orderList);
this.sendBatchGetPDFCMD(tplCode,printerName,orderList);
this.recievePdfFileTimer = setTimeout(function(){
if(this.onBatchGetPDFCallback){
if(this.onBatchGetPDFCallback.length>0){
@ -170,19 +160,30 @@ class TanexPrinterSdk {
}
}
// 批量打印
batchPrint(tplName,printerName,orderList){
if(tplName&&printerName&&orderList&&orderList.length>0){
this.sendBatchPrintCMD(tplName,printerName,orderList);
batchPrint(tplCode,printerName,orderList){
if(tplCode&&printerName&&orderList&&orderList.length>0){
this.sendBatchPrintCMD(tplCode,printerName,orderList);
}
}
refreshPrintTpl(){
this.sendRefreshPrintTplListCMD();
}
getRequestId() {
let requestId = 'req' + new Date().getTime().toString(36) + Math.random().toString(36).substring(2, 9);
return requestId;
}
//--内部方法--------------------------------------------------------------
sendSetTokenCMD(){
// if(this.isSendSetToken){
// return;
// }
// {"CMD":"setToken","status":"1","Data":"token"}
var printCmd={};
printCmd['RequestId']=this.getRequestId();
printCmd['CMD']="setToken";
printCmd['Status']="1";
printCmd['Data']=getToken();
@ -190,14 +191,15 @@ class TanexPrinterSdk {
this.send(JSON.stringify(printCmd),null);
}
sendBatchPrintCMD(tplName,printerName,orderList){
sendBatchPrintCMD(tplCode,printerName,orderList){
// {"CMD":"batchPrint","status":"1","Data":["DT20210901001","DT20210901002"]}
var printCmd={};
printCmd['RequestId']=this.getRequestId();
printCmd['CMD']="batchPrint";
printCmd['Status']="1";
if(orderList!=null && orderList.length>0){
let printData={
"tplName":tplName,
"tplCode":tplCode,
"printerName":printerName,
"orderList":orderList.toString()
}
@ -207,14 +209,15 @@ class TanexPrinterSdk {
}
}
sendBatchGetPDFCMD(tplName,printerName,orderList){
sendBatchGetPDFCMD(tplCode,printerName,orderList){
// {"CMD":"batchGetPDF","status":"1","Data":["DT20210901001","DT20210901002"]}
var printCmd={};
printCmd['RequestId']=this.getRequestId();
printCmd['CMD']="batchGetPDF";
printCmd['Status']="1";
if(orderList!=null && orderList.length>0){
let printData={
"tplName":tplName,
"tplCode":tplCode,
"printerName":printerName,
"orderList":orderList.toString()
}
@ -230,7 +233,13 @@ class TanexPrinterSdk {
sendGetPrinterListCMD(){
// {"CMD":"getPrinterList","status":"1","Data":""}
// if(this.isSendGetPrinter){
// return;
// }
var printCmd={};
printCmd['RequestId']=this.getRequestId();
printCmd['CMD']="getPrinterList";
printCmd['Status']="1";
printCmd['Data']="";
@ -239,8 +248,12 @@ class TanexPrinterSdk {
}
sendGetPrintTplListCMD(){
// if(this.isSendGetTpl){
// return;
// }
// {"CMD":"getPrintTplList","status":"1","Data":""}
var printCmd={};
printCmd['RequestId']=this.getRequestId();
printCmd['CMD']="getPrintTplList";
printCmd['Status']="1";
printCmd['Data']="";
@ -248,12 +261,23 @@ class TanexPrinterSdk {
this.send(JSON.stringify(printCmd),null);
}
sendRefreshPrintTplListCMD(){
// {"CMD":"getPrintTplList","status":"1","Data":"reInit"}
var printCmd={};
printCmd['RequestId']=this.getRequestId();
printCmd['CMD']="getPrintTplList";
printCmd['Status']="1";
printCmd['Data']="reInit";
// console.log(JSON.stringify(printCmd));
this.send(JSON.stringify(printCmd),null);
}
// 连接服务器的方法
connect() {
// 连接服务器
if (!window.WebSocket) {
// console.log('您的浏览器不支持WebSocket');
console.log('您的浏览器不支持WebSocket');
return null;
}
@ -300,6 +324,10 @@ class TanexPrinterSdk {
this.connected = false;
this.connectRetryCount++;
if(this.connectRetryCount>120){
this.connectRetryCount=0;
}
if(this.onCloseCallback.length>0){
this.onCloseCallback.forEach(callback=>{
if(callback!=null){
@ -307,10 +335,11 @@ class TanexPrinterSdk {
}
})
}
// * this.connectRetryCount
setTimeout(() => {
this.connect()
}, 500 * this.connectRetryCount)
}, 1000 )
};
this.ws.onmessage = e => {
@ -374,6 +403,10 @@ class TanexPrinterSdk {
innerGetPrinterList(msg){
// console.log("innerGetPrinterList")
this.isSendGetPrinter=true;
if(msg){
this.printerList=[];
// console.log(msg);
@ -391,22 +424,21 @@ class TanexPrinterSdk {
innerGetPrintTplList(msg){
// console.log("innerGetPrintTplList")
this.isSendGetTpl=false;
if(msg){
this.printTplList=[];
msg.Data.tplList.forEach(item=>{
let optionItem={
label:item,
value:item
}
this.printTplList.push(optionItem);
this.selTplName=this.printTplList[0].value;
this.printTplList.push(item);
this.defaultTplCode=this.printTplList[0].tplCode;
})
}
}
innerBatchGetPDF(msg){
// console.log("innerBatchGetPDF")
// console.log(msg)
// 有出错,停止接收数据
if(msg.Status!='2'){
clearTimeout(this.recievePdfFileTimer);
@ -462,9 +494,6 @@ class TanexPrinterSdk {
}
jsonToObj(json){
return JSON.parse(json)
}
@ -487,6 +516,7 @@ class TanexPrinterSdk {
// 发送数据的方法
send(data) {
console.log("send:"+data)
if (this.getWSReadyState() === this.WS_OPEN ) {
this.sendRetryCount = 0
this.ws.send(data)
@ -512,7 +542,7 @@ class TanexPrinterSdk {
// this.ws.ping();
this.ws.send(0x9);
}
}, 10000);
}, 1000);
}
}

View File

@ -11,15 +11,28 @@
<div v-if="printerStatus==1" style="display: inline-flex;">
<div style="font-size: 12px; line-height: 28px;font-weight: 600;">模板:</div>
<div>
<el-select v-model="selTplName" size="mini" placeholder="选择打印模板" clearable filterable>
<el-select v-model="selTplCode" size="mini" placeholder="选择打印模板" clearable filterable>
<template slot="prefix">
<span style="padding: 5px;line-height: 28px;font-size: 16px;color: rgb(111 111 111);cursor: pointer;" @click="refreshPrintTpl()">
<i class="el-icon-refresh"></i>
</span>
</template>
<el-option
v-for="item in printTplList"
:key="item.value"
:label="item.label"
:value="item.value"
:key="item.tplCode"
:label="item.tplName"
:value="item.tplCode"
/>
</el-select>
</div>
<div v-if="selTplCode=='TAN-GC-130'" class="subBillRange" style="display: inline-flex;font-size: 12px; line-height: 28px; font-weight: 600;">
<span >子单:
<el-input size="mini" style="width:40px" v-model="subBillStart" type="text" maxlength="4" ></el-input>
-
<el-input size="mini" style="width:40px" v-model="subBillEnd" type="text" maxlength="4" ></el-input>
</span>
</div>
<div style="font-size: 12px;line-height: 28px;font-weight: 600;">打印机:</div>
<div>
<el-select v-model="selPrinterName" size="mini" placeholder="打印机" clearable filterable>
@ -40,10 +53,10 @@
</div>
</div>
<el-dialog class="printPreDialog" title="预览" :visible.sync="openPdfView" width="70%" :close-on-click-modal="false" v-dialogDrag append-to-body>
<div style="height: 800px;width:100%;overflow: auto;">
<PdfViewer :pdfUrl="pdfUrl" style="width:100%" @onPrint="batchPrint" ></PdfViewer>
</div>
<el-dialog class="printPreDialog" title="预览" :visible.sync="openPdfView" width="95%" :close-on-click-modal="false" v-dialogDrag append-to-body>
<div style="height: 1600px;width:100%;overflow: auto;">
<PdfViewer :pdfUrl="pdfUrl" style="width:100%" @onPrint="batchPrint" ></PdfViewer>
</div>
</el-dialog>
</div>
@ -74,7 +87,8 @@
data() {
return {
svalue: this.value,
subBillStart:1,
subBillEnd:1,
openPdfView:false,
pdfUrl:null,
@ -89,7 +103,7 @@
printerList:[],
printTplList:[],
selTplName:null,
selTplCode:null,
selPrinterName:null,
currentSelection:[],
@ -148,26 +162,74 @@
},
onGetPrintTpl(msg){
// console.log("onGetPrintTpl")
this.printTplList=[];
this.printTplList=this.tanexPrinter.getPrintTplList();
this.selTplName=this.printTplList[0].value;
// console.log(this.printTplList)
this.selTplCode=this.printTplList[0].tplCode;
},
refreshPrintTpl(){
this.printTplList=[];
this.selTplCode=null;
this.tanexPrinter.refreshPrintTpl()
},
lpadZero(val,len) {
return (new Array(len + 1).join('0') + val).slice(-len);
},
batchPrint(orderList){
let that = this;
let newOrderList=[];
if(orderList){
this.orderList=[...orderList]
}
this.tanexPrinter.batchPrint(that.selTplName,that.selPrinterName,that.orderList)
// 打印子单
if(this.selTplCode=="TAN-GC-130"){
for(let i=0;i<this.orderList.length;i++){
let billCode=this.orderList[i];
// 循环子单范围
for(let i=this.subBillStart;i<=this.subBillEnd;i++){
let subBillCode = billCode+""+this.lpadZero(i,4);
newOrderList.push(subBillCode);
}
}
}else{
newOrderList=[...orderList];
}
that.tanexPrinter.batchPrint(that.selTplCode,that.selPrinterName,newOrderList)
},
printPreview(orderList){
let that =this;
let that = this;
let newOrderList=[];
if(orderList){
this.orderList=[...orderList]
}
// 打印子单
if(this.selTplCode=="TAN-GC-130"){
for(let i=0;i<this.orderList.length;i++){
let billCode=this.orderList[i];
// 循环子单范围
for(let i=this.subBillStart;i<=this.subBillEnd;i++){
let subBillCode = billCode+""+this.lpadZero(i,4);
newOrderList.push(subBillCode);
}
}
}else{
newOrderList=[...orderList];
}
const loadingInstance = this.$loading({
text: '正在生成预览...'
})
this.tanexPrinter.batchGetPDF(this.selTplName,this.selPrinterName,this.orderList,function(pdfList,success,erroMsg){
this.tanexPrinter.batchGetPDF(this.selTplCode,this.selPrinterName,newOrderList,function(pdfList,success,erroMsg){
// console.log(erroMsg);
if(success){
const pdfDataList=[...pdfList];
@ -179,7 +241,7 @@
that.openPdfView = true;
})
.catch(error => {
console.log(error)
// console.log(error)
that.$modal.msgError("打印出错:"+erroMsg);
});
}else{
@ -188,15 +250,30 @@
});
},
downPDF(orderList){
let that =this;
let that = this;
let newOrderList=[];
if(orderList){
this.orderList=[...orderList]
}
// 打印子单
if(this.selTplCode=="TAN-GC-130"){
for(let i=0;i<this.orderList.length;i++){
let billCode=this.orderList[i];
// 循环子单范围
for(let i=this.subBillStart;i<=this.subBillEnd;i++){
let subBillCode = billCode+""+this.lpadZero(i,4);
newOrderList.push(subBillCode);
}
}
}else{
newOrderList=[...orderList];
}
const loadingInstance = this.$loading({
text: '正在下载...'
})
this.tanexPrinter.batchGetPDF(this.selTplName,this.selPrinterName,orderList,function(pdfList,success,erroMsg){
this.tanexPrinter.batchGetPDF(this.selTplCode,this.selPrinterName,newOrderList,function(pdfList,success,erroMsg){
loadingInstance.close();
if(success){
const pdfDataList=[...pdfList];
@ -205,7 +282,7 @@
}else{
that.$modal.msgError("下载出错:"+erroMsg);
}
});
});
},
}
@ -218,5 +295,10 @@
margin: 0px!important;
}
.subBillRange .el-input__inner {
padding:0px;
text-align: center;
}
</style>

View File

@ -1,6 +1,6 @@
<template>
<div class="app-container">
<SearchForm :model="queryParams" ref="queryForm" size="mini" :maxShow="8" label-width="100px" v-show="showSearch" @search="handleQuery" @reset="resetQuery">
<XdPageContainer class="app-container">
<SearchForm slot="pageHeader" :model="queryParams" ref="queryForm" size="mini" :maxShow="8" label-width="100px" v-show="showSearch" @search="handleQuery" @reset="resetQuery">
<el-form-item label="" prop="billCode">
<div slot="label">
<el-radio-group class="query-label" v-model="queryOrderType">
@ -197,7 +197,12 @@
</SearchForm>
<XdTable v-loading="loading"
<XdTable
slot="pageContent"
slot-scope="slotProps"
:height="(slotProps.contentHeight)+'px'"
v-loading="loading"
border stripe
size="small"
:data="emisWaybillList"
@ -207,7 +212,6 @@
@queryTable="getList"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
v-if="tableHeight" :max-height="tableHeight + 'px'"
>
<div slot="toolbar">
@ -472,7 +476,7 @@
-->
</div>
</XdPageContainer>
</template>
<script>
@ -741,14 +745,6 @@ export default {
this.getList();
this.queryOrderType="1";
// this.initTanexPrinterSdk();
// 调整表格的高度,不允许滚动
this.$nextTick(function() {
let queryFormEl = this.$refs.queryForm.$el;
let tableH = queryFormEl.offsetHeight+190;
this.tableHeight = window.innerHeight - tableH;
});
},
methods: {

View File

@ -189,7 +189,9 @@
<script>
import { addEmisWaybillProblemInfo,listEmisWaybillProblemInfo } from "@/api/emis/emisWaybillProblemInfo";
import { doScan } from "@/api/emis/emisTmsScanRecord";
import { listEmisWaybill } from "@/api/emis/emisWaybill";
// import { listEmisWaybill } from "@/api/emis/emisWaybill";
import { getWaybillDetail } from "@/api/emis/emisWaybill";
import EmisSiteSimplePicker from '@/views/emis/EmisBaseTools/EmisSiteSimplePicker.vue';
import ProblemTypePicker from '@/views/emis/EmisBaseTools/ProblemTypePicker.vue';
@ -343,15 +345,15 @@ export default {
this.$message.error("输入单号后回车");
return;
}
if(this.form.notifySite==null || this.form.notifySite==''){
this.$message.error("请选择通知网点");
return;
}
// if(this.form.notifySite==null || this.form.notifySite==''){
// this.$message.error("请选择通知网点");
// return;
// }
if(this.form.problemType==null || this.form.problemType==''){
this.$message.error("请选择问题类型");
return;
}
// if(this.form.problemType==null || this.form.problemType==''){
// this.$message.error("请选择问题类型");
// return;
// }
// if(this.dataMap[this.form.billCode]){
// this.$message.error("重复登记");