queryView.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. queryView_parameter = {};
  2. function queryView_init() {
  3. $('#content').html('');
  4. $('#result').html('');
  5. var str = '<table border="1" width="100%">';
  6. str += '<tr><td colspan="2"><a href="#" id="list">list</a>&nbsp;<a href="#" id="get">get</a>&nbsp;<a href="#" id="execute">execute</a></td></tr>';
  7. str += '<tr><td>applicationFlag:</td><td><input type="text" id="applicationFlag" style="width:95%"/></td></tr>';
  8. str += '<tr><td>flag:</td><td><input type="text" id="flag" style="width:95%"/></td></tr>';
  9. str += '<tr><td colspan="2">date</td></tr>';
  10. str += '<tr><td colspan="2"><textarea id="date" style="width:95%;height:300px"></textarea></td></tr>';
  11. str += '<tr><td colspan="2">sample</td></tr>';
  12. str += '<tr><td colspan="2">{<br>';
  13. str += '"dateRangeType": "none",<br>';
  14. str += '"dateEffectType": "completed",<br>';
  15. str += '"start": "",<br>';
  16. str += '"completed": "",<br>';
  17. str += '"year": "",<br>';
  18. str += '"month": "",<br>';
  19. str += '"date": "",<br>';
  20. str += '"season": 0,<br>';
  21. str += '"week": 0,<br>';
  22. str += '"adjust": 0<br>';
  23. str += '}';
  24. str += '</td></tr>';
  25. str += '<tr><td colspan="2">filter</td></tr>';
  26. str += '<tr><td colspan="2"><textarea id="filter" style="width:95%;height:300px"></textarea></td></tr>';
  27. str += '<tr><td colspan="2">sample</td></tr>';
  28. str += '<tr><td colspan="2">{<br>';
  29. str += '"path": "",<br>';
  30. str += '"value": "",<br>';
  31. str += '"formatType": "",<br>';
  32. str += '"completed": "",<br>';
  33. str += '"logic": "",<br>';
  34. str += '"comparison": ""<br>';
  35. str += '}';
  36. str += '</td></tr>';
  37. str += '<tr><td colspan="2">where application</td></tr>';
  38. str += '<tr><td colspan="2"><textarea id="application" style="width:95%;height:100px"></textarea></td></tr>';
  39. str += '<tr><td colspan="2">where process</td></tr>';
  40. str += '<tr><td colspan="2"><textarea id="process" style="width:95%;height:100px"></textarea></td></tr>';
  41. str += '<tr><td colspan="2">where company</td></tr>';
  42. str += '<tr><td colspan="2"><textarea id="company" style="width:95%;height:100px"></textarea></td></tr>';
  43. str += '<tr><td colspan="2">where department</td></tr>';
  44. str += '<tr><td colspan="2"><textarea id="department" style="width:95%;height:100px"></textarea></td></tr>';
  45. str += '<tr><td colspan="2">where person</td></tr>';
  46. str += '<tr><td colspan="2"><textarea id="person" style="width:95%;height:100px"></textarea></td></tr>';
  47. str += '<tr><td colspan="2">where identity</td></tr>';
  48. str += '<tr><td colspan="2"><textarea id="identity" style="width:95%;height:100px"></textarea></td></tr>';
  49. str += '<tr><td colspan="2">column</td></tr>';
  50. str += '<tr><td colspan="2"><textarea id="column" style="width:95%;height:100px"></textarea></td></tr>';
  51. str += '</table>';
  52. $('#content').html(str);
  53. $('#list').click(function() {
  54. queryView_list($('#applicationFlag').val());
  55. });
  56. $('#get').click(function() {
  57. queryView_get($('#flag').val(), $('#applicationFlag').val());
  58. });
  59. $('#execute').click(function() {
  60. queryView_execute($('#flag').val(), $('#applicationFlag').val());
  61. });
  62. }
  63. function queryView_list(applicationFlag) {
  64. $('#result').html('');
  65. star
  66. $.ajax({
  67. type : 'get',
  68. dataType : 'json',
  69. url : '../jaxrs/queryview/list/application/flag/' + applicationFlag,
  70. xhrFields : {
  71. 'withCredentials' : true
  72. },
  73. crossDomain : true
  74. }).always(function(json) {
  75. $('#result').html(JSON.stringify(json, null, 4));
  76. });
  77. }
  78. function queryView_get(flag, applicationFlag) {
  79. $('#result').html('');
  80. $.ajax({
  81. type : 'get',
  82. dataType : 'json',
  83. url : '../jaxrs/queryview/flag/' + flag + '/application/flag/' + applicationFlag,
  84. xhrFields : {
  85. 'withCredentials' : true
  86. },
  87. crossDomain : true
  88. }).always(function(json) {
  89. $('#result').html(JSON.stringify(json, null, 4));
  90. });
  91. }
  92. function queryView_execute(flag, applicationFlag) {
  93. $('#result').html('');
  94. var data = {};
  95. if ($('#date').val().length > 0) {
  96. data.date = JSON.parse($('#date').val());
  97. }
  98. if ($('#filter').val().length > 0) {
  99. data.filter = JSON.parse($('#filter').val());
  100. }
  101. if ($('#application').val().length > 0) {
  102. data.application = JSON.parse($('#application').val());
  103. }
  104. if ($('#process').val().length > 0) {
  105. data.process = JSON.parse($('#process').val());
  106. }
  107. if ($('#company').val().length > 0) {
  108. data.company = JSON.parse($('#company').val());
  109. }
  110. if ($('#department').val().length > 0) {
  111. data.department = JSON.parse($('#department').val());
  112. }
  113. if ($('#person').val().length > 0) {
  114. data.person = JSON.parse($('#person').val());
  115. }
  116. if ($('#identity').val().length > 0) {
  117. data.identity = JSON.parse($('#identity').val());
  118. }
  119. if ($('#column').val().length > 0) {
  120. data.column = JSON.parse($('#column').val());
  121. }
  122. $.ajax({
  123. type : 'put',
  124. dataType : 'json',
  125. url : '../jaxrs/queryview/flag/' + flag + '/application/flag/' + applicationFlag + '/execute',
  126. contentType : 'application/json; charset=utf-8',
  127. data : JSON.stringify(request),
  128. xhrFields : {
  129. 'withCredentials' : true
  130. },
  131. crossDomain : true
  132. }).always(function(json) {
  133. $('#result').html(JSON.stringify(json, null, 4));
  134. });
  135. }