反饋已提交
網絡繁忙
和 10.0 差別:
新增 servletURL、serverURL、server、fineServletURL、SessionMgr.getSessionID() API
補充 FVS 範本相關API說明
適用於安裝了「FineVis資料視覺化」插件 V1.8.0 及之後版本的使用者
showDialog 新增 padding、titleStyle、backgroundStyle 三個參數欄位,僅支援 FVS V2.0.0 及之後版本
showDialog 新增 dialogType、line、coordinate 三個參數欄位,僅支援 FVS V2.0.1 及之後版本
新增 getCoordinate API,配合 showDialog 使用
注意事項必看:
1)在普通報表和決策報表(新版), 以下 API 使用方式為 FR.xxx ,FVS 企業戰情室範本中使用方式為 duchamp.xxx 。
2)部分API中,FVS 企業戰情室範本參數為 json 格式,普通報表和決策報表中,參數為 字串 格式,詳情看以下API介紹。
屬性
servletURL
獲取servletURL。
參數
-
回傳值
string
獲取servletURL,回傳值為字串,格式如:
/webroot/decision/view/report
範例
普通報表、決策報表範例:
FR.servletURL;
FVS 企業戰情室範本範例:
duchamp.servletURL;
應用範例
行動端
支援行動端,行動端傳回格式和PC端有差別,如:/webroot/decision
serverURL
獲取serverURL。
獲取serverURL,回傳值為字串,格式如:
http://localhost:8075
FR.serverURL;
duchamp.serverURL;
普通報表、決策報表不支援,FVS企業戰情室範本支援行動端
server
獲取server。
獲取server,回傳值為字串,格式如:
http://localhost:8075/webroot
FR.server;
duchamp.server;
獲取 fineServletURL,回傳值為字串,格式如:
/webroot/decision
FR.fineServletURL;
duchamp.fineServletURL;
方法
SessionMgr.getSessionID()
獲取sessionId
獲取sessionId,回傳值為字串,如:
62a0f071-c2c6-4623-91c3-3d58c6265c19
FR.SessionMgr.getSessionID();
點選按鈕,列印報表的sessionId:
點選可下載範本:列印sessionId.cpt。
FVS 企業戰情室範本:列印sessionId.fvs
支援行動端。
showDialog(title,width,height,innerContent)
開啟一個對話框。
title:string
width:number
height:number
innerContent:iframe
title:對話框標題,字串。
width:對話框寬度。
height:對話框高度。
innerContent:對話框內容,iframe標簽,如果要開啟工程下的報表,需先將報表定義為iframe標簽。
void
開啟一個標題為“彈窗”,寬600、高400內容為“HelloWorld”的對話框:
FR.showDialog("彈窗",600,400,"HelloWorld");
開啟一個標題為“銷量彈窗”,寬700,高500,彈窗內容為內建範本GettingStartedTW.cpt的對話框:
//建立對話框內的iframe,iframe參數的命名及寬高等var iframe=$(<iframeid='inp'name='inp'width='100%'height='100%'scrolling='no'frameborder='0'>");//給iframe新增src屬性,指向需要展示的範本地址iframe.attr("src","/webroot/decision/view/report?viewlet=GettingStartedTW.cpt");//彈出對話框FR.showDialog("對話框",700,500,iframe);
點選按鈕,開啟一個標題為“銷量彈窗”,寬700,高500,彈窗內容為內建範本GettingStartedTW.cpt的對話框:
詳細內容介紹可參考:JS實現彈窗後資料回填
不支援行動端。
showDialog(
{
title:string,
width:number,
height:number,
innerContent:iframe,
padding: style,
titleStyle:style,
backgroundStyle: style,
dialogType:string,
line: style,
coordinate: array
}
)
title:string
width:number
height:number
innerContent:iframe
padding: style
titleStyle:style
backgroundStyle: style
dialogType:string
line: style
title:彈出框標題,字串
width:彈出框寬度
可填寫具體數值,數值單位為 px 。例如 width: 500
可使用百分比表示佔瀏覽器視窗的比例,例如 width:"50%"
height:彈出框高度
可填寫具體數值,數值單位為 px 。例如 height: 300
可使用百分比表示佔瀏覽器視窗的比例,例如 height:"50%"
innerContent:彈出框內容,iframe 標籤,如果要開啟工程下的報表,需先將報表定義為 iframe 標籤
padding:內邊距設定,例如 padding: "10px"
titleStyle:標題樣式設定
backgroundStyle:邊框背景樣式設定
注:titleStyle 和 backgroundStyle 較為靈活,css 能實現的寫法這裏均支援
dialogType:彈出框的形式,預設為置中顯示
dialogType:"center" 代表彈出框置中顯示
dialogType:"dynamic" 代表彈出框動態顯示,帶有引導線
line:引導線配置
type 屬性僅支援 color ,即引導線的顏色
例如 line: { type: "color", value:{ color: "red" }},
coordinate:引導線開始的座標,基於預覽模式下的座標系,座標為相對螢幕的座標。例如 coordinate: [200, 300]
注:coordinate 可結合 getCoordinate 獲取組件座標API使用,可使得引導線總是在組件位置開啟
範例1:開啟一個標題為“銷量彈窗”,寬 700、高 500 ,內邊距為 15px,字體粗體,字號 24px,背景色是綠色,內容為 “Hello World”的彈出框
duchamp.showDialog({ title: "銷量彈窗", width: 700, height: 500, innerContent: "Hello World", padding: "15px", titleStyle: { fontSize: "24px", fontWeight: "bold" }, backgroundStyle: { background:"green" }, dialogType:"center",});
範例2:開啟一個標題為“銷量彈窗”,寬 700,高 500 ,彈窗內容為內建範本 GettingStarted.cpt 且置中顯示的彈出框
"use document";const iframe = document.createElement("iframe");iframe.width = "100%";iframe.height = "100%";iframe.scrolling = "no";iframe.style="border: none";iframe.src = "/webroot/decision/view/report?viewlet=GettingStarted.cpt";duchamp.showDialog( { title:"銷量彈窗", width: 700, height: 500, innerContent:iframe, dialogType:"center", });
範例3:開啟一個標題為“銷量彈窗”,寬 500,高 500 ,彈窗內容為內建範本 GettingStarted.cpt 的動態顯示彈出框
"use document"const iframe = document.createElement("iframe");iframe.width = "100%";iframe.height = "100%";iframe.scrolling = "no";iframe.style="border: none";iframe.src = "/webroot/decision/view/report?viewlet=GettingStarted.cpt";duchamp.showDialog({ title: "銷量彈窗", width: 500, height: 500, innerContent: iframe, padding: "15px", titleStyle: { fontSize: "24px",color:"white", fontWeight: "bold" }, backgroundStyle: { background:"green" }, dialogType:"dynamic", line: { type: "color", value: { color: "red" } }, coordinate: [300, 240],});
參考上述 範例2 和 範例3 製作範本,效果如下圖所示:
點選下載範本:JS實現點選開啟彈出框.fvs
獲取 FVS 範本在預覽狀態時,組件/模型的座標
一般結合 showDialog API展示動態彈出框時使用
參數 name 僅用於獲取三維組件模型mesh物件名稱,傳回物件座標。例如:
duchamp.getWidgetByName("三維組件名稱").getCoordinate("模型名稱");
不傳參時,獲取組件中心座標。例如:
duchamp.getWidgetByName("組件名稱").getCoordinate();
範例1:點選標題,獲取標題組件座標,在該座標位置開啟一個帶有引導線的彈出框
const coordinate = duchamp.getWidgetByName("標題1_頁面1").getCoordinate();duchamp.showDialog({ title: "銷量彈窗", width: 700, height: 500, innerContent: "Hello World", padding: "15px", titleStyle: { fontSize: "24px", fontWeight: "bold" }, backgroundStyle: { background: "green" }, coordinate:coordinate, dialogType: "dynamic",});
範例2:獲取三維組件「停車場模型」中的「車輛002」模型物件的座標,在該座標位置開啟一個彈出框 注:此方法開啟的彈出框不會跟隨模型縮放或視角變化而行動位置
const coordinate = duchamp.getWidgetByName("停車場模型").getCoordinate("車輛002");duchamp.showDialog({ title: "車輛資訊彈出框", width: 500, height: 300, innerContent: "Hello World", padding: "15px", titleStyle: { fontSize: "24px", fontWeight: "bold" }, backgroundStyle: { background: "green" }, coordinate:coordinate, dialogType: "dynamic",});
範例3:獲取三維組件「停車場模型」中的「車輛002」模型物件的座標,在該座標位置開啟一個彈出框 注:此方法開啟的彈出框會跟隨模型縮放或視角變化而行動位置
duchamp.getWidgetByName("停車場模型").showDialogByMesh({ title: "車輛資訊彈出框", width: 500, height: 300, innerContent: "Hello World", padding: "15px", titleStyle: { fontSize: "24px", fontWeight: "bold" }, backgroundStyle: { background:"green" }, meshName:"車輛002",});
點選下載範本:JS實現獲取組件座標後開啟彈出框.fvs
closeDialog()
關閉對話窗。
FR.closeDialog();
duchamp.closeDialog();
彈窗選擇資料後,自動關閉已經開啟的對話框:
doHyperlinkByGet(url,config,target,feature)
Get方法開啟一個網頁頁面,可以傳遞參數,可以設定頁面屬性。
URL :object
config :object
target :object
feature :object
注:11.0.10 及以後版本參數支援 json 格式,如下:
支援的絕對路徑如:
http://192.168.100.1:8080/webroot/decision/view/report?viewlet=GettingStarted.cpt
相對路徑如:/webroot/decision/view/report?viewlet=GettingStarted.cpt
config:傳遞的參數,可以不寫
target:超連結子頁的開啟位置,可以不寫
_dialog:對話框
_self:當前頁
某個 iframe 的 name,當前頁開啟,post 方式提交
feature:超連結開啟位置的屬性,可以不寫
注:行動端不支援 target 和 feature 參數效果
feature:超連結開啟位置的屬性,可以不寫。
開啟內建範本 GettingStarted.cpt,一個為“銷售報表”,傳遞參數“華東”和是否顯示參數面板,開啟方式為對話框,對話框寬 700、高 500:
FR.doHyperlinkByGet({ //報表路徑 "url":"/webroot/decision/view/report?viewlet=GettingStartedTW.cpt", //參數 "para":{ "地區":"華東" }, "target":"_dialog", //對話框方式開啟 "feature":{ "width":700, "height":500, "title":"銷售報表" } })
點選按鈕,開啟標題為“銷售報表”,內容為華東地區銷量情況,寬700、高500對話框:
詳細內容介紹可參考:JS實現點選超連結開啟對話框報表並傳參
支援行動端
doHyperlinkByGet(
url:object,
para:object,
target:object,
feature:object
url:object
para:object
target:object
URL:URL 或 Json 超連結定義,必填
http://192.168.100.1:8080/webroot/decision/view/report?viewlet=GettingStartedTW.cpt
相對路徑如:/webroot/decision/view/report?viewlet=GettingStartedTW.cpt
para:傳遞的參數,選填
target:超連結子頁的開啟位置,選填,預設為 _dialog
feature:超連結開啟位置的屬性,選填
duchamp.doHyperlinkByGet({//報表路徑"url":"/webroot/decision/view/report?viewlet=GettingStartedTW.cpt",//參數"para":{"地區":"華東" },"target":"_dialog", //對話框方式開啟"feature":{"width":700,"height":500,"title":"銷售報表" } })
點選按鈕,開啟標題為“銷售報表”,內容為華東地區銷量情況,寬 700、高 500對話框:
點選下載範本:Get 方法開啟對話框.fvs
doHyperlinkByPost(url,config,target,feature)
Post方法開啟一個網頁頁面,可以傳遞參數,可以設定頁面屬性。
URL:object
config:object
target:object
feature:object
相對路徑如:
/webroot/decision/view/report?viewlet=GettingStartedTW.cpt
某個 iframe 的 name,當前頁開啟, post 方式提交
注:行動端不支援 target 和 feature 參數效果。
開啟內建範本GettingStartedTW.cpt,一個為“銷售報表”,傳遞參數“華東”和是否顯示參數面板,開啟方式為對話框,對話框寬700、高500:
FR.doHyperlinkByPost({//報表路徑"url":"/webroot/decision/view/report?viewlet=GettingStartedTW.cpt",//參數"para":{"地區":"華東" },"target":"_dialog",//對話框方式開啟"feature":{"width":700,"height":500,"title":"銷售報表" } })
doHyperlinkByPost(
config:object,
config:傳遞的參數,選填
duchamp.doHyperlinkByPost({//報表路徑"url":"/webroot/decision/view/report?viewlet=GettingStartedTW.cpt",//參數"para":{"地區":"華東" },"target":"_dialog", //對話框方式開啟"feature":{"width":700,"height":500,"title":"銷售報表" } })
點選下載範本:Post 方法開啟對話框.fvs
注:FVS 企業戰情室範本不支援 doURLPrint 。
doURLPrint(config)
呼叫列印工具,列印報表。
config:列印參數,參數格式見doURLPrint。
Void
見:doURLPrint。
自訂列印按鈕,以【零使用者端】方式列印報表:
Msg
FR內建統一風格的訊息框,可以替代Window中的alert、confirm以及prompt。
需呼叫其方法使用,詳細內容可見:Msg。
見:Msg
給【正文元件】增加【編輯結束】事件,當填入的工號長度不是6時,彈窗提示:工號必須為6位:
remoteEvaluate(formula)
執行 FR 內建公式,傳回公式計算結果。
注1:remoteEvaluate(String) 不支援 tablename.select 函式。
注2:網頁中不支援呼叫 remoteEvaluate(String) 。
formula:String
公式
object
普通報表、決策報表呼叫 FR 中 sum 函式對 A1、A2 求和:
FR.remoteEvaluate("sum(A1,A2)");
普通報表、決策報表呼叫 FR 中字串連結函式 CONCATENATE 連結字串
FR.remoteEvaluate('CONCATENATE("001","1201110")');
FVS 企業戰情室範本範例(支援 V1.15.0 及之後版本):
duchamp.remoteEvaluate("sum(A1,A2)");
注:行動端 App 9.0 及之後的版本不再支援 FR.remoteEvaluate(formula) ,否則會報錯 synchronous http requests are not supported 。
注意事項:
使用remoteEvaluateAPI存在安全風險,可能會導致攻擊者對資料庫進行增刪改查等操作,其風險等級相當於遠端執行。
所以在「數據決策系統」中增加了「腳本呼叫公式限制」功能且預設開啟,當使用者使用了remoteEvaluateAPI,且開啟了腳本呼叫公式限制開關,則效果預覽時會彈出提示框資訊:此呼叫存在安全風險,如需使用請在安全管理中修改腳本呼叫公式限制。
如下圖所示:
如果使用者想要取消此訊息彈窗,需要在平台中關閉此開關。如何操作可查看:安全防護
jsonEncode(String)
對字串進行jsonEncode編碼。
code:String
必填,需要轉碼的字串
String
對報表路徑進行 jsonEncode 編碼
FR.jsonEncode("/webroot/decision/view/report?viewlet=GettingStarted.cpt");
duchamp.jsonEncode("/webroot/decision/view/report?viewlet=GettingStarted.cpt");
jsonDecode(jsonEncodeString)
對字串進行jsonEncode解碼。
jsonEncode:String
必填,需要解碼的字串
FR.jsonDecode(FR.jsonEncode("/webroot/decision/view/report?viewlet=GettingStartedTW.cpt");
對 jsonEncode 轉碼過的報表路徑進行解碼
FR.jsonDecode(FR.jsonEncode("/webroot/decision/view/report?viewlet=GettingStarted.cpt");
duchamp.jsonDecode(duchamp.jsonEncode("/webroot/decision/view/report?viewlet=GettingStarted.cpt");
ajax(options)
封裝過的jQuery.ajax()函式,對data參數做了中日韓文編碼處理,可以透過FR.ajax(options)在任何可以用JS的地方進行呼叫。
options
Ajax參數,JSON格式,說明見:ajax 。
見:ajax
判斷物件是否為空
物件
是否為空,布林型
true :是
false:否
1)查看「正文框元件」text0 是否存在
普通報表、決策報表(參數面板中的元件)範例:
var a = FR.isEmpty(_g().getParameterContainer().getWidgetByName("text0"));alert(a);
var a = duchamp.isEmpty(duchamp.getWidgetByName("text0"));alert(a);
2)查看「正文框元件」text0 是否為空值
var a = FR.isEmpty(_g().getParameterContainer().getWidgetByName("text0").getValue());alert(a);
var a = duchamp.isEmpty(duchamp.getWidgetByName("text0").getValue());alert(a);
判斷物件是否為陣列
定義一個陣列,查看其是否為陣列
var txt = new Array("I","love","FR");FR.isArray(txt);
var txt = new Array("I","love","FR");alert(duchamp.isArray(txt));
cellStr2ColumnRow(cell)
根據儲存格編號獲取列欄索引。
cell
儲存格編號。
{col:colindex,row:rowindex}
行欄索引,json格式。
col:欄索引,從0開始。
row:行索引,從0開始。
範例1:普通報表或決策報表中,傳回 A1 儲存格的行列資訊
FR.cellStr2ColumnRow("A1");
範例2:普通報表或決策報表中,列印 A1 儲存格的行號
var a=FR.cellStr2ColumnRow("A1").row 1;FR.Msg.alert("提示", "A1儲存格的行號為" a);
範例3:FVS 企業戰情室範本中,列印儲存格的行列號
var a=duchamp.cellStr2ColumnRow("A3").col 1;var b=duchamp.cellStr2ColumnRow("A3").row 1;//alert(a);duchamp.Msg.alert({ title: "提示", message: "A3儲存格的列號為" a,});duchamp.Msg.alert({ title: "提示", message: "A3儲存格的行號為" b,});
點選按鈕,列印A1儲存格的行號,如下圖所示:
FVS 企業戰情室範本範例:點選按鈕,列印 A3 儲存格的行列號
點選下載範本:列印儲存格的行列號.fvs
columnRow2CellStr({col:colindex,row:rowindex})
根據行欄號獲取儲存格編號。
列欄索引,json格式。
row:列索引,從0開始。
儲存格編號
範例1:普通報表或決策報表中,傳回行索引為 3,列索引為 1 的儲存格編號
FR.columnRow2CellStr({col:1, row:3});
範例2:普通報表或決策報表中,列印行索引為 3,列索引為 1 的儲存格編號
var a=FR.columnRow2CellStr({col:1, row:3})FR.Msg.alert("提示", "行索引3,列索引為1的儲存格編號為" a);
範例3:FVS 企業戰情室範本中,列印行索引為 3,列索引為 1 的儲存格編號
var a=duchamp.columnRow2CellStr({col:1, row:3})duchamp.Msg.alert({ title: "提示", message: "行索引3,列索引為1的儲存格編號為" a,});
列印列索引為3,欄索引為1的儲存格編號,如下圖所示:
FVS 企業戰情室範本範例:列印行索引為 3,列索引為 1 的儲存格編號
點選下載範本:根據行列號獲取儲存格編號.fvs
普通報表、決策報表不支援行動端;FVS企業戰情室範本支援行動端
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
反馈已提交
网络繁忙