hotel_room.js 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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: 'hotel_room/index' + location.search,
  8. add_url: 'hotel_room/add',
  9. edit_url: 'hotel_room/edit',
  10. del_url: 'hotel_room/del',
  11. multi_url: 'hotel_room/multi',
  12. import_url: 'hotel_room/import',
  13. table: 'hotel_room',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'hotel_id', title: __('Hotel_id')},
  29. {field: 'name', title: __('Name'), operate: 'LIKE'},
  30. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  31. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  32. {field: 'original_price', title: __('Original_price'), operate:'BETWEEN'},
  33. {field: 'space', title: __('Space')},
  34. {field: 'floor', title: __('Floor')},
  35. {field: 'is_wifi', title: __('Is_wifi'), searchList: {"1":__('Is_wifi 1'),"0":__('Is_wifi 0')}, formatter: Table.api.formatter.normal},
  36. {field: 'window', title: __('Window'), searchList: {"1":__('Window 1'),"0":__('Window 0')}, formatter: Table.api.formatter.normal},
  37. {field: 'breakfast', title: __('Breakfast'), searchList: {"1":__('Breakfast 1'),"0":__('Breakfast 0')}, formatter: Table.api.formatter.normal},
  38. {field: 'people_num', title: __('People_num')},
  39. {field: 'bad', title: __('Bad'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  40. {field: 'wifi_phone', title: __('Wifi_phone'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  41. {field: 'room_layout', title: __('Room_layout'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  42. {field: 'wash_use', title: __('Wash_use'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  43. {field: 'facility', title: __('Facility'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  44. {field: 'bathroom', title: __('Bathroom'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  45. {field: 'tips', title: __('Tips'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  46. {field: 'cancel_explain', title: __('Cancel_explain'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  47. {field: 'weigh', title: __('Weigh'), operate: false},
  48. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  49. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  50. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  51. {field: 'hotel.name', title: __('Hotel.name'), operate: 'LIKE'},
  52. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  53. ]
  54. ]
  55. });
  56. // 为表格绑定事件
  57. Table.api.bindevent(table);
  58. },
  59. add: function () {
  60. Controller.api.bindevent();
  61. },
  62. edit: function () {
  63. Controller.api.bindevent();
  64. },
  65. api: {
  66. bindevent: function () {
  67. Form.api.bindevent($("form[role=form]"));
  68. }
  69. }
  70. };
  71. return Controller;
  72. });