--[[
|
编码: JX-83-13
|
名称: 料箱格显示前事件
|
作者:KUN
|
日期:2025-1-29
|
|
入口函数:BeforeGridShow
|
|
功能说明:
|
|
--]]
|
|
json = require("json")
|
mobox = require("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
|
local EMPTYFULL_STATE_NAME = {"空", "未满", "满","分配"}
|
local EMPTYFULL_STATE_COLORS = {
|
{text_color = "#000000", bk_color = "#7FFFAA"}, -- 空状态(红色背景,白色字体)
|
{text_color = "#000000", bk_color = "#BFD641"}, -- 未满状态(绿色背景,黑色字体)
|
{text_color = "#FFFFFF", bk_color = "#6495ED"}, -- 满状态(蓝色背景,白色字体)
|
{text_color = "#000000", bk_color = "#DCDCDC"}, -- 预分配状态
|
}
|
|
function BeforeGridShow(strLuaDEID)
|
local nRet, strRetInfo, i, j
|
|
-- 获取入库单明细数据
|
local data_objs
|
nRet, data_objs = m3.GetSysDataJson(strLuaDEID)
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "获取数据失败: " .. data_objs)
|
end
|
|
local 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 = {}
|
row_item.row_button_hidden = "加货品"
|
|
-- 遍历属性列表
|
for j = 1, #obj.attrs do
|
local attr = obj.attrs[j]
|
local attr_name = attr.attr
|
local attr_value = attr.value
|
|
-- 处理空满状态(N_EMPTY_FULL)
|
if (attr_name == "N_EMPTY_FULL") then
|
local state_index = lua.StrToNumber(attr_value)
|
if (state_index >= 0 and state_index <= 3) then
|
-- 设置状态文字描述
|
attr.value = EMPTYFULL_STATE_NAME[state_index + 1]
|
|
-- 设置字体颜色和背景颜色
|
local colors = EMPTYFULL_STATE_COLORS[state_index + 1]
|
attr.text_color = colors.text_color
|
attr.bk_color = colors.bk_color
|
|
-- 当状态值不为 2(满状态)时,显示控件“加货品”
|
if (state_index ~= 2) then
|
row_item.row_button_hidden = ""
|
end
|
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
|