model.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. if($ == undefined){
  2. $ = jQuery;
  3. }
  4. function initModelTree(){
  5. $("#modeltree").tree({
  6. data:[{
  7. id:"datasource",
  8. text:"数据源",
  9. iconCls:"icon-dsource",
  10. attributes:{type:'dsource'}
  11. },{
  12. id:"dataset",
  13. text:"数据集",
  14. iconCls:"icon-dataset2",
  15. attributes:{type:'dset'}
  16. },{
  17. id:"cube",
  18. iconCls:"icon-cube",
  19. text:"立方体",
  20. attributes:{type:'cube'}
  21. }],
  22. onClick:function(node){
  23. if(node.attributes && node.attributes.type == "dsource"){
  24. initdsourcetable();
  25. }else if(node.attributes && node.attributes.type == "dset"){
  26. initdsetTable();
  27. }else if(node.attributes && node.attributes.type == "cube"){
  28. initcubeTable();
  29. }
  30. }
  31. });
  32. $('#modeltree').tree('select', $("#modeltree div[node-id='datasource']"));
  33. initdsourcetable();
  34. }
  35. //tp表示是提示信息还是错误信息
  36. function msginfo(input, tp){
  37. var str = null;
  38. if(tp && tp == 'suc'){
  39. str = "<div class='msginfo msgsuc'>" + input +"</div>";
  40. }else{
  41. str = "<div class='msginfo msgerr'>" + input+"</div>";
  42. }
  43. $.messager.show({
  44. title: (tp && tp == 'suc')? '成功了' : '出错了',
  45. msg:str,
  46. showType:'fade',
  47. timeout:2000,
  48. style:{
  49. right:'',
  50. top:document.body.scrollTop+document.documentElement.scrollTop + 10,
  51. bottom:''
  52. }
  53. });
  54. }
  55. //在textarea光标处插入文本
  56. function insertText2focus(obj,str) {
  57. str = str + " ";
  58. obj.focus();
  59. if (document.selection) {
  60. var sel = document.selection.createRange();
  61. sel.text = str;
  62. } else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
  63. var startPos = obj.selectionStart,
  64. endPos = obj.selectionEnd,
  65. cursorPos = startPos,
  66. tmpStr = obj.value;
  67. obj.value = tmpStr.substring(0, startPos) + "" + str + tmpStr.substring(endPos, tmpStr.length);
  68. cursorPos += str.length;
  69. obj.selectionStart = obj.selectionEnd = cursorPos;
  70. } else {
  71. obj.value += str;
  72. }
  73. }
  74. function ischinese(a){
  75. if (/[\u4E00-\u9FA5]/i.test(a)) {
  76. return true;
  77. }else{ return false }
  78. }
  79. //生成唯一标识
  80. function newGuid()
  81. {
  82. var guid = "";
  83. for (var i = 1; i <= 32; i++){
  84. var n = Math.floor(Math.random()*16.0).toString(16);
  85. guid += n;
  86. //if((i==8)||(i==12)||(i==16)||(i==20))
  87. // guid += "-";
  88. }
  89. return guid;
  90. }
  91. //去除重复
  92. Array.prototype.uniqueArray = function(){
  93. var res = [];
  94. var json = {};
  95. for(var i = 0; i < this.length; i++){
  96. if(!json[this[i]]){
  97. res.push(this[i]);
  98. json[this[i]] = 1;
  99. }
  100. }
  101. return res;
  102. }