uu
This commit is contained in:
parent
d4b2360736
commit
34f121f4ca
@ -143,6 +143,11 @@ export const getRealGetWaybillPrintData = (data = {})=> {
|
||||
return coreRequest(url.getRealGetWaybillPrintData, data, {}, "GET")
|
||||
}
|
||||
|
||||
// 运单 打印数据--打印指令
|
||||
export const getRealGetPrintCommandByApp = (data = {})=> {
|
||||
return coreRequest(url.getRealGetPrintCommandByApp, data, {}, "GET")
|
||||
}
|
||||
|
||||
// 获取运单详细信息-图片
|
||||
export const queryPrintListSimple = (data = {})=> {
|
||||
return coreRequest(url.queryPrintListSimple, data, {}, "GET")
|
||||
|
||||
@ -41,7 +41,8 @@ export default {
|
||||
getWaybillStatMap: `/emis/emisWaybill/getWaybillStatMap`, // 运单统计数据
|
||||
getOrderDetail: `/emis/emisWaybill/getWaybillDetail`, // 订单详情
|
||||
scanRecord: `/emis/emisTmsScanRecord/scan`, // 扫描- 揽收
|
||||
getRealGetWaybillPrintData: `/emis/emisWaybill/realGetPrintList`, // 运单 打印数据
|
||||
getRealGetWaybillPrintData: `/emis/emisWaybill/realGetPrintList`, // 运单 打印数据--图片
|
||||
getRealGetPrintCommandByApp: `/emis/emisWaybill/realGetPrintByApp`, // 运单 打印数据--打印指令
|
||||
queryPrintListSimple: `/emis/emisWaybill/queryPrintListSimple`, // 运单 打印数据-列表
|
||||
getNextStationList: `/emis/emisTmsScanRecord/getNextStationList`, // 获取-扫描下一网点
|
||||
getPreStationList: `/emis/emisTmsScanRecord/getPreStationList`, // 获取-扫描上一网点
|
||||
|
||||
@ -45,8 +45,8 @@ export default {
|
||||
async initData() {
|
||||
|
||||
},
|
||||
// 打印
|
||||
handlePrint(imgsRes){
|
||||
// 打印图片
|
||||
handlePrintImgs(imgsRes){
|
||||
const that = this
|
||||
return new Promise(async (resolve, reject)=> {
|
||||
let imgLen = imgsRes.length
|
||||
@ -76,6 +76,15 @@ export default {
|
||||
// printModule.printTestSimple(deviceId)
|
||||
})
|
||||
},
|
||||
// 直接传打印指令给打印机
|
||||
handlePrintCommandData(str){
|
||||
let { bl, deviceId } = that.checkPrintParam()
|
||||
if(!bl) {
|
||||
return reject('打印参数校验不通过')
|
||||
}
|
||||
debugger
|
||||
printModule.sendData(str)
|
||||
},
|
||||
checkPrintParam() {
|
||||
let msg = '', bl = false
|
||||
let { deviceId, isStateOn } = this.$refs.curBlueTooth.getConData()
|
||||
@ -90,7 +99,7 @@ export default {
|
||||
}
|
||||
},
|
||||
// 给外部调用api,打印自定义图
|
||||
async callPrint({ paperWidth, imgsRes }) {
|
||||
async callPrint({ paperWidth, imgsRes, prtCmdData }) {
|
||||
this.paperWidth = paperWidth || this.paperWidth
|
||||
let conSta = await this.$refs.curBlueTooth.autoConnect()
|
||||
this.$emit('autoConnectCallback', conSta)
|
||||
@ -101,7 +110,11 @@ export default {
|
||||
if(conSta) {
|
||||
showLoading('正在发送打印数据..')
|
||||
try{
|
||||
await this.handlePrint(imgsRes)
|
||||
if(prtCmdData) {
|
||||
await this.handlePrintCommandData(prtCmdData)
|
||||
} else {
|
||||
await this.handlePrintImgs(imgsRes)
|
||||
}
|
||||
showToast('数据发送成功,如果无法打印请重连设备重试')
|
||||
cBl = true
|
||||
}catch(e){
|
||||
|
||||
@ -81,12 +81,14 @@ export default {
|
||||
this.previewModel.show = true
|
||||
}
|
||||
},
|
||||
async confirmPrint(imgs){
|
||||
imgs = imgs || this.imageUrl
|
||||
if(imgs.length == 0) {
|
||||
this.showToast('缺少预览内容')
|
||||
async confirmPrint(opt = { }){
|
||||
let { imageUrl, prtCmdData } = opt
|
||||
imageUrl = imageUrl || this.imageUrl || []
|
||||
prtCmdData = prtCmdData || ''
|
||||
if(imageUrl.length == 0 && !prtCmdData) {
|
||||
this.showToast('缺少打印内容')
|
||||
} else {
|
||||
this.goto(`print/bluetoothPrinter?imageUrl=${imgs.join(",")}`)
|
||||
this.goto(`print/bluetoothPrinter?imageUrl=${imageUrl.join(",")}&prtCmdData=${prtCmdData}`)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@ -66,7 +66,8 @@ export default {
|
||||
imageUrl: [],
|
||||
paperWidth: 560,
|
||||
show: false,
|
||||
allImgRes: []
|
||||
allImgRes: [],
|
||||
prtCmdData: ''
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
@ -85,25 +86,30 @@ export default {
|
||||
current:index
|
||||
})
|
||||
},
|
||||
async startPrint({ imageUrl, paperWidth } = {}, preview = true) {
|
||||
async startPrint({ imageUrl, paperWidth, prtCmdData } = {}, preview = true) {
|
||||
|
||||
this.imageUrl = [] // 每次打印前,清空历史数据
|
||||
this.allImgRes = []
|
||||
this.prtCmdData = ''
|
||||
// 默认先做预览
|
||||
if(imageUrl.length > 0) {
|
||||
if(imageUrl.length == 0 && !prtCmdData) {
|
||||
this.showToast('缺少打印内容')
|
||||
} else {
|
||||
if(!Array.isArray(imageUrl)){
|
||||
imageUrl = [imageUrl]
|
||||
}
|
||||
this.imageUrl = imageUrl
|
||||
this.paperWidth = paperWidth || this.paperWidth
|
||||
this.prtCmdData = prtCmdData || ''
|
||||
if(preview) {
|
||||
this.previewModel.show = true
|
||||
}
|
||||
await promiseTimeout(450) // 保证页面节点渲染出来
|
||||
await this.setAllImgRes()
|
||||
// 有打印指令,跳过canvas画图
|
||||
if(!prtCmdData) {
|
||||
await promiseTimeout(450) // 保证页面节点渲染出来
|
||||
await this.setAllImgRes()
|
||||
}
|
||||
!preview && this.confirmPrint()
|
||||
} else {
|
||||
this.showToast('缺少打印内容')
|
||||
}
|
||||
},
|
||||
setAllImgRes(){
|
||||
@ -124,7 +130,8 @@ export default {
|
||||
async confirmPrint(){
|
||||
let res = await this.$refs.curPrint.callPrint({
|
||||
imgsRes: this.allImgRes,
|
||||
paperWidth: this.paperWidth
|
||||
paperWidth: this.paperWidth,
|
||||
prtCmdData: this.prtCmdData
|
||||
})
|
||||
},
|
||||
autoConnectCallback(bl){
|
||||
|
||||
@ -302,6 +302,7 @@
|
||||
import TpxBluetoothPrintPreview from "@/components/tpx-bluetooth-print/tpx-bluetooth-print-preview"
|
||||
import { debounce } from "@/common/util"
|
||||
import * as apiService from "@/common/api"
|
||||
import { getBillPrintData } from "@/pages/print/printData"
|
||||
import { getOrderModels } from "./model"
|
||||
const pageTypeEnum = {
|
||||
create: 'create',
|
||||
@ -524,9 +525,8 @@
|
||||
if(blGenSubbill == '1' && parcelQty) {
|
||||
param.subBillCodeRange = `1,${parcelQty}`
|
||||
}
|
||||
let prtRes = await apiService.getRealGetWaybillPrintData({ ...param, _loading: true })
|
||||
let imgUrls = prtRes?.data?.map(t=> t.imageUrl) || []
|
||||
this.$refs.curPrint.confirmPrint(imgUrls.filter(v=> !!v))
|
||||
let prtRes = await getBillPrintData(param)
|
||||
this.$refs.curPrint.confirmPrint(prtRes)
|
||||
this.resetForm()
|
||||
},
|
||||
async saveSuccessBack(){
|
||||
|
||||
@ -32,10 +32,12 @@ export default {
|
||||
methods: {
|
||||
initData(){
|
||||
let urls = this.queryOption?.imageUrl?.split(",")
|
||||
let prtCmdData = this.queryOption?.prtCmdData || ''
|
||||
this.pageLoading = false
|
||||
if(urls?.length > 0) {
|
||||
this.$refs.curPrint.startPrint({
|
||||
imageUrl: urls,
|
||||
prtCmdData
|
||||
}, false)
|
||||
} else {
|
||||
this.showToast('缺少打印内容')
|
||||
|
||||
@ -170,6 +170,8 @@
|
||||
import { checkParams } from "@/common/validate"
|
||||
import { getAddressDetail } from "@/common/util"
|
||||
import TpxBluetoothPrintPreview from "@/components/tpx-bluetooth-print/tpx-bluetooth-print-preview"
|
||||
import { getBillPrintData } from "@/pages/print/printData"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TpxBluetoothPrintPreview,
|
||||
@ -248,10 +250,6 @@
|
||||
handleSearch(){
|
||||
this.triggerListReload()
|
||||
},
|
||||
async handleSubmitPrint() {
|
||||
const imgUrls = await this.getPrintImages()
|
||||
this.$refs.curPrint.confirmPrint(imgUrls.filter(v=> !!v))
|
||||
},
|
||||
handleSelAll() {
|
||||
if(this.submitParam.billCode.length == this.resData.list.length) {
|
||||
this.submitParam.billCode = []
|
||||
@ -259,12 +257,21 @@
|
||||
this.submitParam.billCode = this.resData.list.map(item=> item.val)
|
||||
}
|
||||
},
|
||||
async getRealGetWaybillPrintData() {
|
||||
getParams(){
|
||||
// 请求后端接口
|
||||
let param = JSON.parse(JSON.stringify(this.submitParam))
|
||||
param.printType = param.printType.join(',')
|
||||
param.billCode = param.billCode.join(',')
|
||||
param.subBillCodeRange = param.subBillCodeRange.join(',')
|
||||
return param
|
||||
},
|
||||
async handleSubmitPrint() {
|
||||
let param = this.getParams()
|
||||
let prtRes = await getBillPrintData(param)
|
||||
this.$refs.curPrint.confirmPrint(prtRes)
|
||||
},
|
||||
async getRealGetWaybillPrintData() {
|
||||
let param = this.getParams()
|
||||
await checkParams(param, this.submitValidConfig)
|
||||
let res = await apiService.getRealGetWaybillPrintData({ ...param, _loading: true })
|
||||
return res
|
||||
|
||||
28
pages/print/printData.js
Normal file
28
pages/print/printData.js
Normal file
@ -0,0 +1,28 @@
|
||||
import * as apiService from "@/common/api"
|
||||
|
||||
// 打印模板是否支持了打印命令
|
||||
const isSupportCommandType = (type = '')=> {
|
||||
let allType = type.split(",")
|
||||
let supportTypes = [
|
||||
'TAN-GC-130' // 子单模板
|
||||
]
|
||||
// 判断是否全支持
|
||||
let isSupportAll = allType.filter(v=> supportTypes.indexOf(v) > -1).length == allType.length
|
||||
return isSupportAll
|
||||
}
|
||||
|
||||
export const getBillPrintData = async (params)=> {
|
||||
let imageUrl = [], prtCmdData = ''
|
||||
if(isSupportCommandType(params.printType)) {
|
||||
let cmdPrtRes = await apiService.getRealGetPrintCommandByApp({ ...params, _loading: true })
|
||||
prtCmdData = cmdPrtRes.data
|
||||
} else {
|
||||
let imgPrtRes = await apiService.getRealGetWaybillPrintData({ ...params, _loading: true })
|
||||
imageUrl = imgPrtRes?.data?.map(t=> t.imageUrl) || []
|
||||
imageUrl = imageUrl.filter(v=> !!v)
|
||||
}
|
||||
return {
|
||||
imageUrl,
|
||||
prtCmdData
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user