medicalCommunity_info.js 2.6 KB

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