batch.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /**
  2. * 批次管理管理初始化
  3. */
  4. var Batch = {
  5. id: "BatchTable", //表格id
  6. seItem: null, //选中的条目
  7. table: null,
  8. layerIndex: -1
  9. };
  10. Feng.ctxPath = "/admin";
  11. /**
  12. * 初始化表格的列
  13. */
  14. Batch.initColumn = function () {
  15. return [
  16. {field: 'selectItem', radio: true},
  17. {title: '申报类别', field: 'type', visible: true, align: 'center', valign: 'middle'},
  18. {title: '人才类型', field: 'source', visible: true, align: 'center', valign: 'middle',
  19. formatter: function (value, row, index) {
  20. if (value == 1) {
  21. return "晋江市优秀人才";
  22. }
  23. if (value == 2) {
  24. return "晋江市集成电路优秀人才";
  25. }
  26. }
  27. },
  28. {title: '申报批次', field: 'batch', visible: true, align: 'center', valign: 'middle'},
  29. {title: '申报开始时间', field: 'startTime', visible: true, align: 'center', valign: 'middle'},
  30. {title: '申报截止时间', field: 'endTime', visible: true, align: 'center', valign: 'middle'},
  31. {title: '提交截止时间', field: 'submitEndTime', visible: true, align: 'center', valign: 'middle'},
  32. {title: '公示开始时间', field: 'publicStartTime', visible: true, align: 'center', valign: 'middle'},
  33. {title: '公示截止时间', field: 'publicEndTime', visible: true, align: 'center', valign: 'middle'},
  34. {title: '平均工资', field: 'averageWage', visible: true, align: 'center', valign: 'middle'},
  35. {title: '是否有效', field: 'active', visible: true, align: 'center', valign: 'middle',
  36. formatter: function (value, row, index) {
  37. if (value == 1) {
  38. return "<span style='color: green'>是</span>";
  39. }
  40. if (value == 2) {
  41. return "<span style='color: red'>否</span>";
  42. }
  43. }
  44. },
  45. {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle'}
  46. ];
  47. };
  48. /**
  49. * 检查是否选中
  50. */
  51. Batch.check = function () {
  52. var selected = $('#' + this.id).bootstrapTable('getSelections');
  53. if (selected.length == 0) {
  54. Feng.info("请先选中表格中的某一记录!");
  55. return false;
  56. } else {
  57. Batch.seItem = selected[0];
  58. return true;
  59. }
  60. };
  61. /**
  62. * 点击添加批次管理
  63. */
  64. Batch.openAddBatch = function () {
  65. var index = layer.open({
  66. type: 2,
  67. title: '添加批次',
  68. area: ['800px', '420px'], //宽高
  69. fix: false, //不固定
  70. maxmin: true,
  71. content: Feng.ctxPath + '/batch/add'
  72. });
  73. Batch.layerIndex = index;
  74. };
  75. /**
  76. * 打开查看批次管理详情
  77. */
  78. Batch.openBatchDetail = function () {
  79. if (this.check()) {
  80. var index = layer.open({
  81. type: 2,
  82. title: '批次管理详情',
  83. area: ['800px', '420px'], //宽高
  84. fix: false, //不固定
  85. maxmin: true,
  86. content: Feng.ctxPath + '/batch/edit/id/' + Batch.seItem.id
  87. });
  88. Batch.layerIndex = index;
  89. }
  90. };
  91. /**
  92. * 删除批次管理
  93. */
  94. Batch.delete = function () {
  95. if (this.check()) {
  96. var operation = function () {
  97. var ajax = new $ax(Feng.ctxPath + "/batch/delete", function (data) {
  98. Feng.success("删除成功!");
  99. Batch.table.refresh();
  100. }, function (data) {
  101. Feng.error("删除失败!" + data.responseJSON.message + "!");
  102. });
  103. ajax.set("batchId", Batch.seItem.id);
  104. ajax.start();
  105. };
  106. Feng.confirm("是否刪除该批次?", operation);
  107. }
  108. };
  109. /**
  110. * 查询表单提交参数对象
  111. * @returns {{}}
  112. */
  113. Batch.formParams = function () {
  114. var queryData = {};
  115. queryData['type'] = $("#type").val();
  116. queryData['source'] = $("#source").val();
  117. queryData['active'] = $("#active").val();
  118. return queryData;
  119. }
  120. /**
  121. * 查询批次管理列表
  122. */
  123. Batch.search = function () {
  124. Batch.table.refresh({query: Batch.formParams()});
  125. };
  126. /**
  127. * 重置
  128. */
  129. Batch.reset = function () {
  130. $("#type").val("");
  131. $("#active").val("");
  132. $("#source").val("");
  133. }
  134. /**
  135. * 设置生效
  136. */
  137. Batch.setActive = function () {
  138. if (this.check()) {
  139. if (Batch.seItem.active == 1) {
  140. Feng.error("该批次已生效,无需再次操作");
  141. return;
  142. }
  143. var operation = function () {
  144. var ajax = new $ax(Feng.ctxPath + "/batch/setActive", function (data) {
  145. if (data.code == "200") {
  146. Feng.success(data.msg);
  147. Batch.table.refresh();
  148. } else {
  149. Feng.error(data.msg);
  150. }
  151. }, function (data) {
  152. Feng.error("设置生效失败!" + data.responseJSON.message + "!");
  153. });
  154. ajax.set("batchId", Batch.seItem.id);
  155. ajax.start();
  156. };
  157. Feng.confirm("一旦设置生效,该类别其他批次将无效,确认生效吗?", operation);
  158. }
  159. }
  160. Batch.setNotActive = function () {
  161. if (this.check()) {
  162. if (Batch.seItem.active == 2) {
  163. Feng.error("该批次未生效,无需再次操作");
  164. return;
  165. }
  166. var operation = function () {
  167. var ajax = new $ax(Feng.ctxPath + "/batch/setNotActive", function (data) {
  168. if (data.code == "200") {
  169. Feng.success(data.msg);
  170. Batch.table.refresh();
  171. } else {
  172. Feng.error(data.msg);
  173. }
  174. }, function (data) {
  175. Feng.error("设置失效失败!" + data.responseJSON.message + "!");
  176. });
  177. ajax.set("batchId", Batch.seItem.id);
  178. ajax.start();
  179. };
  180. Feng.confirm("确认设置失效吗?", operation);
  181. }
  182. }
  183. $(function () {
  184. var defaultColunms = Batch.initColumn();
  185. var table = new BSTable(Batch.id, "/batch/list", defaultColunms);
  186. table.setPaginationType("server");
  187. Batch.table = table.init();
  188. //下拉框数据动态加载
  189. Feng.addAjaxSelect({
  190. "id": "type",
  191. "displayCode": "code",
  192. "displayName": "name",
  193. "type": "GET",
  194. "url": Feng.ctxPath + "/dict/findChildDictByCode?code=un_project"
  195. });
  196. });