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
--[[
    编码: JX-83-11
    名称: 容器料格-自定义表单-选货品后
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: AfterSelectGood
 
    功能:
        在货品查询面板中选中一个货品后
 
    更改记录:
 
--]]
 
wms_base = require ("wms_base")
jx_base = require( "jx_base" )
 
function AfterSelectGood ( strLuaDEID )
    local nRet, strRetInfo, select_dataobj
 
    nRet, select_dataobj = m3.GetSysInputParameter( strLuaDEID ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取选中数据对象属性失败! "..select_dataobj ) end 
    local item_code = select_dataobj.S_ITEM_CODE
    local item_name = select_dataobj.S_ITEM_NAME
    local weight = lua.StrToNumber( select_dataobj.F_WEIGHT )
    local volume = lua.StrToNumber( select_dataobj.F_VOLUME )
 
    if ( volume == 0 ) then 
        lua.Error( strLuaDEID, debug.getinfo(1), "选中的物料体积为0! " ) 
    end
 
 
    -- 获取当前容器的料箱类型
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_CELL_NO" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local cell_no = lua.Get_StrAttrValue( obj_attrs[1].value )
 
    local seg = lua.split( cell_no, '-' )
    local cell_type = seg[1]
    local cell_volume
    nRet, cell_volume = jx_base.GetCellVolume( strLuaDEID, cell_type )
    if ( nRet ~= 0 ) then
        mobox.stopProgram( strLuaDEID, cell_volume )
        return
    end
 
    -- 计算料格最多可以存储货品数量
    local qty = math.floor( cell_volume/ volume )
 
    local action = {
        {
            action_type = "set_dlg_attr",
            value = {
                    { attr = "S_ITEM_CODE", value = item_code },
                    { attr = "S_ITEM_NAME", value = item_name },
                    { attr = "Volume", value = volume },
                    { attr = "Weight", value = weight },
                    { attr = "Qty", value = qty },
                    { attr = "MaxQty", value = qty }
            }
        }
    }
 
    lua.Debug( strLuaDEID, debug.getinfo(1),"action", action)
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action)  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end     
 
end