1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
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
--[[
   编码: AMS-107-01
   名称: 
   作者:
   日期:2025-06-02
 
   函数: AfterCntrCodeInput
   功能:
    -- 料箱号变化后回填SN号
 
   更改记录:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require ("oi_base_mobox")
 
function AfterCntrCodeInput( strLuaDEID )
    local nRet, strRetInfo
    -- 获取参数
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID,"S_CNTR_CODE")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! " .. strRetInfo) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local cntr_code = obj_attrs[1].value
    if(cntr_code == nil or cntr_code == '')then
        return
    end
    
    -- 获取SN号
    strCondition = "S_CODE = '" .. cntr_code .. "'"
    nRet, strRetInfo = m3.GetDataObjByCondition(strLuaDEID, "Container", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "GetDataObjByCondition失败! " .. strRetInfo) end
    
    -- 设置action
    local setAttr = '[{"attr":"S_SN","value":"'..strRetInfo.udf01..'"}]'
    local action = {}
 
    action.action_type = "set_dlg_attr"
    action.value = json.decode(setAttr)
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, '['..lua.table2str(action)..']'  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end 
 
end