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
66
67
68
69
70
71
72
ÿþ--[[
    x: GT-19-11
     Tðy: Am4l÷SÞVŒ
    \O€ÿLZH
    åegÿ2024-5-9
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
 
    ýQpeÿ CallBack
 
    ŸRý€:
        10·ƒÖS0RPDAkbx„vAm4l÷SŒTXbØv÷S
        209hncAm4l÷Sågâ‹agîváOo` ÿ¡l    g1\¥b•
        309hncXbØv÷Sågâ‹XbØváOo` ÿ¡l    gXbØv1\9hncXbØv÷SRú^N*NXbØv
        409hncågâ‹úQeg„vagxáOo`Çaction¾‹n0Ru˜b—
    ôf9e°‹U_:
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
require("WMS-BASE")
m3 = require( "oi_base_mobox" )
function CallBack(strLuaDEID)
    lua.Debug( strLuaDEID, debug.getinfo(1), '¹[hVagxÑ~š[','¹[hVagxÑ~š[' )
    local nRet, strRetInfo
    -- ·ƒÖSPDAÂSpe
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_SERIAL_NO", "S_CNTR_CODE")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "Œ(u¹eÕlGetSysDataJsonúQ•") end
    local obj_attrs = json.decode(strRetInfo)
 
    local serial_no = obj_attrs[1].value
    if (serial_no == nil or serial_no == '') then return end
    local cntr_code = obj_attrs[2].value
    if (cntr_code == nil or cntr_code == '') then return end
    
    -- V2.1 $R­e¹[hV/f&Tò]Ñ~š['ÁT
    local count
    local strCondtion = "S_CNTR_CODE = '" .. cntr_code .. "'"
    nRet, count = mobox.getDataObjCount( strLuaDEID,  "CG_Detail", strCondtion )
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS¹[hV'ÁTfÆ~1Y%!") end
    if(tonumber(count) > 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "¹[hVò]Ñ~š['ÁT!")
    end
 
    --ågâ‹agxáOo`
    local label_attrs,strCondition
    nRet, label_attrs = m3.GetDataObjectByKey(strLuaDEID, "GT_Label_Crad", "S_SERIAL_NO",serial_no)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), strRetInfo) end
 
    -- åg⋹[hV/f&TX[(W
    strCondition = "S_CODE = '" .. cntr_code .. "'"
    nRet, strRetInfo = m3.QueryDataObject(strLuaDEID, "Container", strCondition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS¹[hVáOo`1Y%ÿ" .. strRetInfo) end
    if (strRetInfo == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "¹[hV NX[(Wÿ")
    end
    
    -- ¾‹n—zãS-N„v ir™eáOo`
    local setAttr = '[{"attr":"S_ITEM_CODE","value":"' .. label_attrs.item_code .. '"},'
    setAttr = setAttr..'{"attr":"S_ITEM_NAME","value":"'..label_attrs.item_name..'"},'
    setAttr = setAttr..'{"attr":"S_BATCH_NO","value":"'..label_attrs.batch_no..'"},'
    setAttr = setAttr..'{"attr":"F_QTY","value":"'..label_attrs.qty..'"}]'
    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), "setAction1Y%! " .. strRetInfo .. ' action = ' .. strAction) end
    
    mobox.setInfo(strLuaDEID, "Íd\ObŸR!")
end