batch_info.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /**
  2. * 初始化批次管理详情对话框
  3. */
  4. Feng.ctxPath = "/admin";
  5. var BatchInfoDlg = {
  6. batchInfoData: {},
  7. validateFields: {
  8. type: {
  9. validators: {
  10. notEmpty: {
  11. message: '申报类别不能为空'
  12. }
  13. }
  14. },
  15. source: {
  16. validators: {
  17. notEmpty: {
  18. message: '人才类型不能为空'
  19. }
  20. }
  21. },
  22. batch: {
  23. validators: {
  24. notEmpty: {
  25. message: '申报批次不能为空'
  26. },
  27. regexp: {
  28. regexp: /^\d+$/,
  29. message: "只能输入数字"
  30. }
  31. }
  32. },
  33. active: {
  34. validators: {
  35. notEmpty: {
  36. message: '有效状态不能为空'
  37. }
  38. }
  39. },
  40. startTime: {
  41. validators: {
  42. notEmpty: {
  43. message: '申报开始时间不能为空'
  44. }
  45. }
  46. },
  47. endTime: {
  48. validators: {
  49. notEmpty: {
  50. message: '申报截止时间不能为空'
  51. }
  52. }
  53. },
  54. }
  55. };
  56. /**
  57. * 清除数据
  58. */
  59. BatchInfoDlg.clearData = function () {
  60. this.batchInfoData = {};
  61. }
  62. /**
  63. * 设置对话框中的数据
  64. *
  65. * @param key 数据的名称
  66. * @param val 数据的具体值
  67. */
  68. BatchInfoDlg.set = function (key, val) {
  69. this.batchInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  70. return this;
  71. }
  72. /**
  73. * 设置对话框中的数据
  74. *
  75. * @param key 数据的名称
  76. * @param val 数据的具体值
  77. */
  78. BatchInfoDlg.get = function (key) {
  79. return $("#" + key).val();
  80. }
  81. /**
  82. * 关闭此对话框
  83. */
  84. BatchInfoDlg.close = function () {
  85. parent.layer.close(window.parent.Batch.layerIndex);
  86. }
  87. /**
  88. * 收集数据
  89. */
  90. BatchInfoDlg.collectData = function () {
  91. this
  92. .set('id')
  93. .set('type')
  94. .set('source')
  95. .set('batch')
  96. .set('startTime')
  97. .set('endTime')
  98. .set('submitEndTime')
  99. .set('publicStartTime')
  100. .set('publicEndTime')
  101. .set('averageWage')
  102. .set('active')
  103. .set('description');
  104. }
  105. /**
  106. * 验证数据是否为空
  107. */
  108. BatchInfoDlg.validate = function () {
  109. $('#batchInfoForm').data("bootstrapValidator").resetForm();
  110. $('#batchInfoForm').bootstrapValidator('validate');
  111. return $("#batchInfoForm").data('bootstrapValidator').isValid();
  112. }
  113. /**
  114. * 提交添加
  115. */
  116. BatchInfoDlg.addSubmit = function () {
  117. this.clearData();
  118. this.collectData();
  119. if (!this.validate()) {
  120. return;
  121. }
  122. //提交信息
  123. var ajax = new $ax(Feng.ctxPath + "/batch/add", function (data) {
  124. if (data.code == "200") {
  125. Feng.success(data.msg);
  126. window.parent.Batch.table.refresh();
  127. BatchInfoDlg.close();
  128. } else {
  129. Feng.error(data.msg);
  130. }
  131. }, function (data) {
  132. Feng.error("添加失败!" + data.responseJSON.message + "!");
  133. });
  134. ajax.set(this.batchInfoData);
  135. ajax.start();
  136. }
  137. /**
  138. * 提交修改
  139. */
  140. BatchInfoDlg.editSubmit = function () {
  141. this.clearData();
  142. this.collectData();
  143. if (!this.validate()) {
  144. return;
  145. }
  146. //提交信息
  147. var ajax = new $ax(Feng.ctxPath + "/batch/edit", function (data) {
  148. if (data.code == "200") {
  149. Feng.success(data.msg);
  150. window.parent.Batch.table.refresh();
  151. BatchInfoDlg.close();
  152. } else {
  153. Feng.error(data.msg);
  154. }
  155. }, function (data) {
  156. Feng.error("修改失败!" + data.responseJSON.message + "!");
  157. });
  158. ajax.set(this.batchInfoData);
  159. ajax.start();
  160. }
  161. $(function () {
  162. Feng.initValidator("batchInfoForm", BatchInfoDlg.validateFields);
  163. //下拉框数据动态加载
  164. Feng.addAjaxSelect({
  165. "id": "type",
  166. "displayCode": "code",
  167. "displayName": "name",
  168. "type": "GET",
  169. "url": Feng.ctxPath + "/dict/findChildDictByCode?code=declare_type"
  170. });
  171. //批量加载时间控件
  172. $("input[time='time']").each(function () {
  173. laydate.render({
  174. elem: "#" + $(this).attr("id")
  175. , type: $(this).attr("format")
  176. , trigger: 'click'
  177. });
  178. });
  179. //下拉框数据回显
  180. $("select").each(function () {
  181. console.log($(this).attr("selectVal"))
  182. $(this).val($(this).attr("selectVal"));
  183. });
  184. });