Mobox低代碼平臺有數(shù)據(jù)是通過json格式進行傳遞的,對于json格式 有4類
1、返回純數(shù)組
描述:[“12.5″,”235”]
數(shù)據(jù)獲取過程:
2、返回純對象
描述:{“id”:”%s”,”name”:”%s”}
數(shù)據(jù)獲取過程:
3、返回對象(包含數(shù)組)
描述:{“id”:”xxx”,”attrs”:[{“attr”:”attr1″,”value”:”xxx1″},{“attr”:”attr2″,”value”:”xxx2″}, …]}
數(shù)據(jù)獲取過程:
4、返回數(shù)組 [含對象(含數(shù)組)]? ? 最復(fù)雜
描述:[{“id”:”xxx”,”attrs”:[{“attr”:”attr1″,”value”:”xxx1″},{“attr”:”attr2″,”value”:”xxx2″}, …]},…]
數(shù)組 含 對象(含數(shù)組) 比較多的出現(xiàn)在 grid ,行列處理 (比如 遍歷表,做顯示前處理)
【例子】
json = require (“json”)
mobox = require (“OILua_JavelinExt”)
function AfterSelectCustomer ( strLuaDEID )
local nRet, strUserLogin, strUserName , strRetInfo
local strRetInfo
— 獲取當(dāng)前選擇數(shù)據(jù)
nRet, strRetInfo = mobox.getCurEditDataPacket( strLuaDEID )
if ( nRet~=0 ) then
mobox.error( strLuaDEID, “無法獲取Lua數(shù)據(jù)包!”)
return
end
if ( strRetInfo==” ) then
mobox.error( strLuaDEID, “接口數(shù)據(jù)包為空!”)
return
end
local Retobjs
local n, nCount
local strKAtax, strKAName, strKASCode, strINDUSTRY, strNATURE, strTEL, strADDRESS, strBank, strACCOUNT, strEXPRESS
Retobjs = json.decode(strRetInfo)
nCount = #Retobjs
if (nCount == 0) then
return
end
local obj, attrs
for n = 1, nCount do
obj = Retobjs[n]
attrs = obj.attrs
nattr_count = #attrs
— 獲取 相關(guān)參數(shù)
for nIndex = 1, nattr_count do
strAttr = attrs[nIndex].attr
strValue = attrs[nIndex].value
if (strAttr == ‘S_KA_NAME’) then
strKAName = strValue
end
if (strAttr == ‘S_TAX_CODE’) then
strKAtax = strValue
— 如果客戶的稅號沒有填寫 ,不允許做合同
if ( strKAtax == ” or strKAtax == nil ) then
mobox.error( strLuaDEID, “稅號不能為空 ! 先修改此客戶屬性,將其稅號(及相關(guān)開票信息)加入”)
return
end
end
— 以下以此類推 ,對相關(guān)需要賦值的 變量 。。。
end
end
— 設(shè)置 商機編號,客戶編號,客戶名稱local setAttr = ‘[{“attr”:”S_KA_CODE”,”value”:”‘..strKASCode..'”},{“attr”:”S_KA_NAME”,”value”:”‘..strKAName..'”},{“attr”:”S_INDUSTRY”,”value”:”‘..strINDUSTRY..'”},{“attr”:”S_NATURE”,”value”:”‘..strNATURE..'”},{“attr”:”S_ACCOUNT”,”value”:”‘..strACCOUNT..'”},{“attr”:”S_TEL”,”value”:”‘..strTEL..'”},{“attr”:”S_ADDRESS”,”value”:”‘..strADDRESS..'”},{“attr”:”S_BANK”,”value”:”‘..strBank..'”},{“attr”:”S_EXPRESS”,”value”:”‘..strEXPRESS..'”},{“attr”:”S_TAX_CODE”,”value”:”‘..strKAtax..'”}]’
mobox.setCurEditDataObjAttr( strLuaDEID,setAttr )
end