IntegralMgr_info.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * 初始化认定条件管理详情对话框
  3. */
  4. var IntegralMgrInfo = {
  5. integralMgrInfoData: {},
  6. validateFields: {
  7. type: {
  8. validators: {
  9. notEmpty: {
  10. message: '请选择人才类型'
  11. }
  12. }
  13. },
  14. name: {
  15. validators: {
  16. notEmpty: {
  17. message: '请填写项目名称'
  18. }
  19. }
  20. },
  21. projectType: {
  22. validators: {
  23. notEmpty: {
  24. message: '请选择项目类别'
  25. }
  26. }
  27. },
  28. active: {
  29. validators: {
  30. notEmpty: {
  31. message: '请选择启用状态'
  32. }
  33. }
  34. }
  35. }
  36. };
  37. /**
  38. * 清除数据
  39. */
  40. IntegralMgrInfo.clearData = function () {
  41. this.integralMgrInfoData = {};
  42. }
  43. /**
  44. * 设置对话框中的数据
  45. *
  46. * @param key 数据的名称
  47. * @param val 数据的具体值
  48. */
  49. IntegralMgrInfo.set = function (key, val) {
  50. this.integralMgrInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  51. return this;
  52. }
  53. /**
  54. * 设置对话框中的数据
  55. *
  56. * @param key 数据的名称
  57. * @param val 数据的具体值
  58. */
  59. IntegralMgrInfo.get = function (key) {
  60. return $("#" + key).val();
  61. }
  62. /**
  63. * 关闭此对话框
  64. */
  65. IntegralMgrInfo.close = function () {
  66. parent.layer.close(window.parent.IntegralMgr.layerIndex);
  67. }
  68. /**
  69. * 收集数据
  70. */
  71. IntegralMgrInfo.collectData = function () {
  72. this
  73. .set('id')
  74. .set('type')
  75. .set('name')
  76. .set('projectType')
  77. .set('active');
  78. }
  79. /**
  80. * 提交添加
  81. */
  82. IntegralMgrInfo.addSubmit = function () {
  83. this.clearData();
  84. this.collectData();
  85. if (!this.validate()) {
  86. return;
  87. }
  88. var ajax = new $ax("/admin/integral_mgr/add", function (data) {
  89. if (data.code == "200") {
  90. Feng.success(data.msg);
  91. window.parent.IntegralMgr.table.refresh();
  92. IntegralMgrInfo.close();
  93. } else {
  94. Feng.error(data.msg);
  95. }
  96. }, function (data) {
  97. Feng.error("添加失败!" + data.responseJSON.message + "!");
  98. });
  99. ajax.set(this.integralMgrInfoData);
  100. ajax.start();
  101. }
  102. /**
  103. * 提交修改
  104. */
  105. IntegralMgrInfo.editSubmit = function () {
  106. this.clearData();
  107. this.collectData();
  108. if (!this.validate()) {
  109. return;
  110. }
  111. var ajax = new $ax(Feng.ctxPath + "/admin/integral_mgr/edit", function (data) {
  112. if (data.code == "200") {
  113. Feng.success(data.msg);
  114. window.parent.IntegralMgr.table.refresh();
  115. IntegralMgrInfo.close();
  116. } else {
  117. Feng.error(data.msg);
  118. }
  119. }, function (data) {
  120. Feng.error("修改失败!" + data.responseJSON.message + "!");
  121. });
  122. ajax.set(this.integralMgrInfoData);
  123. ajax.start();
  124. }
  125. /**
  126. * 验证数据是否为空
  127. */
  128. IntegralMgrInfo.validate = function () {
  129. $('#integraMgrInfoForm').data("bootstrapValidator").resetForm();
  130. $('#integraMgrInfoForm').bootstrapValidator('validate');
  131. return $("#integraMgrInfoForm").data('bootstrapValidator').isValid();
  132. }
  133. $(function () {
  134. Feng.initValidator("integraMgrInfoForm", IntegralMgrInfo.validateFields);
  135. //下拉框数据回显
  136. $("select").each(function () {
  137. $(this).val($(this).attr("selectVal"));
  138. });
  139. });