order.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: 'user_type', title: __("用户类型"),
  33. searchList: {0:__('假人'), 1:__('真人')},
  34. formatter: Table.api.formatter.status
  35. },
  36. {field: 'note', title: __('Note'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  37. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'operate', title: __('Operate'),
  40. table: table,
  41. buttons: [{
  42. name: "operate",
  43. text: __('Operate'),
  44. classname: 'btn btn-xs btn-danger btn-magic btn-dialog',
  45. url: 'trade/order/operate',
  46. visible: function (row) {
  47. if(row.status == 0 && parseFloat(row.users.balance) >= parseFloat(row.amount)){
  48. return true;
  49. }
  50. return false;
  51. }
  52. }],
  53. events: Table.api.events.operate, formatter: Table.api.formatter.operate
  54. }
  55. ]
  56. ]
  57. });
  58. // 为表格绑定事件
  59. Table.api.bindevent(table);
  60. },
  61. operate: function () {
  62. Controller.api.bindevent();
  63. },
  64. api: {
  65. bindevent: function () {
  66. Form.api.bindevent($("form[role=form]"));
  67. }
  68. }
  69. };
  70. return Controller;
  71. });