BusQueryRuleUtil.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. // 查询规则的帮助类
  2. if (typeof BusQueryRuleUtil == 'undefined') {
  3. BusQueryRuleUtil = {};
  4. }
  5. /**
  6. * 编辑窗口
  7. *
  8. * @param {}
  9. * conf
  10. */
  11. BusQueryRuleUtil.eidtDialog = function(conf) {
  12. var url = __ctx + '/platform/bus/busQueryRule/edit_' + conf.tableName
  13. + '.ht', height = screen.availHeight - 35, width = screen.availWidth
  14. - 5;
  15. url = url.getNewUrl();
  16. $.openFullWindow(url);
  17. }
  18. /**
  19. * 保存过滤条件
  20. *
  21. * @param {}
  22. * conf
  23. */
  24. BusQueryRuleUtil.saveFilter = function(conf) {
  25. var filterId = conf.filterFlag, tableName = conf.tableName, filterKey = conf.filterKey;
  26. var target = "";
  27. if (!$.isEmpty(filterId)) {
  28. var url = __ctx + "/platform/bus/busQueryFilter/get.ht";
  29. $.post(url, {
  30. id : filterId
  31. }, function(data) {
  32. var busQueryFilter = data.busQueryFilter;
  33. if (!$.isEmpty(busQueryFilter)) {
  34. target = '<div>'
  35. + '<form id="__formSaveFilter__"><table class="table-detail" cellpadding="0" cellspacing="0" border="0">'
  36. + '<tr><th style="width:113px;text-align:right;" nowrap="nowrap">过滤名称:</th>'
  37. + '<td><input type="text" name="filterName" value="'
  38. + busQueryFilter.filterName
  39. + '" /></td></tr>'
  40. + '<tr><th style="text-align:right;">描述:</th>'
  41. + '<td><textarea name="filterDesc" cols="1" rows="5" style="width:200px">'
  42. + busQueryFilter.filterDesc
  43. + '</textarea></td></tr>' + '</table>'
  44. + '</form></div>';
  45. $.ligerDialog.open({
  46. title : '保存过滤条件',
  47. target : target,
  48. width : 400,
  49. height : 250,
  50. buttons : [{
  51. text : '保存',
  52. onclick : function(item, dialog) {
  53. saveFilter(item, dialog,
  54. filterId);
  55. }
  56. }, {
  57. text : '另存为',
  58. onclick : saveFilter
  59. }, {
  60. text : '取消',
  61. onclick : function(item, dialog) {
  62. dialog.hide();
  63. }
  64. }]
  65. }).show();
  66. } else {
  67. target = '<div>'
  68. + '<form id="__formSaveFilter__"><table class="table-detail" cellpadding="0" cellspacing="0" border="0">'
  69. + '<tr><th style="width:113px;text-align:right;" nowrap="nowrap">过滤名称:</th>'
  70. + '<td><input type="text" name="filterName" /></td></tr>'
  71. + '<tr><th style="text-align:right;">描述:</th>'
  72. + '<td><textarea name="filterDesc" cols="1" rows="5" style="width:200px"></textarea></td></tr>'
  73. + '</table>' + '</form></div>';
  74. $.ligerDialog.open({
  75. title : '保存过滤条件',
  76. target : target,
  77. width : 400,
  78. height : 250,
  79. buttons : [{
  80. text : '保存',
  81. onclick : saveFilter
  82. }, {
  83. text : '取消',
  84. onclick : function(item, dialog) {
  85. dialog.hide();
  86. }
  87. }]
  88. }).show();
  89. }
  90. });
  91. } else {
  92. target = '<div>'
  93. + '<form id="__formSaveFilter__"><table class="table-detail" cellpadding="0" cellspacing="0" border="0">'
  94. + '<tr><th style="width:113px;text-align:right;" nowrap="nowrap">过滤名称:</th>'
  95. + '<td><input type="text" name="filterName" /></td></tr>'
  96. + '<tr><th style="text-align:right;">描述:</th>'
  97. + '<td><textarea name="filterDesc" cols="1" rows="5" style="width:200px"></textarea></td></tr>'
  98. + '</table>' + '</form></div>';
  99. $.ligerDialog.open({
  100. title : '保存过滤条件',
  101. target : target,
  102. width : 400,
  103. height : 250,
  104. buttons : [{
  105. text : '保存',
  106. onclick : saveFilter
  107. }, {
  108. text : '取消',
  109. onclick : function(item, dialog) {
  110. dialog.hide();
  111. }
  112. }]
  113. }).show();
  114. }
  115. /**
  116. * 序列化查询参数
  117. *
  118. * @param {}
  119. * form
  120. * @return {}
  121. */
  122. function serializeObject(form) {
  123. var o = {};
  124. var a = $(form).serializeArray();
  125. $.each(a, function() {
  126. if (o[this.name]) {
  127. if (!o[this.name].push) {
  128. o[this.name] = [o[this.name]];
  129. }
  130. o[this.name].push(this.value || '');
  131. } else {
  132. o[this.name] = this.value || '';
  133. }
  134. });
  135. return o;
  136. }
  137. function setUrlParams(params, url) {
  138. if (url.indexOf("?") != -1) {
  139. var str = url.substr(1), strs = str.split("&");
  140. for (var i = 0; i < strs.length; i++) {
  141. params[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
  142. }
  143. }
  144. return params;
  145. }
  146. /**
  147. * 保存
  148. */
  149. function saveFilter(item, dialog, filterId) {
  150. var filterName = $("[name='filterName']", dialog.dialog), filterDesc = $(
  151. "[name='filterDesc']", dialog.dialog);
  152. var sorted = $(dialog.dialog).parent().find('.panel-table')
  153. .find('.sortable.sorted').find("a");
  154. if (filterName.val() == "") {
  155. $.ligerDialog.warn("请填写过滤名称!", "提示");
  156. return;
  157. }
  158. var params = serializeObject(searchForm);
  159. params.filterName = filterName.val();
  160. params.filterDesc = filterDesc.val();
  161. params.tableName = tableName;
  162. params.filterKey = filterKey;
  163. if (!$.isEmptyObject(sorted)) {
  164. var h = sorted.attr("href");
  165. if (!$.isEmpty(h))
  166. setUrlParams(params, h);
  167. }
  168. if (!$.isEmpty(filterId))
  169. params.filterId = filterId;
  170. var url = __ctx + "/platform/bus/busQueryFilter/saveFilter.ht";
  171. $.post(url, params, function(responseText) {
  172. var obj = new com.hotent.form.ResultMessage(responseText);
  173. if (obj.isSuccess()) {
  174. $.ligerDialog.success('保存成功!',
  175. '提示', function() {
  176. dialog.hide();
  177. });
  178. } else {
  179. $.ligerDialog.err('提示', '保存失败!',
  180. obj.getMessage());
  181. }
  182. });
  183. };
  184. };
  185. /**
  186. * 我的过滤器
  187. *
  188. * @param {}
  189. * conf
  190. */
  191. BusQueryRuleUtil.myFilter = function(conf) {
  192. var url = __ctx + '/platform/bus/busQueryFilter/list.ht?tableName='
  193. + conf.tableName + '&url=' + conf.url;
  194. url = url.getNewUrl();
  195. DialogUtil.open({
  196. height:400,
  197. width: 500,
  198. title : '我的过滤器',
  199. url: url,
  200. isResize: true,
  201. data:{},
  202. //自定义参数
  203. sucCall:function(rtn){
  204. if (rtn != undefined)
  205. window.location.href = conf.url + rtn;
  206. }
  207. });
  208. }
  209. BusQueryRuleUtil.setting = function(conf) {
  210. var url = __ctx + '/platform/bus/busQuerySetting/edit.ht?tableName='+conf.tableName;
  211. url = url.getNewUrl();
  212. DialogUtil.open({
  213. height: 400,
  214. width: 500,
  215. title : '',
  216. url: url,
  217. isResize: true,
  218. //自定义参数
  219. data: {},
  220. sucCall:function(rtn){
  221. if (rtn != undefined)
  222. window.location.href = location.href.getNewUrl();
  223. }
  224. });
  225. }