lave.js 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: 'lave/index' + location.search,
  8. add_url: 'lave/add',
  9. edit_url: 'lave/edit',
  10. del_url: 'lave/del',
  11. multi_url: 'lave/multi',
  12. import_url: 'lave/import',
  13. table: 'lave',
  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: 'id', title: __('Id')},
  26. {field: 'cid', title: __('Cid')},
  27. {field: 'user_id', title: __('User_id')},
  28. {field: 'order_id', title: __('Order_id'), operate: 'LIKE'},
  29. {field: 'order_name', title: __('Order_name'), operate: 'LIKE'},
  30. {field: 'category_id', title: __('Category_id')},
  31. {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
  32. {field: 'name', title: __('Name'), operate: 'LIKE'},
  33. {field: 'contact', title: __('Contact'), operate: 'LIKE'},
  34. {field: 'tel', title: __('Tel'), operate: 'LIKE'},
  35. {field: 'address', title: __('Address'), operate: 'LIKE'},
  36. {field: 'is_open', title: __('Is_open'), searchList: {"0":__('Is_open 0'),"1":__('Is_open 1')}, formatter: Table.api.formatter.normal},
  37. {field: 'is_ticket', title: __('Is_ticket'), searchList: {"0":__('Is_ticket 0'),"1":__('Is_ticket 1')}, formatter: Table.api.formatter.normal},
  38. {field: 'paid', title: __('Paid'), searchList: {"0":__('Paid 0'),"1":__('Paid 1')}, formatter: Table.api.formatter.normal},
  39. {field: 'pay_type', title: __('Pay_type'), searchList: {"0":__('Pay_type 0'),"1":__('Pay_type 1'),"2":__('Pay_type 2'),"3":__('Pay_type 3'),"4":__('Pay_type 4')}, formatter: Table.api.formatter.normal},
  40. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41. {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42. {field: 'SN', title: __('Sn'), operate: 'LIKE'},
  43. {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1')}, formatter: Table.api.formatter.normal},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  45. ]
  46. ]
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. },
  51. add: function () {
  52. $("#c-user_id").data("params", function (obj) {
  53. return {custom: {cid: $("#c-cid").val()}};
  54. });
  55. Controller.api.bindevent();
  56. },
  57. edit: function () {
  58. $("#c-user_id").data("params", function (obj) {
  59. return {custom: {cid: $("#c-cid").val()}};
  60. });
  61. Controller.api.bindevent();
  62. },
  63. api: {
  64. bindevent: function () {
  65. Form.api.bindevent($("form[role=form]"));
  66. }
  67. }
  68. };
  69. return Controller;
  70. });