1
Jianw
2025-07-09 88e26a2a960dbbc148332772448b79b9877102d8
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
--[[
    编码: WMS-85-20
    名称: 新增小窗口-初始化
    作者:HAN
    日期:2025-1-29
 
    级别:项目
    
    函数: InitialDlg
 
    功能:
        -- 获取【码盘单】中的码盘编码流水号,容器号属性
 
    更改记录:
       
--]]
 
wms_cntr = require( "wms_container" )
 
function InitialDlg ( strLuaDEID ) 
    local nRet, strRetInfo
    local run_paramter
    
    -- step1  获取运行环境参数
    nRet, run_paramter = m3.GetRuntimeParam(strLuaDEID) 
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), run_paramter ) end
    local master = run_paramter.master
    if (master == nil) then lua.Error( strLuaDEID, debug.getinfo(1), "系统没有在环境参数中定义master对象信息!" ) end
 
    local cntr_code = master.objAttr.S_CNTR_CODE or ''
    local inb_no = master.objAttr.S_IBP_NO or ''
 
    if ( cntr_code == '' or inb_no == '') then return end
 
    local cntr
    nRet, cntr = wms_cntr.GetInfo( strLuaDEID, cntr_code )
    if ( nRet ~= 0 ) then
        return 2, cntr
    end
 
    local  attr_value = {
        { attr = "S_IBP_NO", value = inb_no },
        { attr = "S_CNTR_CODE", value = cntr_code }
    }    
    if ( cntr.type == "Cell_Box" )  then 
        local cell_list = {}
 
        local strCondition = "S_CNTR_CODE = '"..cntr_code.."'"
        nRet, data_objects = m3.QueryDataObject(strLuaDEID, "Container_Cell", strCondition, "S_CELL_NO" )
        if (nRet ~= 0) then 
            lua.Stop( strLuaDEID, "QueryDataObject失败!"..data_objects )
            return
        end
        if ( data_objects ~= '') then
            for n = 1, #data_objects do
                data_attr = m3.KeyValueAttrsToObjAttr(data_objects[n].attrs)
                table.insert( cell_list, data_attr.S_CELL_NO )
            end
        end
 
        local attr_set = { attr = "S_CELL_NO", value = "", choice_list = cell_list }
        table.insert( attr_value, attr_set )
 
        local action = {
            {
                action_type = "set_dlg_attr",
                value = attr_value
            }
        }
        nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action )  )
        if ( nRet ~= 0 ) then 
            lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction ) 
            return
        end          
    else 
        -- 如果不是带料格的料箱 不显示 料格
        local action = {
                    {
                        action_type = "set_dlg_attr_show",
                        value = {
                                    { attr = "S_CELL_NO",show = false}
                                }
                    }
                }
        nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action )  )
        if ( nRet ~= 0 ) then 
            lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction ) 
            return
        end        
    end  
 
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, "设置【逻辑库区】信息失败!  "..strRetInfo )
        return
    end
end