fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
--[[
    编码: WMS-17-13
    名称: 计划盘点容器-子表显示
    作者:HAN  
    日期:2025-1-29
 
    级别:固定 (说明本段代码在项目中不太会变化)
    
    函数: BeforeGridShow
 
    功能:
        显示盘点状态、容器的锁状态
 
    更改记录:        
--]]
 
wms_base = require( "wms_base" )
 
function BeforeGridShow ( strLuaDEID ) 
    local nRet, strRetInfo
    local input_datajson
 
    -- 获取Grid显示数据对象
    -- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
    nRet, input_datajson = m3.GetSysDataJson( strLuaDEID )
    if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "无法获取Grid显示数据包!") end
    local n, nCount
 
    nCount = #input_datajson
    if (nCount == 0) then  return end
 
    local obj, lock_state, strAttr
    local b_state = 0
    local row_data_set = {}
 
    for n = 1, nCount do
        local row_item = {}
 
        obj = input_datajson[n]
        row_item.id = obj.id
        row_item.attrs = {}
 
        -- 获取 物料编码 和 库区编码
        for nIndex = 1, #obj.attrs do
            local attr_cell = {}
 
            attr_cell.attr  = obj.attrs[nIndex].attr
            attr_cell.value = obj.attrs[nIndex].value
            strAttr = attr_cell.attr
 
            if (strAttr == 'a.N_B_STATE') then
                b_state = lua.StrToNumber( attr_cell.value )
                if ( b_state == 0 ) then 
                    attr_cell.value = "未盘点"
                elseif ( b_state == 1 ) then 
                    attr_cell.bk_color = "#708090"
                    attr_cell.text_color = "#000000"      
                    attr_cell.value = "已锁定"
                elseif ( b_state == 2 ) then
                    attr_cell.bk_color = "#6495ED"
                    attr_cell.text_color = "#FFFFFF"                          
                    attr_cell.value = "可盘点"
                elseif ( b_state == 3 ) then
                    attr_cell.bk_color = "#32CD32"
                    attr_cell.text_color = "#FFFFFF"                      
                    attr_cell.value = "已盘点"                    
                end
            elseif (strAttr == 'b.N_LOCK_STATE') then
                attr_cell.show_style = "segment_arcbox"
                lock_state = lua.StrToNumber( attr_cell.value )
                if ( lock_state == 0 ) then
                    attr_cell.value = "无"
                elseif ( lock_state == 1 ) then 
                    attr_cell.value = "入库锁"
                elseif ( lock_state == 2 ) then 
                    attr_cell.value = "出库锁"
                elseif ( lock_state == 4 ) then 
                    attr_cell.value = "盘点锁"
                else     
                    attr_cell.value = "其它锁"               
                end
            end
            table.insert( row_item.attrs, attr_cell )
        end
        table.insert( row_data_set, row_item)
    end
 
    local action = {
        {
            action_type = "reset_data_attr",
            value = row_data_set
        }    
    }
 
    lua.Debug( strLuaDEID, debug.getinfo(1), "action", action )
 
    nRet, strRetInfo = mobox.setAction(strLuaDEID, lua.table2str(action))
    if ( nRet ~= 0 ) then 
        lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) 
    end  
 
end