editorRuleJs.jsp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 type="text/javascript">
  4. /* *************************** 模块初始化 ***************************** */
  5. var editorParam = {
  6. //form
  7. actionUrl:"${contextRoot}/rule/addRule",
  8. init: function () {
  9. this.toDisable();
  10. this.bindEvents();
  11. this.initForm();
  12. },
  13. toDisable: function () {
  14. if ($("#flag").val() == 'disabled') {
  15. $("#btnEditor").show();
  16. $("#btnSave").hide();
  17. $("input[name='type']").attr("disabled", "disabled");
  18. $("input[name='name']").attr("disabled", "disabled");
  19. $("input[name='describe']").attr("disabled", "disabled");
  20. $("input[name='rule']").attr("disabled", "disabled");
  21. $("input[name='error_code']").attr("disabled", "disabled");
  22. }
  23. },
  24. initForm: function () {
  25. var me = this;
  26. $("#type").ligerComboBox({dict: true, dictName: "RULE_TYPE"});
  27. $("#error_code").ligerComboBox({dict: true, dictName: "GLOBAL_ERROR_CODE"});
  28. var data;
  29. var modelString = "${model.id}";
  30. if (modelString != undefined && modelString != null && modelString.length > 0) {
  31. data = {
  32. id: "${model.id}",
  33. type: "${model.type}",
  34. name: "${model.name}",
  35. describe: "${model.describe}",
  36. rule: "${model.rule}",
  37. error_code: "${model.error_code}"
  38. };
  39. me.actionUrl = "${contextRoot}/rule/updateRule";
  40. }
  41. $("#div_info_form").ligerAutoForm({
  42. data: data,
  43. validate: {
  44. name:"required",
  45. describe:"required",
  46. rule:"required",
  47. error_code:"required",
  48. type:"required"
  49. }
  50. });
  51. },
  52. bindEvents: function () {
  53. var me = this;
  54. $(".m-form-bottom").on("click", "#btnSave", function () {
  55. if (!$("#div_info_form").ligerAutoForm("validate")) {
  56. return;
  57. }
  58. var data = $("#div_info_form").ligerAutoForm("getData");
  59. $.ajax({ //ajax处理
  60. type: "POST",
  61. url: me.actionUrl,
  62. dataType: "json",
  63. data: data,
  64. cache: false,
  65. success: function (data) {
  66. if (data.successFlg) {
  67. parent.rule.dialogSuccess(data.message);
  68. }
  69. else {
  70. $.ligerDialog.error(data.message);
  71. }
  72. $("#btnSave").css("pointer-events", "");
  73. },
  74. error: function (data) {
  75. $.ligerDialog.error("Status:" + data.status + "(" + data.statusText + ")");
  76. $("#btnSave").css("pointer-events", "");
  77. }
  78. });
  79. });
  80. $(".m-form-bottom").on("click", "#btnEditor", function () {
  81. $("#btnEditor").hide();
  82. $("#btnSave").show();
  83. $("input[name='type']").removeAttr("disabled");
  84. $("input[name='name']").removeAttr("disabled");
  85. $("input[name='describe']").removeAttr("disabled");
  86. $("input[name='rule']").removeAttr("disabled");
  87. $("input[name='error_code']").removeAttr("disabled");
  88. $("#flag").val("");
  89. });
  90. $(".m-form-bottom").on("click", "#btnCancel", function () {
  91. parent.rule.dialog.close();
  92. });
  93. // $("#type").ligerComboBox({
  94. // data: [{"value": "完整性", "code": "1"}, {"value": "及时性", "code": "2"}, {"value": "准确性", "code": "3"}],
  95. // cancelable: false,
  96. // onSuccess: function (data) {
  97. // }
  98. // });
  99. }
  100. };
  101. $(function () {
  102. editorParam.init();
  103. });
  104. </script>
  105. <script type="text/javascript" src="${staticRoot}/lib/jquery/jqueryform.js"></script>