Jianw
2025-05-14 29f8b36ebb718d2051bf0e7e701973ec4419ee80
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
--[[
    编码: WMS-01-15
    名称: 容器-显示前
    作者:HAN    
    日期: 2025-01-29
 
    入口函数:BeforeGridShow
 
    功能说明:
        把锁、空满等显示成文字
--]]
 
json  = require ("json")
mobox = require ("OILua_JavelinExt")
m3 = require("oi_base_mobox")
 
function BeforeGridShow ( strLuaDEID ) 
    local nRet, strRetInfo
    local cntr_objs
    local n, nCount
    local lock_state_name = {"","入库锁","出库锁","其它","盘点锁"}
    local emptyfull_state_name = {"","有货","满"}
 
    nRet, cntr_objs = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), cntr_objs ) end  
    nCount = #cntr_objs
    if (nCount == 0) then  return end
 
    local obj
    local row_data_set = {}
    local lock_state, emptyfull_state, cntr_type
 
    strDataJson = '['
    for n = 1, nCount do
        local row_item = {}
 
        obj = cntr_objs[n]
        row_item.id = obj.id
        row_item.attrs = {}
        row_item.row_button_hidden = ""
        -- 获取 项目清单 对象属性
        for nIndex = 1, #obj.attrs do
            local attr_value = {}
 
            attr_value.attr  = obj.attrs[nIndex].attr
            attr_value.value = obj.attrs[nIndex].value
 
            if ( attr_value.attr  == 'N_LOCK_STATE' ) then
                lock_state = lua.StrToNumber( attr_value.value )
                attr_value.value = lock_state_name[lock_state+1]
                if ( lock_state > 0 ) then
                    attr_value.bk_color = "#FFFACD"
                    attr_value.text_color = "#000000"
                else
                    row_item.row_button_hidden = "解锁"
                end
            elseif ( attr_value.attr  == 'C_ENABLE' ) then
                if ( attr_value.value == 'Y') then
                    img = "mobox-normal-disable"
                else
                    img = "mobox-normal-circle-arrow2"
                end
 
                attr_value.ext_button = {
                    type = "trigger_event", 
                    img = img,
                    set = { cls_name = "Container", event_name = "禁用启用"}
                }
    
            elseif ( attr_value.attr  == 'N_EMPTY_FULL' ) then
                emptyfull_state = lua.StrToNumber( attr_value.value )
                attr_value.value = emptyfull_state_name[emptyfull_state+1]
                if ( emptyfull_state == 1 ) then
                    attr_value.bk_color = "#6495ED"
                    attr_value.text_color = "#000000"                    
                elseif ( emptyfull_state == 2 ) then
                    attr_value.bk_color = "#FFA500"
                    attr_value.text_color = "#000000"                    
                end
            elseif ( attr_value.attr  == 'N_TYPE' ) then   
                cntr_type = lua.StrToNumber( attr_value.value )
                if ( cntr_type == 3 ) then  
                    attr_value.value = '料箱'
                elseif ( cntr_type == 4 ) then
                    attr_value.value = '拣料箱'
                elseif ( cntr_type == 2 ) then
                    attr_value.value = '容器'
                else
                    attr_value.value = '托盘'
                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