--[[
|
编码: WMS-81-10
|
名称: 出入库测试-新增窗口-初始化
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: InitialNewAddDlg
|
|
功能:
|
根据登录人员获取仓库下拉列表
|
|
更改记录:
|
|
--]]
|
|
wms_base = require ("wms_base")
|
|
function InitialNewAddDlg ( strLuaDEID )
|
local nRet, strRetInfo
|
local strUserLogin, strUserName
|
|
nRet, strUserLogin, strUserName = mobox.getCurUserInfo( strLuaDEID )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "获取当前操作人员信息失败! "..strUserLogin )
|
return
|
end
|
-- 获取当前操作人员的单位编码,作为工厂标识
|
nRet, strRetInfo = mobox.getUserSectionUnit( strUserLogin )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "获取当前操作人员所属单位失败! "..strRetInfo )
|
return
|
end
|
if ( strRetInfo ~= '' ) then
|
local orgInfo = json.decode( strRetInfo )
|
factory = orgInfo.company_code
|
else
|
nRet, factory = wms_base.Get_sConst2( "WMS_Default_Factory" )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "系统无法获取常量'WMS_Default_Factory'")
|
return
|
end
|
end
|
|
local choic_items = {}
|
local wh_code = ''
|
if ( factory ~= '' ) then
|
local strCondition
|
local strOrder = 'S_CODE'
|
strCondition = "S_FACTORY = '"..factory.."'"
|
nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder,"S_CODE" )
|
if (nRet ~= 0) then
|
lua.Stop( strLuaDEID, "获取【仓库】信息失败! " .. strRetInfo)
|
return
|
end
|
if ( strRetInfo ~= '' ) then
|
local warehouse = {}
|
local n, nCount
|
local success
|
local attrs
|
success, warehouse = pcall( json.decode, strRetInfo)
|
if ( success == false ) then
|
lua.Stop( strLuaDEID, "获取【仓库】信息失败! 非法的JSON格式!"..warehouse )
|
return
|
end
|
|
nCount = #warehouse
|
-- 组织下拉列表选项
|
for n = 1, nCount do
|
attrs = warehouse[n].attrs
|
table.insert( choic_items, attrs[1].value )
|
end
|
-- 如果只有一个仓库,那么就默认选这个仓库
|
if ( nCount == 1) then wh_code = attrs[1].value end
|
end
|
end
|
|
local action = {
|
{
|
action_type = "set_dlg_attr",
|
value = {
|
{ attr = "S_TO_WH_CODE", value = wh_code, choice_list = choic_items }
|
}
|
},
|
{
|
action_type = "set_dlg_attr_show",
|
value = {
|
{ attr = "S_CNTR_FROM", show = false }
|
}
|
}
|
}
|
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action ) )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction )
|
return
|
end
|
end
|