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
107
108
109
110
111
112
113
114
115
--[[
    编码: WMS-16-10
    名称: 盘点计划-查询自定义表单-初始化
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: InitialQueryPanel
 
    功能:
        -- 获取当前登录人员的【工厂】中的工厂标识,初始化【仓库】中的下拉框里内容
        -- 默认设置盘点类型为 货物盘点
        -- 查询输入界面 隐藏  Layout_Location 和 Layout_cntr_code
    更改记录:
        -- V2.0 HAN 20240617  隐藏  Layout_Location
        -- V2.1 HAN 20240618  隐藏  Layout_cntr_code
--]]
 
wms_base = require("wms_base")
 
function InitialQueryPanel(strLuaDEID)
    local nRet, strRetInfo, factory
 
    -- 1. 获取当前登录人员的工厂标识
    nRet, factory = wms_base.GetMyFactory(strLuaDEID)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "GetMyFactory失败! " .. factory)
    end
    if (factory == "") then
        nRet, factory = wms_base.Get_sConst2(strLuaDEID, "WMS_Default_Factory")
        if ( nRet ~= 0 ) then
            lua.Stop( strLuaDEID, "系统无法获取常量'WMS_Default_Factory'")
            return
        end
    end
    if (factory == "") then
        lua.Error(strLuaDEID, debug.getinfo(1), "当前操作人员无法获取所属工厂!")
    end
 
    -- 2. 获取当前工厂下的仓库列表
    local strCondition = "S_FACTORY = '" .. factory .. "'"
    local strOrder = "S_CODE"
    nRet, strRetInfo = mobox.queryDataObjAttr(strLuaDEID, "Warehouse", strCondition, strOrder, "S_CODE")
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "获取【仓库】信息失败! " .. strRetInfo)
    end
    if (strRetInfo == "") then
        lua.Error(strLuaDEID, debug.getinfo(1), "当前操作人员所属工厂没定义仓库!")
    end
 
    -- 3. 解析仓库列表
    local warehouse = {}
    local success
    success, warehouse = pcall(json.decode, strRetInfo)
    if (success == false) then
        lua.Error(strLuaDEID, debug.getinfo(1), "非法的JSON格式!" .. warehouse)
    end
 
    -- 4. 组织下拉列表选项
    local choic_items = ""
    local nCount = #warehouse
    for n = 1, nCount do
        local attrs = warehouse[n].attrs
        choic_items = choic_items .. '"' .. attrs[1].value .. '",'
    end
    choic_items = lua.trim_laster_char(choic_items)
 
    -- 5. 设置窗口中的仓库列表和盘点类型
    local action_list = {}
 
    local nType = wms_base.Get_nConst(strLuaDEID, "盘点类型-货品盘点")
    local setAttr = '[{"attr":"S_WH_CODE","value":"","choice_list":[' .. choic_items .. ']},'
    setAttr = setAttr .. '{"attr":"N_TYPE","value":"' .. nType .. '"}]'
 
    local action = {}
    action.action_type = "set_dlg_attr"
    action.value = json.decode(setAttr)
    action_list[1] = action
 
    -- 6. 设置界面控件的显示和隐藏
    local action = {}
    action.action_type = "set_dlg_attr_show"
    local value = {}
 
    -- 隐藏 Layout_Location
    local ctrl_attr = {}
    ctrl_attr.attr = "Layout_Location"
    ctrl_attr.show = false
    value[1] = ctrl_attr
 
    -- 显示 Layout_Material
    local ctrl_attr = {}
    ctrl_attr.attr = "Layout_Material"
    ctrl_attr.show = true
    value[2] = ctrl_attr
    
    -- BY KUN 新增容器查询
    -- 隐藏 Layout_cntr_code
    local ctrl_attr = {}
    ctrl_attr.attr = "Layout_cntr_code"
    ctrl_attr.show = false
    value[3] = ctrl_attr
 
    action.value = value
    action_list[2] = action
 
    -- 7. 执行动作
    lua.Debug(strLuaDEID, debug.getinfo(1), "action_list", action_list)
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action_list))
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo .. " action = " .. lua.table2str(action_list))
    end
end