--[[
|
编码: JX-35-15
|
名称: 指定出库容器明细-3053-指定出库-条码输入变化后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterUPCChange
|
|
功能:
|
-- 根据输入的条码到【SKU_UPC】找到货品编码
|
-- 如果当前入库任务的货品编码相同 组盘数量+1
|
|
|
更改记录:
|
|
--]]
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function AfterUPCChange ( strLuaDEID )
|
local nRet, strRetInfo
|
|
-- 获取UPC
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "UPC","S_ITEM_CODE","F_ACT_QTY" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local upc = lua.Get_StrAttrValue( obj_attrs[1].value )
|
local item_code = lua.Get_StrAttrValue( obj_attrs[2].value )
|
local act_qty = lua.Get_NumAttrValue( obj_attrs[3].value )
|
if ( upc == '' ) then return end
|
|
-- 通过条码找到物料编码
|
local material_barcode
|
nRet, material_barcode = m3.GetDataObjectByKey(strLuaDEID, "SKU_UPC", "S_UPC_CODE", upc)
|
if (nRet ~= 0 ) then
|
if ( nRet == 1 ) then
|
mobox.setInfo( strLuaDEID, "条码'"..upc.."'没有对应的货品,请检查物料条码对照表!")
|
goto set_dlg_attr
|
end
|
lua.Error( strLuaDEID, debug.getinfo(1), "获取【物料条码】信息失败! " .. material_barcode )
|
end
|
|
-- 判断扫码的货品是否是目前的入库任务
|
if ( item_code ~= material_barcode.item_code ) then
|
mobox.setInfo( strLuaDEID, "条码'"..upc.."'对应的货品编码='"..material_barcode.item_code.."不是当前入库任务中的货物!")
|
goto set_dlg_attr
|
end
|
act_qty = act_qty + 1
|
|
::set_dlg_attr::
|
local action =
|
{
|
{
|
action_type = "set_panel_dlg_attr",
|
value = {
|
panel_name = "指定出库",
|
attrs = {
|
{
|
attr = "F_ACT_QTY",
|
value = act_qty
|
},
|
{
|
attr = "UPC",
|
value = ""
|
}
|
}
|
}
|
|
}
|
}
|
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end
|
|
end
|