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
ÿþ--[[
   x: 
    Tðy: 
   \O€ÿ
   åegÿ2024-11-19
 
   ýQpeÿ AfterQtyInput
   ŸRý€:  S_PDA„vXbpeØSSTꁨR·ƒÖS'MO÷S¾‹nۏhˆUS
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
require ("GT-Base")
function AfterQtyInput( strLuaDEID )
    local nRet, strRetInfo
    -- ·ƒÖSÂSpe
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID,"item_code","batch_no","qtys")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    lua.Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local item_code = obj_attrs[1].value
    local batch_no = obj_attrs[2].value
    local qty = obj_attrs[3].value
    
    -- ·ƒÖSå‹ir™e„vir™e{|‹W
    local item_type, material
    nRet, item_type, material = GT_Get_ItemType(strLuaDEID, item_code)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), item_type) end
    
    local area = ''
    if(item_type == '³xў') then
        area = 'TH'
    elseif(item_type == '^P[^')then
        area = 'LZB'
    elseif(item_type == '…Pg')then
        area = 'FC'
    else
        area = 'LK'
        -- lua.Error(strLuaDEID, debug.getinfo(1), "^—s^“^ir™e!")
    end
    strCondition = "S_LOC_CODE IN (SELECT S_CODE FROM TN_Location WHERE S_AREA_CODE = '"..area.."')"
    strCondition = strCondition .. " AND S_CNTR_CODE IN (SELECT S_CNTR_CODE FROM TN_CG_Detail WHERE S_ITEM_CODE = '"..item_code.."' AND S_BATCH_NO = '"..batch_no.."')"
    local loc_cntr
    nRet, loc_cntr = m3.GetDataObjByCondition(strLuaDEID, "Loc_Container", strCondition,"T_CREATE")
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖS0'MO¹[hV0áOo`1Y%! " .. loc_cntr) end
    local loc_code = loc_cntr.loc_code
    
    -- ¾‹naction
    local setAttr = '[{"attr":"loc_code","value":"'..loc_code..'"},{"attr":"new_qty","value":"'..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 
 
end