order.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: 'trade/order/index' + location.search,
  8. table: 'order',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'id',
  16. sortName: 'id',
  17. fixedColumns: true,
  18. fixedRightNumber: 1,
  19. columns: [
  20. [
  21. {checkbox: true},
  22. {field: 'id', title: __('Id')},
  23. {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
  24. {field: 'users.mobile', title: __('User_id')},
  25. {field: 'title', title: __('Title'), operate: 'LIKE'},
  26. {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
  27. {field: 'bonus', title: __('Bonus'), operate:'BETWEEN'},
  28. {field: 'status', title: __("Status"),
  29. searchList: {0:__('Unpaid'), 1:__('Finish'), 2:__('Freeze'), 3:__('Cancel')},
  30. formatter: Table.api.formatter.status
  31. },
  32. {field: 'note', title: __('Note'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  33. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'operate', title: __('Operate'),
  36. table: table,
  37. buttons: [{
  38. name: "operate",
  39. text: __('Operate'),
  40. classname: 'btn btn-xs btn-danger btn-magic btn-dialog',
  41. url: 'trade/order/operate',
  42. visible: function (row) {
  43. if(row.status == 0 && parseFloat(row.users.balance) >= parseFloat(row.amount)){
  44. return true;
  45. }
  46. return false;
  47. }
  48. }],
  49. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  50. }
  51. ]
  52. ]
  53. });
  54. // 为表格绑定事件
  55. Table.api.bindevent(table);
  56. },
  57. operate: function () {
  58. Controller.api.bindevent();
  59. },
  60. api: {
  61. bindevent: function () {
  62. Form.api.bindevent($("form[role=form]"));
  63. }
  64. }
  65. };
  66. return Controller;
  67. });