案例中心 视频中心

Mobox 3000功能点页面按钮隐藏的lua实现方法 Mobox 3000功能点页面按钮隐藏的lua实现方法

Mobox 3000功能点页面按钮隐藏的lua实现方法

分类:二次开发 产品中心 17

需求,我们有一个任务执行后,需要对这个任务做后做评价。为此与任务系统集成通过3000功能点定义了一个任务评分的功能点。任务评分后,不能通过新增,对这个任务再次增加一个评分。因此第一个任务评分后,需要将页面按钮(新增)隐藏掉

脚本列子

— 功能:
— 3000 功能点 列出与某一个taskid相关的数据
— 若列出数据已经有,将 新增 页面按钮屏蔽 (这个功能是做任务评测结果的,结果只能有一个,不可能多个)
————————————————————————–
json = require (“json”)
mobox = require (“OILua_JavelinExt”)

function shownowtaskdata ( strLuaDEID )

local nRet, strRetInfo
local nType
local strTaskID
local bHidden=false
local strClsID=""
--拿到数据对象标识
nRet, strRetInfo = mobox.getCurEditExtInfo( strLuaDEID )
if ( nRet ~= 0 ) then
    mobox.error( strLuaDEID, "系统获取扩展属性失败 "..strRetInfo )
    return
end
if ( strRetInfo =='' or strRetInfo==nil or strRetInfo=='{}' ) then
    mobox.error( strLuaDEID, "系统获取扩展属性为空!" )
    return
end
local extinfo = json.decode( strRetInfo )
strClsID=extinfo.cls_id -- 得到当前cls的id ,下面操作需要

— 获取任务全局属性 (这个案例是与 Gungho任务系统集成,所以需要这个参数,别的环境这个可以忽略
nRet, strRetInfo = mobox.getGlobalAttr( strLuaDEID, “task_id” )
if ( nRet ~= 0 or strRetInfo == ” ) then
mobox.error( strLuaDEID, “系统无法获取任务号 “..strRetInfo )
return
end
local input_paramter = json.decode( strRetInfo )
local strTaskID = input_paramter[1].value

local strCondition
strCondition = "G_TASK_ID='"..strTaskID.."'"

--增加隐藏按钮的依据-通过条件查询返回符合数据>0 既隐藏
-- local strQeuryCondition="S_TESTITEM='X'" (定义grid某一个字段内有某些数值 这里没有启用)
nRet, strRetInfo = mobox.getDataObjCount(strLuaDEID, strClsID, strCondition)
if (nRet ~= 0 ) then
    mobox.error(strLuaDEID, "得到数据数量失败,原因:" .. strRetInfo)
    return
end

--转为整数类型
local nDataCount = tonumber(strRetInfo)
if (nDataCount >0) then
    bHidden=true
end

--隐藏页面按钮 “新增”
local strHiddenButton = ''
if (bHidden) then
    strHiddenButton =
    ',{"action_type":"hidden_button","value":[{"name":"新增"}]}'
end

local strAction = '[{"action_type":"set_query_condition","value":{"where":"' .. strCondition .. '","order":""}}'
strAction = strAction .. strHiddenButton .. ']'
mobox.setAction( strLuaDEID, strAction )
end
这个列子也可以用于别的一些非法字符串的处理
标签:脚本 上一篇: 下一篇:
展开更多
预约软件体验

loading...