json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function BeforeGridShow(strLuaDEID)
|
local nRet, strRetInfo
|
local data_objs
|
local nCount
|
local attr,attr_name,attr_value,state_index
|
local obj,cr_state_index
|
|
-- 状态名称定义
|
local state_names = {"未执行", "组盘", "组盘完成", "入库完成"}
|
local cr_state_names = {"没回报", "回报成功", "调接口错误", "反馈错误"}
|
|
nRet, data_objs = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "获取数据失败: " .. data_objs)
|
end
|
|
nCount = #data_objs
|
if (nCount == 0) then return end
|
|
local row_data_set = {}
|
for i = 1, nCount do
|
local row_item = {}
|
local obj = data_objs[i]
|
row_item.id = obj.id
|
row_item.attrs = {}
|
|
for j = 1, #obj.attrs do
|
attr = obj.attrs[j]
|
attr_name = attr.attr
|
attr_value = attr.value
|
|
|
if (attr_name == "N_B_STATE") then
|
state_index = lua.StrToNumber(attr_value)
|
if (state_index >= 0 and state_index <= 3) then
|
attr.value = state_names[state_index + 1]
|
end
|
elseif (attr_name == "N_CR_STATE") then
|
cr_state_index = lua.StrToNumber(attr_value)
|
if (cr_state_index >= 0 and cr_state_index <= 3) then
|
attr.value = cr_state_names[cr_state_index + 1]
|
end
|
end
|
|
table.insert(row_item.attrs, attr)
|
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), "更新数据失败: " .. strRetInfo)
|
end
|
end
|