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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
ÿþ--[[
    x: WMS-19-04
     Tðy: ¹[hV'ÁTfÆ~-xØv-nxš[
    \O€ÿHAN
    åegÿ2023-8-18
 
    §~+RÿúVš[ (ô‹f,gµkãNx(Wy˜îv-N N*YOØSS)
 
    ýQpeÿ ClickOK
 
    ŸRý€:
        -- (WxØvLub— ÿ¹pnxš[
        -- ·ƒÖS "ck(WxØv" u˜~{-N„v'ÁT ÿ Rú^0¹[hV'ÁTfÆ~0xØvÍd\O
    ôf9e°‹U_:
        V6.0 HAN 2023/9/6  -- lua.Error/lua.Debug ýQpeØSS
        V7.0 HAN 2023/10/26 -- ÖSˆm wms_CGBinding Rú^ CG_Detail ù[aŒ
--]]
 
require("WMS-BASE")
 
function ClickOK (strLuaDEID)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strLuaDEID', strLuaDEID)
    local nRet, strRetInfo
    local attrs
 
    -- step1  ·ƒÖS5600xØvLub—-Nhˆ4YLub—„v“eQÂSpeÿ¹[hV÷S/XbØv÷S    ÿ
    nRet, attrs = m3.GetSysInputParameter(strLuaDEID)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR“eQb—g̑„v^\'`1Y%! " .. attrs)
    end
 
    local input_attr = m3.KeyValueAttrsToObjAttr(attrs)
    local cntr_code = input_attr.S_CNTR_CODE
    if (cntr_code == nil or cntr_code == '') then
        lua.Error(strLuaDEID, debug.getinfo(1), "¹[hVx Ný€:Nzz!")
    end
 
    local strDataJson
    -- step2  ·ƒÖS"ck(WxØv"-N„vpencù[aŒÿNag    ÿ ÿُ›NpencÝOX[(W DataJson-N <h_‚Y Nÿ
    --        {"id":"","attrs":[{"attr":"x1","value":"xx"},...]}
    nRet, strDataJson = mobox.getCurEditDataPacket(strLuaDEID)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "àeÕl·ƒÖSLuapencS!")
    end
    if (strDataJson == '') then
        mobox.setInfo(strLuaDEID, "ck(WxØv-N„váOo` Ný€:Nzz!")
        return
    end
    -- ã‰g“eQ„vJson<h_‡e,g
    local obj, success
    success, obj = pcall(json.decode, strDataJson)
    if (success == false) then
        lua.Error(strLuaDEID, debug.getinfo(1), "^—Õl„vJSON<h_!" .. obj)
    end
 
    -- step3 Rú^0¹[hV'ÁTfÆ~0
    -- èla°etQُ*Ny˜îv-Nù[0¹[hV'ÁTfÆ~0-N„v^\'`‰Bl‚Y N
    --[[
        S_CNTR_CODE -- ¹[hVx
        S_SERIAL_NO -- '÷S(§NÁTû|R÷S)
        S_ITEM_CODE -- ir™e÷S
        S_ITEM_NAME -- ir™e Tðy
        S_BATCH_NO  -- yb!k÷SÿïSåN¡l    g    ÿ
        F_QTY -- peϑ
        S_UOM -- USMO(m)
        S_PUTAWAY_NO -- 
N¶gUS÷S
        F_NET_WEIGHT
        F_GROSS_WEIGHT
        S_WU
    --]]
 
    -- ·ƒÖSN*NRËY„v0¹[hV'ÁTfÆ~0pencù[aŒ
    local cg_detail = m3.AllocObject(strLuaDEID, "CG_Detail")
    -- Šb attrs -N„v [{"attr":"S_ITEM_CODE","value":"123"},..] lS:N
    -- {"S_ITEM_CODE":"123",...} Ù7h¹e¿O¿‹î•
    local input_obj = m3.KeyValueAttrsToObjAttr(obj.attrs)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'input_obj', input_obj)
 
    cg_detail.cntr_code = cntr_code
    cg_detail.serial_no = lua.Get_StrAttrValue(input_obj.S_SERIAL_NO)
    cg_detail.batch_no = lua.Get_StrAttrValue(input_obj.S_BATCH_NO)
    cg_detail.item_code = lua.Get_StrAttrValue(input_obj.S_ITEM_CODE)
    cg_detail.item_name = lua.Get_StrAttrValue(input_obj.S_ITEM_NAME)
    cg_detail.item_state = 1
    cg_detail.item_spec = lua.Get_StrAttrValue(input_obj.S_ITEM_SPEC)
    -- cg_detail.putaway_no = lua.Get_StrAttrValue(input_obj.S_PUTAWAY_NO)
    cg_detail.bs_no = lua.Get_StrAttrValue(input_obj.S_BS_NO)
    cg_detail.qty = lua.Get_NumAttrValue(input_obj.F_QTY)
    cg_detail.uom = lua.Get_StrAttrValue(input_obj.S_UOM)
    cg_detail.net_weight = lua.Get_StrAttrValue(input_obj.F_NET_WEIGHT)
    cg_detail.gross_weight = lua.Get_StrAttrValue(input_obj.F_GROSS_WEIGHT)
    cg_detail.wu = lua.Get_StrAttrValue(input_obj.S_WU)
 
    lua.Debug(strLuaDEID, debug.getinfo(1), "'ÁTfÆ~Rú^MR:", cg_detail)
 
    -- V7.0
    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
 
    -- Rú^bŸR—‰JTɋMRïz (W"ò]xØv"ÒceQNagxØv°‹U_
    local row = '{"id":"' .. cg_detail.id .. '",'
    row = row .. '"attrs":[{"attr":"S_PUTAWAY_NO","value":"' .. cg_detail.putaway_no .. '"},'
    row = row .. '{"attr":"S_ITEM_CODE","value":"' .. cg_detail.item_code .. '"},'
    row = row .. '{"attr":"S_ITEM_NAME","value":"' .. cg_detail.item_name .. '"},'
    row = row .. '{"attr":"S_ITEM_STATE","value":"' .. cg_detail.item_state .. '"},'
    row = row .. '{"attr":"S_SERIAL_NO","value":"' .. cg_detail.serial_no .. '"},'
    row = row .. '{"attr":"S_BS_NO","value":"' .. cg_detail.bs_no .. '"},'           -- egnUS÷S
    row = row .. '{"attr":"F_QTY","value":"' .. cg_detail.qty .. '"}]}'
 
    strDataJson = '{"page_name":"ò]xØv","row":' .. row .. '}'
    strAction = '[{"action_type":"insert_subtable_page_row","value":' .. strDataJson .. '}]'
    nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction)
    lua.Debug(strLuaDEID, debug.getinfo(1), 'nxš[nRet', nRet)
    if (nRet ~= 0) then
        lua.Error(strLuaDEID, debug.getinfo(1), "setAction1Y%! " .. strRetInfo .. ' action = ' .. strAction)
    end
end