剩余模块:生产退料

This commit is contained in:
2025-06-09 22:07:10 +08:00
parent 63a44af1d8
commit 03e22dd9f6
77 changed files with 2832 additions and 817 deletions

View File

@@ -151,10 +151,11 @@
const createLabel = (item : any) => {
var command = tsc.default.createNew()
command.setSize(100, 50)
command.setGap(2)
command.setCls()
command.setQR(30, 100, "L", 7, "A", item.FBarCode)
command.setText(280, 40, "TSS24.BF2", 1, 1, `Supplier Name${item.FSupplierId}`)
command.setText(280, 40, "TSS24.BF2", 1, 1, `Supplier Name${state.pageData.FSupplierId}`)
command.setText(280, 80, "TSS24.BF2", 1, 1, `P/N${item.FMaterialId}`)
command.setText(280, 120, "TSS24.BF2", 1, 1, `Qty${item.FQty}`)
command.setText(280, 160, "TSS24.BF2", 1, 1, `Batch No${item.FLot}`)
@@ -165,47 +166,59 @@
command.setPagePrint()
state.sendData = command.getData();
}
const sendHexStr = () => {
let arr = []
let data1 = {
FBarCodeRule: "01",
FBarCode: `${state.pageData.FBillCode}*${state.pageData.FMaterialId}*${state.pageData.FLotText}*${Number(state.pageData.FQty) - Number(state.pageData.splitQty)}`,
FBillCode:state.pageData.FBillCode,
FMaterialId: state.pageData.FMaterialId,
FSupplierLot: state.pageData.FSupplierLot,
FLot: state.pageData.FLotText,
FQty: (Number(state.pageData.FQty) - Number(state.pageData.splitQty)) + ''
}
let data2 = {
FBarCodeRule: "01",
FBarCode: `${state.pageData.FBillCode}*${state.pageData.FMaterialId}*${state.pageData.FLotText}*${Number(state.pageData.splitQty)}`,
FBillCode:state.pageData.FBillCode,
FMaterialId: state.pageData.FMaterialId,
FSupplierLot: state.pageData.FSupplierLot,
FLot: state.pageData.FLotText,
FQty: Number(state.pageData.splitQty) + ''
}
arr = [data1,data2]
UHIK_BD_BarCodeMainFileSave({
Key: 'qwe123!@#',
Items: arr
},true).then((res : any) => {
console.log(res);
if (res.code == 200) {
setTimeout(()=>{
createLabel(arr[0])
initPrint()
},2000)
setTimeout(()=>{
createLabel(arr[1])
initPrint()
},4000)
} else {
uni.$u.toast(res.msg)
}
})
const sendHexStr = async () => {
try {
// 1. 提取通用数据创建逻辑
const createItem = (qty:any) => ({
FBarCodeRule: "01",
FBarCode: `${state.pageData.FBillCode}*${state.pageData.FMaterialId}*${state.pageData.FLotText}*${qty}`,
FBillCode: state.pageData.FBillCode,
FMaterialId: state.pageData.FMaterialId,
FSupplierLot: state.pageData.FSupplierLot,
FLot: state.pageData.FLotText,
FQty: String(qty)
});
// 2. 数值计算只执行一次
const originalQty = Number(state.pageData.FQty);
const splitQty = Number(state.pageData.splitQty);
const remainingQty = originalQty - splitQty;
// 3. 创建数据项数组
const items = [
createItem(remainingQty),
createItem(splitQty)
];
// 4. 密钥应该从安全配置获取,避免硬编码
const API_KEY = process.env.BARCODE_API_KEY || 'qwe123!@#';
// 5. 使用async/await处理异步
const res = await UHIK_BD_BarCodeMainFileSave({
Key: API_KEY,
Items: items
}, true);
if (res.code !== 200) {
uni.$u.toast(res.msg);
return;
}
// 6. 顺序打印(避免使用固定延迟)
for (const [index, item] of items.entries()) {
// 第一个立即执行,后续延迟执行
if (index > 0) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
createLabel(item);
initPrint();
}
} catch (error) {
console.error('标签打印失败:', error);
uni.$u.toast('操作失败,请重试');
}
}
const initPrint = () => {
if (state.sendData == null) {