fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
--[[
    编码: WMS-04-12
    名称: 查询面板-仓库变化后
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: WarehouseChange
 
    功能:
        需要设置 库区下拉列表 的变化
 
    更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function WarehouseChange( strLuaDEID )
    local nRet, strRetInfo
    local parameter = {}
    local attrs
 
    -- 获取查询面板里的输入的仓库编码属性
    nRet, parameter = m3.GetSysInputParameter( strLuaDEID ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "m3.GetSysInputParameter 失败! "..attrs ) end 
    attrs = m3.KeyValueAttrsToObjAttr( parameter )
    local wh_code = lua.Get_StrAttrValue( attrs.S_WH_CODE ) 
 
    if ( wh_code == '' or wh_code == nil ) then return end
    -- 查询仓库里的库区编码
    
    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
 
    local choice_items = {}    
    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
            table.insert( choice_items, attrs[1].value )
        end
    end
 
    local action = {
        {
            action_type = "set_dlg_attr",
            value = {
                { attr = "S_AREA_CODE", value = "", choice_list = choice_items }
            }
        },
        {
            action_type = "click_query_button",
            value = ""
        }
    }
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action )  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end 
end