1
Jianw
2025-07-09 f6f5e6b632d6649386a380558d84003f3de7ec6c
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
--[[
   编码: WMS-20-20
   名称: 显示一个料格图片
   作者:
   日期:2025-1-29
 
   函数: OpenHTMLViewDlg
   功能:
 
   更改记录:
 
--]]
 
wms_base = require( "wms_base" )
 
-- 生成一个容器料格货品显示样式
local function generate_html_item( strLuaDEID, cntr_code, cell_no, item_code, item_name, qty )
    local nRet, img_url
    nRet, img_url = wms_base.Get_ImgUrl( )
    if ( nRet ~= 0 ) then 
        return 1, img_url 
    end
 
    local img = img_url..cell_no..".png"
 
    local content = 
        '<div style="width:560px;height:150px;border:1px solid #ddd;border-radius:6px;padding-left:9px;">'..
            '<div>'..
                '<span style="color:black;">料箱号:</span>'..
                '<span style="color:blue;">'..cntr_code..'</span>'..
            '</div>'..
            '<div style="display:flex;flex-direction:row;">'..
                '<div style="width: 200px;">'..
                    '<img src="'..img..'" '..
                        'style="width: 200px;height: 110px;border: 1px solid #ddd;">'..
                '</div>'..
                '<div style="width: 320px;padding-left:6px;">'..
                    '<div>'..
                        '<span style="color:black;padding-left: 26px;">料格:</span>'..
                        '<span style="color:blue;">'..cell_no..'</span>'..
                    '</div>'..    
                    '<div>'..
                        '<span style="color:black;">货品编码:</span>'..
                        '<span style="color:blue;">'..item_code..'</span>'..
                    '</div>'..
                    '<div style="display:flex;">'..
                        '<span style="color:black;">货品名称:</span>'..
                        '<span style="color:blue;width:calc(100% - 70px);">'..item_name..'</span>'..
                    '</div>'..
                    '<div>'..
                        '<span style="color:black;padding-left: 26px;">数量:</span>'..
                        '<span style="color:blue;font-size:20px;vertical-align:middle;font-weight:bold;">'..qty..'</span>'..
                    '</div>'..
                '</div>'..
            '</div>'..
        '</div>'
  
    return 0, content
end
 
function OpenHTMLViewDlg( strLuaDEID )
    local nRet, strRetInfo, data_json, img_url
    nRet, img_url = wms_base.Get_ImgUrl( )
    if ( nRet ~= 0 ) then
        lua.Stop( strLuaDEID, img_url )
        return
    end
 
    nRet, data_json = m3.GetSysDataJson( strLuaDEID )
    if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), data_json ) end  
 
    local str_html
    if ( data_json.cntr_cell_list == nil or #data_json.cntr_cell_list == 0 ) then
        str_html= '<img src="'..img_url..'noanything.7364c627.png" style="width: 200px;height: 110px;border: 1px solid #ddd;">'        
    else
        str_html = '<div style="display:flex;flex-direction:row;flex-wrap:wrap;gap:20px;">'
        local str_item
    
        for n = 1, #data_json.cntr_cell_list do
            nRet, str_item = generate_html_item(  strLuaDEID,
                                            data_json.cntr_cell_list[n].S_CNTR_CODE,
                                            data_json.cntr_cell_list[n].S_CELL_NO,
                                            data_json.cntr_cell_list[n].S_ITEM_CODE,
                                            data_json.cntr_cell_list[n].S_ITEM_NAME,
                                            data_json.cntr_cell_list[n].F_QTY )
            if ( nRet ~= 0 ) then
                lua.Stop( strLuaDEID, str_item ) 
                return
            end
            str_html = str_html..str_item
        end
    
        str_html = str_html..'</div>'
    end
 
    local action = {
        {
            action_type = "set_panel_html",
            value = str_html
        }
    }
    nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) )
    if ( nRet ~= 0 ) then 
        lua.Stop( strLuaDEID, "setAction失败! "..strRetInfo..' action = '..strAction ) 
        return 
    end     
end