duty_basic.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area", ["768px", "410px"]);
  6. Table.api.init({
  7. extend: {
  8. index_url: 'duty_basic/index' + location.search,
  9. add_url: 'duty_basic/add',
  10. edit_url: 'duty_basic/edit',
  11. del_url: 'duty_basic/del',
  12. multi_url: 'duty_basic/multi',
  13. import_url: 'duty_basic/import',
  14. table: 'duty_basic',
  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: __('Unit_id'), operate: 'LIKE'},
  28. {field: 'people_id_text', title: __('People_id'), operate: 'LIKE'},
  29. {field: 'post_id_text', title: __('Post_id'), operate: 'LIKE'},
  30. {field: 'office_phone', title: __('Office_phone'), operate: 'LIKE'},
  31. {field: 'dormitory_phone', title: __('Dormitory_phone'), operate: 'LIKE'},
  32. {field: 'mobile_phone', title: __('Mobile_phone'), operate: 'LIKE'},
  33. {field: 'people_id1_text', title: __('People_id1'), operate: 'LIKE'},
  34. {field: 'post_id1_text', title: __('Post_id1'), operate: 'LIKE'},
  35. {field: 'unit_id1_text', title: __('Unit_id1')},
  36. //{field: 'statusdata', title: __('Statusdata'), searchList: {"当日值班":__('当日值班'),"次日值班":__('次日值班')}, formatter: Table.api.formatter.normal},
  37. //{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'duty_roster_time', title: __('Duty_roster_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  39. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  45. table.on('post-body.bs.table', function () {
  46. $(".btn-editone").data("area", ["768px", "410px"]);
  47. })
  48. $('.J_list').click(function(){
  49. var container = $("#table").data("bootstrap.table").$container;
  50. var options = $("#table").bootstrapTable('getOptions');
  51. //这里我们手动将数据填充到表单然后提交
  52. $("form.form-commonsearch [name='duty_roster_time']", container).val($(this).data('statusdata'));
  53. $("form.form-commonsearch", container).trigger('submit');
  54. });
  55. },
  56. add: function () {
  57. Controller.api.bindevent();
  58. $("#c-people_id").data("eSelect", function(){
  59. $.get('duty_basic/huoq',{id:$("#c-people_id").val()},function(res){
  60. $('#c-post_id').val(res.data.post_id);
  61. $('#c-post_id').selectPageRefresh();
  62. });
  63. //后续操作
  64. });
  65. $("#c-people_id1").data("eSelect", function(){
  66. $.get('duty_basic/huoq',{id:$("#c-people_id1").val()},function(res){
  67. $('#c-post_id1').val(res.data.post_id);
  68. $('#c-post_id1').selectPageRefresh();
  69. });
  70. //后续操作
  71. });
  72. },
  73. edit: function () {
  74. Controller.api.bindevent();
  75. },
  76. api: {
  77. bindevent: function () {
  78. Form.api.bindevent($("form[role=form]"));
  79. }
  80. }
  81. };
  82. return Controller;
  83. });