IntegralItemMgr_info.js 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /**
  2. * 初始化认定条件管理详情对话框
  3. */
  4. var IntegralItemMgrInfo = {
  5. integralMgrInfoData: {},
  6. validateFields: {
  7. projectId: {
  8. validators: {
  9. notEmpty: {
  10. message: '请选择所属积分项目'
  11. }
  12. }
  13. },
  14. name: {
  15. validators: {
  16. notEmpty: {
  17. message: '请输入标准名称'
  18. }
  19. }
  20. },
  21. active: {
  22. validators: {
  23. notEmpty: {
  24. message: '请选择启用状态'
  25. }
  26. }
  27. },
  28. plan: {
  29. validators: {
  30. notEmpty: {
  31. message: '请选择积分方案'
  32. }
  33. }
  34. },
  35. unit: {
  36. validators: {
  37. notEmpty: {
  38. message: '请输入计量单位'
  39. }
  40. }
  41. },
  42. fstNeedAmount: {
  43. validators: {
  44. notEmpty: {
  45. message: '请输入首次达成量'
  46. }
  47. }
  48. },
  49. fstGainPoints: {
  50. validators: {
  51. notEmpty: {
  52. message: '请输入首次获得积分'
  53. }
  54. }
  55. },
  56. stepNeedAmount: {
  57. validators: {
  58. notEmpty: {
  59. message: '请输入每新增量'
  60. }
  61. }
  62. },
  63. stepGainPoints: {
  64. validators: {
  65. notEmpty: {
  66. message: '请输入每新增获得积分'
  67. }
  68. }
  69. },
  70. maxGainPoints: {
  71. validators: {
  72. notEmpty: {
  73. message: '请输入积分上限'
  74. }
  75. }
  76. },
  77. yearly: {
  78. validators: {
  79. notEmpty: {
  80. message: '请选择累计积分方案'
  81. }
  82. }
  83. }
  84. }
  85. };
  86. /**
  87. * 清除数据
  88. */
  89. IntegralItemMgrInfo.clearData = function () {
  90. this.integralMgrInfoData = {};
  91. }
  92. /**
  93. * 设置对话框中的数据
  94. *
  95. * @param key 数据的名称
  96. * @param val 数据的具体值
  97. */
  98. IntegralItemMgrInfo.set = function (key, val) {
  99. this.integralMgrInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  100. return this;
  101. }
  102. /**
  103. * 设置对话框中的数据
  104. *
  105. * @param key 数据的名称
  106. * @param val 数据的具体值
  107. */
  108. IntegralItemMgrInfo.get = function (key) {
  109. return $("#" + key).val();
  110. }
  111. /**
  112. * 关闭此对话框
  113. */
  114. IntegralItemMgrInfo.close = function () {
  115. parent.layer.close(window.parent.IntegralMgr.layerIndex);
  116. }
  117. /**
  118. * 收集数据
  119. */
  120. IntegralItemMgrInfo.collectData = function () {
  121. this
  122. .set('id')
  123. .set('type')
  124. .set('projectId')
  125. .set('name')
  126. .set('plan')
  127. .set('unit')
  128. .set('fstNeedAmount')
  129. .set('fstGainPoints')
  130. .set('stepNeedAmount')
  131. .set('stepGainPoints')
  132. .set('maxGainPoints')
  133. .set('yearly')
  134. .set('fileTypeId')
  135. .set('active');
  136. }
  137. IntegralItemMgrInfo.onTypeChange = function () {
  138. var type = $("#type").val();
  139. Feng.addAjaxSelect({
  140. "id": "projectId",
  141. "displayCode": "id",
  142. "displayName": "name",
  143. "type": "GET",
  144. "url": "/admin/integral_mgr/getProjectsByType/type/" + type
  145. });
  146. var projectId = $("#projectId").attr("selectVal");
  147. $("#projectId").val(projectId);
  148. Feng.addAjaxSelect({
  149. "id": "fileTypeId",
  150. "displayCode": "id",
  151. "displayName": "name",
  152. "type": "GET",
  153. "url": "/admin/integral_mgr/getFilesByType/type/" + type
  154. });
  155. $("#fileTypeId").trigger('chosen:updated');
  156. }
  157. //切换积分方案
  158. IntegralItemMgrInfo.onIntegralPlanChange = function () {
  159. var plan = $("#plan").val();
  160. switch (plan) {
  161. case "1":
  162. $(".planb").css("display", "none");
  163. $('#integraMgrInfoForm').bootstrapValidator('removeField', "stepNeedAmount");
  164. $('#integraMgrInfoForm').bootstrapValidator('removeField', "stepGainPoints");
  165. $('#integraMgrInfoForm').bootstrapValidator('removeField', "maxGainPoints");
  166. $('#integraMgrInfoForm').bootstrapValidator('removeField', "yearly");
  167. break;
  168. case "2":
  169. $(".planb").css("display", "block");
  170. $('#integraMgrInfoForm').bootstrapValidator('addField', "stepNeedAmount", {validators: {notEmpty: {message: '请填写每新增量'}}});
  171. $('#integraMgrInfoForm').bootstrapValidator('addField', "stepGainPoints", {validators: {notEmpty: {message: '请填写每新增获得积分'}}});
  172. $('#integraMgrInfoForm').bootstrapValidator('addField', "maxGainPoints", {validators: {notEmpty: {message: '请填写积分上限'}}});
  173. $('#integraMgrInfoForm').bootstrapValidator('addField', "yearly", {validators: {notEmpty: {message: '请选择累计积分方案'}}});
  174. break;
  175. }
  176. }
  177. /**
  178. * 提交添加
  179. */
  180. IntegralItemMgrInfo.addSubmit = function () {
  181. this.clearData();
  182. this.collectData();
  183. if (!this.validate()) {
  184. return;
  185. }
  186. var ajax = new $ax("/admin/integral_mgr/addItem", function (data) {
  187. if (data.code == "200") {
  188. Feng.success(data.msg);
  189. window.parent.IntegralMgr.table.refresh();
  190. IntegralItemMgrInfo.close();
  191. } else {
  192. Feng.error(data.msg);
  193. }
  194. }, function (data) {
  195. Feng.error("添加失败!" + data.responseJSON.message + "!");
  196. });
  197. ajax.set(this.integralMgrInfoData);
  198. ajax.start();
  199. }
  200. /**
  201. * 提交修改
  202. */
  203. IntegralItemMgrInfo.editSubmit = function () {
  204. this.clearData();
  205. this.collectData();
  206. if (!this.validate()) {
  207. return;
  208. }
  209. var ajax = new $ax(Feng.ctxPath + "/admin/integral_mgr/editItem", function (data) {
  210. if (data.code == "200") {
  211. Feng.success(data.msg);
  212. window.parent.IntegralMgr.table.refresh();
  213. IntegralItemMgrInfo.close();
  214. } else {
  215. Feng.error(data.msg);
  216. }
  217. }, function (data) {
  218. Feng.error("修改失败!" + data.responseJSON.message + "!");
  219. });
  220. ajax.set(this.integralMgrInfoData);
  221. ajax.start();
  222. }
  223. /**
  224. * 验证数据是否为空
  225. */
  226. IntegralItemMgrInfo.validate = function () {
  227. $('#integraMgrInfoForm').data("bootstrapValidator").resetForm();
  228. $('#integraMgrInfoForm').bootstrapValidator('validate');
  229. return $("#integraMgrInfoForm").data('bootstrapValidator').isValid();
  230. }
  231. $(function () {
  232. Feng.initValidator("integraMgrInfoForm", IntegralItemMgrInfo.validateFields);
  233. //下拉框数据回显
  234. $("select").each(function () {
  235. $(this).val($(this).attr("selectVal"));
  236. });
  237. IntegralItemMgrInfo.onTypeChange();
  238. IntegralItemMgrInfo.onIntegralPlanChange();
  239. $("#fileTypeId").chosen({
  240. no_results_text: "没有找到结果!",
  241. width:'100%',
  242. search_contains:true,    //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
  243. disable_search: false,
  244. enable_split_word_search: true,
  245. rtl:true
  246. });
  247. });