duty.js 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area",["920px","480px"]);
  6. // $(".btn-edit").data("area",["860px","70%"]);
  7. Table.api.init({
  8. extend: {
  9. index_url: 'duty/index' + location.search,
  10. add_url: 'duty/add',
  11. edit_url: 'duty/edit',
  12. del_url: 'duty/del',
  13. multi_url: 'duty/multi',
  14. import_url: 'duty/import',
  15. table: 'duty',
  16. }
  17. });
  18. var table = $("#table");
  19. // 初始化表格
  20. table.bootstrapTable({
  21. url: $.fn.bootstrapTable.defaults.extend.index_url,
  22. pk: 'id',
  23. sortName: 'id',
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'order_number', title: __('序号'),operate:false},
  28. //{field: 'unit_id_text', title: __('Unit_id'),operate:false},
  29. {field: 'duty_roster_time', title: __('duty_roster_time'), operate:'=', addclass:'datepicker', autocomplete:false},
  30. {field: 'people_id', title: __('People_id'),operate:false},
  31. //{field: 'post_id', title: __('Post_id')},
  32. //{field: 'office_phone', title: __('Office_phone'), operate:false},
  33. //{field: 'dormitory_phone', title: __('Dormitory_phone'), operate: 'LIKE'},
  34. //{field: 'mobile_phone', title: __('Mobile_phone'), operate: 'LIKE'},
  35. {field: 'people_id1', title: __('People_id1'),operate:false},
  36. //{field: 'post_id1', title: __('Post_id1')},
  37. //{field: 'office_phone1', title: __('Office_phone1'),operate:false},
  38. //{field: 'mobile_phone1', title: __('Mobile_phone1'), operate: 'LIKE'},
  39. //{field: 'unit_id1', title: __('Unit_id1'),operate:false},
  40. {field: 'team1', title: __('Team1'),operate:false},
  41. {field: 'team2', title: __('Team2'),operate:false},
  42. {field: 'team3', title: __('Team3'),operate:false},
  43. //{field: 'team_number1', title: __('Team_number1')},
  44. //{field: 'team_number2', title: __('Team_number2')},
  45. //{field: 'team_number3', title: __('Team_number3')},
  46. {field: 'createtime', title: __('Createtime'),operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  47. //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  48. //{field: 'field1', title: __('Field1'), operate: 'LIKE'},
  49. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  50. ]
  51. ]
  52. });
  53. // 为表格绑定事件
  54. Table.api.bindevent(table);
  55. table.on('post-body.bs.table',function(){
  56. $(".btn-editone").data("area",["920px","480px"]);
  57. })
  58. $('.J_list').click(function(){
  59. var container = $("#table").data("bootstrap.table").$container;
  60. var options = $("#table").bootstrapTable('getOptions');
  61. //这里我们手动将数据填充到表单然后提交
  62. $("form.form-commonsearch [name='duty_roster_time']", container).val($(this).data('statusdata'));
  63. $("form.form-commonsearch", container).trigger('submit');
  64. });
  65. },
  66. add: function () {
  67. Controller.api.bindevent();
  68. $("#c-people_id").data("eSelect", function(){
  69. $.get('duty/huoq',{id:$("#c-people_id").val()},function(res){
  70. $('#c-post_id').val(res.data.post_id);
  71. $('#c-post_id').selectPageRefresh();
  72. });
  73. //后续操作
  74. });
  75. $("#c-people_id1").data("eSelect", function(){
  76. $.get('duty/huoq',{id:$("#c-people_id1").val()},function(res){
  77. $('#c-post_id1').val(res.data.post_id);
  78. $('#c-post_id1').selectPageRefresh();
  79. });
  80. //后续操作
  81. });
  82. },
  83. edit: function () {
  84. Controller.api.bindevent();
  85. },
  86. api: {
  87. bindevent: function () {
  88. Form.api.bindevent($("form[role=form]"));
  89. }
  90. }
  91. };
  92. return Controller;
  93. });