bireport.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. if($ == undefined){
  2. $ = jQuery;
  3. }
  4. function reloadDatasetTree(){
  5. $("#datasettreediv ul").remove();
  6. var css = "tableTreeCss";
  7. var tab = $('div.tabs-container li.active a');
  8. if(tab.length > 0 ){
  9. var idx = tab.attr("idx");
  10. if(Number(idx) == 2){
  11. css = "chartTreeCss";
  12. }
  13. }
  14. $("#datasettreediv").append("<ul id=\"datasettree\" class=\""+css+"\"></ul>");
  15. if(pageInfo.selectDs == null || pageInfo.selectDs == "null"){
  16. $('#datasettree').tree({
  17. dnd:false,
  18. data:[{"id":"err","text":"数据还未创建立方体。", "iconCls":"icon-no"}]
  19. });
  20. return
  21. }else if(pageInfo.selectDs == ''){
  22. $('#datasettree').tree({
  23. dnd:false,
  24. data:[{"id":"err","text":"还未选择数据。", "iconCls":"icon-no"}]
  25. });
  26. return
  27. }else{
  28. $('#datasettree').tree({
  29. url:'../model/treeCube.action?cubeId=' + pageInfo.selectDs,
  30. dnd:true,
  31. lines:false,
  32. onBeforeDrag:function(target){
  33. if(!target.attributes || target.attributes.tp == 'root'){
  34. return false;
  35. }
  36. return true;
  37. },
  38. onDragEnter:function(target, source){
  39. return false;
  40. }
  41. });
  42. }
  43. }
  44. function newpage(){
  45. var url = 'ReportDesign.action?menus='+curTmpInfo.menus+'&showtit='+showtit;
  46. if(curTmpInfo.isupdate == true){
  47. if(confirm('页面还未保存\n是否保存当前页面?')){
  48. savepage(function(){
  49. location.href = url;
  50. });
  51. }else{
  52. location.href = url;
  53. }
  54. }else{
  55. location.href = url;
  56. }
  57. }
  58. function initparam(){
  59. //回写参数值
  60. if(pageInfo.params && pageInfo.params.length>0){
  61. $("#p_param div.ptabhelpr").remove();
  62. $("#p_param").append("<b>参数: </b>");
  63. for(i=0; i<pageInfo.params.length; i++){
  64. var obj = $("#p_param");
  65. var str = "<span class=\"pppp\" id=\"pa_"+pageInfo.params[i].id+"\"><span title=\"筛选\" onclick=\"paramFilter('"+pageInfo.params[i].id+"', '"+pageInfo.params[i].type+"', '"+pageInfo.params[i].name+"')\" class=\"text\">"+pageInfo.params[i].name+"(";
  66. if(pageInfo.params[i].type == 'day' || pageInfo.params[i].type == 'month'){
  67. str = str + pageInfo.params[i].st + " 至 " + pageInfo.params[i].end;
  68. }else{
  69. str = str + (!pageInfo.params[i].valStrs || pageInfo.params[i].valStrs == ''?"无":pageInfo.params[i].valStrs);
  70. }
  71. str = str + ")</span><button title=\"删除\" class=\"btn btn-default btn-xs\" onclick=\"deleteParam('"+pageInfo.params[i].id+"')\"><i class=\"fa fa-remove\"></i></button></span>";
  72. obj.append(str);
  73. }
  74. }
  75. //注册接收维度拖拽事件
  76. $("#p_param").droppable({
  77. accept:"#datasettree .tree-node",
  78. onDragEnter:function(e,source){
  79. var node = $("#datasettree").tree("getNode", source);
  80. var tp = node.attributes.col_type;
  81. //对维度拖拽设置图标
  82. if(tp == 1 ){
  83. $(source).draggable('proxy').find("span").removeClass("tree-dnd-no");
  84. $(source).draggable('proxy').find("span").addClass("tree-dnd-yes");
  85. $(this).css("border", "1px solid #ff0000");
  86. }
  87. e.cancelBubble=true;
  88. e.stopPropagation(); //阻止事件冒泡
  89. },
  90. onDragLeave:function(e,source){
  91. $(source).draggable('proxy').find("span").addClass("tree-dnd-no");
  92. $(source).draggable('proxy').find("span").removeClass("tree-dnd-yes");
  93. $(this).css("border", "1px solid #d3d3d3");
  94. e.cancelBubble=true;
  95. e.stopPropagation(); //阻止事件冒泡
  96. },
  97. onDrop:function(e,source){
  98. e.cancelBubble=true;
  99. e.stopPropagation(); //阻止事件冒泡
  100. $(this).css("border", "1px solid #d3d3d3");
  101. var node = $("#datasettree").tree("getNode", source);
  102. var tp = node.attributes.col_type;
  103. if(tp == 1){
  104. if(!pageInfo.params){
  105. pageInfo.params = [];
  106. }
  107. //判断是否存在
  108. if(findParamById(node.attributes.col_id) != null){
  109. msginfo("您已经添加了该参数!", "error");
  110. return;
  111. }
  112. var id = node.attributes.col_id;
  113. var p = {"id":id, "name":node.text, "type":node.attributes.dim_type, "colname":node.attributes.col_name,"alias":node.attributes.alias, "tname":node.attributes.tname,"cubeId":node.attributes.cubeId,"valType":node.attributes.valType,"tableName":node.attributes.tableName, "tableColKey":node.attributes.tableColKey,"tableColName":node.attributes.tableColName,"calc":node.attributes.calc, "dimord":node.attributes.dimord, "grouptype":node.attributes.grouptype,"dateformat":(node.attributes.dateformat==null?"":node.attributes.dateformat),dsid:node.attributes.dsid};
  114. pageInfo.params.push(p);
  115. var obj = $(this);
  116. obj.find("div.ptabhelpr").remove();
  117. if(obj.find("b").size() == 0){
  118. obj.append("<b>参数: </b>");
  119. }
  120. obj.append("<span class=\"pppp\" id=\"pa_"+id+"\"><span title=\"筛选\" onclick=\"paramFilter('"+id+"', '"+node.attributes.dim_type+"','"+node.text+"')\" class=\"text\">"+node.text+"(无)</span><button class=\"btn btn-default btn-xs\" title=\"删除\" onclick=\"deleteParam('"+id+"')\"><i class=\"fa fa-remove\"></i></button></span>");
  121. //弹出筛选窗口
  122. paramFilter(id, p.type, p.name);
  123. }
  124. }
  125. });
  126. }
  127. function paramFilter(id, type, name){
  128. var param = findParamById(id);
  129. $('#pdailog').dialog({
  130. title: name+' - 参数值筛选',
  131. width: 290,
  132. height: param.type == 'month' || param.type == 'day' ? 240 : 320,
  133. closed: false,
  134. cache: false,
  135. modal: true,
  136. content:'<div id="div_paramfilter"><div class="panel-loading">Loading...</div></div>',
  137. buttons:[{
  138. text:'确定',
  139. iconCls:'icon-ok',
  140. handler:function(){
  141. var vals = "";
  142. var valStrs = "";
  143. if(param.type == 'month'){
  144. param.st = $("#pdailog #dfm2").val();
  145. param.end = $("#pdailog #dfm1").val();
  146. //判断是否st < ed
  147. if(Number(param.st) > Number(param.end)){
  148. msginfo("您选择的开始月份不能大于结束月份。", "error");
  149. return;
  150. }
  151. $("#p_param #pa_"+id+" span.text").text(name + "("+ param.st + " 至 " + param.end+")");
  152. }else if(param.type == 'day'){
  153. param.st = $("#pdailog #dft2").val();
  154. param.end = $("#pdailog #dft1").val();
  155. //判断是否st < ed
  156. if(Number(param.st.replace(/-/g, "")) > Number(param.end.replace(/-/g, ""))){
  157. msginfo("您选择的开始日期不能大于结束日期。", "error");
  158. return;
  159. }
  160. $("#p_param #pa_"+id+" span.text").text(name + "("+ param.st + " 至 " + param.end+")");
  161. }else{
  162. var seles = $("#pdailog input[name='dimval']:checkbox:checked");
  163. seles.each(function(a, b){
  164. if(a >= 10){ //只能最多选10个
  165. return;
  166. }
  167. vals = vals + $(this).val();
  168. if(a == seles.size() - 1 || a == 9){
  169. }else{
  170. vals = vals + ',';
  171. }
  172. valStrs = valStrs + $(this).attr("desc");
  173. if(a == seles.size() - 1 || a == 9){
  174. }else{
  175. valStrs = valStrs + ',';
  176. }
  177. });
  178. $("#p_param #pa_"+id+" span.text").text(name+"("+(valStrs == '' ? '无':valStrs)+")");
  179. param.vals = vals;
  180. param.valStrs = valStrs;
  181. }
  182. $('#pdailog').dialog('close');
  183. curTmpInfo.isupdate = true;
  184. flushPage();
  185. }
  186. },{
  187. text:'取消',
  188. iconCls:"icon-cancel",
  189. handler:function(){
  190. $('#pdailog').dialog('close');
  191. }
  192. }]
  193. });
  194. var url = (curTmpInfo.filterUrl ? curTmpInfo.filterUrl :"paramFilter.action") + "?cubeId="+param.cubeId+"&id="+id+"&dsid="+param.dsid;
  195. if(param.type == "month"){
  196. url = url + "&st="+(param.st?param.st:"")+"&end="+(param.end?param.end:"");
  197. }else if(param.type == "day"){
  198. url = url + "&st="+(param.st?param.st:"")+"&end="+(param.end?param.end:"");
  199. }else{
  200. //url = url + "&vals="+(!param.vals || param.vals =='' ? '':param.vals );;
  201. }
  202. $("#pdailog #div_paramfilter").load(url, {vals:(!param.vals || param.vals =='' ? '':param.vals),t:Math.random()});
  203. }
  204. function searchDims2(val, id){
  205. var param = findParamById(id);
  206. var url = "paramSearch.action?cubeId="+param.cubeId+"&id="+id+"&dsid=" + param.dsid ;
  207. $.ajax({
  208. type:"POST",
  209. url:url,
  210. data:{keyword:val, vals:(!param.vals || param.vals =='' ? '':param.vals), t:Math.random()},
  211. dataType:'HTML',
  212. success:function(resp){
  213. $("#pdailog .dfilter").html(resp);
  214. }
  215. });
  216. }
  217. function flushPage(){
  218. //刷新页面
  219. for(var k=0; pageInfo.comps&&k<pageInfo.comps.length; k++){
  220. var tp = pageInfo.comps[k].type;
  221. if(tp == 'table'){
  222. /**
  223. 如果表格组件的时间维度和参数的时间维度不一致,删除计算度量
  224. **/
  225. var comp = pageInfo.comps[k];
  226. if(!paramsamedimdate(comp)){
  227. for(i=0; comp.kpiJson&&i<comp.kpiJson.length; i++){
  228. delete comp.kpiJson[i].compute;
  229. }
  230. }
  231. tableView(pageInfo.comps[k], pageInfo.comps[k].id);
  232. }else if(tp == 'chart'){
  233. chartview(pageInfo.comps[k], pageInfo.comps[k].id);
  234. }
  235. }
  236. }
  237. function deleteParam(id){
  238. $("#p_param #pa_" + id).remove();
  239. var idx = -1;
  240. for(i=0; pageInfo.params&&i<pageInfo.params.length; i++){
  241. var p = pageInfo.params[i];
  242. if(p.id == id){
  243. idx = i;
  244. break;
  245. }
  246. }
  247. pageInfo.params.splice(idx, 1);
  248. if(pageInfo.params.length == 0){
  249. $("#p_param").html("<div class=\"ptabhelpr\">拖拽维度到此处作为页面参数</div>");
  250. }
  251. flushPage();
  252. }
  253. function openreport(){
  254. var ctx = "<div class=\"openlistbody\"><div style=\"margin:5px 5px 5px 1px;float:left;\"><a id=\"rename\">更名</a> <a id=\"delreport\">删除</a></div><div align=\"right\" style=\"margin:5px;\"><input id=\"subSearchBox\" style=\"width:160px\"></input></div><div class=\"openlist\"></div></div>";
  255. $('#pdailog').dialog({
  256. title: '打开报表',
  257. width: 620,
  258. height: 400,
  259. closed: false,
  260. cache: false,
  261. modal: true,
  262. toolbar:null,
  263. content:ctx,
  264. onLoad:function(){},
  265. buttons:[{
  266. text:'确定',
  267. iconCls:'icon-ok',
  268. handler:function(){
  269. var r = $("input[name=\"reportId\"]:checked").val();
  270. if(!r || r == null){
  271. msginfo("请至少选择一个报表!", "error");
  272. return;
  273. }
  274. $('#pdailog').dialog('close');
  275. $(this).attr("href", "#");
  276. var url = 'ReportDesign.action?pageId='+r+'&showtit='+showtit+'&menus='+curTmpInfo.menus;
  277. if(curTmpInfo.isupdate == true){
  278. if(confirm('页面还未保存\n是否保存当前页面?')){
  279. savepage(function(){
  280. location.href = url;
  281. });
  282. }else{
  283. location.href = url;
  284. }
  285. }else{
  286. location.href = url;
  287. }
  288. }
  289. },{
  290. text:'取消',
  291. iconCls:"icon-cancel",
  292. handler:function(){
  293. $('#pdailog').dialog('close');
  294. }
  295. }]
  296. });
  297. $("#rename").linkbutton({'iconCls':'icon-edit', plain:true}).click(function(){
  298. var r = $("input[name=\"reportId\"]:checked").val();
  299. if(!r || r == null){
  300. msginfo("请至少选择一个报表!", "error");
  301. return;
  302. }
  303. $.messager.prompt('报表改名', '请输入新的报表名称?', function(msg){
  304. if(msg){
  305. $.ajax({
  306. type: "POST",
  307. url: "renameReport.action",
  308. dataType:"HTML",
  309. data: {pageId:r, pageName:msg},
  310. success: function(resp){
  311. $('#pdailog .openlist').load('listReport.action?t='+Math.random());
  312. },
  313. error:function(){
  314. }
  315. });
  316. }
  317. });
  318. });
  319. $("#delreport").linkbutton({'iconCls':'icon-remove', plain:true}).click(function(){
  320. var r = $("input[name=\"reportId\"]:checked").val();
  321. if(!r || r == null){
  322. msginfo("请至少选择一个报表!", "error");
  323. return;
  324. }
  325. if(confirm('是否确认删除?')){
  326. $.ajax({
  327. type: "POST",
  328. url: "deleteReport.action",
  329. dataType:"HTML",
  330. data: {id:r},
  331. success: function(resp){
  332. $('#pdailog .openlist').load('listReport.action?t='+Math.random());
  333. },
  334. error:function(){
  335. }
  336. });
  337. }
  338. });
  339. $("#subSearchBox").searchbox({
  340. searcher:function(value,name){
  341. $('#pdailog .openlist').load('listReport.action',{"keyword":value,"t":Math.random()});
  342. },
  343. prompt:'请输入查询关键字.'
  344. });
  345. $('#pdailog .openlist').load('listReport.action?t='+Math.random());
  346. }
  347. /**
  348. function delComp(id){
  349. //从全局对象中移除
  350. var idx = -1;
  351. for(i=0;i<pageInfo.comps.length; i++){
  352. var t = pageInfo.comps[i];
  353. if(t.id == id){
  354. idx = i;
  355. break;
  356. }
  357. }
  358. pageInfo.comps.splice(idx, 1);
  359. $("#T" + id).remove();
  360. if(pageInfo.comps.length == 0){
  361. $("#optarea").append("<div class='tabhelpr'>请先添加组件再进行多维分析(点击<strong>插入</strong>按钮)。</div>");
  362. }
  363. }
  364. **/
  365. /**
  366. * tp = table, chart, text 3种内置类型
  367. name : 组件标题
  368. ispush:是否添加到组件视图树
  369. curComp:组件配置信息
  370. ctx:组件InnerHTML
  371. **/
  372. function addComp(id, name, ctx, ispush, tp, curComp){
  373. if(ctx == null || ctx == undefined){
  374. if(tp =='table'){
  375. //判断是新增,还是回写已有的
  376. if(curComp == null || curComp == undefined){
  377. ctx = crtCrossTable();
  378. }else{
  379. if(curComp.cols == undefined || curComp.kpiJson == undefined){ //添加了组件,但未选度量
  380. ctx = crtCrossTable();
  381. }else{
  382. ctx = "";
  383. }
  384. }
  385. }else if(tp == 'chart'){
  386. ctx = crtChart(id);
  387. }
  388. }
  389. //是否向全局对象中添加内容
  390. if(ispush == true){
  391. pageInfo.comps.push({"id":id, "name":name, "type":tp});
  392. curTmpInfo.isupdate= true;
  393. }
  394. var titleHTML="<div class=\"comp_table\" tp=\""+tp+"\" id=\"T"+id+"\">" +
  395. "<div class=\"ctx\">"+(ctx == null ? "" : ctx)+"</div>" +
  396. "</div>";
  397. if(tp == "table"){
  398. $("#optarea").html(titleHTML);
  399. }else if(tp == "chart"){
  400. $("#chartarea").html(titleHTML);
  401. }
  402. //如果是表格或图形,增加接受拖拽事件
  403. if(tp == 'table'){
  404. btns=[];
  405. //表格接收拖拽事件
  406. if(curComp != null && curComp != undefined){
  407. if(curComp.cols == undefined || curComp.kpiJson == undefined){ //添加了组件,但未选度量,需要添加拖放度量事件
  408. initDropDiv(id);
  409. }else{
  410. tableView(curComp, id);
  411. }
  412. }else{
  413. initDropDiv(id);
  414. }
  415. }
  416. if(tp == 'chart'){
  417. //如果是回写,更新图形数据
  418. if(curComp != null && curComp != undefined){
  419. chartview(curComp, id);
  420. //回写配置信息
  421. backChartData(curComp);
  422. //图形接收拖拽事件
  423. if(curComp.chartJson.type == 'bubble' || curComp.chartJson.type == 'scatter'){
  424. initChartByScatter(id);
  425. }else{
  426. initChartKpiDrop(id)
  427. }
  428. }else{
  429. //或者是新增
  430. //图形接收拖拽事件
  431. if(curTmpInfo.charttype == 'bubble' || curTmpInfo.charttype == 'scatter'){
  432. initChartByScatter(id);
  433. }else{
  434. initChartKpiDrop(id)
  435. }
  436. }
  437. }
  438. }
  439. function selectdataset(){
  440. $('#pdailog').dialog({
  441. title: '选择数据模型 ',
  442. width: 520,
  443. height: 400,
  444. closed: false,
  445. cache: false,
  446. modal: true,
  447. toolbar:null,
  448. content:"<div align=\"right\" style=\"margin:5px;\"><input id=\"subSearchBox\" style=\"width:200px\"></input></div><table id=\"subjectlist\" title=\"\" style=\"width:510px;height:300px;\" ><thead><tr><th data-options=\"field:'ck',checkbox:true\"><th data-options=\"field:'cubeName',width:160\">名称</th><th data-options=\"field:'desc',width:300\">说明</th></tr></thead></table>",
  449. buttons:[{
  450. text:'确定',
  451. iconCls:'icon-ok',
  452. handler:function(){
  453. var row = $("#subjectlist").datagrid("getChecked");
  454. if(row == null || row.length == 0){
  455. msginfo("请勾选数据。", "error");
  456. return;
  457. }
  458. pageInfo.selectDs = row[0].cubeId;
  459. $('#pdailog').dialog('close');
  460. //更新页面为已修改
  461. curTmpInfo.isupdate = true;
  462. //更新数据集
  463. reloadDatasetTree();
  464. }
  465. },{
  466. text:'取消',
  467. iconCls:"icon-cancel",
  468. handler:function(){
  469. $('#pdailog').dialog('close');
  470. }
  471. }]
  472. });
  473. $("#subSearchBox").searchbox({
  474. searcher:function(value,name){
  475. $("#subjectlist").datagrid("load",{"id":"0", key:value,t:Math.random()});
  476. },
  477. prompt:'请输入查询关键字.'
  478. });
  479. $("#subjectlist").datagrid({
  480. singleSelect:true,
  481. collapsible:false,
  482. pagination:true,
  483. pageSize:20,
  484. border:true,
  485. url:'../model/pageCube.action',
  486. method:'post',
  487. queryParams:{id:"0", t: Math.random()}
  488. });
  489. }
  490. /**
  491. 保存页面
  492. @param {Function} 保存完成后回调函数
  493. */
  494. function savepage(cb){
  495. for(k=0; k<pageInfo.comps.length; k++){
  496. var cmp=pageInfo.comps[k];
  497. var tp = cmp.type,id=cmp.id;
  498. }
  499. var jsonStr = JSON.stringify(pageInfo);
  500. var pageId = pageInfo.id;
  501. if(pageId == undefined || pageId == null){
  502. pageId = "";
  503. }
  504. if(pageId == ''){ //未保存过,提示用户输入名称
  505. var ctx = "<div style=\"margin:10px 20px 5px 20px;\"><br/><span style=\"display:inline-block;width:60px;\"> 报表名称: </span><input type=\"text\" style=\"width:187px;\" id=\"pageName\"></div>";
  506. $('#pdailog').dialog({
  507. title: '保存报表',
  508. width: 330,
  509. height: 160,
  510. closed: false,
  511. cache: false,
  512. modal: true,
  513. toolbar:null,
  514. content: ctx,
  515. buttons:[{
  516. text:'确定',
  517. iconCls:'icon-ok',
  518. handler:function(){
  519. var name = $("#pdailog #pageName").val();
  520. if(name == ''){
  521. msginfo("您还未录入文件名称。", "error");
  522. $("#pdailog #pageName").focus();
  523. return;
  524. }
  525. $.post("saveReport.action", {"pageInfo": jsonStr, "pageId":"", "pageName" : name}, function(resp){
  526. if(resp.result == 0){
  527. msginfo("保存失败,名称存在重复。", "error");
  528. return;
  529. }
  530. pageInfo.id = Number(resp.rows);
  531. if(cb != undefined){
  532. cb();
  533. }else{
  534. }
  535. msginfo("保存成功!", "success");
  536. //更新页面为未修改
  537. curTmpInfo.isupdate = false;
  538. $('#pdailog').dialog('close');
  539. });
  540. }
  541. },{
  542. text:'取消',
  543. iconCls:"icon-cancel",
  544. handler:function(){
  545. $('#pdailog').dialog('close');
  546. }
  547. }]
  548. });
  549. }else{ //已经保存过,直接update
  550. $.post("saveReport.action", {"pageInfo": jsonStr, "pageId":pageId}, function(resp){
  551. if(cb != undefined){
  552. cb();
  553. }else{
  554. }
  555. msginfo("保存成功!", "success");
  556. //更新页面为未修改
  557. curTmpInfo.isupdate = false;
  558. });
  559. }
  560. }
  561. //打印页面
  562. function printData(){
  563. var tabId = $("div.tabs-container li.active a").attr("idx");
  564. var info = JSON.parse(JSON.stringify(pageInfo)); //复制对象
  565. var comp = findCompById(tabId, info);
  566. delete comp.dims;
  567. info.comps = [comp];
  568. var json = JSON.stringify(info);
  569. var url2 = "about:blank";
  570. var name = "printwindow";
  571. window.open(url2, name);
  572. var ctx = "<form name='prtff' method='post' target='printwindow' action=\"print.action\" id='expff'><input type='hidden' name='pageInfo' id='ppageInfo'></form>";
  573. var o = $(ctx).appendTo("body");
  574. $("#ppageInfo").val(json);
  575. o.submit().remove();
  576. }
  577. //导出页面
  578. function exportPage(tp){
  579. var ctx = "<form name='expff' method='post' action=\"ReportExport.action\" id='expff'><input type='hidden' name='type' id='type'><input type='hidden' name='json' id='json'><input type='hidden' name='picinfo' id='picinfo'></form>";
  580. if($("#expff").size() == 0){
  581. $(ctx).appendTo("body");
  582. }
  583. var tabId = $("div.tabs-container li.active a").attr("idx");
  584. var info = JSON.parse(JSON.stringify(pageInfo)); //复制对象
  585. var comp = findCompById(tabId, info);
  586. delete comp.dims;
  587. info.comps = [comp];
  588. $("#expff #type").val(tp);
  589. $("#expff #json").val(JSON.stringify(info));
  590. //把图形转换成图片
  591. var strs = "";
  592. if(tp == "pdf" || tp == "excel" || tp == "word"){
  593. $("div.chartUStyle").each(function(index, element) {
  594. var id = $(this).attr("id");
  595. id = id.substring(1, id.length);
  596. var chart = echarts.getInstanceByDom(document.getElementById(id));
  597. var str = chart.getDataURL({type:'png', pixelRatio:1, backgroundColor: '#fff'});
  598. str = str.split(",")[1]; //去除base64标记
  599. str = $(this).attr("label") + "," + str; //加上label标记
  600. strs = strs + str;
  601. if(index != $("div.chartUStyle").size() - 1){
  602. strs = strs + "@";
  603. }
  604. });
  605. }
  606. $("#expff #picinfo").val(strs);
  607. $("#expff").submit();
  608. }
  609. function cleanData(){
  610. var idx = pageInfo.idx ? pageInfo.idx : "1";
  611. if(idx == "1"){
  612. pageInfo.comps[0] = {"name":"表格组件","id":1, "type":"table"};
  613. $("#T1 div.ctx").html(crtCrossTable());
  614. initDropDiv("1");
  615. }else if(idx == "2"){
  616. pageInfo.comps[1] = {"name":"","id":2, "type":"chart",chartJson:{type:"line",params:[]},kpiJson:[]};
  617. $("#T2 div.ctx").html(crtChart(2));
  618. initChartKpiDrop(2)
  619. }
  620. }
  621. function kpidesc(){
  622. $('#pdailog').dialog({
  623. title: '度量解释',
  624. width: 600,
  625. height: 350,
  626. closed: false,
  627. cache: false,
  628. modal: true,
  629. toolbar:null,
  630. buttons:[{
  631. text:'关闭',
  632. iconCls:"icon-ok",
  633. handler:function(){
  634. $('#pdailog').dialog('close');
  635. }
  636. }]
  637. });
  638. $('#pdailog').dialog('refresh', "kpidesc.action?cubeId="+pageInfo.selectDs, {t:Math.random()});
  639. }