Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
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
--[[
    编码: WMS-01-18
    名称: 批量新增料箱-初始化
    作者:HAN  
    日期:2025-4-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: DlgInitial
 
    功能:
        -- 弹出自定义表单编辑 容器类型定义 属性时,初始化自定义表单界面
    更改记录:
 
--]]
 
wms_base = require( "wms_base" )
 
function DlgInitial ( strLuaDEID ) 
    local nRet, strRetInfo, n, nCount
    local choice_items = {}
    local strCondition, ctd_code
    local strOrder = 'S_CTD_CODE'
    
    strCondition = ""
    nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Container_Type_Def", strCondition, strOrder,"S_CTD_CODE","S_NAME" )
    if (nRet ~= 0) then 
        lua.Stop( strLuaDEID, "获取【Container_Type_Def】信息失败! " .. strRetInfo )
        return
    end
 
    ctd_code = ''
    if ( strRetInfo ~= '' ) then
        local ctd_set = {}
        local success
        local attrs
        success, ctd_set = pcall( json.decode, strRetInfo)
        if ( success == false ) then 
            lua.Stop( strLuaDEID, "获取【Container_Type_Def】信息失败! 非法的JSON格式!"..ctd_set ) 
            return
        end
 
        nCount = #ctd_set
 
        -- 组织下拉列表选项
        local ctd_name
        for n = 1, nCount do
            attrs = ctd_set[n].attrs
            ctd_name = attrs[2].value
            choice_items[n] = attrs[1].value
            if ( ctd_name ~= '' ) then
                choice_items[n] = choice_items[n].."/"..ctd_name
            end
        end
        -- 如果只有一个仓库,那么就默认选这个仓库
        if ( nCount == 1) then 
            ctd_code = choice_items[1] 
        end
    end
 
    if ( #choice_items == 0 ) then return end
    local action = {
        {
            action_type = "set_dlg_attr",
            value = {
                { attr = "S_CTD_CODE", value = ctd_code, choice_list = choice_items }
            }
        }
    }
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str( action )  )
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction )
        return
    end 
end