buying.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: 'product/buying/index' + location.search,
  8. table: 'product_buying',
  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. //users,productlists'
  24. {field: 'users.address', title: __('User_id')},
  25. {field: 'productlists.zh_name', title: __('Product_id')},
  26. {field: 'min_price', title: __('Min_price'), operate: false},
  27. {field: 'stock', title: __('Stock')},
  28. {field: 'num', title: __('Num'), operate: false},
  29. {field: 'total_price', title: __('Total_price'), operate:false},
  30. {field: 'status', title: __('Status'), searchList: {0:__('关闭'),1 :__('正常'), 2:__('已出售')}, formatter: Table.api.formatter.status},
  31. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  32. {field: 'operate', title: __('Operate'),
  33. buttons:[
  34. {
  35. classname: 'btn btn-xs btn-info btn-dialog',
  36. name: '出售记录',
  37. text: __('出售记录'),
  38. title: __('出售记录'),
  39. url: 'user/buying/index',
  40. extend:'data-area=["90%","85%"]',
  41. //refresh:true,
  42. },
  43. ],
  44. 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. Controller.api.bindevent();
  53. },
  54. edit: function () {
  55. Controller.api.bindevent();
  56. },
  57. api: {
  58. bindevent: function () {
  59. Form.api.bindevent($("form[role=form]"));
  60. }
  61. }
  62. };
  63. return Controller;
  64. });