fy36
2025-05-14 a37aca60ff9914b0abb710f04118b22420f4f398
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
--[[
    编码: WMS-38-24
    名称: 任务-PDA-任务显示HTML页面
    作者:HAN  
    日期:2025-1-29
 
    级别:项目
    
    函数: GenerateViewHTML
 
    功能:
        生产一个任务对象属性显示页面的HTML
        <div>
                <label class="item-label">任务编码:</label>
                <span class="item-span">TA240318-00005</span>
        </div>
        要求包括任务搬运容器里的物料,批次号等属性
 
    更改记录:
 
--]]
wms_wh = require( "wms_wh" )
 
local function gen_attr_div_html( attr_name, attr_value )
    local str_html = '<div><label class="item-label">'..attr_name..':</label>'
    str_html = str_html..'<span class="item-span">'..attr_value..'</span></div>'
    return str_html
end
 
function GenerateViewHTML ( strLuaDEID ) 
    local nRet, strRetInfo, strErr
    local task
    local str_html = ""
 
    nRet, task = m3.GetSysCurEditDataObj(strLuaDEID,"Task")
 
    -- 生成HTML
    str_html = gen_attr_div_html( "任务编码", task.code )
    str_html = str_html..gen_attr_div_html( "作业编码", task.op_code )
    str_html = str_html..gen_attr_div_html( "作业名称", task.op_name )
    str_html = str_html..gen_attr_div_html( "容器编码", task.cntr_code )
 
    -- 获取容器里的物料
    local cg_detail
    nRet, cg_detail = wms_cntr.Get_Container_Goods( strLuaDEID, task.cntr_code )
    if (nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "WMS_Get_Container_Goods失败! "..cg_detail ) end 
    if ( cg_detail ~= nil and #cg_detail > 0 ) then
        local item = m3.KeyValueAttrsToObjAttr(cg_detail[1].attrs)
        str_html = str_html..gen_attr_div_html( "物料编码", item.S_ITEM_CODE )
        str_html = str_html..gen_attr_div_html( "物料名称", item.S_ITEM_NAME )
        str_html = str_html..gen_attr_div_html( "批次", item.S_SERIAL_NO )
    end
    -- 获取库区名称
    local area
    nRet, area = wms_wh.GetAreaInfo( task.start_area_code )
    if (nRet ~= 0) then 
        strErr = "从内存获取编码'"..task.start_area_code.."'的库区信息失败!"
        lua.Error( strLuaDEID, debug.getinfo(1), strErr )
    end
    str_html = str_html..gen_attr_div_html( "起始库区", '#'..task.start_area_code..'#'..area.name )
    str_html = str_html..gen_attr_div_html( "货位", task.start_loc_code )
    -- 终点库区
    nRet, area = wms_wh.GetAreaInfo( task.end_area_code )
    if (nRet ~= 0) then 
        strErr = "从内存获取编码'"..task.end_area_code.."'的库区信息失败!"
        lua.Error( strLuaDEID, debug.getinfo(1), strErr )
    end
    str_html = str_html..gen_attr_div_html( "终点库区", '#'..task.end_area_code..'#'..area.name )
    str_html = str_html..gen_attr_div_html( "货位", task.end_loc_code )
 
 
    local action = {}
 
    action.action_type = "set_panel_html"
    action.value = str_html
 
    lua.Debug( strLuaDEID, debug.getinfo(1), "action! ", action )
 
    nRet, strRetInfo = mobox.setAction( strLuaDEID, '['..lua.table2str(action)..']'  )
    if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo..' action = '..strAction ) end 
 
end