ruleJs.jsp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
  2. <%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
  3. <script>
  4. /* *************************** 模块初始化 ***************************** */
  5. var rule = {
  6. grid: null,
  7. dialog: null,
  8. init: function () {
  9. this.bindEvents();
  10. this.initForm();
  11. },
  12. initForm: function () {
  13. var me = this;
  14. $('.m-retrieve-area').show();
  15. $("#txtName").ligerSearch({
  16. onClick:function(value){
  17. me.reloadGrid();
  18. }});
  19. me.grid = $("#div_grid").ligerGrid({
  20. url: '${contextRoot}/rule/getRuleList',
  21. parms: {
  22. name: $('#txtName').val(),
  23. },
  24. checkbox:true,
  25. columns: [
  26. {display: '名称', name: 'name', width: '10%'},
  27. {display: '分类', id: 'type', name: 'type', width: '10%'},
  28. {display: '规则描述', name: 'describe', width: '20%'},
  29. {display: '脚本(或接口)', name: 'rule', width: '20%'},
  30. {display: '统一错误代码', id: 'error_code', name: 'error_code', width: '20%'
  31. },
  32. {
  33. display: '操作', name: 'operator', width: '20%', render: function (row) {
  34. var html = '<div class="m-inline-buttons" style="width:350px;">';
  35. html += "<a class=\"m-btn\" style=\"padding-right:10px\" onclick=\"rule.editorDialog('"+row.id+"','disabled')\">查看详情</a>";
  36. html += "<a class=\"m-btn-edit\" onclick=\"rule.editorDialog('"+row.id+"','')\"></a>";
  37. html += "<a class=\"m-btn-delete\" onclick=\"rule.delete('"+row.id+"')\"></a>";
  38. html += '</div>';
  39. return html;
  40. }
  41. }
  42. ],
  43. onDblClickRow: function (row) {
  44. me.editorDialog(row.id);
  45. }
  46. });
  47. },
  48. bindEvents: function () {
  49. var me = this;
  50. var flag = false;
  51. $('#div_new_record').click(function () {
  52. me.editorDialog();
  53. });
  54. $('#div_delete_record').click(function(){
  55. var rows = rule.grid.getSelecteds();
  56. if(rows.length > 0){
  57. var idArr = [];
  58. for(var i in rows){
  59. idArr.push(rows[i].id);
  60. }
  61. rule.deleteBatch(idArr.join(","));
  62. }else{
  63. $.ligerDialog.error("请选择要删除的规则信息!");
  64. return false;
  65. }
  66. })
  67. $(".l-text").css("display","inline-block");
  68. $(".l-text-wrapper").css("display","inline-block");
  69. },
  70. delete:function(id){
  71. var message = "确定要删除该规则信息吗?";
  72. jQuery.ligerDialog.confirm(message, function (confirm) {
  73. if (confirm)
  74. {
  75. $.ajax({ //ajax处理
  76. type: "POST",
  77. url : "${contextRoot}/rule/deleteRule",
  78. dataType : "json",
  79. data:{id:id},
  80. cache:false,
  81. success :function(data){
  82. if(data.successFlg) {
  83. $.ligerDialog.success(data.message);
  84. rule.grid.reload();
  85. }
  86. else{
  87. $.ligerDialog.error(data.message);
  88. }
  89. },
  90. error :function(data){
  91. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  92. }
  93. });
  94. }
  95. });
  96. },
  97. // 批量删除
  98. deleteBatch: function (idList) {
  99. var message = "确定要删除选中的规则信息吗?";
  100. jQuery.ligerDialog.confirm(message, function (confirm) {
  101. if (confirm)
  102. {
  103. $.ajax({ //ajax处理
  104. type: "POST",
  105. url : "${contextRoot}/rule/deleteRuleBatch",
  106. dataType : "json",
  107. data:{idList: idList},
  108. cache:false,
  109. success :function(data){
  110. if(data.successFlg) {idList
  111. $.ligerDialog.success(data.message);
  112. rule.grid.reload();
  113. }
  114. else{
  115. $.ligerDialog.error(data.message);
  116. }
  117. },
  118. error :function(data){
  119. $.ligerDialog.error("Status:"+data.status +"(" +data.statusText+")");
  120. }
  121. });
  122. }
  123. });
  124. },
  125. //刷新列表数据
  126. reloadGrid: function () {
  127. this.grid.set({
  128. parms: {name: $('#txtName').val(),valid:$('#valid_val').val()}
  129. });
  130. this.grid.reload();
  131. },
  132. //编辑弹窗
  133. editorDialog: function (id, flag) {
  134. var me = this;
  135. var title = "规则录入";
  136. var params = null;
  137. if (id != undefined && id != null) {
  138. title = "规则录入";
  139. params = {"id": id, "flag": flag};
  140. }
  141. me.dialog = $.ligerDialog.open({
  142. height: 400,
  143. width: 500,
  144. title: title,
  145. url: '${contextRoot}/rule/editorRule',
  146. //load: true,
  147. urlParms: params
  148. });
  149. },
  150. dialogDetail: function (id) {
  151. var me = this;
  152. var title = "规则详情";
  153. var params = null;
  154. if (id != undefined && id != null) {
  155. params = {"id": id};
  156. }
  157. me.dialog = $.ligerDialog.open({
  158. height: 500,
  159. width: 500,
  160. title: title,
  161. url: '${contextRoot}/rule/ruleDetail',
  162. //load: true,
  163. urlParms: params
  164. });
  165. },
  166. anthorize: function (id) {
  167. },
  168. //弹窗返回
  169. dialogSuccess: function (message) {
  170. $.ligerDialog.success(message);
  171. rule.reloadGrid();
  172. rule.dialog.close();
  173. }
  174. };
  175. $(function () {
  176. rule.init();
  177. });
  178. </script>