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
77
78
79
80
81
82
83
84
85
86
87
88
89
--[[
    编码: WMS-04-13
    名称: 查询面板-库区变化后
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: AreaChange
 
    功能:
        需要设置 巷道、排下拉列表
 
    更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function AreaChange( 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 area_code = lua.Get_StrAttrValue( attrs.S_AREA_CODE ) 
 
    if ( area_code == '' or area_code == nil ) then return end
    -- 查询货位里的巷道库区编码
    
    local strCondition
    local strOrder = 'N_AISLE'
    
    strCondition = "S_AREA_CODE = '"..area_code.."'"
    nRet, strRetInfo = mobox.groupDataObjAttr( strLuaDEID, "Location", strCondition, "N_AISLE", strOrder )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "无法从【货位】中获取信息!"..strRetInfo ) end 
 
    local groups = json.decode( strRetInfo ) 
    local n
    local value = {}
    if ( #groups == 0 ) then
        value = {
            { attr = "Aisle", value = "" },
            { attr = "Row", value = "" }            
        }
    else
        local aisle_choice_items = {}
        for n = 1, #groups do
            table.insert( aisle_choice_items, groups[n].value )
        end
        value[1] = { attr = "Aisle", value = "", choice_list = aisle_choice_items }
 
        strOrder = "N_ROW"
        nRet, strRetInfo = mobox.groupDataObjAttr( strLuaDEID, "Location", strCondition, "N_ROW", strOrder )
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "无法从【货位】中获取信息!"..strRetInfo ) end 
 
        groups = json.decode( strRetInfo ) 
        if ( #groups == 0 ) then
            value[2] = { attr = "Row", value = "" }
        else
            local row_choice_items = {}
            for n = 1, #groups do
                table.insert( row_choice_items, groups[n].value )
            end
            value[2] = { attr = "Row", value = "", choice_list = row_choice_items }
        end
    end
 
    local action = {
        {
            action_type = "set_dlg_attr",
            value = value
        },
        {
            action_type = "click_query_button",
            value = ""
        }
    }
 
    lua.Debug( strLuaDEID, debug.getinfo(1), "action", action )
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action )  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end 
end