1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
--[[
    编码: WMS-04-10
    名称: 查询输入面板-初始化
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: InitialDlg
 
    功能:
        -- 设置仓库查询列表控件
 
    更改记录:
 
--]]
 
wms_base = require ("wms_base")
 
function InitialDlg ( strLuaDEID ) 
    local nRet, strRetInfo
 
    local strUserLogin, strUserName
    nRet, strUserLogin, strUserName = mobox.getCurUserInfo( strLuaDEID )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前操作人员信息失败! "..strUserLogin ) end
    -- 获取当前操作人员的单位编码,作为工厂标识
    nRet, strRetInfo = mobox.getUserSectionUnit( strUserLogin )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前操作人员所属单位失败! "..strRetInfo ) end
    if ( strRetInfo ~= '' ) then
        local orgInfo = json.decode( strRetInfo ) 
        factory = orgInfo.company_code
    else
        nRet, factory = wms_base.Get_sConst2( "WMS_Default_Factory" )
        if ( nRet ~= 0 ) then
            lua.Stop( strLuaDEID, "系统无法获取常量'WMS_Default_Factory'")
            return
        end          
    end
 
    local choice_items = {}
    local wh_code = ''
    local area_choice_items = {}
    local n, nCount
 
    if ( factory ~= '' ) then
        local strCondition
        local strOrder = 'S_CODE'
        
        strCondition = "S_FACTORY = '"..factory.."'"
        nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder,"S_CODE" )
        if (nRet ~= 0) then error( "获取【仓库】信息失败! " .. strRetInfo) end
        if ( strRetInfo ~= '' ) then
            local warehouse = {}
            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
                choice_items[n] = attrs[1].value
            end
            -- 如果只有一个仓库,那么就默认选这个仓库
            if ( nCount == 1) then 
                wh_code = attrs[1].value 
                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 = {}
                    success, area = pcall( json.decode, strRetInfo)
                    if ( success == false ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【库区】信息失败! 非法的JSON格式!"..area ) end
                    for n = 1, #area do
                        attrs = area[n].attrs
                        area_choice_items[n] = attrs[1].value
                    end
                end
            
            end
        end
    end
 
    if ( #choice_items == 0 ) then return end
    local action = {}
    action[1] = {
                    action_type = "set_dlg_attr",
                    value = {
                        { attr = "S_WH_CODE", value = wh_code, choice_list = choice_items }
                    }
                 }
    if ( nCount == 1 ) then
        action[2] = {
            action_type = "set_dlg_attr",
            value = {
                { attr = "S_AREA_CODE", value = "", choice_list = area_choice_items }
            }
         }        
    end
 
    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