--[[ 编码: GT-103-13 名称: 作者: 日期:2025-05-20 函数: BeforeGridShow 功能: 更改记录: --]] json = require("json") m3 = require("oi_base_mobox") mobox = require("OILua_JavelinExt") function BeforeGridShow(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 nCount = #arobjs if (nCount == 0) then return end local obj, attrs, id local strDataJson local strCurYear = os.date("%Y") strCurYear = strCurYear .. "--" strDataJson = '[' for n = 1, nCount do obj = arobjs[n] attrs = obj.attrs nattr_count = #attrs id = obj.id local str = m3.KeyValueAttrsToObjAttr(attrs) lua.Debug(strLuaDEID, debug.getinfo(1), "str", str) local strAttrs = '' -- 获取 物料编码 和 库区编码 for nIndex = 1, nattr_count do local strAttr = attrs[nIndex].attr local strValue = attrs[nIndex].value local strItem = '{"attr":"' .. strAttr .. '","value":"' .. strValue .. '"},' strAttrs = strAttrs .. strItem end -- 流水号未绑定容器状态为未绑定,绑定了容器状态为已绑定 local cg_detail local strValue local strCondition = "S_SERIAL_NO = '"..str.S_SERIAL_NO.."'" nRet, cg_detail = m3.GetDataObjByCondition(strLuaDEID, "CG_Detail", strCondition, "T_CREATE DESC") lua.Debug(strLuaDEID, debug.getinfo(1), "cg_detail", cg_detail) if (nRet == 1) then strValue = '未绑定' elseif (nRet == 0) then strValue = '已绑定' elseif (nRet > 1) then lua.Error(strLuaDEID, debug.getinfo(1), "获取流水号信息失败!" .. cg_detail) end local strItem = '{"attr":"CUSTOM_STATE","value":"' .. strValue .. '"},' strAttrs = strAttrs .. strItem strAttrs = lua.trim_laster_char(strAttrs) local strRow = '{"id":"' .. id .. '","attrs":[' .. strAttrs .. ']},' strDataJson = strDataJson .. strRow end -- 取消最后一个,号 strDataJson = lua.trim_laster_char(strDataJson) strDataJson = strDataJson .. ']' local strAction = '[{"action_type":"reset_data_attr","value":' .. strDataJson .. '}]' lua.Debug(strLuaDEID, debug.getinfo(1), "strAction", strAction) 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