IntegralMgr_info.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. limit: {
  29. validators: {
  30. notEmpty: {
  31. message: '请选择是否上限'
  32. }
  33. }
  34. },
  35. active: {
  36. validators: {
  37. notEmpty: {
  38. message: '请选择启用状态'
  39. }
  40. }
  41. }
  42. }
  43. };
  44. /**
  45. * 清除数据
  46. */
  47. IntegralMgrInfo.clearData = function () {
  48. this.integralMgrInfoData = {};
  49. }
  50. /**
  51. * 设置对话框中的数据
  52. *
  53. * @param key 数据的名称
  54. * @param val 数据的具体值
  55. */
  56. IntegralMgrInfo.set = function (key, val) {
  57. this.integralMgrInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  58. return this;
  59. }
  60. /**
  61. * 设置对话框中的数据
  62. *
  63. * @param key 数据的名称
  64. * @param val 数据的具体值
  65. */
  66. IntegralMgrInfo.get = function (key) {
  67. return $("#" + key).val();
  68. }
  69. /**
  70. * 关闭此对话框
  71. */
  72. IntegralMgrInfo.close = function () {
  73. parent.layer.close(window.parent.IntegralMgr.layerIndex);
  74. }
  75. /**
  76. * 收集数据
  77. */
  78. IntegralMgrInfo.collectData = function () {
  79. this
  80. .set('id')
  81. .set('type')
  82. .set('name')
  83. .set('projectType')
  84. .set('limit')
  85. .set('yearly')
  86. .set('max')
  87. .set('active');
  88. }
  89. IntegralMgrInfo.onLimitChange = function () {
  90. var limit = $("#limit").val();
  91. switch (limit) {
  92. case "1":
  93. $('#integraMgrInfoForm').bootstrapValidator('addField', "yearly", {validators: {notEmpty: {message: '请选择上限方案'}}});
  94. $('#integraMgrInfoForm').bootstrapValidator('addField', "max", {validators: {notEmpty: {message: '请填写积分上限'}}});
  95. $(".limit-setting").css("display", "block");
  96. break;
  97. default:
  98. $('#integraMgrInfoForm').bootstrapValidator('removeField', "yearly");
  99. $('#integraMgrInfoForm').bootstrapValidator('removeField', "max");
  100. $(".limit-setting").css("display", "none");
  101. }
  102. }
  103. /**
  104. * 提交添加
  105. */
  106. IntegralMgrInfo.addSubmit = function () {
  107. this.clearData();
  108. this.collectData();
  109. if (!this.validate()) {
  110. return;
  111. }
  112. var ajax = new $ax("/admin/integral_mgr/add", function (data) {
  113. if (data.code == "200") {
  114. Feng.success(data.msg);
  115. window.parent.IntegralMgr.table.refresh();
  116. IntegralMgrInfo.close();
  117. } else {
  118. Feng.error(data.msg);
  119. }
  120. }, function (data) {
  121. Feng.error("添加失败!" + data.responseJSON.message + "!");
  122. });
  123. ajax.set(this.integralMgrInfoData);
  124. ajax.start();
  125. }
  126. /**
  127. * 提交修改
  128. */
  129. IntegralMgrInfo.editSubmit = function () {
  130. this.clearData();
  131. this.collectData();
  132. if (!this.validate()) {
  133. return;
  134. }
  135. var ajax = new $ax(Feng.ctxPath + "/admin/integral_mgr/edit", function (data) {
  136. if (data.code == "200") {
  137. Feng.success(data.msg);
  138. window.parent.IntegralMgr.table.refresh();
  139. IntegralMgrInfo.close();
  140. } else {
  141. Feng.error(data.msg);
  142. }
  143. }, function (data) {
  144. Feng.error("修改失败!" + data.responseJSON.message + "!");
  145. });
  146. ajax.set(this.integralMgrInfoData);
  147. ajax.start();
  148. }
  149. /**
  150. * 验证数据是否为空
  151. */
  152. IntegralMgrInfo.validate = function () {
  153. $('#integraMgrInfoForm').data("bootstrapValidator").resetForm();
  154. $('#integraMgrInfoForm').bootstrapValidator('validate');
  155. return $("#integraMgrInfoForm").data('bootstrapValidator').isValid();
  156. }
  157. $(function () {
  158. Feng.initValidator("integraMgrInfoForm", IntegralMgrInfo.validateFields);
  159. //下拉框数据回显
  160. $("select").each(function () {
  161. $(this).val($(this).attr("selectVal"));
  162. });
  163. });