--[[
|
编码: GK-56-20
|
来源: WMS-56-20
|
名称: 显示料箱格
|
作者:
|
日期:2025-1-29
|
|
函数: ShowHTMLPage
|
功能:
|
|
更改记录:
|
|
--]]
|
|
wms_base = require ("wms_base")
|
wms_wh = require ("wms_wh")
|
|
local function selectjh(tbData, v)
|
local borderColor = "#ddd"
|
local backgroundColor = "#f5f5f5"
|
for _, data in ipairs(tbData) do
|
if v == data.value then
|
-- borderColor = data.color
|
backgroundColor = data.color
|
end
|
end
|
return borderColor, backgroundColor
|
end
|
|
|
function ShowHTMLPage( strLuaDEID )
|
local nRet, strRetInfo, data_json
|
local runtime_parameter
|
nRet, runtime_parameter = m3.GetRuntimeParam(strLuaDEID)
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "GetRuntimeParam失败! "..runtime_parameter )
|
return
|
end
|
|
-- 获取【料格显示】面板的参数
|
-- 参数格式: { cell_no, loc_code, light_color }
|
|
local parameter
|
nRet, parameter = m3.GetRuntimePanel_InputParamter( strLuaDEID, runtime_parameter.panel, "料格显示" )
|
if ( nRet == 1 ) then return end
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, parameter )
|
return
|
end
|
if ( parameter == nil ) then return end
|
|
local img_url -- 浏览图片要用到
|
nRet, img_url = wms_base.Get_ImgUrl( )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, img_url )
|
return
|
end
|
|
local cell_no = parameter.cell_no
|
local loc_code = parameter.loc_code or ''
|
local to_loc = {}
|
local row = 0
|
local col = 0
|
local layer = 0
|
|
if loc_code ~= '' then
|
nRet, to_loc = wms_wh.GetLocInfo( loc_code )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, '获取货位信息失败! '..to_loc)
|
return
|
end
|
row = to_loc.row
|
col = to_loc.col
|
layer = to_loc.layer
|
end
|
|
local img
|
if ( cell_no == nil or cell_no == '' ) then
|
-- 显示一个?
|
img = img_url.."nothing.png"
|
else
|
img = img_url..cell_no..".png"
|
end
|
|
-- 生成分拣位
|
--[[ 拣货信息 ]]
|
local tbJh = {
|
{ Row = 1, Col = 4, Layer = 3, Title = "拣货1" },
|
{ Row = 2, Col = 4, Layer = 3, Title = "拣货2" }
|
}
|
--[[ 代表要选中的格子 ]]
|
--[[ value=row - layer - col 组成]]
|
local show_point = row.."-"..col.."-"..layer
|
local color = parameter.light_color or " #7CFC00"
|
local tbData = {
|
{ value = show_point, color = color }
|
}
|
--[[ 格子高宽 ]]
|
local strJhWH = "30px"
|
local strHtml =
|
'<div class="view-jh" style=" display: flex;justify-content: center;align-items: center;margin-top: 40px;"><div style=" display: flex;justify-content: center;align-items: center;text-align: center;gap: 100px;">'
|
|
for i = 1, #tbJh do
|
local strLayerHtml = ""
|
local nlayer = tbJh[i].Layer
|
local nCol = tbJh[i].Col
|
local strTitle = tbJh[i].Title
|
local nRow = tbJh[i].Row
|
|
for j = 1, nlayer do
|
local strColHtml = ""
|
for index = 1, nCol do
|
--[[ row - layer - col ]]
|
local coordinate = nRow .. "-" .. j .. "-" .. index
|
--[[ 拿当前坐标到 tbData中查是否存在 返回对应的颜色]]
|
local borderColor, backgroundColor = selectjh(tbData, coordinate)
|
|
strColHtml = strColHtml .. '<td><a title="GKS' .. coordinate .. '" style="background: ' ..
|
backgroundColor .. ';border: 1px solid ' .. borderColor .. '; width: ' .. strJhWH ..
|
';height: ' .. strJhWH .. ';display: inline-block;vertical-align: sub;"></a></td>'
|
|
end
|
if (strColHtml ~= "") then
|
strLayerHtml = '<tr>' .. strColHtml .. '</tr>' .. strLayerHtml
|
end
|
end
|
|
strHtml = strHtml .. '<div class="view-jh' .. i .. '"> <label class="lb_row">' .. strTitle ..
|
'</label><table> <table>' .. strLayerHtml .. ' </tbody></table></div>';
|
end
|
strHtml = strHtml .. '</div></div>'
|
strHtml = strHtml .. '<div title="" style="text-align: center;height:calc(100% - 210px);width: 100%;margin: 20px 0px 10px 0px;">'
|
strHtml = strHtml .. '<img src="' .. img .. '"style=" width: 70%;height: 100%;">'
|
strHtml = strHtml .. '</div>'
|
|
local action = {
|
{
|
action_type = "set_panel_html",
|
value = strHtml
|
}
|
}
|
nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
|
if ( nRet ~= 0 ) then
|
lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction )
|
return
|
end
|
end
|