preorder.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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: 'preorder/index' + location.search,
  8. add_url: 'preorder/add',
  9. // edit_url: 'preorder/edit',
  10. // del_url: 'preorder/del',
  11. multi_url: 'preorder/multi',
  12. import_url: 'preorder/import',
  13. table: 'pre_order',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. search:false,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. {field: 'id', title: __('Id')},
  29. {field: 'pre_order_no', title: __('Pre_order_no'), operate: 'LIKE'},
  30. {field: 'pre_order_status', title: __('Pre_order_status'), searchList: {"0":__('Pre_order_status 0'),"1":__('Pre_order_status 1'),"2":__('Pre_order_status 2')}, formatter: Table.api.formatter.status},
  31. {field: 'company_id', title: __('Company_id')},
  32. {field: 'company.name', title: __('Company.name'), operate: 'LIKE'},
  33. {field: 'user_id', title: __('User_id')},
  34. // {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  35. // {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
  36. {field: 'name', title: __('Name'), operate: 'LIKE'},
  37. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  38. {field: 'address', title: __('Address'), operate: 'LIKE'},
  39. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  40. // {field: 'car_id', title: __('Car_id')},
  41. {field: 'car_number', title: __('Car_number'), operate: 'LIKE'},
  42. // {field: 'servicetype_id', title: __('Servicetype_id')},
  43. {field: 'servicetype.title', title: __('Servicetype.title'), operate: 'LIKE'},
  44. {field: 'pre_time', title: __('Pre_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  45. // {field: 'order_id', title: __('Order_id')},
  46. {field: 'order_time', title: __('Order_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  47. {field: 'order.orderno', title: __('Order.orderno'), operate: 'LIKE'},
  48. {field: 'cancel_time', title: __('Cancel_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  49. {field: 'cancel_reason', title: __('Cancel_reason'), operate: 'LIKE'},
  50. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  51. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  52. {field: 'operate', title: __('Operate'), table: table,
  53. buttons:[
  54. {
  55. name:'cancel',
  56. text:'取消预约',
  57. title:'取消预约',
  58. icon:'fa fa-exclamation-circle',
  59. classname:'btn btn-xs btn-info btn-dialog',
  60. extend: 'data-area=["80%","80%"]',
  61. url:'preorder/cancel/id/{ids}?dialog=1',
  62. target:'_self',
  63. hidden:function($row){
  64. if($row.pre_order_status == 1){
  65. return false;
  66. }
  67. return true;
  68. }
  69. },
  70. {
  71. name:'submitorder',
  72. text:'立即开单',
  73. title:'立即开单',
  74. icon:'fa fa-exclamation-circle',
  75. classname:'btn btn-xs btn-info btn-dialog',
  76. extend: 'data-area=["80%","80%"]',
  77. url:'preorder/submitorder/id/{ids}?dialog=1',
  78. target:'_self',
  79. hidden:function($row){
  80. if($row.pre_order_status == 1){
  81. return false;
  82. }
  83. return true;
  84. }
  85. },
  86. ],
  87. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  88. ]
  89. ]
  90. });
  91. // 为表格绑定事件
  92. Table.api.bindevent(table);
  93. },
  94. add: function () {
  95. Controller.api.bindevent();
  96. },
  97. edit: function () {
  98. Controller.api.bindevent();
  99. },
  100. cancel: function () {
  101. Controller.api.bindevent();
  102. },
  103. submitorder: function () {
  104. Controller.api.bindevent();
  105. },
  106. api: {
  107. bindevent: function () {
  108. Form.api.bindevent($("form[role=form]"));
  109. }
  110. }
  111. };
  112. return Controller;
  113. });