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
ÿþ--[[
   x: GT-122-27
    Tðy: 
   \O€ÿ
   åegÿ2025-03-26
 
   ýQpeÿ ClickOk
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
require ("oi_basestrfunc")
 
function ClickOk( strLuaDEID )
    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 mobox.setInfo(strLuaDEID,"Am4l÷S Ný€:Nzzÿ") return end
    local cntr_code = obj_attrs[2].value
    if (cntr_code == nil or cntr_code == '') then mobox.setInfo(strLuaDEID,"¹[hV÷S Ný€:Nzzÿ") return 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
    
    -- $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
    
    -- ·ƒÖSîvƉaS-N„váOo` ÿ(uُ*NaS-N„váOo`Rú^ CG_Detail
    local strCondition = "S_SERIAL_NO = '" .. serial_no .. "'"
    local label_card
    nRet, label_card = m3.GetDataObjByCondition(strLuaDEID, "GT_Label_Crad", strCondition)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. label_card)
    end
    
    -- Rú^¹[hV'ÁTfÆ~°‹U_
    local cg_detail = m3.AllocObject(strLuaDEID, "CG_Detail")
    cg_detail.cntr_code = cntr_code
    cg_detail.item_merge = 'N'  --  NTv^ir™eub Container_Good
    cg_detail.batch_no = label_card.batch_no
    cg_detail.item_code = label_card.item_code
    cg_detail.item_name = label_card.item_name
    cg_detail.qty = label_card.qty
    cg_detail.uom = 'kg'
    cg_detail.serial_no = label_card.serial_no
    lua.Debug(strLuaDEID, debug.getinfo(1), 'cg_detail', cg_detail)
    nRet, cg_detail = m3.CreateDataObj(strLuaDEID, cg_detail)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), 'mobox Rú^0¹[hV'ÁTfÆ~0ù[aŒ1Y%!' .. cg_detail) end
 
    mobox.setInfo(strLuaDEID,"Íd\ObŸR!")
end