// 弹窗询问是否打印标签
async inlinePrint() {
await this.$confirm('样品添加成功,是否打印标签?!', '提示', {
confirmButtonText: '确定',
cancelButtonTex: '取消',
type: 'warning',
callback: action => {
if (action === 'confirm') {
var printData = this.cellList.filter((this.checkBarcode))
printData.forEach(this.deleteObj)
var printDataC = this.setPrintArr(printData)
this.sendRequest(printDataC)
} else {
this.$message({
type: 'info',
message: '已取消打印'
})
}
}
})
},
// 造打印数组
setPrintArr(printData) {
var printDataB = [
{
testBillNumber: '',
testItem: '',
nominalCapacity: '',
serialNumber: '',
barcode: '',
proposer: ''
}]
debugger
printDataB[0].testBillNumber = printData[0].testBillNumber
printDataB[0].testItem = printData[0].testItem
printDataB[0].nominalCapacity = printData[0].nominalCapacity
printDataB[0].serialNumber = printData[0].serialNumber
printDataB[0].barcode = printData[0].barcode
printDataB[0].proposer = printData[0].proposer
return printDataB
},
这么点东西写了一上午
优化:
其实代码我自己可能都懒得看,说下优化的地方吧
1、去掉没必要的变量
2、造数组由删掉无用属性改为只拿有用的属性
// 弹窗询问是否打印标签
async inlinePrint() {
await this.$confirm('样品添加成功,是否打印标签?!', '提示', {
confirmButtonText: '确定',
cancelButtonTex: '取消',
type: 'warning',
callback: action => {
if (action === 'confirm') {
var printData = this.setPrintArr(this.tempCell[0])
this.sendRequest(printData)
} else {
this.$message({
type: 'info',
message: '已取消打印'
})
}
}
})
},
// 造打印数组
setPrintArr(cellData) {
var printData = [
{
testBillNumber: this.ManageList[0].testBillNumber,
testItem: cellData.testItem,
nominalCapacity: cellData.nominalCapacity,
serialNumber: cellData.serialNumber,
barcode: cellData.barcode,
proposer: this.ManageList[0].proposer
}]
return printData
},
网友评论