--[[
|
编码: JX-25-14
|
名称: 显示前事件--出库类型和状态
|
作者:HAN
|
日期: 2024-12-21
|
|
入口函数:BeforeGridShow
|
|
功能说明:
|
显示业务状态(N_TYPE)和执行状态(N_B_STATE)
|
--]]
|
|
json = require ("json")
|
mobox = require ("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function BeforeGridShow(strLuaDEID)
|
local nRet, strRetInfo
|
local data_objs
|
local nCount
|
local type_name = { "指定货品出库", "指定容器出库"}
|
local state_name = {"未执行", "启动中", "执行中", "完成", "出错"}
|
|
-- 获取数据
|
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 = {}
|
local type_index , state_index
|
local obj
|
|
-- 遍历所有行数据
|
for n = 1, nCount do
|
local row_item = {}
|
obj = data_objs[n]
|
row_item.id = obj.id
|
row_item.attrs = {}
|
|
-- 遍历当前行的属性
|
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_TYPE") then
|
type_index = lua.StrToNumber(attr_value.value)
|
if (type_index >= 1 and type_index <= 2) then
|
attr_value.value = type_name[type_index + 1]
|
end
|
elseif (attr_value.attr == "N_B_STATE") then
|
state_index = lua.StrToNumber(attr_value.value)
|
if (state_index >= 0 and state_index <= 4) then
|
attr_value.value = state_name[state_index + 1]
|
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), "更新数据失败: " .. strRetInfo)
|
end
|
end
|