Jianw
2025-05-14 29f8b36ebb718d2051bf0e7e701973ec4419ee80
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
--[[
    编码: WMS-16-01
    名称: 盘点计划-创建前
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeDataObjCreate
 
    功能:
        -- 生成到盘点计划号格式:CP2301-00001
        -- 盘点类型名称 赋值
 
    更改记录:
 
--]]
wms_base = require( "wms_base" )
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_CP_NO", "N_TYPE" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local cp_code = lua.Get_StrAttrValue( obj_attrs[1].value )
    local count_type = lua.Get_NumAttrValue( obj_attrs[2].value )  
 
    -- 生成盘点计划号
    if  ( cp_code == '' ) then
        local strHeader = 'CP'..os.date("%y%m")..'-'
        nRet,cp_code = mobox.getSerialNumber( "盘点计划", strHeader, 4 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1),  '生成盘点计划号失败!'..cp_code ) end
    end
     
    local str_count_type = wms_base.GetDictItemName( strLuaDEID, "WMS_CountType", count_type ) 
 
    -- 设置信息
    local   attr_value = {}
    attr_value[1] = lua.KeyValueObj( "S_CP_NO", cp_code )
    attr_value[2] = lua.KeyValueObj( "S_TYPE", str_count_type )
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【盘点计划】信息失败!  "..strRetInfo ) end   
end