This commit is contained in:
linfso 2024-05-15 07:37:18 +08:00
parent dfda93000c
commit 3d72755b46
4 changed files with 2489 additions and 0 deletions

View File

@ -0,0 +1,240 @@
'use strict'
/*
TanexPrinterSdk
getPrinterList: 获取打印机列表
getPrinterTplList: 获取打印模版列表
batchPrint:发送打印
getPrinterVer:获取打印组件版本信息
printerIsRead:打印机已经OK的信号
*/
import { getToken } from '@/utils/auth'
class TanexPrinterSdk {
VERSION="1.0.0"
MAX_SENT_RETRY_COUNT = 9;
// WS_URL = "ws://127.0.0.1:17080";
WS_URL = "ws://192.168.88.100:17080";
AUTH_TOKEN=null;
WS_INIT = 0;
WS_OPEN = 1;
WS_CLOSING = 2;
WS_CLOSE = 3;
// 和服务端连接的socket对象
ws = null;
// WS 回调函数
onOpen =null;
onClose = null;
onError =null;
onMessage = null;
// 自定义 回调函数
callbacks ={}
// 标识:是否连接成功 , 记录重试的次数,重新连接尝试的次数
connected = false;
printerIsRead = false;
sendRetryCount = 0;
connectRetryCount = 0;
// static instance = null;
// static getInstance() {
// if (!this.instance) {
// this.instance = new TanexPrinterSdk()
// }
// return this.instance
// }
initSdk(callbacks){
this.token=getToken();
this.callbacks=callbacks;
this.onOpen=callbacks['onOpen'];
this.onClose=callbacks['onClose'];
this.onError=callbacks['onError'];
this.connect();
this.start();
}
sendToken(){
// {"CMD":"setToken","status":"1","Data":"token"}
var printCmd={};
printCmd['CMD']="setToken";
printCmd['Status']="1";
printCmd['Data']=getToken();
console.log(JSON.stringify(printCmd));
this.send(JSON.stringify(printCmd),null);
}
batchPrint(tplName,printerName,orderList){
// {"CMD":"batchPrint","status":"1","Data":["DT20210901001","DT20210901002"]}
var printCmd={};
printCmd['CMD']="batchPrint";
printCmd['Status']="1";
if(orderList!=null && orderList.length>0){
let printData={
"tplName":tplName,
"printerName":printerName,
"orderList":orderList.toString()
}
printCmd['Data']=printData
console.log(JSON.stringify(printCmd));
this.send(JSON.stringify(printCmd),null);
}
}
getPrinterList(callback){
// {"CMD":"getPrinterList","status":"1","Data":""}
var printCmd={};
printCmd['CMD']="getPrinterList";
printCmd['Status']="1";
printCmd['Data']="";
console.log(JSON.stringify(printCmd));
this.send(JSON.stringify(printCmd),callback);
}
getPrinterTplList(callback){
// {"CMD":"getPrinterTplList","status":"1","Data":""}
var printCmd={};
printCmd['CMD']="getPrinterTplList";
printCmd['Status']="1";
printCmd['Data']="";
console.log(JSON.stringify(printCmd));
this.send(JSON.stringify(printCmd),callback);
}
// 连接服务器的方法
connect() {
// 连接服务器
if (!window.WebSocket) {
console.log('您的浏览器不支持WebSocket');
return null;
}
if (!this.ws || this.getWSReadyState() === this.WS_CLOSING || this.getWSReadyState() === this.WS_CLOSE) {
try {
this.ws = new WebSocket(this.WS_URL);
this.ws.onerror = () => {
console.log("ws onerror!");
if(this.onError!=null){
this.onError();
}
}
this.ws.onopen = () => {
console.log("ws onopen!");
this.connected = true
this.connectRetryCount = 0
if(this.onOpen != null){
this.onOpen()
}
this.sendToken();
// this.getPrinterList();
};
this.ws.onclose = () => {
console.log("ws onclose!");
this.connected = false;
this.connectRetryCount++;
if(this.onClose != null){
this.onClose()
}
setTimeout(() => {
this.connect()
}, 500 * this.connectRetryCount)
};
this.ws.onmessage = e => {
console.log('ws onmessage:' + e.data)
if (e.data.charAt(0) === "{") {
var msg = this.jsonToObj(e.data);
if(msg["CMD"]=='printerIsRead'){
printerIsRead=true;
}else{
if (this.callbacks[msg["CMD"]]) {
this.callbacks[msg["CMD"]](msg);
}
}
} else {
console("数据格式非法:" + e.data);
}
};
} catch (ex) {
debugger
if (console && console.log) {
console.log(ex);
}
}
}
return this.ws;
}
jsonToObj(json){
return JSON.parse(json)
}
objToJson(obj){
return JSON.stringify(obj)
}
/**
* readyState->0:尚未建立连接;1:已经建立连接;2:正在关闭;3:已经关闭或不可用
* @param thisWs
* @returns {*}
*/
getWSReadyState() {
if (this.ws.readyState !== undefined) {
return this.ws.readyState;
}
return this.WS_INIT;
};
// 发送数据的方法
send(data) {
if (this.getWSReadyState() === this.WS_OPEN ) {
this.sendRetryCount = 0
this.ws.send(data)
return 1;
} else {
console.log("Ws is abnormal,send faild!!")
return -1
}
}
// 关闭socket连接
close() {
if (this.ws) {
this.ws.close();
this.connected = false; // 更新连接状态
clearInterval(this.heartbeatInterval); // 清除心跳检测定时器
}
}
// 开启心跳检测
start() {
this.heartbeatInterval = setInterval(() => {
this.data = {type: "ping"};
this.send(JSON.stringify(this.data));
}, 5000);
}
}
export default TanexPrinterSdk;

