Jianw
2025-05-13 3b39fe3810c3ee2ec9ec97236c1769c5c85e062c
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
--[[
    编码: WMS-71-14
    名称: 显示前
    作者:HAN    
    日期:2025-1-29    
    入口函数:BeforeGridShow
 
    功能说明:
        如果作有错误信息显示红色
    更改记录:
 
--]]
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function BeforeGridShow ( strLuaDEID ) 
    local nRet, strRetInfo
    local arobjs, attrs
    local n, nCount
 
    nRet, arobjs = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), arobjs ) end  
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    nCount = #arobjs
    if (nCount == 0) then  return end
 
    local obj, id
    local row_data_set = {}
    local data_attr
    local qty, t_qty, m_qty
 
    for n = 1, nCount do
        local row_item = {}
 
        obj = arobjs[n]
        row_item.id = obj.id
        row_item.attrs = {}
 
        data_attr = m3.KeyValueAttrsToObjAttr(obj.attrs)
        qty = lua.StrToNumber( data_attr.F_QTY )
        t_qty = lua.StrToNumber( data_attr.F_TABLE_QTY )
        m_qty = lua.StrToNumber( data_attr.F_MEMORY_QTY )
 
        -- 获取 物料编码 和 库区编码
        for nIndex = 1, #obj.attrs do
            local attr_value = {}
 
            attr_value.attr  = obj.attrs[nIndex].attr
            attr_value.value = obj.attrs[nIndex].value
 
            strCellBkground = ''
            if (attr_value.attr == 'F_TABLE_QTY') then
                if ( t_qty ~= qty ) then
                    attr_value.bk_color = "#FF0000"
                    attr_value.text_color = "#FFFFFF"                      
                end
            elseif (attr_value.attr == 'F_MEMORY_QTY') then
                if ( t_qty ~= m_qty ) then
                    attr_value.bk_color = "#FF1493"
                    attr_value.text_color = "#FFFFFF"                           
                end
            end
            table.insert( row_item.attrs, attr_value )
        end
        table.insert( row_data_set, row_item)        
    end
 
    local action = {
        {
            action_type = "reset_data_attr",
            value = row_data_set
        }
    }
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if ( nRet ~= 0 ) then 
        lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) 
    end   
end