1
Jianw
2025-07-09 88e26a2a960dbbc148332772448b79b9877102d8
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
--[[
   编码: GK-52-15#2
 
   名称: 显示播种墙
   作者:
   日期:2025-7-5
 
   函数: 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 tbJh = {
        Row = 1,
        Col = 4,
        Layer = 3,
        Title = "博种墙"
    }
 
    --[[ 代表要选中的格子 ]]
    --[[ 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;height: 100%;"><div  style=" display: flex;justify-content: center;align-items: center;text-align: center;gap: 100px;">'
 
    local strLayerHtml = ""
    local nlayer = tbJh.Layer
    local nCol = tbJh.Col
    local strTitle = tbJh.Title
    local nRow = tbJh.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 style="padding: 2px 3px;"><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-jh01">  <label class="lb_row">' .. strTitle .. '</label><table> <tbody>' ..
                  strLayerHtml .. ' </tbody></table></div>';
 
    strHtml = strHtml .. '</div></div>'
 
    local action = {{
        action_type = "set_panel_html",
        value = strHtml
    }}
    nRet, strRetInfo = mobox.setAction(strLuaDEID, json.encode(action))
    if (nRet ~= 0) then
        lua.Stop(strLuaDEID, "setAction失败! " .. strRetInfo .. ' action = ' .. action)
        return
    end
end