wsz
2025-06-20 19898bd66dec87b500b200d5d50961d0fb538ce5
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
--[[
    编码: WMS-22-01
    名称: 发货单-创建前
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
        1)生成到发货单编码 S_NO 格式:SO2301-00001
 
    更改记录:
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    -- step1: 获取当前【发货单】编码
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_NO", "S_FACTORY" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local strCode = obj_attrs[1].value    
    local strFactory = obj_attrs[2].value    
 
    -- 生成发货单编码
    if ( strCode == '') then
        local strHeader = 'SO'..os.date("%y%m")..'-'
        nRet,strCode = mobox.getSerialNumber( "发货单", strHeader, 5 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '申请发货单编码失败!'..strCode ) end
 
    end
 
    -- 如果没有输入工厂标识获取操作人的工厂编码
    if (strFactory == '') then 
        nRet, strFactory = m3.GetMyFactory( strLuaDEID )
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetMyFactory失败! "..strFactory ) end
    end
       
    -- 设置信息
    local   attr_value = {}
    attr_value[1] = lua.KeyValueObj( "S_NO", strCode )
    attr_value[2] = lua.KeyValueObj( "S_FACTORY", strFactory )
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【发货单】信息失败!  "..strRetInfo ) end       
end