second.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'second/index' + location.search,
  8. add_url: 'second/add',
  9. //edit_url: 'second/edit',
  10. del_url: 'second/del',
  11. multi_url: 'second/multi',
  12. import_url: 'second/import',
  13. table: 'second',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'order_number', title: __('序号')},
  26. {field: 'people_id_text', title: __('People_id')},
  27. {field: 'unit_id_text', title: __('Unit_id')},
  28. {field: 'unit_id1', title: __('Unit_id1'), operate: 'LIKE'},
  29. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  30. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  31. {field: 'contents', title: __('Contents'), operate: 'LIKE'},
  32. {field: 'duty', title: __('Duty'), operate: 'LIKE'},
  33. {field: 'rank_id_text', title: __('Post_id')},
  34. {field: 'level_id_text', title: __('Level_id')},
  35. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime},
  36. {field: 'admin_id_text', title: __('创建人')},
  37. {field: 'rejoin', title: __('状态'), searchList: {"0":__('未归队'),"1":__('已归队')}, formatter: Table.api.formatter.normal},
  38. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  39. {
  40. name: '归队',
  41. text: '归队',
  42. title: '归队',
  43. confirm: '确定归队吗?',
  44. classname: 'btn btn-xs btn-info btn-ajax',
  45. icon: 'fa fa-calendar-check-o',
  46. url: 'second/rejoin',
  47. visible:function(row){
  48. if(row.rejoin == 0){
  49. return true;
  50. }
  51. return false;
  52. },
  53. refresh: true
  54. }
  55. ], formatter: Table.api.formatter.operate}
  56. ]
  57. ]
  58. });
  59. // 为表格绑定事件
  60. Table.api.bindevent(table);
  61. },
  62. add: function () {
  63. Controller.api.bindevent();
  64. $("#c-people_id").data("eSelect", function(){
  65. $.get('second/huoq',{id:$("#c-people_id").val()},function(res){
  66. $('#rank_id').val(res.data.rank_id);
  67. $('#level_id').val(res.data.level_id);
  68. $('#duty').val(res.data.duty);
  69. //console.log(res);
  70. });
  71. //后续操作
  72. });
  73. $("#c-people_id").data("params", function (obj) {
  74. var unit_id = $('#J_unitselect').val();
  75. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  76. // return {custom: {unit_id: $("#J_unitselect").val()}};
  77. });
  78. },
  79. // edit: function () {
  80. // Controller.api.bindevent();
  81. // $("#c-people_id").data("eSelect", function(){
  82. // $.get('second/huoq',{id:$("#c-people_id").val()},function(res){
  83. // //console.log(res.data);
  84. // $('#rank_id').val(res.data.rank_id);
  85. // $('#level_id').val(res.data.level_id);
  86. // $('#duty').val(res.data.duty);
  87. // //console.log(res);
  88. // });
  89. // //后续操作
  90. // });
  91. // $("#c-people_id").data("params", function (obj) {
  92. // var unit_id = $('#J_unitselect').val();
  93. // return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  94. // // return {custom: {unit_id: $("#J_unitselect").val()}};
  95. // });
  96. // },
  97. api: {
  98. bindevent: function () {
  99. Form.api.bindevent($("form[role=form]"));
  100. }
  101. }
  102. };
  103. return Controller;
  104. });