IntegralMgr_info.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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('limit')
  78. .set('yearly')
  79. .set('max')
  80. .set('active');
  81. }
  82. IntegralMgrInfo.onLimitChange = function () {
  83. var limit = $("#limit").val();
  84. switch (limit) {
  85. case "1":
  86. $('#integraMgrInfoForm').bootstrapValidator('addField', "yearly", {validators: {notEmpty: {message: '请选择上限方案'}}});
  87. $('#integraMgrInfoForm').bootstrapValidator('addField', "max", {validators: {notEmpty: {message: '请填写积分上限'}}});
  88. $(".limit-setting").css("display", "block");
  89. break;
  90. default:
  91. $('#integraMgrInfoForm').bootstrapValidator('removeField', "yearly");
  92. $('#integraMgrInfoForm').bootstrapValidator('removeField', "max");
  93. $(".limit-setting").css("display", "none");
  94. }
  95. }
  96. /**
  97. * 提交添加
  98. */
  99. IntegralMgrInfo.addSubmit = function () {
  100. this.clearData();
  101. this.collectData();
  102. if (!this.validate()) {
  103. return;
  104. }
  105. var ajax = new $ax("/admin/integral_mgr/add", function (data) {
  106. if (data.code == "200") {
  107. Feng.success(data.msg);
  108. window.parent.IntegralMgr.table.refresh();
  109. IntegralMgrInfo.close();
  110. } else {
  111. Feng.error(data.msg);
  112. }
  113. }, function (data) {
  114. Feng.error("添加失败!" + data.responseJSON.message + "!");
  115. });
  116. ajax.set(this.integralMgrInfoData);
  117. ajax.start();
  118. }
  119. /**
  120. * 提交修改
  121. */
  122. IntegralMgrInfo.editSubmit = function () {
  123. this.clearData();
  124. this.collectData();
  125. if (!this.validate()) {
  126. return;
  127. }
  128. var ajax = new $ax(Feng.ctxPath + "/admin/integral_mgr/edit", function (data) {
  129. if (data.code == "200") {
  130. Feng.success(data.msg);
  131. window.parent.IntegralMgr.table.refresh();
  132. IntegralMgrInfo.close();
  133. } else {
  134. Feng.error(data.msg);
  135. }
  136. }, function (data) {
  137. Feng.error("修改失败!" + data.responseJSON.message + "!");
  138. });
  139. ajax.set(this.integralMgrInfoData);
  140. ajax.start();
  141. }
  142. /**
  143. * 验证数据是否为空
  144. */
  145. IntegralMgrInfo.validate = function () {
  146. $('#integraMgrInfoForm').data("bootstrapValidator").resetForm();
  147. $('#integraMgrInfoForm').bootstrapValidator('validate');
  148. return $("#integraMgrInfoForm").data('bootstrapValidator').isValid();
  149. }
  150. $(function () {
  151. Feng.initValidator("integraMgrInfoForm", IntegralMgrInfo.validateFields);
  152. //下拉框数据回显
  153. $("select").each(function () {
  154. $(this).val($(this).attr("selectVal"));
  155. });
  156. IntegralMgrInfo.onLimitChange();
  157. });