integralItemMgr.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /**
  2. * 认定条件管理管理初始化
  3. */
  4. var IntegralItemMgr = {
  5. id: "IntegralItemMgrTable", //表格id
  6. seItem: null, //选中的条目
  7. table: null,
  8. layerIndex: -1
  9. };
  10. /**
  11. * 初始化表格的列
  12. */
  13. IntegralItemMgr.initColumn = function () {
  14. return [
  15. {field: 'selectItem', radio: true},
  16. {title: '人才类别', field: 'type', visible: true, align: 'center', valign: 'middle',
  17. formatter: function (value, row, index) {
  18. if (value == 1) {
  19. return "晋江市现代产业体系人才";
  20. }
  21. if (value == 2) {
  22. return "集成电路优秀人才";
  23. }
  24. }
  25. },
  26. {title: '标准名称', field: 'name', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip'},
  27. {title: '所属项目', field: 'projectName', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip'},
  28. {title: '项目类别', field: 'projectType', visible: true, align: 'center', valign: 'middle',
  29. formatter: function (value, row, index) {
  30. switch (value) {
  31. case 1:
  32. return "基础分";
  33. case 2:
  34. return "贡献分";
  35. case 3:
  36. return "资历分";
  37. }
  38. }
  39. },
  40. {title: '首次积分规则', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip',
  41. formatter: function (value, row, index) {
  42. return "首次达成" + row.fstNeedAmount + row.unit + "可获得" + row.fstGainPoints + "积分";
  43. }
  44. },
  45. {title: '增量积分规则', visible: true, align: 'center', valign: 'middle', 'class': 'uitd_showTip',
  46. formatter: function (value, row, index) {
  47. if (row.stepNeedAmount > 0) {
  48. return "每新增" + row.stepNeedAmount + row.unit + "可获得" + row.stepGainPoints + "积分";
  49. } else {
  50. return "未设置";
  51. }
  52. }
  53. },
  54. {title: '上限设置', field: 'limit', visible: true, align: 'center', valign: 'middle',
  55. formatter: function (value, row, index) {
  56. switch (value) {
  57. case 1:
  58. var limitStr = "上限" + row.max;
  59. switch (row.yearly) {
  60. case 1:
  61. limitStr += "(年度重置)";
  62. break;
  63. case 2:
  64. limitStr += "(不重置)";
  65. break;
  66. }
  67. return "<button type=\"button\" style=\"line-height: 1.3\" class=\"btn btn-primary btn-xs\">" + limitStr + "</button>";
  68. default:
  69. return "<button type=\"button\" style=\"line-height: 1.3\" class=\"btn btn-warning btn-xs\">关闭</button>";
  70. }
  71. }
  72. },
  73. {title: '是否启用', field: 'active', visible: true, align: 'center', valign: 'middle',
  74. formatter: function (value, row, index) {
  75. if (value == 1) {
  76. return "<button type=\"button\" style=\"line-height: 1.3\" class=\"btn btn-primary btn-xs\">启用</button>";
  77. }
  78. if (value == 2) {
  79. return "<button type=\"button\" style=\"line-height: 1.3\" class=\"btn btn-warning btn-xs\">停用</button>";
  80. }
  81. }
  82. }
  83. ];
  84. };
  85. /**
  86. * 检查是否选中
  87. */
  88. IntegralItemMgr.check = function () {
  89. var selected = $('#' + this.id).bootstrapTable('getSelections');
  90. if (selected.length == 0) {
  91. Feng.info("请先选中表格中的某一记录!");
  92. return false;
  93. } else {
  94. IntegralItemMgr.seItem = selected[0];
  95. return true;
  96. }
  97. };
  98. /**
  99. * 点击添加积分项目
  100. */
  101. IntegralItemMgr.openAddIntegralItem = function () {
  102. var index = layer.open({
  103. type: 2,
  104. title: '添加积分标准',
  105. area: ['1126px', '420px'], //宽高
  106. fix: false, //不固定
  107. maxmin: true,
  108. content: Feng.ctxPath + '/admin/integral_mgr/addItem'
  109. });
  110. this.layerIndex = index;
  111. };
  112. /**
  113. * 打开编辑积分项目
  114. */
  115. IntegralItemMgr.openEditIntegralItem = function () {
  116. if (this.check()) {
  117. var index = layer.open({
  118. type: 2,
  119. title: '编辑积分标准',
  120. area: ['1126px', '420px'], //宽高
  121. fix: false, //不固定
  122. maxmin: true,
  123. content: Feng.ctxPath + '/admin/integral_mgr/editItem/id/' + IntegralItemMgr.seItem.id
  124. });
  125. this.layerIndex = index;
  126. }
  127. };
  128. /**
  129. * 删除积分项目
  130. */
  131. IntegralItemMgr.delete = function () {
  132. if (this.check()) {
  133. var operation = function () {
  134. var ajax = new $ax(Feng.ctxPath + "/admin/integral_mgr/deleteItem/id/", function (data) {
  135. Feng.success("删除成功!");
  136. IntegralItemMgr.table.refresh();
  137. }, function (data) {
  138. Feng.error("删除失败!" + data.responseJSON.message + "!");
  139. });
  140. ajax.set("id", IntegralItemMgr.seItem.id);
  141. ajax.start();
  142. }
  143. Feng.confirm("是否刪除该积分标准?", operation);
  144. }
  145. };
  146. /**
  147. * 查询表单提交参数对象
  148. * @returns {{}}
  149. */
  150. IntegralItemMgr.formParams = function () {
  151. var queryData = {};
  152. queryData['type'] = $("#type").val();
  153. queryData['name'] = $("#name").val();
  154. queryData['projectType'] = $("#projectType").val();
  155. queryData['active'] = $("#active").val();
  156. return queryData;
  157. }
  158. /**
  159. * 查询认定条件管理列表
  160. */
  161. IntegralItemMgr.search = function () {
  162. IntegralItemMgr.table.refresh({query: IntegralItemMgr.formParams()});
  163. };
  164. /**
  165. * 重置
  166. */
  167. IntegralItemMgr.reset = function () {
  168. $("#type").val("");
  169. $("#name").val("");
  170. $("#projectType").val("");
  171. $("#active").val("");
  172. }
  173. //回调
  174. IntegralItemMgr.callBack = function (data) {
  175. Feng.info(data.msg);
  176. if (data.code == 200) {
  177. $("#importModal").modal("hide");
  178. IntegralItemMgr.table.refresh();
  179. }
  180. }
  181. $(function () {
  182. var defaultColunms = IntegralItemMgr.initColumn();
  183. var table = new BSTable(IntegralItemMgr.id, "/admin/integral_mgr/itemList", defaultColunms);
  184. table.setPaginationType("server");
  185. IntegralItemMgr.table = table.init();
  186. });