application.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. application_parameter = {};
  2. function application_create() {
  3. var str = '<table border="1" width="100%">';
  4. str += '<tr><td colspan="2"><a href="#" id="post">post</a></td></tr>';
  5. str += '<tr><td>name:</td><td><input type="text" id="name" style="width:95%"/></td></tr>';
  6. str += '<tr><td>alias:</td><td><input type="text" id="alias" style="width:95%"/></td></tr>';
  7. str += '<tr><td>applicationCategory:</td><td><input type="text" id="applicationCategory" style="width:95%"/></td></tr>';
  8. str += '<tr><td>description:</td><td><input type="text" id="description" style="width:95%"/></td></tr>';
  9. str += '<tr><td>availableIdentityList:</td><td><textarea id="availableIdentityList" style="width:95%"/></td></tr>';
  10. str += '<tr><td>availableDepartmentList:</td><td><textarea id="availableDepartmentList" style="width:95%"/></td></tr>';
  11. str += '<tr><td>availableCompanyList:</td><td><textarea id="availableCompanyList" style="width:95%"/></td></tr>';
  12. str += '<tr><td>controllerList:</td><td><textarea id="controllerList" style="width:95%"/></td></tr>';
  13. str += '</table>';
  14. $('#content').html(str);
  15. $('#post').click(function() {
  16. application_post();
  17. });
  18. }
  19. function application_post() {
  20. $.ajax({
  21. type : 'post',
  22. dataType : 'json',
  23. url : '../jaxrs/application',
  24. contentType : 'application/json; charset=utf-8',
  25. data : JSON.stringify({
  26. name : $('#name').val(),
  27. alias : $('#alias').val(),
  28. description : $('#description').val(),
  29. availableIdentityList : $('#availableIdentityList').val().split(','),
  30. availableDepartmentList : $('#availableDepartmentList').val().split(','),
  31. availableCompanyList : $('#availableCompanyList').val().split(','),
  32. applicationCategory : $('#applicationCategory').val(),
  33. controllerList : $('#controllerList').val().split(',')
  34. }),
  35. xhrFields : {
  36. 'withCredentials' : true
  37. },
  38. crossDomain : true
  39. }).done(function(json) {
  40. $('#result').html(JSON.stringify(json, null, 4));
  41. });
  42. }
  43. function application_edit(id) {
  44. var str = '<table border="1" width="100%">';
  45. str += '<tr><td colspan="2"><a href="#" id="put">put</a></td></tr>';
  46. str += '<tr><td>id:</td><td id="id">&nbsp;</td></tr>';
  47. str += '<tr><td>createTime:</td><td id="createTime">&nbsp;</td></tr>';
  48. str += '<tr><td>creatorPerson:</td><td id="creatorPerson">&nbsp;</td></tr>';
  49. str += '<tr><td>lastUpdateTime:</td><td id="lastUpdateTime">&nbsp;</td></tr>';
  50. str += '<tr><td>lastUpdatePerson:</td><td id="lastUpdatePerson">&nbsp;</td></tr>';
  51. str += '<tr><td>name:</td><td><input type="text" id="name" style="width:95%"/></td></tr>';
  52. str += '<tr><td>alias:</td><td><input type="text" id="alias" style="width:95%"/></td></tr>';
  53. str += '<tr><td>applicationCategory:</td><td><input type="text" id="applicationCategory" style="width:95%"/></td></tr>';
  54. str += '<tr><td>description:</td><td><input type="text" id="description" style="width:95%"/></td></tr>';
  55. str += '<tr><td>availableIdentityList:</td><td><textarea id="availableIdentityList" style="width:95%"/></td></tr>';
  56. str += '<tr><td>availableDepartmentList:</td><td><textarea id="availableDepartmentList" style="width:95%"/></td></tr>';
  57. str += '<tr><td>availableCompanyList:</td><td><textarea id="availableCompanyList" style="width:95%"/></td></tr>';
  58. str += '<tr><td>controllerList:</td><td><textarea id="controllerList" style="width:95%"/></td></tr>';
  59. str += '</table>';
  60. $('#content').html(str);
  61. $('#put').click(function() {
  62. application_put(id);
  63. });
  64. $.ajax({
  65. type : 'get',
  66. dataType : 'json',
  67. url : '../jaxrs/application/' + id,
  68. xhrFields : {
  69. 'withCredentials' : true
  70. },
  71. crossDomain : true
  72. }).done(function(json) {
  73. $('#result').html(JSON.stringify(json, null, 4));
  74. if (json.type == 'success') {
  75. $('#id').html(json.data.id);
  76. $('#createTime').html(json.data.createTime);
  77. $('#creatorPerson').html(json.data.creatorPerson);
  78. $('#lastUpdateTime').html(json.data.lastUpdateTime);
  79. $('#lastUpdatePerson').html(json.data.lastUpdatePerson);
  80. $('#name').val(json.data.name);
  81. $('#alias').val(json.data.alias);
  82. $('#applicationCategory').val(json.data.applicationCategory);
  83. $('#description').val(json.data.description);
  84. $('#availableIdentityList').val(joinValue(json.data.availableIdentityList, ','));
  85. $('#availableDepartmentList').val(joinValue(json.data.availableDepartmentList, ','));
  86. $('#availableCompanyList').val(joinValue(json.data.availableCompanyList, ','));
  87. $('#controllerList').val(joinValue(json.data.controllerList, ','));
  88. }
  89. });
  90. }
  91. function application_put(id) {
  92. $.ajax({
  93. type : 'put',
  94. dataType : 'json',
  95. url : '../jaxrs/application/' + id,
  96. contentType : 'application/json; charset=utf-8',
  97. data : JSON.stringify({
  98. name : $('#name').val(),
  99. alias : $('#alias').val(),
  100. description : $('#description').val(),
  101. availableIdentityList : splitValue($('#availableIdentityList').val()),
  102. availableDepartmentList : splitValue($('#availableDepartmentList').val()),
  103. availableCompanyList : splitValue($('#availableCompanyList').val()),
  104. applicationCategory : $('#applicationCategory').val(),
  105. controllerList : $('#controllerList').val().split(',')
  106. }),
  107. xhrFields : {
  108. 'withCredentials' : true
  109. },
  110. crossDomain : true
  111. }).done(function(json) {
  112. $('#result').html(JSON.stringify(json, null, 4));
  113. });
  114. }
  115. function application_delete(id) {
  116. $.ajax({
  117. type : 'delete',
  118. dataType : 'json',
  119. url : '../jaxrs/application/' + id,
  120. xhrFields : {
  121. 'withCredentials' : true
  122. },
  123. crossDomain : true
  124. }).done(function(json) {
  125. $('#result').html(JSON.stringify(json, null, 4));
  126. });
  127. }
  128. function application_list_summary() {
  129. $.ajax({
  130. type : 'get',
  131. dataType : 'json',
  132. url : '../jaxrs/application/list/summary',
  133. xhrFields : {
  134. 'withCredentials' : true
  135. },
  136. crossDomain : true
  137. }).done(function(json) {
  138. $('#result').html(JSON.stringify(json, null, 4));
  139. if (json.type == 'success') {
  140. var str = '<table border="1" width="100%"><tbody>';
  141. str += '<tr><th>id</th><th>process</th><th>form</th><th>icon</th><th>name</th><th>operate</th><th>process</th><th>form</th><th>script</th><th>dict</th></tr>';
  142. $.each(json.data, function(index, item) {
  143. str += '<tr>';
  144. str += '<td>' + item.id + '</td>';
  145. str += '<td>' + item.processList.length + '</td>';
  146. str += '<td>' + item.formList.length + '</td>';
  147. if (item.icon && item.icon != '') {
  148. str += '<td><img src="data:image/png;base64,' + item.icon + '"/></td>';
  149. } else {
  150. str += '<td>&nbsp;</td>';
  151. }
  152. str += '<td>' + item.name + '</td>';
  153. str += '<td>';
  154. str += '<a href="#" onclick="application_edit(\'' + item.id + '\')">edit</a>&nbsp;';
  155. str += '<a href="#" onclick="application_delete(\'' + item.id + '\')">delete</a>';
  156. str += '</td>';
  157. str += '<td>';
  158. str += '<a href="#" onclick="process_listWithApplication(\'' + item.id + '\')">list</a>&nbsp;';
  159. str += '</td>';
  160. str += '<td>';
  161. str += '<a href="#" onclick="form_listWithApplication(\'' + item.id + '\')">list</a>&nbsp;';
  162. str += '</td>';
  163. str += '<td>';
  164. str += '<a href="#" onclick="script_listWithApplication(\'' + item.id + '\')">list</a>&nbsp;';
  165. str += '</td>';
  166. str += '<td>';
  167. str += '<a href="#" onclick="applicationDict_listWithApplication(\'' + item.id + '\')">list</a>&nbsp;';
  168. str += '</td>';
  169. str += '</tr>';
  170. });
  171. str += '</tbody></table>';
  172. $('#content').html(str);
  173. }
  174. });
  175. }
  176. function application_icon_update() {
  177. str = '<table border="1" width="100%">';
  178. str += '<tr><td colspan="2"><a href="#" id="put">put</a></td></tr>';
  179. str += '<tr><td>application id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
  180. str += '<tr><td>icon:</td><td><form><input type="file" id="file" name="file" style="width:95%"/></form></td></tr>';
  181. str += '<tr><td colspan="2" id="result">&nbsp;</td></tr>';
  182. str += '</table>';
  183. $('#content').html(str);
  184. $('#put').click(function() {
  185. application_icon_post($('#id').val());
  186. });
  187. }
  188. function application_icon_post(id) {
  189. var formData = new FormData($('form')[0]);
  190. $.ajax({
  191. type : 'post',
  192. dataType : 'json',
  193. url : '../servlet/application/' + id + '/icon',
  194. data : formData,
  195. contentType : false,
  196. cache : false,
  197. processData : false,
  198. xhrFields : {
  199. 'withCredentials' : true
  200. },
  201. crossDomain : true,
  202. success : function(result) {
  203. $('#result').html(JSON.stringify(json, null, 4));
  204. }
  205. });
  206. }