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
--[[
   编码: AMS-52-21
   名称: 
   作者:
   日期:2025-05-28
 
   函数: ClickItem
   功能:
 
   更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require ("oi_base_mobox")
 
function ClickItem( strLuaDEID )
    
        -- 获取输入参数
    nRet, attrs = m3.GetSysInputParameter(strLuaDEID)
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "获取当前输入面板里的属性失败! " .. attrs)
        return
    end
    lua.Debug(strLuaDEID, debug.getinfo(1), "attrs", attrs)
    
    local input_attr = m3.KeyValueAttrsToObjAttr(attrs)
    local wave_no = input_attr.S_WAVE_NO --波次号
    
    -- 正在码盘和已码盘页面
    local nRet, obj = m3.GetSysDataJson(strLuaDEID) 
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "无法获取数据包! " .. obj)
        return
    end
    
    local input_objs = m3.KeyValueAttrsToObjAttr(obj)
    local item_code = input_objs.S_ITEM_CODE
    local item_name = input_objs.S_ITEM_NAME
    local loc = input_objs.S_LOC_CODE
    
    local strCondition = "S_LOC_CODE = '" .. loc .. "' AND S_ITEM_CODE = '" .. item_code .. "' AND S_WAVE_NO = '" .. wave_no .. "' "
    local data_objs
    nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Distribution_CNTR_Detail", strCondition)
 
    if (nRet ~= 0) then
        mobox.setInfo(strLuaDEID, "查询Distribution_CNTR_Detail失败!" .. data_objs)
        return
    end
    lua.Debug(strLuaDEID, debug.getinfo(1), "data_objs", data_objs)
    
    local list_data = {}
        if data_objs and #data_objs > 0 then
            for i, obj in ipairs(data_objs) do
                -- 从attrs数组中提取S_BS_NO和F_QTY
                local s_bs_no, f_qty
                for _, attr in ipairs(obj.attrs) do
                    if attr.attr == "S_BS_NO" then
                        s_bs_no = attr.value
                    elseif attr.attr == "F_QTY" then
                        f_qty = attr.value
                    end
                end
                
                -- 构建list项
                table.insert(list_data, {
                    S_BS_NO = s_bs_no or "",
                    F_QTY = f_qty or 0
                })
            end
        end
    
    local action_array = {}
    action_array[1] = {
        action_type = "jump_pda_page",
        value = {
            page = {
                page_name = "波次详细界面", 
                list = list_data  -- 使用处理后的数据
            },
            master_view = {  
                S_WAVE_NO = wave_no,
                S_ITEM_CODE = item_code,
                S_ITEM_NAME = item_name 
            }
        }
    }
    
    -- 提交前端操作
    lua.Debug(strLuaDEID, debug.getinfo(1), "action_array", action_array)
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action_array))
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo)
    end
 
 
end