--[[
|
编码: WMS-33-01
|
名称: 指定出库-创建前
|
作者:HAN
|
日期:2025-1-29
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: BeforeDataObjCreate
|
|
功能:
|
-- 考虑到物料编码和容器编码允许输入,因此需要判断一下物料编码是否有效
|
|
更改记录:
|
--]]
|
|
wms_base = require ("wms_base")
|
|
function BeforeDataObjCreate ( strLuaDEID )
|
local nRet, strRetInfo
|
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "N_TYPE", "S_ITEM_CODE", "S_ITEM_NAME", "S_SO_NO")
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local so_type = lua.Get_NumAttrValue( obj_attrs[1].value )
|
local so_no = lua.Get_StrAttrValue( obj_attrs[4].value )
|
local attr_value = {}
|
local nIndex = 1
|
local str_so_type = wms_base.GetDictItemName( strLuaDEID, "WMS_SpecifyOutboundType", so_type )
|
|
-- 2 指定货品出库
|
if ( so_type == 2 ) then
|
local item_code = lua.Get_StrAttrValue( obj_attrs[2].value )
|
local item_name = lua.Get_StrAttrValue( obj_attrs[3].value )
|
|
if ( item_name == '') then
|
local material
|
if ( item_code == '' ) then
|
mobox.stopProgram( strLuaDEID, "物料/货品编码不能为空!" )
|
return
|
end
|
nRet, material = m3.GetDataObjectByKey( strLuaDEID, "SKU", "S_ITEM_CODE", item_code )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetDataObjectByKey失败"..material ) end
|
|
|
attr_value[nIndex] = lua.KeyValueObj( "S_ITEM_NAME", material.item_name )
|
nIndex = nIndex + 1
|
end
|
end
|
|
-- 生成指定出库号
|
if ( so_no == '' ) then
|
local strHeader = 'SOO'..os.date("%y%m")..'-'
|
nRet,so_no = mobox.getSerialNumber( "指定出库单", strHeader, 4 )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '生成指定出库单号失败!'..so_no ) end
|
|
-- 设置信息
|
attr_value[nIndex] = lua.KeyValueObj( "S_SO_NO", so_no )
|
nIndex = nIndex + 1
|
end
|
attr_value[nIndex] = lua.KeyValueObj( "S_TYPE", str_so_type )
|
nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置信息失败! "..strRetInfo ) end
|
|
end
|