View File

@ -0,0 +1,121 @@
import { Message } from 'element-ui'
import { getToken } from '@/utils/auth'
let websock = null
let messageCallback = null
let errorCallback = null
let wsUrl = ''
let tryTime = 0
// 与后端的协商,websocket请求需要带上token参数
/*
命令名称:
command
getPrinterList: 获取打印机列表
getPrinterTplList: 获取打印模版列表
sendPrinterTplList: 获取打印模版列表
sendToPrint:发送打印
getPrinterVer:获取打印组件版本信息
*/
// 接收ws后端返回的数据
function websocketonmessage (e) {
messageCallback(JSON.parse(e.data))
}
/**
* 发起websocket连接
* @param {Object} agentData 需要向后台传递的参数数据
*/
function websocketSend (agentData) {
// 加延迟是为了尽量让ws连接状态变为OPEN
setTimeout(() => {
// 添加状态判断,当为OPEN时,发送消息
if (websock.readyState === websock.OPEN) { // websock.OPEN = 1
// 发给后端的数据需要字符串化
websock.send(JSON.stringify(agentData))
}
if (websock.readyState === websock.CLOSED) { // websock.CLOSED = 3
console.log('websock.readyState=3')
Message.error('ws连接异常,请稍候重试')
errorCallback()
}
}, 500)
}
// 关闭ws连接
function websocketclose (e) {
// e.code === 1000 表示正常关闭。 无论为何目的而创建, 该链接都已成功完成任务。
// e.code !== 1000 表示非正常关闭。
if (e && e.code !== 1000) {
Message.error('ws连接异常,请稍候重试')
errorCallback()
// // 如果需要设置异常重连则可替换为下面的代码,自行进行测试
// if (tryTime < 10) {
// setTimeout(function() {
// websock = null
// tryTime++
// initWebSocket()
// console.log(`第${tryTime}次重连`)
// }, 3 * 1000)
//} else {
// Message.error('重连失败!请稍后重试')
//}
}
}
// 建立ws连接
function websocketOpen (e) {
// console.log('ws连接成功')
}
// 初始化weosocket
function initWebSocket () {
if (typeof (WebSocket) === 'undefined') {
Message.error('您的浏览器不支持WebSocket,无法获取数据')
return false
}
const token = 'X-Token=' + getToken()
// ws请求完整地址
const requstWsUrl = wsUrl + '?' + token
websock = new WebSocket(requstWsUrl)
websock.onmessage = function (e) {
websocketonmessage(e)
}
websock.onopen = function () {
websocketOpen()
}
websock.onerror = function () {
Message.error('ws连接异常,请稍候重试')
errorCallback()
}
websock.onclose = function (e) {
websocketclose(e)
}
}
/**
* 发起websocket请求函数
* @param {string} url ws连接地址
* @param {Object} agentData 传给后台的参数
* @param {function} successCallback 接收到ws数据,对数据进行处理的回调函数
* @param {function} errCallback ws连接错误的回调函数
*/
export function sendWebsocket (url, agentData, successCallback, errCallback) {
wsUrl = url
initWebSocket()
messageCallback = successCallback
errorCallback = errCallback
websocketSend(agentData)
}
/**
* 关闭websocket函数
*/
export function closeWebsocket () {
if (websock) {
websock.close() // 关闭websocket
websock.onclose() // 关闭websocket
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,797 @@
<template>
<div class="app-container">
<SearchForm :model="queryParams" ref="queryForm" size="mini" :maxShow="5" 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="queryParams.params.queryOrderType">
<el-radio label="1">运单号</el-radio>
<el-radio label="0">订单号</el-radio>
</el-radio-group>
</div>
<el-input
v-model="queryParams.billCode"
:placeholder="$t('多个流水号逗号或换行隔开')"
clearable
type="textarea"
rows="2"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="收件人" prop="receiveName">
<el-input
v-model="queryParams.receiveName"
:placeholder="$t('收件人')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="收件电话" prop="receiveMobile">
<el-input
v-model="queryParams.receiveMobile"
:placeholder="$t('收件电话')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="收件公司" prop="receiveCompany">
<el-input
v-model="queryParams.receiveCompany"
:placeholder="$t('收件公司')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="目的国" prop="receiveCountry">
<CountryPicker0 v-model="queryParams.receiveCountry" :placeholder="$t('目的国')" @onChange="handleQuery"></CountryPicker0>
</el-form-item>
<el-form-item label="寄件人" prop="sendName">
<el-input
v-model="queryParams.sendName"
:placeholder="$t('寄件人')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="寄件人电话" prop="sendMobile">
<el-input
v-model="queryParams.sendMobile"
:placeholder="$t('寄件人电话')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="寄件公司" prop="sendCompany">
<el-input
v-model="queryParams.sendCompany"
:placeholder="$t('寄件公司')"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="寄件国" prop="sendCountry">
<CountryPicker1 v-model="queryParams.sendCountry" :placeholder="$t('目的国')" @onChange="handleQuery"></CountryPicker1>
</el-form-item>
<el-form-item label="运单状态" prop="siteType">
<el-select v-model="queryParams.waybillStatus" placeholder="运单状态" clearable filterable>
<el-option
v-for="dict in dict.type.emis_waybill_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="报关方式" prop="customsEclaration">
<el-select v-model="queryParams.customsEclaration" placeholder="请选择">
<el-option
v-for="dict in dict.type.emis_declare_mode"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="清关方式" prop="customsClear">
<el-select v-model="queryParams.customsClear" placeholder="请选择">
<el-option
v-for="dict in dict.type.emis_customs_clear"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="付款方式" prop="paymentType" label-width="70px">
<el-select v-model="queryParams.paymentType" placeholder="请选择">
<el-option
v-for="dict in dict.type.emis_payment_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="" prop="dateTimeRange">
<div slot="label">
<el-radio-group class="query-label" v-model="queryParams.params.queryOrderDateType">
<el-radio label="1">下单时间</el-radio>
<el-radio label="0">录单时间</el-radio>
</el-radio-group>
</div>
<elDateAdvPicker clearable v-model="dateTimeRange" @dateTimeChange="onDateSelect" ></elDateAdvPicker>
</el-form-item>
</SearchForm>
<div>
<el-tag type="danger" v-if="printerStatus==0">{{ printerStatusMessage }}</el-tag>
<el-tag type="success" v-if="printerStatus==1">{{ printerStatusMessage }}</el-tag>
</div>
<XdTable v-loading="loading"
border stripe
size="small"
:data="emisWaybillList"
:showSearch.sync="showSearch"
:queryParams="queryParams"
:total="total"
@queryTable="getList"
@selection-change="handleSelectionChange"
@sort-change="handleSortChange"
>
<div slot="toolbar">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-print"
size="mini"
:disabled="multiple"
@click="handleBatchPrint"
>批量打印</el-button>
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleView"
>查看</el-button>
</el-col> -->
<el-col :span="1.5">
<el-button
type="primary"
plain
size="mini"
:disabled="multiple"
@click="handlePrintPreview"
>预览面单</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
size="mini"
:disabled="multiple"
@click="handleDownPDF"
>下载pdf</el-button>
</el-col>
<el-col :span="1.5">
<div 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-option
v-for="item in printTplList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</div>
</el-col>
<el-col :span="1.5">
<div style="display: inline-flex;">
<div style="font-size: 12px;
line-height: 28px;
font-weight: 600;">选择打印机:</div>
<div>
<el-select v-model="selPrinterName" size="mini" placeholder="选择打印机" clearable filterable>
<el-option
v-for="item in printerList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</div>
</div>
</el-col>
<!-- <el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['emis:emisWaybill:export']"
>导出</el-button>
</el-col> -->
</el-row>
</div>
<el-table-column type="selection" width="55" align="center" />
<!--
<el-table-column label="序号" align="center" min-width="60">
<template slot-scope="scope">
<span v-text="getIndex(scope.$index)"> </span>
</template>
</el-table-column>
-->
<!-- <el-table-column :label="$t('订单号')" align="center" prop="orderSn" min-width="100" /> -->
<el-table-column :label="$t('运单号')" align="center" prop="billCode" width="120" :show-overflow-tooltip="true">
<template slot-scope="scope">
<router-link :to="'/d24/waybillManagement/waybillEntry?billCode=' + scope.row.billCode" class="link-type">
<span>{{ scope.row.billCode }}</span>
</router-link>
</template>
</el-table-column>
<el-table-column :label="$t('打印状态')" align="center" prop="blPrint" width="100" >
<template slot-scope="scope">
<el-tag type="success" v-if="scope.row.blPrint==1">已打印</el-tag>
<el-tag type="info" v-else>待打印</el-tag>
</template>
</el-table-column>
<el-table-column :label="$t('打印时间')" align="center" prop="printDate" width="170" />
<el-table-column :label="$t('打印次数')" align="center" prop="printCount" width="80" />
<el-table-column :label="$t('打印人')" align="center" prop="printManName" width="100" />
<!-- <el-table-column :label="$t('订单号')" align="center" prop="orderSn" width="100" :show-overflow-tooltip="true"/> -->
<el-table-column :label="$t('进仓单号')" align="center" prop="warehouseInNo" width="100" :show-overflow-tooltip="true"/>
<!-- <el-table-column :label="$t('子单号,逗号隔开')" align="center" prop="billCodeSub" min-width="100" /> -->
<!-- <el-table-column :label="$t('订单状态')" align="center" prop="orderStatus" min-width="100" /> -->
<el-table-column :label="$t('运单状态')" align="center" prop="waybillStatus" width="100" >
<template slot-scope="scope">
<dict-tag :options="dict.type.emis_waybill_status" :value="scope.row.waybillStatus"/>
</template>
</el-table-column>
<el-table-column :label="$t('物流信息')" align="center" prop="lastTraceInfo" width="100" />
<el-table-column :label="$t('国家')" align="center" prop="receiveCountryName" width="100" />
<el-table-column :label="$t('线路')" align="center" prop="transLineTypeName" min-width="100" />
<el-table-column :label="$t('产品类型')" align="center" prop="productTypeName" min-width="100" />
<el-table-column :label="$t('时效')" align="center" prop="timeType" min-width="100" />
<el-table-column :label="$t('计泡比例')" align="center" prop="meterType" min-width="100" />
</XdTable>
<!--
<el-dialog :title="titleView" :visible.sync="openView" width="60%" :close-on-click-modal="false" v-dialogDrag append-to-body>
<emisWaybillView :id="id" ></EmisWaybillView>
</el-dialog>
-->
<!-- <el-dialog :title="titlePdfView" :visible.sync="openPdfView" width="60%" :close-on-click-modal="false" v-dialogDrag append-to-body>
<div>
<pdf ref="pdf" :src="pdfUrl"></pdf>
</div>
</el-dialog> -->
</div>
</template>
<script>
import { listEmisWaybill, getEmisWaybill, delEmisWaybill, addEmisWaybill, updateEmisWaybill } from "@/api/emis/emisWaybill";
import emisWaybillForm from '@/views/emis/emisWaybill/emisWaybillForm';
import elDateAdvPicker from '@/components/DatePickerAdv/elDateAdvPicker';
import CountryPicker0 from '@/views/emis/EmisBaseTools/CountryPicker.vue';
import CountryPicker1 from '@/views/emis/EmisBaseTools/CountryPicker.vue';
// import pdf from 'vue-pdf'
import TanexPrinterSdk from '@/utils/TanexPrinterSdk'
export default {
name: "WaybillIsPrinted",
components: { elDateAdvPicker,emisWaybillForm,CountryPicker0,CountryPicker1 },
dicts: ['emis_waybill_status','emis_declare_mode','emis_customs_clear','emis_payment_type','emis_print_type'
],
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// 运单列表表格数据
emisWaybillList: [],
currentId:null,
openForm: false,
titleForm: "",
tanexPrinter:null,
printerStatus:0,
printerStatusMessage:'打印组件未连接',
printerList:[],
printTplList:[],
selTplName:null,
selPrinterName:null,
currentSelection:[],
// 弹出展示层
id:null,
titleView:"",
openView: false,
// 更新网点时间范围
daterangeOrderDate: [],
// 更新网点时间范围
daterangeEstimateDate: [],
// 更新网点时间范围
daterangePickStartDate: [],
// 更新网点时间范围
daterangePickFinishDate: [],
// 更新网点时间范围
daterangeDispFdDate: [],
// 更新网点时间范围
daterangeRegisterDate: [],
// 更新网点时间范围
daterangeSendDate: [],
// 更新网点时间范围
daterangeProduceBillDate: [],
// 更新网点时间范围
daterangeCreateTime: [],
// 更新网点时间范围
daterangeUpdateTime: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
orderSn: null,
billCode: null,
billCodeSub: null,
orderStatus: null,
waybillStatus: null,
orderType: null,
orderDate: null,
customerCode: null,
customerName: null,
receiveCustomerCode: null,
receiveCustomerName: null,
thirdCustomerCode: null,
thirdCustomerName: null,
receiveName: null,
receiveCompany: null,
receiveMobile: null,
receiveTel: null,
receiveCountry: null,
receiveProvince: null,
receiveCity: null,
receiveCounty: null,
receiveTown: null,
receiveAddress: null,
receivePostcode: null,
receivePcd: null,
sendName: null,
sendCompany: null,
sendMobile: null,
sendTel: null,
sendCountry: null,
sendProvince: null,
sendCity: null,
sendCounty: null,
sendTown: null,
sendAddress: null,
sendPostcode: null,
sendPcd: null,
paymentType: null,
calcFeeType: null,
custNo: null,
transLineType: null,
productType: null,
timeType: null,
meterType: null,
customsClear: null,
customsEclaration: null,
estimateDate: null,
packType: null,
dispatchMethod: null,
pickupMethod: null,
pickStartDate: null,
pickFinishDate: null,
pickFailReason: null,
intoWarehouseCode: null,
intoWarehouseName: null,
intoWarehouseAddress: null,
intoWarehouseContact: null,
intoWarehousePhone: null,
intoWarehouseBillCode: null,
warehouseInNo: null,
customerDeliveryBeginTime: null,
customerDeliveryEndTime: null,
goodsType: null,
goodsInfo: null,
goodsPics: null,
blPrepareInFreight: null,
prepareInEstFee: null,
prepareInRealFee: null,
prepareInExpress: null,
prepareInBillCode: null,
prepareInRemark: null,
prepareInSupplier: null,
totalWeight: null,
totalVolume: null,
parcelQty: null,
billWeight: null,
volumeWeight: null,
currency: null,
settlementWeight: null,
feeWeight: null,
freight: null,
blOverLong: null,
blBill: null,
blOverWeight: null,
overWeightNumber: null,
feeRemaker: null,
thirdCode: null,
realValue: null,
blInsure: null,
insureValue: null,
insureValueCurrency: null,
insureFeeCurrency: null,
insureFee: null,
insureRemark: null,
insureSiteCode: null,
insureDate: null,
blPrint: null,
printManCode: null,
printSite: null,
printDate: null,
printCount: null,
blDispFd: null,
transferCode: null,
transferBillcode: null,
dispFdDate: null,
dispFdReason: null,
currentSiteCode: null,
lastSiteCode: null,
registerSiteCode: null,
registerDate: null,
registerManCode: null,
takePieceEmployeeCode: null,
sendSiteCode: null,
sendDate: null,
dispatchManCode: null,
dispatchDate: null,
dispatchSiteCode: null,
produceBillDate: null,
produceBillSiteCode: null,
produceBillManCode: null,
destinationCode: null,
destinationProvince: null,
destinationCity: null,
destinationCounty: null,
dispatchUnderlingSiteCode: null,
destinationCenterCode: null,
marketManCode: null,
payee: null,
salesmen: null,
operateEmployeeCode: null,
blIsQuestion: null,
problemType: null,
problemCause: null,
problemDelayDays: null,
blMessage: null,
blAcceptMessage: null,
blGenSubbill: null,
signMan: null,
signManCode: null,
signSiteCode: null,
signDate: null,
billPicSendRmk: null,
billPicDispatchRmk: null,
timezoneOffset: null,
delFlag: null,
remark: null,
params:{
queryOrderType:1,
queryOrderDateType:1
}
},
};
},
created() {
this.getList();
this.initTanexPrinterSdk();
},
beforeDestroy(){
this.tanexPrinter.close();
},
methods: {
initTanexPrinterSdk(){
// this.tanexPrinter = TanexPrinterSdk.getInstance();
this.tanexPrinter = new TanexPrinterSdk();
// openCallback, closeCallback,errorCallback,messageCallback
//tanexPrinterIns
let callbacks={
onOpen: this.onPrinterOpen,
onClose: this.onPrinterClose,
onError: this.onPrinterError,
getPrinterList:this.onGetPrinterList,
getPrinterTplList:this.onGetPrinterTplList
}
this.tanexPrinter.initSdk(callbacks);
},
onPrinterOpen(evt){
console.log("onPrinterOpen")
// this.tanexPrinter.sendToken();
this.tanexPrinter.getPrinterList();
this.tanexPrinter.getPrinterTplList();
this.printerStatus = 1;
this.printerStatusMessage="打印组件已连接,可以打印.";
},
onPrinterClose(evt){
console.log("onPrinterClose")
this.printerStatus = 0;
this.printerStatusMessage="打印组件已断开!";
},
onPrinterError(evt){
console.log("onPrinterError")
this.printerStatus = 0;
this.printerStatusMessage="打印组件已断开!";
},
onGetPrinterList(msg){
console.log("onGetPrinterList")
if(msg){
this.printerList=[];
msg.Data.printerList.forEach(item=>{
let optionItem={
label:item,
value:item
}
this.printerList.push(optionItem);
this.selPrinterName=msg.Data.defaultPrinter;
})
}
},
onGetPrinterTplList(msg){
console.log("onGetPrinterTplList")
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;
})
}
},
handleBatchPrint(){
// 重要,设置为true才会把右上角X和取消区分开来
this.$confirm("确定批量打印?", "提示", {
cancelButtonText: "不打印",
confirmButtonText: "确定打印",
type: "warning",
distinguishCancelAndClose: true,
closeOnClickModal: false
}).then(() => {
let orderList=[];
this.currentSelection.forEach(item=>{
orderList.push(item.billCode);
});
this.tanexPrinter.batchPrint(this.selTplName,this.selPrinterName,orderList)
}).catch(() => {});
},
handlePrintPreview(){
},
handleDownPDF(){
},
/** 查询运单列表列表 */
getList() {
this.loading = true;
this.queryParams.params = {};
listEmisWaybill(this.addDateRange(this.queryParams, this.dateTimeRange)).then(response => {
this.emisWaybillList = response.rows;
this.total = response.total;
this.loading = false;
});
},
onDateSelect(value){
console.log("date picker---->", value)
this.dateTimeRange=value;
// scanDate
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.currentSelection=selection;
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
// 排序 查询字段是表格中字段名字 动态取值排序顺序
handleSortChange(column) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
/** 新增按钮操作 */
handleAdd(row) {
this.currentId=null;
this.openForm= true;
this.titleForm = "新增";
},
handleShowMoreInput(){
this.moreInputVisible = !this.moreInputVisible;
},
/** 修改按钮操作 */
handleUpdate(row) {
this.currentId= row.id;
this.openForm = true;
this.titleForm = "修改";
},
handleView(row) {
this.id=row.id;
this.titleView="查看";
this.openView=true;
// this.router.push({ path: '/emis/emisWaybill/viewDetail', query: { id: row.id }})
},
handleFormChanged(){
this.openForm = false;
this.getList();
},
cancelForm(){
this.openForm = false;
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisWaybill(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// this.download('emis/emisWaybill/export', {
// ...this.queryParams
// }, `emisWaybill_${new Date().getTime()}.xlsx`)
const loadingInstance = this.$loading({
text: '正在导出...'
})
var qParam = {...this.queryParams};
qParam.pageNum=1;
qParam.pageSize=5000;
listEmisWaybill(this.addDateRange(qParam, this.dateTimeRange)).then(response => {
this.downloadLoading = false
if (response.code === 200) {
const curList = response.rows
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id','订单号','客户单号,合同号','运单号','子单号,逗号隔开','订单状态','运单状态','订单类型','下单时间','客户ID','客户编号2502021','客户名称','收件客户编号2502021','收件客户客户名称','第三方客户客户编号','第三方客户客户名称','wx','收货人名','收货公司','收货人手机号','收货人电话','收货人国家','省','市','区','县','收货地址','邮编','寄件人省市区名称,逗号分隔','寄件人名','寄件公司','寄件人手机号','寄件人电话','寄件人国家','寄件省','寄件市','寄件区','寄件县','寄件地址','寄件邮编','发件人省市区名称,逗号分隔','支付方式','计费方式','支付月结编号','快递线路','快递产品类型','时效','计泡比例','清关方式','报关方式','预计到达时间','包装类型','派件方式:1-送货上门','取件方式:1-上门取件','预计上门取件开始时间','预计上门取件结束时间','取货失败原因','入仓代码','入仓名称','入仓地址','入仓联系人','入仓联系人电话','入仓单号','实际进仓单关联','客户发货开始时间','客户发货截止时间','货物大类','货物描述','货物图片,逗号隔开','预入仓代垫运费','预入仓代垫运费','预入仓实际运费','预入仓快递公司','预入仓快递单号','预入仓自定义标识','预入仓供应商','总重量','总体积','件数','实际重量','体积重量','费用币种','结算重量','计费重量','运费','是否超长','是否出账','账单备注','是否超重','超重重量','费用备注','三段码','实际货值','是否投保','投保货值','投保货值币种','保费币种','保费','保险备注','保险站点代码','投保日期','是否打印','打印人编号','打印站点','打印时间','打印次数','是否同行转单','转单代码','转单单号','转单时间','转单原因','当前网点编号','下一网点编号','上一网点点号','寄件站点代码','寄件日期','寄件人编号','取件员代码','发件网点代码','发货时间','派件人代码','派件时间','派件网点代码','生成账单时间','生成账单站点代码','生成账单人代码','目的地编号','目的省','目的城市','目的国家','目的地网点代码','目的地财务中心代码','业务人代码','销售回款人','销售联系人','操作员代码','是否问题件','问题件类型','问题件原因','问题件延期天数','是否备注消息','是否发送收件人短信','是否生成子单','签收人','签收人代码','签收站点代码','签收时间','揽收图片备注','签收底单图片','时区偏差','删除标志(0代表存在','创建者','创建时间','更新者','更新时间','备注','创建网点','更新网点',];
const filterVal = ['id','orderSn','custOrderId','billCode','billCodeSub','orderStatus','waybillStatus','orderType','orderDate','userId','customerCode','customerName','receiveCustomerCode','receiveCustomerName','thirdCustomerCode','thirdCustomerName','openId','receiveName','receiveCompany','receiveMobile','receiveTel','receiveCountry','receiveProvince','receiveCity','receiveCounty','receiveTown','receiveAddress','receivePostcode','receivePcd','sendName','sendCompany','sendMobile','sendTel','sendCountry','sendProvince','sendCity','sendCounty','sendTown','sendAddress','sendPostcode','sendPcd','paymentType','calcFeeType','custNo','transLineType','productType','timeType','meterType','customsClear','customsEclaration','estimateDate','packType','dispatchMethod','pickupMethod','pickStartDate','pickFinishDate','pickFailReason','intoWarehouseCode','intoWarehouseName','intoWarehouseAddress','intoWarehouseContact','intoWarehousePhone','intoWarehouseBillCode','warehouseInNo','customerDeliveryBeginTime','customerDeliveryEndTime','goodsType','goodsInfo','goodsPics','blPrepareInFreight','prepareInEstFee','prepareInRealFee','prepareInExpress','prepareInBillCode','prepareInRemark','prepareInSupplier','totalWeight','totalVolume','parcelQty','billWeight','volumeWeight','currency','settlementWeight','feeWeight','freight','blOverLong','blBill','blBillText','blOverWeight','overWeightNumber','feeRemaker','thirdCode','realValue','blInsure','insureValue','insureValueCurrency','insureFeeCurrency','insureFee','insureRemark','insureSiteCode','insureDate','blPrint','printManCode','printSite','printDate','printCount','blDispFd','transferCode','transferBillcode','dispFdDate','dispFdReason','currentSiteCode','nextSiteCode','lastSiteCode','registerSiteCode','registerDate','registerManCode','takePieceEmployeeCode','sendSiteCode','sendDate','dispatchManCode','dispatchDate','dispatchSiteCode','produceBillDate','produceBillSiteCode','produceBillManCode','destinationCode','destinationProvince','destinationCity','destinationCounty','dispatchUnderlingSiteCode','destinationCenterCode','marketManCode','payee','salesmen','operateEmployeeCode','blIsQuestion','problemType','problemCause','problemDelayDays','blMessage','blAcceptMessage','blGenSubbill','signMan','signManCode','signSiteCode','signDate','billPicSendRmk','billPicDispatchRmk','timezoneOffset','delFlag','createBy','createTime','updateBy','updateTime','remark','createSite','updateSite',];
const data = this.formatJson(filterVal, curList, response.rows)
excel.export_json_to_excel({
header: tHeader,
data,
filename: '运单列表',
autoWidth: true
})
loadingInstance.close()
})
}
});
},
formatJson(filterVal, jsonData, resData) {
let index = 0
return jsonData.map(v => filterVal.map(j => {
if (j === 'index') {
return ++index
}
if (j === 'status') {
var statusStr='xxx'
if(v[j] == 10){
statusStr='xxx'
}
return statusStr;
}
return v[j]
}))
},
/** 列索引函数 */
getIndex($index) {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
},
/** 时间搜索响应函数 */
dateTimeChange(value){
this.dateTimeRange=value;
},
}
};
</script>
<style lang="scss" scoped>
.el-divider{
margin-top: 0px;
background: 0 0;
border-top: 1px solid #E6EBF5;
}
.el-divider__text {
color: #0955ee;
cursor: pointer;
}
.query-label {
.el-radio{
display: block;
line-height: 23px;
white-space: normal;
margin-right: 0;
}
}
</style>