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
ÿþ--[[
    x: GT-122-02
     Tðy:  ir™eáOo`ÞVŒ
    \O€ÿLZH
    åegÿ2024-6-3
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
 
    ýQpeÿ CallBack
 
    ŸRý€:
        -- Ç¹[hVxÞVŒir™ex0ir™e Tðy0yb!k÷S0Rãbpeϑ
 
    ØSôf†SòS:
    V1.1 LZH 20250217 S_CNTR_CODEW[µk¥c6e„v/f ¹[hV÷Sb€agx,HQåg⋹[hV‚Yœg¡l    g(Wågâ‹agxeg·ƒÖSir™epenc
 
    ôf9e°‹U_:
 
--]]
json  = require("json")
mobox = require("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
function CallBack(strLuaDEID)
    lua.Debug(strLuaDEID, debug.getinfo(1), '1', 1)
    local nRet, strRetInfo, attrs
 
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID, "S_CNTR_CODE")
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    local obj_attrs = json.decode(strRetInfo)
    local cntr_code = obj_attrs[1].value -- XbØvx
    if (cntr_code == nil or cntr_code == '') then mobox.setInfo(strLuaDEID,"÷‹“eQ¹[hV/agxÂSpe!") return end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'cntr_code', cntr_code)
 
    --!hŒš0úQ“^USnc0áOo`
    local stock_out
    local strCondition = "S_CNTR_CODE = '" .. cntr_code .. "' AND S_STATE <> 'Œ[b'"
    nRet, stock_out = m3.GetDataObjByCondition(strLuaDEID, "GT_SO_Detail", strCondition)
    if (nRet == 1) then lua.Error(strLuaDEID, debug.getinfo(1), "XbØv*gågâ‹0RúQ“^USáOo`!") end
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0úQ“^USnc0áOo`1Y%! " .. stock_out) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'stock_out', stock_out)
 
 
    -- ·ƒÖS¹[hV'ÁTfÆ~áOo`
    local cg_detail
    strCondition = "S_CNTR_CODE = '" .. cntr_code .. "'"
    nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
    -- V1.1 LZH 20250217 ¹[hV*gågâ‹0RRågâ‹agx
    if (nRet == 1) then
        strCondition = "S_SERIAL_NO = '" .. cntr_code .. "'"
        nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "XbØv*gågâ‹0Rir™eáOo`!") end
    elseif (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0¹[hV'ÁTfÆ~0áOo`1Y%! " .. cg_detail) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'cg_detail', cg_detail)
 
    -- ¾‹n—zãS-N„váOo`
    setAttr = '[{"attr":"S_ITEM_CODE","value":"' .. cg_detail.item_code .. '"},'
    setAttr = setAttr .. '{"attr":"S_ITEM_NAME","value":"' .. cg_detail.item_name .. '"},'
    setAttr = setAttr .. '{"attr":"S_BATCH_NO","value":"' .. cg_detail.batch_no .. '"},'
    setAttr = setAttr .. '{"attr":"QTY","value":"' .. cg_detail.qty .. '"}]'
 
    local action = {}
 
    action.action_type = "set_dlg_attr"
    action.value = json.decode(setAttr)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'action', action)
    nRet, strRetInfo = mobox.setAction(strLuaDEID, '[' .. lua.table2str(action) .. ']')
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "setAction1Y%! " .. strRetInfo) end
end