order_goods.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_goods/index' + location.search,
  8. // add_url: 'order/order_goods/add',
  9. // edit_url: 'order/order_goods/edit',
  10. // del_url: 'order/order_goods/del',
  11. multi_url: 'order/order_goods/multi',
  12. import_url: 'order/order_goods/import',
  13. table: 'order_goods',
  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: 'order_id', title: __('Order_id')},
  27. {field: 'goods_type', title: __('商品类型'), searchList: {"0":__('书籍'),"1":__('视频')}, formatter: Table.api.formatter.normal},
  28. {field: 'goods.title', title: __('商品')},
  29. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  30. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  31. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  32. // {
  33. // field: 'operate',
  34. // title: __('Operate'),
  35. // table: table,
  36. // events: Table.api.events.operate,
  37. // formatter: Table.api.formatter.operate
  38. // }
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. api: {
  52. bindevent: function () {
  53. Form.api.bindevent($("form[role=form]"));
  54. }
  55. }
  56. };
  57. return Controller;
  58. });