-
-
xxxl 数据领袖Lv6
发表于2020-8-5 17:24
楼主
1.脚本调整移动端报表样式方法
注入脚本格式如下
复制代码2.使用示例
2.1表格不分页,一屏宽
复制代码2.2tab标签头样式修改
复制代码2.3报表下拉框样式
复制代码2.4容器加载完成后显示内容(避免容器渲染时看到内容位置闪动)
复制代码2.5定时刷新
复制代码复制代码
组件 | 脚本方法 |
调整计算参数位置 | function adjustCalcparamPosition() |
WidgetsBuilder 报表加载完毕后的事件,可以调整样式 | function adjustWidgetBuilder(bodyarea) |
WidgetObj 统计图或其他组件样式调整 | function adjustWidgetObj(className,bodyarea,basedom) |
WidgetObj 调整高度 | function adjustWidgetObj_getChildMaxHeight(childnodes,max) |
WidgetParamComboBox 下拉框样式 | function adjustWidgetCombox(basedom,pnode,edit,label) |
WidgetParamComboBox 加载前 | function adjustWidgetCombox_initDom(basedom,pnode,edit,label) |
WidgetParamComboBoxTree 下拉树组件 | function adjustWidgetComboxTree(basedom,pnode,edit,label) |
WidgetParamComboBoxTree 加载前 | function adjustWidgetComboxTree_initDom(basedom,pnode,edit,label) |
WidgetParamDate 日期组件 | function adjustWidgetDate(basedom,pnode,edit,label) |
WidgetParamDate 加载前 | function adjustWidgetDate_initDom(basedom,pnode,edit,label) |
WidgetParamEdit 输入框组件 | function adjustWidgetEdit(basedom,pnode,edit,label) |
WidgetParamEdit 加载前 | function adjustWidgetEdit_initDom(basedom,pnode,edit,label) |
WidgetTab tab组件样式 | function adjustWidgetTab(tab) |
WidgetTab 切换tab页 active 页 | function adjustWidgetTabActive(active,tab) |
WidgetContainer 容器布局 | function adjustWidgetContainer(basedom) |
WidgetContainer 加载前 | function adjustWidgetContainer_initDom(basedom) |
WidgetContainer 渲染完成后 | function adjustWidgetContainer_delayInit(basedom) |
WidgetLayout sheet容器调整 | function adjustAddSheet(widget) |
WidgetResultGrid 表格样式 | function adjustWidgetResultGrid(basedom,table) |
统计图参数设置调整(这里可以看下echart官网配置项 ,datajson里面可以修改,添加属性) | function renderChart(datajson){ return datajson; } |
- //提前注入移动端脚本
- if((typeof(isInjectionMobileJs)!="undefined")&&!isInjectionMobileJs){
- //不显示钻取等待框
- isShowZqWaitToast = false;
- //固定tab标签页+调整参数框位置
- function adjustWidgetTab() {
- ......
- }
- }
2.1表格不分页,一屏宽
1、设置表格外容器|布局,取消勾选【手机自适应】选择
2、适当调整表格中文字大小,12px以上比较好
3、报表添加脚本- function adjustWidgetResultGrid(basedom,table){
- var width = this.document.body.clientWidth;
- var tableWidth = table.clientWidth;
- var scalenum = width/basedom.clientWidth;
- if(tableWidth > basedom.clientWidth){
- scalenum = width/tableWidth;
- }
- basedom.style.top= "-"+table.clientHeight*(1-scalenum)/2+"px";
- basedom.style.transform="scale("+scalenum +")";
- basedom.style.transformOrigin="left";
- }
- function adjustWidgetTab() {
- //标签头字号
- $(".headcontainer .subhead, .headcontainer .subhead_active").css("font-size", "10px");
- //标签头高度
- $(".headcontainer").css({"height":"35px","line-height":"32px"});
- $(".bodycontainer").css({"top":"35px"});
- }
- function adjustWidgetCombox(basedom, pnode, editinput, editlabel) {
- //是否是横屏
- var isHorScreen = false;
- if (window.screen.width > window.screen.height) {
- isHorScreen = true;
- } else {
- if (window.orientation == 90 || window.orientation == -90) {//ios
- isHorScreen = true;
- }
- }
- if(isHorScreen){//横屏情况下下拉框 左右间距20px 宽度占屏幕宽度的三分之一
- basedom.style.left = "0px";
- basedom.style.width = (window.screen.width - 40) / 3 + "px";
- }else{//竖屏情况下下拉框 宽度占屏幕宽度的二分之一
- basedom.style.width = (window.screen.width) / 2 + "px";
- }
-
- }
- function adjustWidgetContainer_initDom(basedom){
- var wid = basedom.getAttribute("wid");
- if(wid==="WidgetContainer78"){
- basedom.style.visibility="hidden";
- }
- }
- function adjustWidgetContainer_delayInit(basedom){
- var wid = basedom.getAttribute("wid");
- if(wid==="WidgetContainer78"){
- basedom.style.visibility="";
- }
- }
[size=13.3333px]PC端分析表支持定时刷新功能,移动端暂不支持。变通解决脚本,采用热区式脚本。
- if ((typeof(isInjectionMobileJs) != "undefined") && !isInjectionMobileJs) {
-
- setInterval(function(){
- //钻取时,不显示黑色等待框
- isShowZqWaitToast = false;
- //热区钻取
- _zcalcn([
- ['Widget1', 'HHH51','@a=1'],
- ['Widget2', 'HHH55','@a=1'],
- ['Widget3', 'HHH59','@a=1'],
- ['Widget4', 'HHH63','@a=1'],
-
- ]);
- //恢复黑色等待框
- isShowZqWaitToast = true;
- },10000);
- }
2.6表格之间的间距
在分析表中设置合适高度后,写脚本如下。
- //生成的表格,空的单元格有 会影响表格高度,这个脚本去掉
- function adjustWidgetResultGrid(basedom, table) {
- for (var i = 0; i < table.rows.length; i++) { //遍历每行
- var tr = table.rows[i];
- var cells = tr.cells;
- for (var j = 0; j < cells.length; j++) {
- if (cells[j].innerHTML === ' ') {
- cells[j].innerHTML = "";
- }
- }
- }
- }