lzh
2025-06-24 13c4a636539584ab977fddacfae884b3ec250aee
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
ÿþ--[[
    x: WMS-40-01
     Tðy: 'MO-Rú^MR
    \O€ÿHAN  
    åegÿ2022-12-23
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
    
    ýQpeÿ BeforeDataObjCreate
 
    ŸRý€:
        1    ÿub\ONx S_OP_CODE ÿ <h_ÿOP221212-00001
        2    ÿK<P S_OP_TYPE
    ôf9e°‹U_:
        V3.0 HAN 2023-6-16
        V3.1 HAN 2023-7-2
            getDictItemIInfo 9eb wms_GetDictTypeName       
        V4.1 HAN 2023-8-9  wmsøvsQ¥cãSŒte
        V4.2 wms_GetDictTypeName -> wms_base.GetDictItemName  
        V6.0 HAN 2023/9/6  -- lua.Error/lua.Debug ýQpeØSS  
        V6.1 HAN 2023/9/20 -- N_OP_TYPE 9e:N  N_TYPE   
--]]
 
require ("WMS-BASE")
 
function BeforeDataObjCreate ( strLuaDEID ) 
    local   nRet, strRetInfo
    -- step1  ·ƒÖSS_MRRú^„v\ONáOo` -- \ON{|‹W ÿN¡R¶r`
    nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "N_TYPE","N_B_STATE","S_CODE" ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! "..strRetInfo ) end 
    local obj_attrs = json.decode( strRetInfo ) 
    local op_type = lua.StrToNumber( obj_attrs[1].value )           -- \ON{|‹W
    local b_state = lua.StrToNumber( obj_attrs[2].value )           -- N¡R¶r`
    local code = obj_attrs[3].value 
 
    if ( b_state == "" ) then b_state = 1 end
    if ( op_type == "" ) then op_type = 0 end
    if ( op_type == 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "\ON{|‹W¡l    gK<P! "..strRetInfo ) end
 
    -- 9hncW[xQ·ƒÖS N_TYPE „v>f:y Tðy
    -- ÔÞVÿ[[ÿ"name":"xxx","order":"1","value":"yyy","default":"1","code":""]ÿ,& ]
    local str_op_type = wms_base.GetDictItemName( strLuaDEID, "WMS_OperationType", op_type ) 
 
    -- 9hncW[xQ·ƒÖS N_B_STATE „v>f:y Tðy
    local str_b_satte = wms_base.GetDictItemName( strLuaDEID, "WMS_OperationState", b_state ) 
    
    if(code == nil or code == '') then
        -- ub\ONx
        local strCode = ''
        local strHeader = 'OP'..os.date("%y%m%d")..'-'
        nRet,strCode = mobox.getSerialNumber( "\ON", strHeader, 5 )  
        if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '3u÷‹\ONx1Y%!'..strCode ) end
        code = strCode
    end
 
 
 
    -- ¾‹náOo`
    local   attr_value = {}
    attr_value[1] = lua.KeyValueObj( "S_B_STATE", str_b_satte )
    attr_value[2] = lua.KeyValueObj( "S_TYPE", str_op_type )
    attr_value[3] = lua.KeyValueObj( "S_CODE", code )
    nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) 
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "¾‹n\ONáOo`1Y%!  "..strRetInfo ) end   
end