duty_bus.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area", ["790px", "300px"]);
  6. Table.api.init({
  7. extend: {
  8. index_url: 'duty_bus/index' + location.search,
  9. add_url: 'duty_bus/add',
  10. edit_url: 'duty_bus/edit',
  11. del_url: 'duty_bus/del',
  12. multi_url: 'duty_bus/multi',
  13. import_url: 'duty_bus/import',
  14. table: 'duty_bus',
  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: __('Id'),operate:false},
  27. {field: 'number', title: __('Number'), operate: 'LIKE'},
  28. {field: 'model_text', title: __('厂牌型号'),operate:false},
  29. {field: 'category', title: __('Category'),operate:false},
  30. {field: 'color', title: __('颜色'),operate:false},
  31. {field: 'status', title: __('Status'),formatter:function(index,row){
  32. if(row.status == 1){
  33. return '<span class="text-success">在位</span>'
  34. }else if(row.status == 2){
  35. return '<span class="text-info">值班</span>'
  36. }else if(row.status == 3){
  37. var str = '<span class="text-danger">出车</span>'
  38. if(row.cause)str+=' <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.cause+'"></i>'
  39. return str;
  40. }else if(row.status == 4){
  41. return '<span class="text-warning">待修</span>'
  42. }
  43. },operate:false},
  44. {field: 'unit_id_text', title: __('车属单位'),operate:false},
  45. {field: 'location', title: __('Location'),operate:false},
  46. {field: 'driver_unit_id_text', title: __('司机单位'),operate:false},
  47. {field: 'driver_id_text', title: __('司机姓名'),operate:false},
  48. {field: 'contact', title: __('司机联系方式'),operate:false},
  49. {field: 'date', title: __('Date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  50. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  51. ]
  52. ]
  53. });
  54. // 为表格绑定事件
  55. Table.api.bindevent(table);
  56. table.on('post-body.bs.table', function () {
  57. $(".btn-editone").data("area", ["790px", "300px"]);
  58. })
  59. },
  60. add: function () {
  61. $(document).on("change", "#c-thebus_id", function(){
  62. $('#c-number').val($('#c-thebus_id_text').val());
  63. var ids = $(this).val();
  64. $.get('thebus/huoq',{ids:ids},function(res){
  65. $('#c-unit_id').val(res.data.unit_id);
  66. $('#c-unit_id').selectpicker('refresh');
  67. $('#c-category').val(res.data.car_type);
  68. $('#c-status').val(res.data.status);
  69. $('#c-status').selectpicker('refresh');
  70. $('#c-location').val(res.data.position);
  71. $('#c-color').val(res.data.vehiclecolor);
  72. $('#c-model').val(res.data.vehiclemodel);
  73. $('#c-model_text').val(res.data.vehiclemodel_text);
  74. });
  75. });
  76. $(document).on('change','#c-driver_id',function(){
  77. var ids = $(this).val();
  78. $('#c-driver_id_texts').val($('#c-driver_id_text').val());
  79. $.get('driver/huoq',{ids:ids},function(res){
  80. $('#c-driver_unit_id').val(res.data.unit_id);
  81. $('#c-contact').val(res.data.contact);
  82. });
  83. });
  84. Controller.api.bindevent();
  85. },
  86. edit: function () {
  87. $(document).on("change", "#c-thebus_id", function(){
  88. $('#c-number').val($('#c-thebus_id_text').val());
  89. var ids = $(this).val();
  90. $.get('thebus/huoq',{ids:ids},function(res){
  91. $('#c-unit_id').val(res.data.unit_id);
  92. $('#c-unit_id').selectpicker('refresh');
  93. $('#c-category').val(res.data.car_type);
  94. $('#c-status').val(res.data.status);
  95. $('#c-status').selectpicker('refresh');
  96. $('#c-location').val(res.data.position);
  97. $('#c-color').val(res.data.vehiclecolor);
  98. $('#c-model').val(res.data.vehiclemodel);
  99. $('#c-model_text').val(res.data.vehiclemodel_text);
  100. });
  101. });
  102. $(document).on('change','#c-driver_id',function(){
  103. var ids = $(this).val();
  104. $('#c-driver_id_texts').val($('#c-driver_id_text').val());
  105. $.get('driver/huoq',{ids:ids},function(res){
  106. $('#c-driver_unit_id').val(res.data.unit_id);
  107. $('#c-contact').val(res.data.contact);
  108. });
  109. });
  110. Controller.api.bindevent();
  111. },
  112. api: {
  113. bindevent: function () {
  114. Form.api.bindevent($("form[role=form]"));
  115. }
  116. }
  117. };
  118. return Controller;
  119. });