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
ÿþ--[[
   x: GT-122-21
    Tðy:     ébir™eMR
   \O€ÿLZH
   åegÿ2025-3-5
 
   ýQpeÿ BeforeSelectMaterial
   ŸRý€:
 
   ôf9e°‹U_:
 
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require( "oi_base_mobox" )
function BeforeSelectMaterial( strLuaDEID )
    local nRet, strRetInfo
    -- ·ƒÖSÂSpe S_AREA 1 ³xў 2 ^P[^ 3 …Pg
    nRet, strRetInfo = mobox.getCurEditDataObjAttr(strLuaDEID,"S_AREA")
    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 area = tonumber(obj_attrs[1].value) -- å]\O:SßW
    if(area == nil)then mobox.setInfo(strLuaDEID,"÷‹HQ    éb\ON:SßW!") return end
 
    -- 9hncå]\O:SßW[{    øvù[”^„vúQ“^US
    local condition = ''
    if(area == 1)then
        condition = "S_STATE = '/T(u' AND S_ITEM_CODE IN (SELECT S_ITEM_CODE FROM TN_Material WHERE (S_SUB_TYPE,S_MINOR_TYPE) in (select S_SUB_TYPE,S_MINOR_TYPE from TN_GT_ITEM_TYPE WHERE S_TYPE = '³xў'))"
    elseif(area == 2)then
        condition = "S_STATE = '/T(u' AND S_ITEM_CODE IN (SELECT S_ITEM_CODE FROM TN_Material WHERE (S_SUB_TYPE,S_MINOR_TYPE) in (select S_SUB_TYPE,S_MINOR_TYPE from TN_GT_ITEM_TYPE WHERE S_TYPE = '^P[^'))"
    else
        condition = "S_STATE = '/T(u' AND S_ITEM_CODE IN (SELECT S_ITEM_CODE FROM TN_Material WHERE (S_SUB_TYPE,S_MINOR_TYPE) in (select S_SUB_TYPE,S_MINOR_TYPE from TN_GT_ITEM_TYPE WHERE S_TYPE = '…Pg'))"
    end
 
    -- ¾‹n action „vÂSpe
    local action = {}
    local value = {}
    local config = {}
    action.action_type = "open_common_dlg"
    config.title = 'úQ“^áOo`'
    config.multiple_choice = 0
    config.appear_style = "sideslip"
    local items = {}
    -- ·ƒÖSúQ“^USáOo`
    nRet, strRetInfo = m3.QueryDataObject(strLuaDEID, "GT_Stock_Out", condition)
    if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "·ƒÖSúQ“^USáOo`1Y%ÿ" .. strRetInfo) end
    if(strRetInfo == '')then mobox.setInfo(strLuaDEID,"¡l    gå‹\ON:SßW„vúQ“^US!") return end
 
    for i = 1,#strRetInfo do
        local stock_out
        nRet, stock_out = m3.ObjAttrStrToLuaObj("GT_Stock_Out", lua.table2str(strRetInfo[i].attrs))
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), stock_out) end
        -- 9hncir™ex·ƒÖSir™e Tðy
        local strCondition = "S_ITEM_CODE = '" .. stock_out.item_code .. "'"
        local material
        nRet, material = m3.GetDataObjByCondition(strLuaDEID, "Material", strCondition)
        if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "m3.GetDataObjByCondition 1Y%!" .. material)
        end
        items[i] = {
            name = material.item_code.."&"..material.item_name.."&"..stock_out.batch_no
        }
    end
 
    config.items = items
    value.config = config
    value.common_dlg_id = "check_list"
    action.value = value
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, '['..lua.table2str(action)..']')
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end
end