--[[
|
编码: WMS-08-02
|
名称: 设备动作队列-显示前
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: BeforeGridShow
|
|
功能:
|
N_B_STATE = 2 错误显示红色
|
更改记录:
|
--]]
|
|
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, attrs, id
|
local strCellBkground, strDataJson
|
local strRowCtrl = ''
|
local b_state = 0
|
|
strDataJson = '['
|
for n = 1, nCount do
|
obj = input_datajson[n]
|
attrs = obj.attrs
|
nattr_count = #attrs
|
id = obj.id
|
|
strAttrs = ''
|
strRowCtrl = ''
|
-- 获取 物料编码 和 库区编码
|
for nIndex = 1, nattr_count do
|
strAttr = attrs[nIndex].attr
|
strValue = attrs[nIndex].value
|
strCellBkground = ''
|
if (strAttr == 'N_B_STATE') then
|
b_state = lua.StrToNumber( strValue )
|
if ( b_state == 0 ) then -- 等待
|
strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
|
strValue = "等待"
|
elseif ( b_state == 1 ) then -- 完成
|
strCellBkground = ', "bk_color":"#00FF00","text_color":"#000000"'
|
strValue = "完成"
|
elseif ( b_state == 2 ) then -- 错误
|
strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
|
strValue = "错误"
|
end
|
elseif (strAttr == 'S_ERR' or strAttr == 'S_DATA') then
|
strValue = string.gsub(strValue, "\\", "/")
|
strValue = string.gsub(strValue, '"','\\\"')
|
strValue = string.gsub(strValue, "'",'\\\"')
|
strValue = string.gsub(strValue, " ","")
|
end
|
strItem = '{"attr":"' .. strAttr .. '","value":"' .. strValue .. '"'..strCellBkground..'},'
|
strAttrs = strAttrs .. strItem
|
end
|
strAttrs = lua.trim_laster_char(strAttrs)
|
strRow = '{"id":"'..id..'"'..strRowCtrl..',"attrs":['..strAttrs..']},'
|
strDataJson = strDataJson .. strRow
|
end
|
-- 取消最后一个,号
|
strDataJson = lua.trim_laster_char(strDataJson)
|
strDataJson = strDataJson .. ']'
|
|
nRet, strRetInfo = mobox.strToBase64( strDataJson )
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "strToBase64 失败: "..strRetInfo) end
|
|
strAction = '[{"action_type":"reset_data_attr","base64":true, "value":"' .. strRetInfo .. '"}]'
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction)
|
if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end
|
|
end
|