hospital_info.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * 医共体
  3. */
  4. var HospitalInfo = {
  5. infoData: {},
  6. validateFields: {
  7. name: {
  8. validators: {
  9. notEmpty: {
  10. message: '医院名称不能为空'
  11. }
  12. }
  13. },
  14. communityId: {
  15. validators: {
  16. notEmpty: {
  17. message: '请选择医共体'
  18. }
  19. }
  20. },
  21. isGeneral: {
  22. validators: {
  23. notEmpty: {
  24. message: '请选择是否总院'
  25. }
  26. }
  27. },
  28. status: {
  29. validators: {
  30. notEmpty: {
  31. message: '启用状态不能为空'
  32. }
  33. }
  34. },
  35. num: {
  36. validators: {
  37. notEmpty: {
  38. message: '排序不能为空'
  39. },
  40. regexp: {
  41. regexp: /^\d+$/,
  42. message: '只能输入数字'
  43. }
  44. }
  45. }
  46. }
  47. };
  48. /**
  49. * 清除数据
  50. */
  51. HospitalInfo.clearData = function () {
  52. this.infoData = {};
  53. }
  54. /**
  55. * 设置对话框中的数据
  56. *
  57. * @param key 数据的名称
  58. * @param val 数据的具体值
  59. */
  60. HospitalInfo.set = function (key, val) {
  61. this.infoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  62. return this;
  63. }
  64. /**
  65. * 设置对话框中的数据
  66. *
  67. * @param key 数据的名称
  68. * @param val 数据的具体值
  69. */
  70. HospitalInfo.get = function (key) {
  71. return $("#" + key).val();
  72. }
  73. /**
  74. * 关闭此对话框
  75. */
  76. HospitalInfo.close = function () {
  77. parent.layer.close(window.parent.Hospital.layerIndex);
  78. }
  79. /**
  80. * 收集数据
  81. */
  82. HospitalInfo.collectData = function () {
  83. this.set('id')
  84. .set('name')
  85. .set('communityId')
  86. .set('isGeneral')
  87. .set('status')
  88. .set('num')
  89. .set('description');
  90. }
  91. /**
  92. * 验证数据是否为空
  93. */
  94. HospitalInfo.validate = function () {
  95. $('#hospitalInfoForm').data("bootstrapValidator").resetForm();
  96. $('#hospitalInfoForm').bootstrapValidator('validate');
  97. return $("#hospitalInfoForm").data('bootstrapValidator').isValid();
  98. }
  99. /**
  100. * 提交修改
  101. */
  102. HospitalInfo.editSubmit = function () {
  103. this.clearData();
  104. this.collectData();
  105. if (!this.validate()) {
  106. return;
  107. }
  108. $('#hospitalInfoForm')[0].submit();
  109. }
  110. //回调
  111. HospitalInfo.callBack = function (data) {
  112. if (data.code == "200") {
  113. Feng.success(data.msg);
  114. window.parent.Hospital.table.refresh();
  115. HospitalInfo.close();
  116. } else {
  117. Feng.error(data.msg);
  118. }
  119. }
  120. $(function () {
  121. //下拉框数据回显
  122. $("select").each(function () {
  123. $(this).val($(this).attr("selectVal"));
  124. });
  125. Feng.initValidator("hospitalInfoForm", HospitalInfo.validateFields);
  126. });