--[[
|
编码: WMS-40-03
|
名称: 显示前
|
作者:HAN
|
日期:2025-1-29
|
|
入口函数:BeforeGridShow
|
|
功能说明:
|
如果作业状态=错误,显示红色
|
|
更改记录:
|
V2.0 HAN 2025-2-23 采用新的程序风格
|
--]]
|
wms_wh = require( "wms_wh" )
|
|
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
|
nCount = #arobjs
|
if (nCount == 0) then return end
|
|
local obj, attrs
|
local strCurYear = os.date("%Y")
|
local area = {}
|
strCurYear = strCurYear.."--"
|
|
local row_data_set = {}
|
local state_cell_set = {
|
{ b_state = 0, state_name = "待启动", bk_color = "", text_color = ""},
|
{ b_state = 1, state_name = "执行", bk_color = "#BDB76B", text_color = "#000000"},
|
{ b_state = 2, state_name = "完成", bk_color = "#00FF00", text_color = "#008000"},
|
{ b_state = 3, state_name = "错误", bk_color = "#FF0000", text_color = "#FFFFFF"},
|
{ b_state = 4, state_name = "启动失败", bk_color = "#FF0000", text_color = "#FFFFFF"},
|
{ b_state = 5, state_name = "暂停", bk_color = "#FFFACD", text_color = "#008000"},
|
{ b_state = 6, state_name = "等待", bk_color = "", text_color = ""},
|
{ b_state = 7, state_name = "取消", bk_color = "#DCDCDC", text_color = "#008000"},
|
{ b_state = 8, state_name = "待启动前", bk_color = "", text_color = ""},
|
}
|
local b_state, state_index, strValue
|
|
for n = 1, nCount do
|
local row_item = {}
|
|
obj = arobjs[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_B_STATE') then
|
b_state = lua.StrToNumber( attr_value.value )
|
state_index = b_state+1
|
attr_value.value = state_cell_set[state_index].state_name
|
attr_value.bk_color = state_cell_set[state_index].bk_color
|
attr_value.text_color = state_cell_set[state_index].text_color
|
|
-- 设置行按钮是否显示
|
-- 3 错误
|
if ( b_state == 3 ) then
|
row_item.row_button_hidden = ""
|
-- 0 待启动 1 -- 执行
|
elseif ( b_state == 0 or b_state == 1 or b_state == 8 or b_state == 6 or b_state == 5 or b_state == 4 ) then
|
-- 可以取消
|
row_item.row_button_hidden = "错误重置"
|
end
|
elseif (attr_value.attr == 'T_START_TIME' or attr_value.attr == 'T_END_TIME' or attr_value.attr == 'T_CREATE') then
|
-- 对时间的处理
|
if (attr_value.value == "1900-1-1 0:0:0") then
|
attr_value.value = ""
|
else
|
-- 如果是本年就不显示 本年年份
|
attr_value.value = string.gsub(attr_value.value, strCurYear, "")
|
end
|
elseif (attr_value.attr == 'S_ERR' or attr_value.attr == 'S_EXT_DATA') then
|
strValue = string.gsub(attr_value.value, "\\", "/")
|
strValue = string.gsub(strValue, '"','\\\"')
|
strValue = string.gsub(strValue, "'",'\\\"')
|
strValue = string.gsub(strValue, " ","")
|
attr_value.value = strValue
|
-- V8.0 MDF BY HAN 20241120
|
elseif (attr_value.attr == 'S_END_AREA' ) then
|
-- 如果是库区编码,把库区名称获取后加另外一个特别的属性列
|
nRet, area = wms_wh.GetAreaInfo( attr_value.value )
|
if ( nRet == 0 ) then
|
local attr_value = {
|
attr = "CUSTOM_E_AREA_NAME", value = area.name
|
}
|
table.insert( row_item.attrs, attr_value )
|
end
|
elseif (attr_value.attr == 'S_START_AREA' ) then
|
nRet, area = wms_wh.GetAreaInfo( attr_value.value )
|
if ( nRet == 0 ) then
|
local attr_value = {
|
attr = "CUSTOM_S_AREA_NAME", value = area.name
|
}
|
table.insert( row_item.attrs, attr_value )
|
end
|
-- END MDF
|
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
|