|
|
|
@ -53,6 +53,7 @@ const printer = { |
|
|
|
orderNo: '', |
|
|
|
templateNo:'', |
|
|
|
printLabelType:0, |
|
|
|
copies:1, |
|
|
|
} |
|
|
|
export default { |
|
|
|
name: 'printer', |
|
|
|
@ -705,8 +706,14 @@ export default { |
|
|
|
if (status === 1){ |
|
|
|
labelList = this.labelFormatList.filter((item)=> item.labelType === 'Roll Label') |
|
|
|
this.printCurrentPart.rollsPerCarton = 1; |
|
|
|
if (this.$store.state.user.copiesForRollLabelFlag === 'Y'){ |
|
|
|
this.printCurrentPart.copies = this.$store.state.user.copies ? this.$store.state.user.copies : 1; |
|
|
|
} else { |
|
|
|
this.printCurrentPart.copies = 1; |
|
|
|
} |
|
|
|
this.$set(this.printCurrentPart,'orderNo','') |
|
|
|
}else if (status === 0){ |
|
|
|
this.$store.state.user.copiesForRollLabelFlag = 'N'; |
|
|
|
labelList = this.labelFormatList.filter((item)=> item.labelType === 'Shipment Carton') |
|
|
|
} |
|
|
|
if (labelList.length === 0){ |
|
|
|
@ -1126,6 +1133,56 @@ export default { |
|
|
|
this.$message.error(error) |
|
|
|
}) |
|
|
|
}, |
|
|
|
doPrintRollLabel(data, params) { |
|
|
|
if (data && data.code === 0) { |
|
|
|
let labelList = this.labelFormatList.filter(item => item.labelType === 'Roll Label'); |
|
|
|
let prints = data.rows.map((item) => { |
|
|
|
return { |
|
|
|
qrCode: `(00)${item.partNo}(01)${item.qtyPerRoll}(02)${item.umName}(03)${item.manufacturerDate}(04)${item.serialNumber ? item.serialNumber : ''}(05)${item.manufacturerNo ? item.manufacturerNo : ''}(06)${item.moldCode ? item.moldCode : ''}(07)(08)${item.rollNo}(09)(10)`, |
|
|
|
ref: item.partNo, |
|
|
|
rev: item.rev, |
|
|
|
qty: item.qtyPerRoll, |
|
|
|
uom: item.umName, |
|
|
|
desc: item.partDesc, |
|
|
|
date: item.manufacturerDate, |
|
|
|
manufacturer: item.manufacturerNo, |
|
|
|
moldCode: item.moldCode, |
|
|
|
rollNo: item.rollNo, |
|
|
|
sn: item.serialNumber, |
|
|
|
rollLabelRequired: item.rollLabelRequired, |
|
|
|
serialNumberRequired: item.serialNumberRequired, |
|
|
|
serialNumber: item.serialNumber, |
|
|
|
rollLabelFlag: item.rollLabelFlag, // 判断标签类型 |
|
|
|
offsetX: item.offsetX, |
|
|
|
offsetY: item.offsetY, |
|
|
|
direction: item.direction, |
|
|
|
} |
|
|
|
}); |
|
|
|
let qrCodeList = this.$refs.qrCode.init(prints.map((item) => { |
|
|
|
return item.qrCode |
|
|
|
})); |
|
|
|
for (let i = 0; i < qrCodeList.length; i++) { |
|
|
|
prints[i].qrCode = qrCodeList[i]; |
|
|
|
} |
|
|
|
let notFound = []; |
|
|
|
for (let label of labelList) { |
|
|
|
if (!this.printerSetupList.includes(label.defaultPrinterName)) { |
|
|
|
notFound.push(label.defaultPrinterName); |
|
|
|
continue; |
|
|
|
} |
|
|
|
print_roll_label(prints, label.defaultPrinterName, params.copies, true); |
|
|
|
} |
|
|
|
this.printTest = false; |
|
|
|
if (notFound.length > 0) { |
|
|
|
this.$message.warning(`The printer ${notFound.join(',')} is not found`); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.$message.success(data.msg); |
|
|
|
} else { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
this.printLoading = false; |
|
|
|
}, |
|
|
|
savePrintRollLabelRecord(){ |
|
|
|
// 新增 打印记录 |
|
|
|
let params = { |
|
|
|
@ -1136,59 +1193,34 @@ export default { |
|
|
|
} |
|
|
|
this.printLoading = true; |
|
|
|
// 请求接口 |
|
|
|
savePrintRollLabelRecord(params).then(({data})=>{ |
|
|
|
if (data && data.code === 0) { |
|
|
|
let labelList = this.labelFormatList.filter((item)=> item.labelType === 'Roll Label') |
|
|
|
let prints = data.rows.map((item) => { |
|
|
|
return { |
|
|
|
qrCode: `(00)${item.partNo}(01)${item.qtyPerRoll}(02)${item.umName}(03)${item.manufacturerDate}(04)${item.serialNumber? item.serialNumber : ''}(05)${item.manufacturerNo? item.manufacturerNo : ''}(06)${item.moldCode? item.moldCode : ''}(07)(08)${item.rollNo}(09)(10)`, |
|
|
|
ref: item.partNo, |
|
|
|
rev: item.rev, |
|
|
|
qty: item.qtyPerRoll, |
|
|
|
uom: item.umName, |
|
|
|
desc: item.partDesc, |
|
|
|
date: item.manufacturerDate, |
|
|
|
manufacturer: item.manufacturerNo, |
|
|
|
moldCode: item.moldCode, |
|
|
|
rollNo: item.rollNo, |
|
|
|
sn: item.serialNumber, |
|
|
|
rollLabelRequired: item.rollLabelRequired, |
|
|
|
serialNumberRequired: item.serialNumberRequired, |
|
|
|
serialNumber: item.serialNumber, |
|
|
|
rollLabelFlag: item.rollLabelFlag,// 判断标签类型 |
|
|
|
offsetX:item.offsetX, |
|
|
|
offsetY:item.offsetY, |
|
|
|
direction:item.direction, |
|
|
|
|
|
|
|
savePrintRollLabelRecord(params).then(async ({data}) => { |
|
|
|
await this.onCopiesInput(params.copies); |
|
|
|
// 校验copies |
|
|
|
if (params.copies > 5) { |
|
|
|
this.$confirm( |
|
|
|
'The copies is greater than 5, are you sure to continue?', |
|
|
|
'Warning', |
|
|
|
{ |
|
|
|
confirmButtonText: 'OK', |
|
|
|
cancelButtonText: 'Cancel', |
|
|
|
type: 'warning' |
|
|
|
} |
|
|
|
).then(() => { |
|
|
|
// 用户确认,执行后续打印逻辑 |
|
|
|
this.doPrintRollLabel(data, params); |
|
|
|
}).catch(() => { |
|
|
|
// 用户取消 |
|
|
|
this.printLoading = false; |
|
|
|
}); |
|
|
|
let qrCodeList = this.$refs.qrCode.init(prints.map((item)=>{ |
|
|
|
return item.qrCode |
|
|
|
})) |
|
|
|
for (let i = 0; i < qrCodeList.length; i++) { |
|
|
|
prints[i].qrCode = qrCodeList[i] |
|
|
|
} |
|
|
|
let notFound = []; |
|
|
|
for (let label of labelList) { |
|
|
|
if (!this.printerSetupList.includes(label.defaultPrinterName)) { |
|
|
|
notFound.push(label.defaultPrinterName) |
|
|
|
continue |
|
|
|
} |
|
|
|
print_roll_label(prints,label.defaultPrinterName,true) |
|
|
|
} |
|
|
|
this.printTest = false |
|
|
|
if (notFound.length > 0){ |
|
|
|
this.$message.warning(`The printer ${notFound.join(',')} is not found`) |
|
|
|
return |
|
|
|
} |
|
|
|
this.$message.success(data.msg) |
|
|
|
}else { |
|
|
|
this.$message.warning(data.msg) |
|
|
|
return; // 阻断后续 |
|
|
|
} |
|
|
|
// 如果copies不大于5,直接执行 |
|
|
|
this.doPrintRollLabel(data, params); |
|
|
|
}).catch((error) => { |
|
|
|
this.$message.error(error); |
|
|
|
this.printLoading = false; |
|
|
|
}).catch((error)=>{ |
|
|
|
this.$message.error(error) |
|
|
|
this.printLoading = false; |
|
|
|
}) |
|
|
|
}); |
|
|
|
}, |
|
|
|
loadQrCode(){ |
|
|
|
let arr = ['2','4','6','8'] |
|
|
|
@ -1416,7 +1448,15 @@ export default { |
|
|
|
handleScanSerialNumber(){ |
|
|
|
this.scanSerialNumberList = [...this.serialNumberList] |
|
|
|
this.serialNumberVisible = true |
|
|
|
} |
|
|
|
}, |
|
|
|
onCopiesInput(val) { |
|
|
|
// 只允许正整数 |
|
|
|
let newVal = String(val).replace(/[^0-9]/g, ''); |
|
|
|
if (newVal === '' || Number(newVal) < 1) { |
|
|
|
newVal = '1'; |
|
|
|
} |
|
|
|
this.printCurrentPart.copies = parseInt(newVal, 10); |
|
|
|
}, |
|
|
|
}, |
|
|
|
mounted () { |
|
|
|
this.getLodopPrinterName(); |
|
|
|
@ -1684,7 +1724,22 @@ export default { |
|
|
|
<!-- </el-col>--> |
|
|
|
<!-- </el-row>--> |
|
|
|
<!-- </div>--> |
|
|
|
<div slot="footer"> |
|
|
|
<div slot="footer" v-if="this.$store.state.user.copiesForRollLabelFlag === 'Y'"> |
|
|
|
<label for="copies-input" style="float:left;line-height:32px;margin-right:4px;margin-top: -5px">Copies</label> |
|
|
|
<el-input-number |
|
|
|
id="copies-input" |
|
|
|
v-model.number="printCurrentPart.copies" |
|
|
|
style="width: 60px; float: left; margin-right: 10px" |
|
|
|
:min="1" |
|
|
|
:controls="false" |
|
|
|
@input="onCopiesInput" |
|
|
|
></el-input-number> |
|
|
|
<el-button type="primary" :loading="printLoading" style="width: 60px;margin-left: -110px" |
|
|
|
@click="handlePrintOrSave">Print |
|
|
|
</el-button> |
|
|
|
<el-button style="width: 60px" @click="printVisible = false">Cancel</el-button> |
|
|
|
</div> |
|
|
|
<div slot="footer" v-else> |
|
|
|
<el-button type="primary" :loading="printLoading" style="width: 60px" @click="handlePrintOrSave">Print</el-button> |
|
|
|
<el-button style="width: 60px" @click="printVisible = false">Cancel</el-button> |
|
|
|
</div> |
|
|
|
|