This commit is contained in:
linfso 2024-05-29 16:18:45 +08:00
parent 6903713973
commit 45b75c8e0d
5 changed files with 194 additions and 84 deletions

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

@ -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>
@ -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("重复登记");