driver.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: 'driver/index' + location.search,
  8. add_url: 'driver/add',
  9. edit_url: 'driver/edit',
  10. del_url: 'driver/del',
  11. multi_url: 'driver/multi',
  12. import_url: 'driver/import',
  13. table: 'driver',
  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: __('序号'),operate:false},
  26. {field: 'unit_id', title: __('Unit_id'),visible:false, searchList: $.getJSON("unit/index?lists=1")},
  27. {field: 'unit_id_text', title: __('Unit_id'),operate:false},
  28. {field: 'people_id', title: __('姓名'),visible:false,operate:false},
  29. {field: 'people_id_text', title: __('姓名'),operate:false},
  30. {field: 'contact', title: __('Contact'),operate:false},
  31. {field: 'drivers_license', title: __('Drivers_license'),operate:false},
  32. {field: 'birth_date', title: __('出生日期'),operate:false},
  33. {field: 'enlist_date', title: __('Enlist_date'),operate:false},
  34. {field: 'sex_list', title: __('Sex_list'), searchList: {"男":__('男'),"女":__('女')}, formatter: Table.api.formatter.normal},
  35. {field: 'rank_id', title: __('Rank_id'),visible:false,operate:false},
  36. {field: 'rank_id_text', title: __('Rank_id'),operate:false},
  37. {field: 'driving_age', title: __('Driving_age'),operate:false},
  38. {field: 'driving_model', title: __('Driving_model'),operate:false},
  39. {field: 'date1', title: __('Date1'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  40. {field: 'date2', title: __('Date2'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  41. {field: 'date3', title: __('Date3'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  42. {field: 'result', title: __('Result'), operate: 'LIKE'},
  43. {field: 'vocational_skills', title: __('Vocational_skills'), operate: 'LIKE'},
  44. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  45. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  46. ]
  47. ]
  48. });
  49. // 为表格绑定事件
  50. Table.api.bindevent(table);
  51. },
  52. add: function () {
  53. Controller.api.bindevent();
  54. $("#c-people_id").data("params", function (obj) {
  55. return {custom: {unit_id: $("#c-unit_id").val()}};
  56. });
  57. $(document).on("change", "#c-people_id", function(){
  58. $.get('people/huoq',{'id':$(this).val()},function(res){
  59. $('#c-contact').val(res.data.phone);
  60. $('#c-birth_date').val(res.data.birth_date);
  61. $('#c-enlist_date').val(res.data.enlist_date);
  62. $('#c-rank_id').val(res.data.rank_id);
  63. $('#c-rank_id').selectPageRefresh();
  64. $('#c-sex_list').val(res.data.sex_list);
  65. $('#c-sex_list').selectpicker('refresh');
  66. });
  67. });
  68. },
  69. edit: function () {
  70. Controller.api.bindevent();
  71. $("#c-people_id").data("params", function (obj) {
  72. return {custom: {unit_id: $("#c-unit_id").val()}};
  73. });
  74. $(document).on("change", "#c-people_id", function(){
  75. $.get('people/huoq',{'id':$(this).val()},function(res){
  76. $('#c-contact').val(res.data.phone);
  77. $('#c-birth_date').val(res.data.birth_date);
  78. $('#c-enlist_date').val(res.data.enlist_date);
  79. $('#c-rank_id').val(res.data.rank_id);
  80. $('#c-rank_id').selectPageRefresh();
  81. $('#c-sex_list').val(res.data.sex_list);
  82. $('#c-sex_list').selectpicker('refresh');
  83. });
  84. });
  85. },
  86. api: {
  87. bindevent: function () {
  88. Form.api.bindevent($("form[role=form]"));
  89. }
  90. }
  91. };
  92. return Controller;
  93. });