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
--[[
   编码: WMS-53-01
   名称: 
   作者:
   日期:2025-07-02
 
   函数: BeforeDataObjCreate
   功能:
 
   更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require ("oi_base_mobox")
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local  nRet, strRetInfo
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_PC_NO") 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local pc_no = lua.Get_StrAttrValue( obj_attrs[1].value )
 
    -- 生成【拣料箱】编码
    if ( pc_no == '' ) then
        local strHeader = 'ZB-'
        nRet, pc_no = mobox.getSerialNumber( "拣料箱", strHeader, 5 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),'申请【拣料箱】编码失败!'..code ) end            
    end
 
    -- 设置信息
    local   attr_value = {}
    attr_value[1] = { attr = "S_PC_NO", value = pc_no }
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),"设置【拣料箱】信息失败!  "..strRetInfo ) end       
end