fy36
2025-07-01 350eb5ec9163d3ea21416b1525bb80191e958071
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
--[[
    编码: WMS-56-23
    名称: 组盘明细-拣料箱输入变化后
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: AfterUPCChange
 
    功能:
        -- 根据扫描的拣料箱号,判断当前扫码的货品是否可以放到扫描的拣料箱中
 
    更改记录:
        V2.0 HAN 20250422 JX_Material_Barcode 改为 Material_Barcode    
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function AfterUPCChange ( strLuaDEID ) 
    local nRet, strRetInfo
 
    -- 获取UPC
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "UPC","S_ITEM_CODE","F_ACT_QTY" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local upc = lua.Get_StrAttrValue( obj_attrs[1].value )  
    local item_code = lua.Get_StrAttrValue( obj_attrs[2].value )  
    local act_qty = lua.Get_NumAttrValue( obj_attrs[3].value )  
    if ( upc == '' ) then return end
 
    -- 通过条码找到物料编码
    local material_barcode
    nRet, material_barcode = m3.GetDataObjectByKey(strLuaDEID, "Material_Barcode", "S_BARCODE", upc)
 
    if (nRet ~= 0 ) then 
        if ( nRet == 1 ) then
            mobox.setInfo( strLuaDEID, "条码'"..upc.."'没有对应的货品,请检查物料条码对照表!")
            goto set_dlg_attr
        end
        lua.Error( strLuaDEID, debug.getinfo(1), "获取【物料条码】信息失败! " .. material_barcode ) 
    end
 
    -- 判断扫码的货品是否是目前的入库任务
    if ( item_code ~= material_barcode.item_code ) then
        mobox.setInfo( strLuaDEID, "条码'"..upc.."'对应的货品编码='"..material_barcode.item_code.."不是当前入库任务中的货物!")
        goto set_dlg_attr    
    end
    act_qty = act_qty + 1
 
    ::set_dlg_attr::
    local action = 
    {
        {
            action_type = "set_panel_dlg_attr",
            value = {
                    panel_name = "组盘输入",
                    attrs = {
                                {
                                    attr = "F_ACT_QTY",
                                    value = act_qty
                                },
                                {
                                    attr = "UPC",
                                    value = ""
                                }                                
                            }
                    }
             
        }
    }
    lua.Debug( strLuaDEID, debug.getinfo(1), "action-AfterUPCChange", action )
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action)  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end 
 
end