fy36
2025-07-01 350eb5ec9163d3ea21416b1525bb80191e958071
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
--[[
    编码: WMS-19-20
    名称: 容器货品明细-5508查询面板-查询
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: Query
 
    功能:
        根据查询面板里的输入,组成SQL的查询条件
    更改记录:
     
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function Query ( strLuaDEID ) 
    local nRet, strRetInfo
    local parameter = {}
    local attrs
    -- 获取查询面板里的输入属性
    nRet, attrs = m3.GetSysInputParameter( strLuaDEID ) 
    if ( nRet ~= 0 )  then lua.Error( strLuaDEID, debug.getinfo(1), "m3.GetSysInputParameter 失败! "..attrs ) end 
    parameter = m3.KeyValueAttrsToObjAttr( attrs )
    lua.Debug( strLuaDEID, debug.getinfo(1), "parameter", lua.table2str(parameter) )
 
    local cntr_code = lua.Get_StrAttrValue( parameter.S_CNTR_CODE )           -- 容器编码
    local item_code = lua.Get_StrAttrValue( parameter.S_ITEM_CODE )           -- 物料编码
    local item_name = lua.Get_StrAttrValue( parameter.S_ITEM_NAME )           -- 物料名称
    local strSQL = ''
 
    if (cntr_code ~= '' and cntr_code ~= nil) then
        strSQL = "S_CNTR_CODE = like '%%"..cntr_code.."%%'"
    end
    if (item_code ~= '' and item_code ~= nil) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = "S_ITEM_CODE = like '%%"..item_code.."%%'"
    end    
    if (item_name ~= '' and item_name ~= nil) then
        if ( strSQL ~= '' ) then strSQL = strSQL.." AND " end
        strSQL = "S_ITEM_NAME = like '%%"..item_name.."%%'"
    end 
 
    if (strSQL == '') then return end
    -- 设置查询面板
    local setAttr = '{"condition":"'..strSQL..'","order":"S_NAME"}'
    local strAction = '[{"action_type":"set_query_condition","value":'..setAttr..'}]'
    nRet, strRetInfo = mobox.setAction( strLuaDEID, strAction  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end 
 
end