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
--[[
    编码: WMS-28-01
    名称: 盘点单-创建前
    作者:HAN  
    日期:2025-1-29
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: 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_COUNT_NO" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local count_code = lua.Get_StrAttrValue( obj_attrs[1].value )
 
 
    -- 生成盘点单号
    if  ( count_code == '' ) then
        local strHeader = 'CO'..os.date("%y%m")..'-'
        nRet,count_code = mobox.getSerialNumber( "盘点单", strHeader, 4 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),  '生成盘点单号失败!'..count_code ) end
    end
     
    -- 设置信息
    local   attr_value = {}
    attr_value[1] = lua.KeyValueObj( "S_COUNT_NO", count_code )
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【盘点单】信息失败!  "..strRetInfo ) end         
  
end