标签打印

master
lion 4 weeks ago
parent dc6af48efa
commit 2db98513a7

@ -570,7 +570,7 @@
// }
// Cookies.remove('objs')
// Cookies.set('objs',JSON.stringify(_objs))
window.open('/admin/print.html?ids=' + this.printArr, '_blank')
window.open('/admin/#/myprint?ids=' + this.printArr, '_blank')
},
async exportExcel(sheetName) {
const res = await index(Object.assign(this.select, {

@ -6,7 +6,8 @@
<div v-if="imgList.length > 0">
<div class="batch-print-btn">
<el-button type="primary" @click="batchPrint"></el-button>
<el-button type="primary" @click="reconnect"></el-button>
<el-button type="primary" :loading="isPrinting" :disabled="isPrinting" @click="batchPrint"></el-button>
<el-button type="primary" @click="showLogDrawer = true">打印日志</el-button>
</div>
<div class="print-preview-title">打印预览</div>
@ -59,7 +60,9 @@ export default {
materialList: [], //
imgList: [], //
showLogDrawer: false,
logs: [] // { type: 'success'|'error'|'info', text: string, time: 'HH:mm:ss' }
logs: [], // { type: 'success'|'error'|'info', text: string, time: 'HH:mm:ss' }
isPrinting: false,
needsReconnect: false
}
},
async created() {
@ -69,7 +72,7 @@ export default {
this.$message.error('请先选择物资')
return
}
//
await this.getInfo()
//
@ -80,6 +83,16 @@ export default {
await this.changeLabelValue(false)
},
methods: {
//
async reconnect() {
//
await this.getInfo()
//
await this.getAllMaterialInfo()
//
await this.changeLabelValue(false)
this.needsReconnect = false
},
//
addLog(type, text) {
const two = n => (n < 10 ? '0' + n : '' + n)
@ -92,7 +105,7 @@ export default {
const res = await sendPostRequestApi(funcId, funcName, data)
if (res.rtnCode === '0') {
if (showMessage) {
this.$message.success(funcName + '成功')
this.$message.success(funcName + '成功')
}
this.addLog('success', funcName + '成功')
return res.outParams ? res.outParams : true
@ -113,9 +126,14 @@ export default {
try {
await this.sendPostRequest('web_DSTP2x_SetLibLang', '设置语言', { language: '0' }, true)
//
const devRes = await this.sendPostRequest('web_DSTP2x_EnumDev', '获取打印设备', {
const devRes = await this.sendPostRequest(
'web_DSTP2x_EnumDev',
'获取打印设备',
{
enumType: '1'
}, true)
},
true
)
console.log('devRes', devRes)
const index = devRes.enumList.indexOf(',')
if (index !== -1) {
@ -123,9 +141,14 @@ export default {
devRes.enumList = devList[0]
}
//
this.connectRes = await this.sendPostRequest('web_DSTP2x_ConnEnumeratedDev', '连接打印设备', {
this.connectRes = await this.sendPostRequest(
'web_DSTP2x_ConnEnumeratedDev',
'连接打印设备',
{
devName: devRes.enumList
}, true)
},
true
)
//
const snRes = await this.sendPostRequest('web_DSTP2x_GetPrtSN', '获取打印机序列号', {
devHdl: this.connectRes.devHdl
@ -143,9 +166,14 @@ export default {
}
//
const statusRes = await this.sendPostRequest('web_DSTP2x_GetPrtStatus', '获取打印状态', {
const statusRes = await this.sendPostRequest(
'web_DSTP2x_GetPrtStatus',
'获取打印状态',
{
devHdl: this.connectRes.devHdl
}, true)
},
true
)
if (statusRes.prtStatusDesc) {
const statusStr = this.getAllStatus(
statusRes.mainStatusCode,
@ -178,10 +206,15 @@ export default {
//
async setTemplatePrint(isprint) {
//
this.labelContent = await this.sendPostRequest('web_DSTP2x_CreateLabelContext', '创建画布', {
width: '80',
height: '40'
}, true)
this.labelContent = await this.sendPostRequest(
'web_DSTP2x_CreateLabelContext',
'创建画布',
{
width: '80',
height: '40'
},
true
)
if (this.labelContent) {
//
await this.sendPostRequest('web_DSTP2x_LcDraw_SetTextFontSize', '设置文本字体', {
@ -212,9 +245,10 @@ export default {
{
lcHdl: this.labelContent.lcHdl,
prnMode: isprint ? '0' : '3'
}, true
},
true
)
} else {
} else {
this.$message.error('创建画布失败')
}
},
@ -357,12 +391,17 @@ export default {
data: hexId
})
const printRes = await this.sendPostRequest('web_DSTP2x_PrintLc', `${index + 1}次打印`, {
devHdl: this.connectRes.devHdl,
lcHdl: this.labelContent.lcHdl,
outFileType: '1',
rfidReadType: '3'
}, true)
const printRes = await this.sendPostRequest(
'web_DSTP2x_PrintLc',
`${index + 1}次打印`,
{
devHdl: this.connectRes.devHdl,
lcHdl: this.labelContent.lcHdl,
outFileType: '1',
rfidReadType: '3'
},
true
)
if (printRes) {
if (!isprint) {
this.imgList.push(printRes.outFile)
@ -371,24 +410,43 @@ export default {
}
}
//
await this.sendPostRequest('web_DSTP2x_DeleteLabelContext', `删除${index + 1}画布句柄`, {
lcHdl: this.labelContent.lcHdl
}, true)
await this.sendPostRequest(
'web_DSTP2x_DeleteLabelContext',
`删除${index + 1}画布句柄`,
{
lcHdl: this.labelContent.lcHdl
},
true
)
this.labelContent = ''
}
if (isprint) {
await this.sendPostRequest('web_DSTP2x_DisconnDev', '断开设备连接', {
devHdl: this.connectRes.devHdl
}, true)
await this.sendPostRequest(
'web_DSTP2x_DisconnDev',
'断开设备连接',
{
devHdl: this.connectRes.devHdl
},
true
)
//
this.needsReconnect = true
}
},
//
async batchPrint() {
// await this.sendPostRequest('web_DSTP2x_SetLcPrnMode', '', {
// lcHdl: this.labelContent.lcHdl,
// prnMode: '0'
// })
await this.changeLabelValue(true)
if (this.isPrinting) return
if (this.needsReconnect) {
this.$message.warning('请重新连接设备')
return
}
this.isPrinting = true
try {
await this.changeLabelValue(true)
} finally {
this.isPrinting = false
}
},
//
async getAllMaterialInfo() {
@ -410,7 +468,7 @@ export default {
//
async getMaterialInfo(id) {
try {
const res = await getMaterialInfo({ id: id })
const res = await getMaterialInfo({ id: id })
if (res) {
return res
}

Loading…
Cancel
Save