soldier.js 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["980px","660px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'soldier/index' + location.search,
  9. add_url: 'soldier/add',
  10. edit_url: 'soldier/edit',
  11. del_url: 'soldier/del',
  12. multi_url: 'soldier/multi',
  13. import_url: 'soldier/import',
  14. table: 'soldier',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'order_number', title: __('序号')},
  27. {field: 'unit_id_text', title: __('单位')},
  28. {field: 'convoke_time', title: __('Convoke_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  29. {field: 'address', title: __('Address'), operate: 'LIKE'},
  30. {field: 'compere_id_text', title: __('Compere_id')},
  31. {field: 'join_id_text', title: __('Join_id'), operate: 'LIKE'},
  32. {field: 'people_ids_text', title: __('People_ids'), operate: 'LIKE'},
  33. {field: 'absent_ids_text', title: __('Absent_ids'), operate: 'LIKE'},
  34. {field: 'people_id_text', title: __('People_id')},
  35. {field: 'title', title: __('Title'), operate: 'LIKE'},
  36. //{field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. //{field: 'updatetime', title: __('Updatetime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  39. {
  40. name: '查看',
  41. text: '查看',
  42. title: '查看',
  43. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  44. icon: 'fa fa-search',
  45. url: 'soldier/details',
  46. refresh: true
  47. }
  48. ], formatter: Table.api.formatter.operate}
  49. ]
  50. ]
  51. });
  52. // 为表格绑定事件
  53. Table.api.bindevent(table);
  54. table.on('post-body.bs.table',function(){
  55. $(".btn-editone").data("area",["980px","660px"]);
  56. })
  57. },
  58. add: function () {
  59. Controller.api.bindevent();$("#c-people_id,#c-compere_id,#c-join_id,#c-people_ids,#c-absent_ids").data("params", function (obj) {
  60. var unit_id = $('#J_unitselect').val();
  61. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  62. });
  63. },
  64. edit: function () {
  65. Controller.api.bindevent();
  66. $("#c-people_id,#c-compere_id,#c-join_id,#c-people_ids,#c-absent_ids").data("params", function (obj) {
  67. var unit_id = $('#J_unitselect').val();
  68. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  69. });
  70. },
  71. api: {
  72. bindevent: function () {
  73. Form.api.bindevent($("form[role=form]"));
  74. }
  75. }
  76. };
  77. return Controller;
  78. });