editorRuleJs.jsp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. $("#btnSave").css("pointer-events", "none");
  56. $("#name_icon").removeClass("required");
  57. if ($("#name_icon").val() == "") {
  58. $("#name_icon").addClass("required");
  59. if (!$("#div_info_form").ligerAutoForm("validate")) {
  60. return;
  61. }
  62. return;
  63. }
  64. if (!$("#div_info_form").ligerAutoForm("validate")) {
  65. return;
  66. }
  67. var data = $("#div_info_form").ligerAutoForm("getData");
  68. $.ajax({ //ajax处理
  69. type: "POST",
  70. url: me.actionUrl,
  71. dataType: "json",
  72. data: data,
  73. cache: false,
  74. success: function (data) {
  75. if (data.successFlg) {
  76. parent.rule.dialogSuccess(data.message);
  77. }
  78. else {
  79. $.ligerDialog.error(data.message);
  80. }
  81. $("#btnSave").css("pointer-events", "");
  82. },
  83. error: function (data) {
  84. $.ligerDialog.error("Status:" + data.status + "(" + data.statusText + ")");
  85. $("#btnSave").css("pointer-events", "");
  86. }
  87. });
  88. });
  89. $(".m-form-bottom").on("click", "#btnEditor", function () {
  90. $("#btnEditor").hide();
  91. $("#btnSave").show();
  92. $("input[name='type']").removeAttr("disabled");
  93. $("input[name='name']").removeAttr("disabled");
  94. $("input[name='describe']").removeAttr("disabled");
  95. $("input[name='rule']").removeAttr("disabled");
  96. $("input[name='error_code']").removeAttr("disabled");
  97. $("#flag").val("");
  98. });
  99. $(".m-form-bottom").on("click", "#btnCancel", function () {
  100. parent.rule.dialog.close();
  101. });
  102. // $("#type").ligerComboBox({
  103. // data: [{"value": "完整性", "code": "1"}, {"value": "及时性", "code": "2"}, {"value": "准确性", "code": "3"}],
  104. // cancelable: false,
  105. // onSuccess: function (data) {
  106. // }
  107. // });
  108. }
  109. };
  110. $(function () {
  111. editorParam.init();
  112. });
  113. </script>
  114. <script type="text/javascript" src="${staticRoot}/lib/jquery/jqueryform.js"></script>