JSD-8210开源任务材料
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

143 lines
5.1 KiB

/**
* @author 秃破天际
* @version 10.0
* Created by 秃破天际 on 2020-04-01
**/
!(function () {
window.onload = function(){
var getQueryVariable = function(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return pair[1];
}
}
return(false);
};
/**
* 是否是填报预览或者数据分析预览
* @returns {boolean}
*/
var isWriteOrView = function () {
return typeof FR != "undefined" && (typeof FR.Write != "undefined" || typeof FR.ViewPane != "undefined")
};
/**
* 是否是新填报预览
* @returns {boolean}
*/
var isWritePlus = function () {
return typeof FR != "undefined" && typeof WT != "undefined";
};
if( getQueryVariable("_show_") != "true" ||( !isWriteOrView() && !isWritePlus() ) ){
return;
}
/**
* 获取当前报表的所有sheet定义
* @returns {*}
*/
var getSheetList = function(){
var list;
FR.ajax({
url:FR.fineServletURL+"/url/sheet/info?sessionId="+_g().currentSessionID,
success:function(data){
list = FR.jsonDecode(data);
},
async:false
});
return list;
};
/**
* 获取当前激活的sheet
*/
var getActiveSheet = function () {
if( isWritePlus() ){
return _g().sheetContainer.activeIndex;
}else{
return _g().$contentPane.data("TabPane").activeTabIndex;
}
};
var $active = null;
var items = [];
/**
* 设置激活的sheet【仅UI,不触发真正的sheet切换】
* @param index
*/
var setActive =function ( index ) {
if( null != $active){
$active.removeClass("hg-active");
}
$active = items[index];
$active.addClass("hg-active");
};
var initSheetItem = function( item,h,idx ){
var lv = "hg-font-lv5";
if( h<=27 ){lv = "hg-font-lv4"}
if( h<=24 ){lv = "hg-font-lv3"}
if( h<=21 ){lv = "hg-font-lv2"}
if( h<=18 ){lv = "hg-font-lv1"}
var $item = $("<li/>").addClass("hg-list-item").addClass(lv)
.append($("<span/>").html(item.name));
$item.click(function (e) {
FR.SheetController.selectSheetByID(item.id);
setActive(idx);
});
return $item;
};
$.extend(FR,{SheetController:{
/**
* 通过sheet名称切换到指定sheet
* @param name
*/
selectSheetByID: function ( id ) {
var self = this;
if( isWritePlus() ){
var list = getSheetList();
list.forEach(function(item,index){
if( item.id == id ){
_g().sheetContainer.selectSheet(index);
}
});
}else{
_g().$contentPane.data("TabPane").selectTabByName(id);
}
},
init:function () {
debugger;
var list = getSheetList();
if( typeof list == "undefined" || list.length <= 1 ){
return ;
}
var $wrap = $("<div/>").addClass("hg-sheet-ctrl-wrap").appendTo("body");
var $sideBtn = $("<div/>").addClass("hg-side-hotspot").appendTo($wrap);
var $guidepost = $("<div/>").addClass("hg-guidepost").appendTo($wrap);
var $list = $("<div/>").addClass("hg-list").addClass("hg-card").appendTo($wrap);
$list.hide();
var showList = function (e) {
var idx = getActiveSheet();
setActive(idx);
$list.show();
$guidepost.hide();
};
var hideList = function (e) {
$list.hide();
$guidepost.show();
};
$sideBtn.mousemove(showList);
$guidepost.click(showList);
$list.mouseleave(hideList);
var item_height = parseInt(document.body.clientHeight/list.length);
list.forEach(function(item,index){
var $item = initSheetItem(item,item_height,index).appendTo($list);
items.push($item);
$item.click(hideList);
});
}
}});
FR.SheetController.init();
};
})();