thebus.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["1000px","650px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'thebus/index' + location.search,
  9. add_url: 'thebus/add',
  10. edit_url: 'thebus/edit',
  11. del_url: 'thebus/del',
  12. multi_url: 'thebus/multi',
  13. import_url: 'thebus/import',
  14. table: 'thebus',
  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: 'st', title: __('状态'),operate:false,formatter:function(index,row){
  27. if(row.status == 1){
  28. return '<i class="fa fa-circle text-success"></i>'
  29. }else if(row.status == 2){
  30. return '<i class="fa fa-circle text-info"></i>'
  31. }else if(row.status == 3){
  32. return '<i class="fa fa-circle text-danger"></i>'
  33. }else if(row.status == 4){
  34. return '<i class="fa fa-circle text-warning"></i>'
  35. }
  36. }},
  37. {field: 'order_number', title: __('Id')},
  38. {field: 'vehiclenumber', title: __('Vehiclenumber'), operate: false},
  39. {field: 'vehiclemodel', title: __('Vehiclemodel'), searchList: $.getJSON('category/searchlist?type=motorcycle_type'),visible:false},
  40. {field: 'vehiclemodel_text', title: __('Vehiclemodel'), operate: false},
  41. {field: 'people_id', title: __('车辆负责人'), operate: false,visible:false},
  42. {field: 'people_id_text', title: __('车辆负责人'), operate: false},
  43. {field: 'unit_id_text', title: __('车属单位'), operate: false},
  44. // {field: 'parkingspacenumber', title: __('Parkingspacenumber'), operate: false},
  45. {field: 'contactnumber', title: __('Contactnumber'), operate: false},
  46. {field: 'engine_number', title: __('发动机号'), operate: false},
  47. {field: 'frame_number', title: __('车架号'), operate: false},
  48. {field: 'source', title: __('车辆来源'), operate: false},
  49. {field: 'vehiclecolor', title: __('Vehiclecolor'), operate: false},
  50. {field: 'date1', title: __('出厂日期'), operate: false},
  51. {field: 'status', title: __('车辆状态'),formatter:function(index,row){
  52. if(row.status == 1){
  53. return '<span class="text-success">在位</span>'
  54. }else if(row.status == 2){
  55. return '<span class="text-info">值班</span>'
  56. }else if(row.status == 3){
  57. var str = '<span class="text-danger">出车</span>'
  58. if(row.cause)str+=' <i class="fa fa-commenting-o" data-toggle="tooltip" data-original-title="'+row.cause+'"></i>'
  59. return str;
  60. }else if(row.status == 4){
  61. return '<span class="text-warning">待修</span>'
  62. }
  63. }},
  64. // {field: 'etc_brand', title: __('ETC品牌'), operate: false},
  65. // {field: 'etc_number', title: __('ETC编码'), operate: false},
  66. {field: 'position', title: __('所在位置'), operate: false},
  67. {field: 'is_listing', title: __('是否挂牌'), operate: false},
  68. {field: 'seat_count', title: __('固定座位数')},
  69. // {field: 'remarks', title: __('Remarks'), operate: false},
  70. {field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  71. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  72. ]
  73. ]
  74. });
  75. // 为表格绑定事件
  76. Table.api.bindevent(table);
  77. table.on('post-body.bs.table',function(){
  78. $(".btn-editone").data("area",["1000px","650px"]);
  79. })
  80. },
  81. index2: function () {
  82. $(".btn-add").data("area",["1000px","650px"]);
  83. // 初始化表格参数配置
  84. Table.api.init({
  85. extend: {
  86. index_url: 'thebus/index2' + location.search,
  87. add_url: 'thebus/add',
  88. edit_url: 'thebus/edit',
  89. del_url: 'thebus/del',
  90. multi_url: 'thebus/multi',
  91. import_url: 'thebus/import',
  92. table: 'thebus',
  93. }
  94. });
  95. var table = $("#table");
  96. // 初始化表格
  97. table.bootstrapTable({
  98. url: $.fn.bootstrapTable.defaults.extend.index_url,
  99. pk: 'id',
  100. sortName: 'id',
  101. columns: [
  102. [
  103. {checkbox: true},
  104. {field: 'order_number', title: __('Id'), operate: false},
  105. {field: 'unit_id_text', title: __('单位'), operate: false},
  106. {field: 'people_id_text', title: __('人员'), operate: false},
  107. {field: 'model', title: __('车辆型号'), operate: false},
  108. {field: 'app_unit_id_text', title: __('用车人员单位'), operate: false},
  109. {field: 'app_people_id_text', title: __('用车人员姓名'), operate: false},
  110. {field: 'contact', title: __('用车人员联系方式'), operate: false},
  111. {field: 'cause', title: __('事由'), operate: false},
  112. {field: 'route', title: __('出车路线'), operate: false},
  113. {field: 'outstatus', title: __('出车状态'),formatter:function(index,row){
  114. if(row.outstatus == 1){
  115. return '<span class="text-success">已出车</span>'
  116. }else if(row.outstatus == 0){
  117. return '未出车'
  118. }
  119. },searchList:{0:'未出车',1:'已出车'},defaultValue:''},
  120. {field: 'outtime', title: __('出车时间'),formatter:Table.api.formatter.datetime, operate: false},
  121. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons: [
  122. {
  123. name: '出车',
  124. text: '出车',
  125. title: '选择司机',
  126. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  127. icon: 'fa fa-automobile',
  128. extend: 'data-area=\'["800px","50%"]\'',
  129. refresh: true,
  130. visible:function(row){
  131. if(row.outstatus != 1)return true;
  132. return false;
  133. },
  134. url:'thebus_apply/outbus'
  135. },
  136. {
  137. name: '查看',
  138. text: '查看',
  139. title: '查看',
  140. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  141. icon: 'fa fa-automobile',
  142. extend: 'data-area=\'["800px","50%"]\'',
  143. refresh: true,
  144. visible:function(row){
  145. if(row.outstatus != 0)return true;
  146. return false;
  147. },
  148. url:'thebus_apply/details'
  149. }
  150. ]}
  151. ]
  152. ]
  153. });
  154. // 为表格绑定事件
  155. Table.api.bindevent(table);
  156. table.on('post-body.bs.table',function(){
  157. $(".btn-editone").data("area",["1000px","650px"]);
  158. })
  159. },
  160. add: function () {
  161. Controller.api.bindevent();
  162. $("#c-people_id").data("eSelect", function(){
  163. $.get('duty_basic/huoq',{id:$("#c-people_id").val()},function(res){
  164. $('#c-contactnumber').val(res.data.phone);
  165. });
  166. //后续操作
  167. });
  168. },
  169. edit: function () {
  170. Controller.api.bindevent();
  171. $("#c-people_id").data("eSelect", function(){
  172. $.get('duty_basic/huoq',{id:$("#c-people_id").val()},function(res){
  173. $('#c-contactnumber').val(res.data.phone);
  174. });
  175. //后续操作
  176. });
  177. },
  178. api: {
  179. bindevent: function () {
  180. Form.api.bindevent($("form[role=form]"));
  181. }
  182. }
  183. };
  184. return Controller;
  185. });