--[[
|
编码: JX-83-11
|
名称: 容器料格-自定义表单-选货品后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterSelectGood
|
|
功能:
|
在货品查询面板中选中一个货品后
|
|
更改记录:
|
|
--]]
|
|
wms_base = require ("wms_base")
|
jx_base = require( "jx_base" )
|
|
function AfterSelectGood ( strLuaDEID )
|
local nRet, strRetInfo, select_dataobj
|
|
nRet, select_dataobj = m3.GetSysInputParameter( strLuaDEID )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取选中数据对象属性失败! "..select_dataobj ) end
|
local item_code = select_dataobj.S_ITEM_CODE
|
local item_name = select_dataobj.S_ITEM_NAME
|
local weight = lua.StrToNumber( select_dataobj.F_WEIGHT )
|
local volume = lua.StrToNumber( select_dataobj.F_VOLUME )
|
|
if ( volume == 0 ) then
|
lua.Error( strLuaDEID, debug.getinfo(1), "选中的物料体积为0! " )
|
end
|
|
|
-- 获取当前容器的料箱类型
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_CELL_NO" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local cell_no = lua.Get_StrAttrValue( obj_attrs[1].value )
|
|
local seg = lua.split( cell_no, '-' )
|
local cell_type = seg[1]
|
local cell_volume
|
nRet, cell_volume = jx_base.GetCellVolume( strLuaDEID, cell_type )
|
if ( nRet ~= 0 ) then
|
mobox.stopProgram( strLuaDEID, cell_volume )
|
return
|
end
|
|
-- 计算料格最多可以存储货品数量
|
local qty = math.floor( cell_volume/ volume )
|
|
local action = {
|
{
|
action_type = "set_dlg_attr",
|
value = {
|
{ attr = "S_ITEM_CODE", value = item_code },
|
{ attr = "S_ITEM_NAME", value = item_name },
|
{ attr = "Volume", value = volume },
|
{ attr = "Weight", value = weight },
|
{ attr = "Qty", value = qty },
|
{ attr = "MaxQty", value = qty }
|
}
|
}
|
}
|
|
lua.Debug( strLuaDEID, debug.getinfo(1),"action", action)
|
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end
|
|
end
|