--[[
|
编码: WMS-70-10
|
名称: 仓库量表-显示前
|
作者:HAN
|
日期:2025-1-29
|
|
级别:固定 (说明本段代码在项目中不太会变化)
|
|
函数: BeforeView
|
|
功能:
|
获取内存中的存储量和分配量,不一致 背景红色
|
|
更改记录:
|
|
--]]
|
|
wms_base = require( "wms_base" )
|
|
function BeforeView ( strLuaDEID )
|
local nRet, strRetInfo
|
local arobjs, attrs
|
local n, nCount
|
|
nRet, arobjs = m3.GetSysDataJson( strLuaDEID )
|
if ( nRet ~=0 ) then lua.Error( strLuaDEID, debug.getinfo(1), arobjs ) end
|
-- [{"id":"","attrs":[{"attr":"","value":""},..]},..]
|
nCount = #arobjs
|
if (nCount == 0) then return end
|
|
local obj, attrs, id
|
local strCellBkground, strDataJson
|
local strRowCtrl = ''
|
local item, obj_attr
|
local qty, alloc_qty
|
local parameter = {}
|
|
strDataJson = '['
|
for n = 1, nCount do
|
obj = arobjs[n]
|
attrs = obj.attrs
|
nattr_count = #attrs
|
id = obj.id
|
-- 获取内存中的 qty, alloc_qty
|
obj_attr = m3.KeyValueAttrsToObjAttr(attrs)
|
parameter = {}
|
parameter.wh_code = lua.Get_StrAttrValue( obj_attr.S_WH_CODE )
|
parameter.end_user = lua.Get_StrAttrValue( obj_attr.S_END_USER )
|
parameter.item_list = {}
|
item = {}
|
item.item_code = lua.Get_StrAttrValue( obj_attr.S_ITEM_CODE )
|
parameter.item_list[1] = item
|
|
nRet, strRetInfo = wms.wms_GetWHInventory( lua.table2str(parameter) )
|
if (nRet == 0) then
|
local ret_info = json.decode( strRetInfo )
|
qty = ret_info[1].qty_storage
|
alloc_qty = ret_info[1].qty_alloc
|
end
|
|
strAttrs = ''
|
for nIndex = 1, nattr_count do
|
strAttr = attrs[nIndex].attr
|
strValue = attrs[nIndex].value
|
strCellBkground = ''
|
if (strAttr == 'F_QTY') then
|
if ( nRet == 0 ) then
|
if (lua.StrToNumber(strValue) ~= qty ) then
|
strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
|
strValue = strValue..'/'..qty
|
end
|
else
|
strValue = strValue..'/Err'
|
strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
|
end
|
elseif (strAttr == 'F_ALLOC_QTY') then
|
if ( nRet == 0 ) then
|
if (lua.StrToNumber(strValue) ~= alloc_qty ) then
|
strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
|
strValue = strValue..'/'..alloc_qty
|
end
|
else
|
strValue = strValue..'/Err'
|
strCellBkground = ', "bk_color":"#FF0000","text_color":"#FFFFFF"'
|
end
|
end
|
strItem = '{"attr":"' .. strAttr .. '","value":"' .. strValue .. '"'..strCellBkground..'},'
|
strAttrs = strAttrs .. strItem
|
end
|
strAttrs = lua.trim_laster_char(strAttrs)
|
strRow = '{"id":"'..id..'"'..strRowCtrl..',"attrs":['..strAttrs..']},'
|
strDataJson = strDataJson .. strRow
|
end
|
-- 取消最后一个,号
|
strDataJson = lua.trim_laster_char(strDataJson)
|
strDataJson = strDataJson .. ']'
|
|
strAction = '[{"action_type":"reset_data_attr","value":' .. strDataJson .. '}]'
|
nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction)
|
if ( nRet ~= 0 ) then
|
lua.Warning( strLuaDEID, debug.getinfo(1), strAction )
|
lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo)
|
end
|
end
|