order.js 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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: 'order/order/index' + location.search,
  8. add_url: 'order/order/add',
  9. edit_url: 'order/order/edit',
  10. del_url: 'order/order/del',
  11. multi_url: 'order/order/multi',
  12. import_url: 'order/order/import',
  13. table: '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. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'user.nickname', title: __('用户')},
  29. {field: 'order_on', title: __('Order_on'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  30. {field: 'status', title: __('订单状态'), searchList: {"-1":__('已取消'),"0":__('未支付'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
  31. // {field: 'is_deleted', title: __('Is_deleted'), searchList: {"0":__('Is_deleted 0'),"1":__('Is_deleted 1')}, formatter: Table.api.formatter.normal},
  32. {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. {field: 'type', title: __('购买类型'), searchList: {"0":__('教材'),"1":__('视频')}, formatter: Table.api.formatter.normal},
  34. {field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
  35. {field: 'pay_type', title: __('支付方式'), searchList: {"0":__('微信'),"1":__('支付宝')}, formatter: Table.api.formatter.normal},
  36. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {
  39. field: 'operate',
  40. title: __('Operate'),
  41. table: table,
  42. events: Table.api.events.operate,
  43. formatter: Table.api.formatter.operate,
  44. buttons: [{
  45. name: '订单商品',
  46. text:'订单商品',
  47. title: '订单商品',
  48. classname: 'btn btn-xs btn-primary btn-dialog',
  49. url: 'order.order_goods/index?order_id={id}',
  50. extend: 'data-area=\'["75%","75%"]\'',
  51. callback: function (data) {
  52. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  53. }
  54. },],
  55. }
  56. ]
  57. ]
  58. });
  59. // 为表格绑定事件
  60. Table.api.bindevent(table);
  61. },
  62. add: function () {
  63. Controller.api.bindevent();
  64. },
  65. edit: function () {
  66. Controller.api.bindevent();
  67. },
  68. api: {
  69. bindevent: function () {
  70. Form.api.bindevent($("form[role=form]"));
  71. }
  72. }
  73. };
  74. return Controller;
  75. });