--[[
|
编码: WMS-13-04
|
名称: 预收货通知-小窗口工厂标识变化
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: FactoryChange
|
|
功能:
|
1)根据工厂标识获取该工厂下面的【仓库】,并且初始化小窗口中的仓库下拉列表框
|
更改记录:
|
|
--]]
|
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function FactoryChange ( strLuaDEID )
|
local nRet, strRetInfo
|
local strCondition = ''
|
local strOrder = 'S_CODE'
|
local strFactory
|
local choic_items = ''
|
local wh_code = ''
|
|
-- 获取当前选中的工厂标识
|
nRet, strFactory = m3.GetSysCurEditDataOneAttr( strLuaDEID, "S_FACTORY" )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetSysCurEditDataOneAttr失败! "..strFactory ) end
|
if (strFactory ~= '') then
|
-- 获取【仓库】
|
strCondition = "S_FACTORY = '"..strFactory.."'"
|
nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder,"S_CODE" )
|
if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【仓库】信息失败! " .. strRetInfo) end
|
local warehouse = {}
|
local n, nCount
|
local success
|
local attrs
|
success, warehouse = pcall( json.decode, strRetInfo)
|
if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "非法的JSON格式!"..warehouse ) end
|
|
nCount = #warehouse
|
-- 组织下拉列表选项
|
|
for n = 1, nCount do
|
attrs = warehouse[n].attrs
|
choic_items = choic_items..'"'..attrs[1].value..'",'
|
end
|
choic_items = lua.trim_laster_char( choic_items )
|
-- 如果只有一个仓库,那么就默认选这个仓库
|
if ( nCount == 1) then wh_code = attrs[1].value end
|
end
|
|
local setAttr = '[{"attr":"S_WH_CODE","value":"'..wh_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
|