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
ÿþ--[[
   x: 
    Tðy: 
   \O€ÿ
   åegÿ2024-11-18
 
   ýQpeÿ CallBack
   ŸRý€:  9hncyb!k÷SŒTir™e÷Sß~¡‹Xbpe
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
require ("oi_basestrfunc")
require("GT-Base")
function AfterItemCodeInput( strLuaDEID )
    local nRet, strRetInfo
    -- ·ƒÖSÂSpe
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID,"item_code")
    if (nRet ~= 0) then Error(strLuaDEID, debug.getinfo(1), "·ƒÖSS_MR‘^\'`1Y%! " .. strRetInfo) end
    Debug(strLuaDEID, debug.getinfo(1), 'strRetInfo', strRetInfo)
    local obj_attrs = json.decode(strRetInfo)
    local item_code = obj_attrs[1].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 Error(strLuaDEID, debug.getinfo(1), item_type) end
    
    -- if(item_type ~= '³xў' and item_type ~= '^P[^' and item_type ~= '…Pg')then
    --     Error(strLuaDEID, debug.getinfo(1), "å‹ir™e^—s^“^ir™e!")
    -- end
    
    -- ·ƒÖSir™eù[”^„vir™eÏcð¾‹nۏLub—,\å‹ir™e„vyb!k÷S¾‹nbN*NRhˆ0RLub—
    -- ·ƒÖS0¹[hV'ÁTfÆ~0áOo`
    local cg_detail
    local strCondition = "S_ITEM_CODE = '" .. item_code .. "' AND S_CNTR_CODE IN(SELECT S_CNTR_CODE FROM TN_Loc_Container)"
    nRet, cg_detail = QueryDataObject(strLuaDEID, "CG_Detail", strCondition)
    if (nRet ~= 0 or cg_detail == '') then mobox.setInfo(strLuaDEID,"å‹ir™e¡l    g“^X[!") return  end
    Debug( strLuaDEID, debug.getinfo(1), 'cg_detail', cg_detail )
    
    local attr
    local item_name = ''
    local batch_list = {}
    local batch_no = ''
    for i = 1, #cg_detail do
        attr = KeyValueAttrsToObjAttr(cg_detail[i].attrs)
        item_name = attr.S_ITEM_NAME
        batch_list[i] = attr.S_BATCH_NO
    end
 
    Debug( strLuaDEID, debug.getinfo(1), 'item_name', item_name )
    Debug( strLuaDEID, debug.getinfo(1), 'batch_list', batch_list)
    
    -- yb!k÷S»S͑
    local result = {}
    local unique = {}
    for _, item in ipairs(batch_list) do
        if not unique[item] then
            table.insert(result, item)
            unique[item] = true
        end
    end
    
    for _, num in ipairs(result) do
        batch_no = batch_no .. '"' .. num .. '",'
    end
    -- ÖSˆmgTN*N,÷S
    batch_no = trim_laster_char(batch_no)   
    Debug( strLuaDEID, debug.getinfo(1), 'batch_no', batch_no)
    
    -- ¾‹nMRïzU\:yaction
    -- ¾‹n—zãS-N„váOo`
    local setAttr = '[{"attr":"item_name","value":"' .. item_name .. '"}]'
    local action1 = {}
    action1.action_type = "set_dlg_attr"
    action1.value = json.decode(setAttr)
    local action2 = {}
    setAttr = '[{"attr":"batch_no","value":"","choice_list":['..batch_no..']}]'
    action2.action_type = "set_dlg_attr"
    action2.value = json.decode(setAttr)
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, '[' .. table2str(action1) .. ',' ..table2str(action2).. ']')
    if (nRet ~= 0) then Error(strLuaDEID, debug.getinfo(1), "setAction1Y%! " .. strRetInfo) end
end