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
--[[
    编码: WMS-71-01
    名称: 货主-创建前
    作者:HAN  
    日期:2025-5-7
    
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
        生成货主编码 ST-0001
 
    变更记录:
        V6.0 HAN 2023/9/6  -- lua.Error/lua.Debug 函数变化  
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo 
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_STORER") 
    if ( nRet ~= 0 )  then 
        lua.Stop( strLuaDEID, "获取当前编辑属性失败! "..strRetInfo ) 
        return
    end 
    local obj_attrs = json.decode( strRetInfo ) 
    local storer_code = lua.Get_StrAttrValue( obj_attrs[1].value )    
    -- 生成货主编码
    if ( storer_code == '' ) then
        local strCode = ''
        nRet,strCode = mobox.getSerialNumber( "货主", "ST-", 4 )  
        if ( nRet ~= 0 ) then 
            lua.Stop( strLuaDEID, '申请【供应商】编码失败!'..strCode ) 
            return
        end
 
        local  attr_value = 
        {
            { attr = "S_STORER", value = strCode }
        }
        nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
        if ( nRet ~= 0 ) then 
            lua.Stop( strLuaDEID, "设置【供应商】信息失败!  "..strRetInfo )
            return
        end   
    end
end