|
|
|
@ -794,6 +794,14 @@ import { |
|
|
|
saveSysLanguageList |
|
|
|
} from "@/api/sysLanguage.js"; |
|
|
|
|
|
|
|
// 引入物料标签打印相关API |
|
|
|
import { |
|
|
|
getPartLabelTemplateList, |
|
|
|
callUspPartLabelTemplate |
|
|
|
} from '@/api/wms/wms'; |
|
|
|
import getLodop from '@/utils/LodopFuncs.js'; |
|
|
|
import labelPrintTemplates from '@/mixins/labelPrintTemplates.js'; |
|
|
|
|
|
|
|
|
|
|
|
/*引入组件*/ |
|
|
|
import comSwitchOperator from "./com_switch_operator";/*切换操作员*/ |
|
|
|
@ -819,6 +827,7 @@ import ComProcessInspection from "./com_process_inspection";/*过程检验组件 |
|
|
|
import ComMrbRegister from "./com_mrb_register";/*MRB异常单登记组件*/ |
|
|
|
var functionId = 'C10000002'; |
|
|
|
export default { |
|
|
|
mixins: [labelPrintTemplates], // 添加标签打印模板 mixin |
|
|
|
data() { |
|
|
|
return { |
|
|
|
titleCon: '', |
|
|
|
@ -4647,18 +4656,161 @@ export default { |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
/*打印流转标签*/ |
|
|
|
printSfdcFlowLabel(sfdcRow) { |
|
|
|
//先查询打印的卷信息 |
|
|
|
getSfdcFlowLabelData(sfdcRow).then(({data}) => { |
|
|
|
//开始打印标签 |
|
|
|
if (data.code == 200) { |
|
|
|
let printList = data.printList; |
|
|
|
/*打印流转标签 - 优化版:使用模板打印*/ |
|
|
|
async printSfdcFlowLabel(sfdcRow) { |
|
|
|
try { |
|
|
|
// 1. 先查询打印的卷信息 |
|
|
|
const {data} = await getSfdcFlowLabelData(sfdcRow); |
|
|
|
|
|
|
|
if (data.code !== 200) { |
|
|
|
this.$message.error(data.msg); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const printList = data.printList || []; |
|
|
|
if (printList.length === 0) { |
|
|
|
this.$message.warning('没有可打印的标签数据'); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 使用模板打印 |
|
|
|
await this.printLabelsWithTemplate(printList); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('打印标签失败:', error); |
|
|
|
this.$message.error('打印标签失败: ' + error.message); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 使用模板打印标签(优化版) |
|
|
|
* @param {Array} printList - 打印数据列表 |
|
|
|
*/ |
|
|
|
async printLabelsWithTemplate(printList) { |
|
|
|
try { |
|
|
|
// 1. 获取 LODOP 打印控件 |
|
|
|
const LODOP = getLodop(); |
|
|
|
if (!LODOP) { |
|
|
|
this.$message.error('无法连接到打印控件,请确保已安装并启动 CLodop!'); |
|
|
|
// 降级处理:使用原有的流转标签打印方式 |
|
|
|
printSfdcLabel(printList); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 2. 查询物料的标签模板设置(找默认模板) |
|
|
|
const templateParams = { |
|
|
|
site: this.scheduleData.site, |
|
|
|
buNo: this.scheduleData.buNo, |
|
|
|
partNo: this.scheduleData.partNo |
|
|
|
}; |
|
|
|
|
|
|
|
const {data: templateData} = await getPartLabelTemplateList(templateParams); |
|
|
|
|
|
|
|
if (!templateData || templateData.code !== 0 || !templateData.list || templateData.list.length === 0) { |
|
|
|
console.warn('未找到物料标签模板配置,使用默认流转标签打印'); |
|
|
|
printSfdcLabel(printList); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 找到默认模板(default_flag = '1') |
|
|
|
const defaultTemplate = templateData.list.find(t => t.defaultFlag === '1') || templateData.list[0]; |
|
|
|
|
|
|
|
if (!defaultTemplate) { |
|
|
|
console.warn('未找到默认模板,使用默认流转标签打印'); |
|
|
|
printSfdcLabel(printList); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const labelNo = defaultTemplate.labelNo; |
|
|
|
|
|
|
|
// 3. 获取默认打印机 |
|
|
|
const printerCount = LODOP.GET_PRINTER_COUNT(); |
|
|
|
let defaultPrinterName = ''; |
|
|
|
if (printerCount > 0) { |
|
|
|
defaultPrinterName = LODOP.GET_PRINTER_NAME(0); |
|
|
|
} else { |
|
|
|
this.$message.error(data.msg); |
|
|
|
this.$message.error('未检测到打印机,请确保已安装并连接打印机!'); |
|
|
|
return; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 4. 调用存储过程获取打印数据 |
|
|
|
const printDataList = []; |
|
|
|
for (const item of printList) { |
|
|
|
const params = { |
|
|
|
site: this.scheduleData.site, |
|
|
|
buNo: this.scheduleData.buNo, |
|
|
|
menuID: '104003006', // 功能ID |
|
|
|
relatedOrderNo: this.scheduleData.orderNo, |
|
|
|
relatedOrderLineNo: this.scheduleData.seqNo, |
|
|
|
documentNo: '', |
|
|
|
partNo: this.scheduleData.partNo, |
|
|
|
labelNo: labelNo, |
|
|
|
rollNo: item.rollNo |
|
|
|
}; |
|
|
|
|
|
|
|
const {data: printData} = await callUspPartLabelTemplate(params); |
|
|
|
if (printData && printData.code === 0 && printData.row) { |
|
|
|
printDataList.push({ |
|
|
|
...printData.row, |
|
|
|
labelNo: labelNo |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.warn(`获取卷号 ${item.rollNo} 的打印参数失败,使用原始数据`); |
|
|
|
printDataList.push({ |
|
|
|
...item, |
|
|
|
labelNo: labelNo |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 5. 执行模板打印 |
|
|
|
this.executePrintWithTemplate(LODOP, printDataList, labelNo, defaultPrinterName); |
|
|
|
|
|
|
|
this.$message.success('标签打印任务已发送!'); |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
console.error('模板打印失败:', error); |
|
|
|
this.$message.warning('模板打印失败,使用默认流转标签打印'); |
|
|
|
// 降级处理:使用原有的流转标签打印方式 |
|
|
|
printSfdcLabel(printList); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行模板打印 |
|
|
|
* @param {Object} LODOP - 打印控件对象 |
|
|
|
* @param {Array} printDataList - 打印数据列表 |
|
|
|
* @param {String} labelNo - 标签模板编号 (A001/A002/A003) |
|
|
|
* @param {String} printerName - 打印机名称 |
|
|
|
*/ |
|
|
|
executePrintWithTemplate(LODOP, printDataList, labelNo, printerName) { |
|
|
|
// 初始化打印任务 |
|
|
|
LODOP.PRINT_INIT('机器下机卷标签打印'); |
|
|
|
|
|
|
|
// 设置打印模式,隐藏水印 |
|
|
|
LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE", true); |
|
|
|
|
|
|
|
// 设置打印机 |
|
|
|
LODOP.SET_PRINTER_INDEX(printerName); |
|
|
|
|
|
|
|
// 循环打印每个标签 |
|
|
|
for (let i = 0; i < printDataList.length; i++) { |
|
|
|
const printData = printDataList[i]; |
|
|
|
const isNewPage = i > 0; |
|
|
|
// 根据 labelNo 调用不同的打印方法(来自 labelPrintTemplates mixin) |
|
|
|
if (labelNo === 'A001') { |
|
|
|
this.printLabelA001(LODOP, printData, isNewPage); |
|
|
|
} else if (labelNo === 'A002') { |
|
|
|
this.printLabelA002(LODOP, printData, isNewPage); |
|
|
|
} else if (labelNo === 'A003') { |
|
|
|
this.printLabelA003(LODOP, printData, isNewPage); |
|
|
|
} else { |
|
|
|
this.$message.warning(`未知的标签模板:${labelNo}`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 预览打印(避免水印) |
|
|
|
LODOP.PREVIEW(); |
|
|
|
}, |
|
|
|
|
|
|
|
// 打开过程检验对话框 |
|
|
|
|