--[[
|
编码: hh-mobox-003
|
名称: 当前入库任务
|
作者:SGX
|
日期:2024-11-17
|
|
函数: GenerateViewHTML
|
功能:
|
|
更改记录:
|
|
--]]
|
json = require("json")
|
mobox = require("OILua_JavelinExt")
|
m3 = require("oi_base_mobox")
|
|
function GenerateViewHTML(strLuaDEID)
|
local nRet, strRetInfo
|
local autoplay = false
|
local strHtmlTitle = "";
|
local strHtmlRow = "";
|
--[[ 获取样式 ]]
|
local strHtmlStyle = GetHtmlStyle();
|
--[[ 列明 ]]
|
local tabTitleList = { "物料编码", "物料名称", "状态", "总重量" }
|
|
--[[ 组织列名 ]]
|
for i = 1, #tabTitleList do
|
strHtmlTitle = strHtmlTitle .. '<div class="table-col' .. i .. '">' .. tabTitleList[i] .. '</div>'
|
end
|
-- 获取执行中的作业数据
|
local tabDataList = {}
|
local operation_list
|
local condition = "TO_CHAR(T_CREATE, 'YYYY-MM-DD') = TO_CHAR(SYSDATE, 'YYYY-MM-DD')"
|
local strFieldList = '["S_STATE","S_ITEM_CODE","S_ITEM_NAME","F_ACTUAL_QTY"]'
|
nRet, operation_list = mobox.queryTable(strLuaDEID, "TN_GT_Incoming_Info", strFieldList, 1000, condition,
|
"T_CREATE ASC")
|
if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "获取【入库单】失败!" .. operation_list) end
|
if (operation_list == '') then return end
|
operation_list = json.decode(operation_list)
|
-- 添加入库信息
|
for i = 1, #operation_list do
|
tabDataList[i] = {
|
item_code = operation_list[i].S_ITEM_CODE,
|
item_name = operation_list[i].S_ITEM_NAME,
|
weight = operation_list[i].F_ACTUAL_QTY
|
}
|
|
if (operation_list[i].S_STATE == '新建') then
|
tabDataList[i].state = "待执行"
|
tabDataList[i].back = "#ff5722"
|
elseif (operation_list[i].S_STATE == '启用') then
|
tabDataList[i].state = "执行中"
|
tabDataList[i].back = "#ffc107"
|
elseif (operation_list[i].S_STATE == '完成') then
|
tabDataList[i].state = "已完成"
|
tabDataList[i].back = "#2196F3"
|
end
|
end
|
-- local tabDataList = {
|
-- {
|
-- item_code = "111",
|
-- item_name = "111",
|
-- state = "执行中",
|
-- weight = 100,
|
-- back = "#ff5722"
|
-- }, {
|
-- item_code = "222",
|
-- item_name = "222",
|
-- state = "完成",
|
-- weight = 100,
|
-- back = "#2196F3"
|
-- }, {
|
-- item_code = "111",
|
-- item_name = "111",
|
-- state = "执行中",
|
-- weight = 100,
|
-- back = "#ff5722"
|
-- }, {
|
-- item_code = "111",
|
-- item_name = "111",
|
-- state = "执行中",
|
-- weight = 100,
|
-- back = "#ff5722"
|
-- }, {
|
-- item_code = "111",
|
-- item_name = "111",
|
-- state = "执行中",
|
-- weight = 100,
|
-- back = "#ff5722"
|
-- }
|
-- }
|
|
|
if (#tabDataList > 4) then
|
autoplay = true
|
end
|
|
--[[ 组织行数据html ]]
|
for i = 1, #tabDataList do
|
strHtmlRow = strHtmlRow .. '<div class="swiper-slide"><div class="table-row-data">' ..
|
'<div class="table-col1">' ..
|
tabDataList[i].item_code .. '</div>' .. '<div class="table-col2">' .. tabDataList[i].item_name ..
|
'</div>' ..
|
'<div class="table-col3">' ..
|
'<div style=" background: ' .. tabDataList[i].back .. ';">' .. tabDataList[i].state
|
..
|
'</div>' .. '</div>' .. '<div class="table-col4">' .. tabDataList[i].weight .. '</div>' .. '</div></div>'
|
end
|
|
--[[ 总html ]]
|
local strHtml = ' <div class="table3">' .. '<div class="table-head">' .. strHtmlTitle .. '</div>' ..
|
'<div class="table-body" style="overflow: hidden;"> <div class="swiper-container crkrw"><div class="swiper-wrapper">' ..
|
strHtmlRow .. '</div></div></div>' .. '</div>'
|
|
local action = {}
|
action[1] = {
|
action_type = "chart",
|
value = {
|
graphicType = "html",
|
title = {
|
text = "当前入库任务",
|
align = "left",
|
color = "#fff",
|
font = "微软雅黑",
|
fontSize = 18
|
},
|
swiper = {
|
--[[ 容器名称不能重复 不能为空 swiper-container class 需要指定 ]]
|
containerName = "crkrw",
|
--[[ 强制Swiper的宽度(px),"undefined" 或 整数, 当你的Swiper在隐藏状态下初始化时用得上。这个参数会使自适应失效。可设置为undefined使这个参数无效。 ]]
|
width = "undefined",
|
--[[ 强制Swiper的高度(px),当你的Swiper在隐藏状态下初始化时且切换方向为垂直才用得上。这个参数会使自适应失效。 ]]
|
height = 150,
|
--[[ 排列方向 vertical , horizontal ]]
|
direction = "vertical",
|
--[[ 切换速度,即slider自动滑动开始到结束的时间(单位ms) ]]
|
speed = 1000,
|
--[[ loop 模式如果与 slidesPerView: 'auto' 一起使用,需要设置 loopedSlides 指定要循环(重复)的幻灯片数量。 ]]
|
loop = true,
|
--[[ 设置slider容器能够同时显示的slides数量,整数或auto ]]
|
slidesPerView = 'auto',
|
--[[ 在slide之间设置距离(单位px)。 ]]
|
spaceBetween = 1,
|
--[[ 默认情况下Swiper 每次滑动时只滑动一个Slide,并且会自动贴合Wrapper。开启自由模式后,Swiper 会根据惯性滑动可能不止一格且不会贴合。 ]]
|
freeMode = true,
|
--[[ 设定slide与左边框的预设偏移量(单位px)。 垂直就行与上方距离 ]]
|
slidesOffsetBefore = 0,
|
--[[ 设定slide与右边框的预设偏移量(单位px)。 垂直就行与下方距离 ]]
|
slidesOffsetAfter = 0,
|
--[[是否自动播放,true 需要指定 autoplayDelay ]]
|
autoplay = autoplay,
|
--[[ 播放间隔时间,单位ms ]]
|
autoplayDelay = 500
|
},
|
html = strHtmlStyle .. strHtml
|
}
|
}
|
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, json.encode(action))
|
if (nRet ~= 0) then
|
lua.Error(strLuaDEID, debug.getinfo(1), "setAction失败! " .. strRetInfo)
|
end
|
end
|
|
function GetHtmlStyle()
|
return
|
'<style>' .. '.table3 {' .. ' border: 2px solid #fff;' .. ' width: 100%;' .. ' height: 100%;' .. '}' ..
|
'.table-head {' .. ' border-bottom: 2px solid #fff; color: #fff;' .. '}' .. '.table-head>div {' ..
|
' text-align: center;' .. ' display: inline-block;' .. ' padding: 5px 0px;' ..
|
' font-size: 17px;' ..
|
' font-weight: 600;' .. '}' .. '.table3 .table-head .table-col1 {' .. ' width: 20%;' ..
|
' border-right: 2px solid;' .. '}'
|
.. '.table3 .table-head .table-col2 {' .. ' width: 50%;' ..
|
' border-right: 2px solid;' .. '}' .. '.table3 .table-head .table-col3 {' .. ' width: 15%;' ..
|
' border-right: 2px solid;' .. '}' .. '.table3 .table-row-data .table-col3>div {' ..
|
' border-radius: 50px;' .. ' width: 92%;' .. ' display: inline-block;' .. ' padding: 5px 1px;' ..
|
' font-size: 12px;' .. '}' .. '.table3 .table-head .table-col4 {' .. ' width: 15%;' .. '}' ..
|
'.table3 .table-body .table-row-data{ margin-top: 10px;} .table-body .table-row-data>div {' ..
|
' text-align: center;' .. ' display: inline-block;' .. ' padding: 5px 0px;' .. ' color: #fff;' ..
|
'}' ..
|
'.table3 .table-row-data .table-col1 {' ..
|
' width: 20%;' .. '}' .. '.table3 .table-row-data .table-col2 {' .. ' width: 50%;' .. '}' ..
|
'.table3 .table-row-data .table-col3 {' ..
|
' width: 15%;' .. '}' .. '.table3 .table-row-data .table-col4 {' .. ' width: 15%;' .. '}' .. '</style>'
|
end
|