案例中心 视频中心

Mobox二开的弹窗选择数据实现技巧 Mobox二开的弹窗选择数据实现技巧

Mobox二开的弹窗选择数据实现技巧

Mobox二开的弹窗选择数据实现技巧

 

需求描述

 

(上图为多选窗口)

实现方式

需要开发2个lua脚本

 

Lua脚本【试验类型选择前

–[[
    这个脚本适合 单个选择的获取过程
–]]

json = require (“json”)

mobox = require (“OILua_JavelinExt”)

function BeforeSelectGP ( strLuaDEID )

local nRet, strRetInfo ,strCondition

strCondition = “”

local action = ‘[{“action_type”:”open_data_query_dlg”,”value”:{“mulit_select”:0,”cls_name”:”供应商”,”order”:””,”grid_style”:”default”,”condition”:”‘..strCondition..'”}}]’

mobox.setAction( strLuaDEID, action )

end

 

  • 弹出窗口定义:   (注意粘贴下面内容的时候  ”  可能是中文的,需要改成英文)
  • 单选 “mulit_select”:0    多选  “mulit_select”:1
  • 关联表名 “cls_name”:”部分性能试验”   (部分性能试验 这个是表名)
  • 排序 “order”:””      (可以设置排序字段名)
  • 窗口grid “grid_style”:”procure”  (不设置就是默认grid)
  • 查询条件 “condition”:”‘..strCondition..’”  ( strCondition 是变量,拼接的查询条件)

 

我们在弹出窗口前,可以将我们需要的通过上述参数设置好后 再弹出

Lua脚本【试验类型选择后】  单选和多选例子

–[[

这个脚本适合 单个选择 的获取过程

–]]

 

json  = require (“json”)

mobox = require (“OILua_JavelinExt”)

function AfterSelectSYTPYE ( strLuaDEID )

local   nRet,  strTpyeDESC , strOldDesc

 

— 获取当前选择数据

nRet, strRetInfo = mobox.getInputParameter( strLuaDEID )

if ( nRet ~= 0 or  strRetInfo == ”) then

mobox.error( strLuaDEID, “无法获取导入数据!”)

return

end

 

local retJson = json.decode( strRetInfo )

local input_parameter = retJson[“parameter”]

local n, nCount

 

strTpyeDESC = input_parameter[“S_TST_TPYEDESC”]

 

if ( strTpyeDESC == ”  ) then

mobox.error( strLuaDEID, “试验类型信息不对!”)

return

end

 

— 设置试验类型信息

local setAttr = ‘[{“attr”:”S_TST_TPYEDESC”,”value”:”‘..strTpyeDESC..'”}]’

mobox.setCurEditDataObjAttr( strLuaDEID,setAttr )

下面是多选的例子

–[[

这个脚本适合 多个选择 的获取过程

–]]

 

json  = require (“json”)

mobox = require (“OILua_JavelinExt”)

function AfterSelectSYTPYE ( strLuaDEID )

local   nRet,  strTpyeDESC

— 获取当前选择数据

nRet, strRetInfo = mobox.getInputParameter( strLuaDEID )

if ( nRet ~= 0 or  strRetInfo == ”) then

mobox.error( strLuaDEID, “无法获取导入数据!”)

return

end

local retJson = json.decode( strRetInfo )

local input_parameter = retJson[“parameter”]      —  或者 retJson.parameter

local n, nCount

nCount = #input_parameter

strTpyeDESC =”

for n = 1 , nCount do                                     — 需要for循环

        if (strTpyeDESC ==”) then

            strTpyeDESC = input_parameter[n].S_TST_TPYEDESC

        else

            strTpyeDESC = strTpyeDESC .. ‘、’..input_parameter[n].S_TST_TPYEDESC

        end

    end

— 设置试验类型信息

local setAttr = ‘[{“attr”:”S_TST_TPYEDESC”,”value”:”‘..strTpyeDESC..'”}]’

mobox.setCurEditDataObjAttr( strLuaDEID,setAttr )

 

之后将这个脚本管理的窗口的定义里面

 

标签:低代码脚本 上一篇: 下一篇:
展开更多
预约软件体验

loading...