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