jformGraphreportHead.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. $("textarea").height(60);
  2. $(function(){
  3. $("body").append("<link href=\"plug-in/lhgDialog/skins/default.css\" rel=\"stylesheet\" id=\"lhgdialoglink\">");
  4. var $btn = $("<div class=\"ui_buttons\" style=\"display:inline-block;padding:0px;\"><input style=\"position: relative;top: 0px;\" class=\"ui_state_highlight\" type=\"button\" value=\"sql解析\" id=\"sqlAnalyze\" /></div>");
  5. $("#cgrSql").after($btn);
  6. $btn.click(function(){
  7. $.ajax({
  8. url:"cgReportController.do?getFields",
  9. data:{sql:$("#cgrSql").val()},
  10. type:"Post",
  11. dataType:"json",
  12. success:function(data){
  13. if(data.status=="success"){
  14. $("#add_jformGraphreportItem_table").empty();
  15. $.each(data.fields,function(index,e){
  16. $("#addJformGraphreportItemBtn").click();
  17. $("#add_jformGraphreportItem_table tr:last").find(":text")
  18. .eq(0).val(e)
  19. .end().eq(1).val(e)
  20. .end().eq(2).val(index);
  21. });
  22. //resetTrNum("add_jform_graphreport_item_table");
  23. }else{
  24. alerLayerTip(data.datas);
  25. }
  26. }
  27. });
  28. });
  29. });
  30. //初始化下标
  31. function resetTrNum(tableId) {
  32. $tbody = $("#"+tableId+"");
  33. $tbody.find('>tr').each(function(i){
  34. $(':input, select,button,a', this).each(function(){
  35. var $this = $(this), name = $this.attr('name'),id=$this.attr('id'),onclick_str=$this.attr('onclick'), val = $this.val();
  36. if(name!=null){
  37. if (name.indexOf("#index#") >= 0){
  38. $this.attr("name",name.replace('#index#',i));
  39. }else{
  40. var s = name.indexOf("[");
  41. var e = name.indexOf("]");
  42. var new_name = name.substring(s+1,e);
  43. $this.attr("name",name.replace(new_name,i));
  44. }
  45. }
  46. if(id!=null){
  47. if (id.indexOf("#index#") >= 0){
  48. $this.attr("id",id.replace('#index#',i));
  49. }else{
  50. var s = id.indexOf("[");
  51. var e = id.indexOf("]");
  52. var new_id = id.substring(s+1,e);
  53. $this.attr("id",id.replace(new_id,i));
  54. }
  55. }
  56. if(onclick_str!=null){
  57. if (onclick_str.indexOf("#index#") >= 0){
  58. $this.attr("onclick",onclick_str.replace(/#index#/g,i));
  59. }else{
  60. }
  61. }
  62. });
  63. $(this).find('div[name=\'xh\']').html(i+1);
  64. });
  65. }
  66. //通用弹出式文件上传
  67. function commonUpload(callback,inputId){
  68. $.dialog({
  69. content: "url:systemController.do?commonUpload",
  70. lock : true,
  71. title:"文件上传",
  72. zIndex:2100,
  73. width:700,
  74. height: 200,
  75. parent:windowapi,
  76. cache:false,
  77. ok: function(){
  78. var iframe = this.iframe.contentWindow;
  79. iframe.uploadCallback(callback,inputId);
  80. return true;
  81. },
  82. cancelVal: '关闭',
  83. cancel: function(){
  84. }
  85. });
  86. }
  87. //通用弹出式文件上传-回调
  88. function commonUploadDefaultCallBack(url,name,inputId){
  89. $("#"+inputId+"_href").attr('href',url).html('下载');
  90. $("#"+inputId).val(url);
  91. }
  92. function decode(value, id) {//value传入值,id接受值
  93. var last = value.lastIndexOf("/");
  94. var filename = value.substring(last + 1, value.length);
  95. $("#" + id).text(decodeURIComponent(filename));
  96. }