--[[
|
编码: WMS-71-11
|
名称: 库存量表差异-新增窗口-选择仓库后
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: AfterWarehouseChg
|
|
功能:
|
根据选中的仓库获取仓库库区列表
|
|
更改记录:
|
|
--]]
|
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function AfterWarehouseChg ( strLuaDEID )
|
local nRet, strRetInfo
|
|
nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_WH_CODE" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end
|
local obj_attrs = json.decode( strRetInfo )
|
local wh_code = obj_attrs[1].value
|
local choic_items = ''
|
local area_code = ''
|
|
if ( wh_code ~= '' ) then
|
local strCondition
|
local strOrder = 'S_CODE'
|
strCondition = "S_WH_CODE = '"..wh_code.."'"
|
nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Area", strCondition, strOrder,"S_CODE" )
|
if (nRet ~= 0) then error( "获取【库区】信息失败! " .. strRetInfo) end
|
if ( strRetInfo ~= '' ) then
|
local area = {}
|
local n, nCount
|
local success
|
local attrs
|
success, area = pcall( json.decode, strRetInfo)
|
if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【仓库】信息失败! 非法的JSON格式!"..area ) end
|
|
nCount = #area
|
-- 组织下拉列表选项
|
|
for n = 1, nCount do
|
attrs = area[n].attrs
|
choic_items = choic_items..'"'..attrs[1].value..'",'
|
end
|
choic_items = lua.trim_laster_char( choic_items )
|
-- 如果只有一个仓库,那么就默认选这个仓库
|
if ( nCount == 1) then area_code = attrs[1].value end
|
end
|
end
|
|
local setAttr = '[{"attr":"S_AREA_CODE","value":"'..area_code..'","choice_list":['..choic_items..']}]'
|
local strAction = '[{"action_type":"set_dlg_attr","value":'..setAttr..'}]'
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, strAction )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end
|
|
end
|