1
Jianw
9 天以前 70f29da38121b9a467841253e3268feb5df02902
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
--[[
   编码: 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