--[[
|
编码: WMS-16-04
|
名称: 盘点单-查询面板-仓库选择变化
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: WHCodeChange
|
|
功能:
|
1)仓库选择变化后需要变化库区
|
更改记录:
|
V6.0 HAN 2023/9/6 -- lua.Error/lua.Debug 函数变化
|
--]]
|
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function WHCodeChange ( strLuaDEID )
|
local nRet, strRetInfo
|
local wh_code
|
|
-- 获取 仓库编码
|
nRet, wh_code = m3.GetSysCurEditDataOneAttr( strLuaDEID, "S_WH_CODE" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetSysCurEditDataOneAttr失败! "..wh_code ) end
|
|
local choic_items = ''
|
if ( wh_code ~= '') then
|
-- 获取【库区】,类型 是储藏区的库区 N_TYPE = 1
|
local strCondition = "S_WH_CODE = '"..wh_code.."' AND N_TYPE = 1"
|
local strOrder = "S_CODE"
|
nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Area", strCondition, strOrder,"S_CODE" )
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【库区】信息失败! " .. strRetInfo) end
|
if ( strRetInfo ~= "") then
|
local areas = {}
|
local n, nCount
|
local success
|
local attrs
|
success, areas = pcall( json.decode, strRetInfo)
|
if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "非法的JSON格式!"..areas ) end
|
|
-- 组织下拉列表选项
|
nCount = #areas
|
for n = 1, nCount do
|
attrs = areas[n].attrs
|
choic_items = choic_items..'"'..attrs[1].value..'",'
|
end
|
choic_items = lua.trim_laster_char( choic_items )
|
end
|
end
|
|
-- 设置窗口中的 库区 列表
|
local setAttr = '[{"attr":"S_AREA_CODE","value":"","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
|