goods.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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: 'goods/index' + location.search,
  8. add_url: 'goods/add',
  9. edit_url: 'goods/edit',
  10. del_url: 'goods/del',
  11. multi_url: 'goods/multi',
  12. import_url: 'goods/import',
  13. table: 'goods',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'spu_id', title: __('Spu_id'), operate: 'LIKE'},
  29. {field: 'category_id', title: __('Category_id')},
  30. {field: 'category.name', title: __('分类名称'), operate: 'LIKE'},
  31. {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  32. {field: 'primary_image', title: __('Primary_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  33. {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  34. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  35. {field: 'spu_stock_quantity', title: __('Spu_stock_quantity')},
  36. {field: 'sold_num', title: __('Sold_num')},
  37. {field: 'weigh', title: __('Weigh'), operate: false},
  38. {field: 'is_put_on_sale_switch', title: __('Is_put_on_sale_switch'), searchList: {"1":__('Yes'),"0":__('No')}, table: table, formatter: Table.api.formatter.toggle},
  39. {field: 'is_available_switch', title: __('Is_available_switch'), searchList: {"0":__('Is_available_switch 0'),"1":__('Is_available_switch 1')}, table: table, formatter: Table.api.formatter.toggle},
  40. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  41. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  43. ]
  44. ]
  45. });
  46. // 为表格绑定事件
  47. Table.api.bindevent(table);
  48. },
  49. add: function () {
  50. Controller.api.bindevent();
  51. },
  52. edit: function () {
  53. Controller.api.bindevent();
  54. },
  55. api: {
  56. bindevent: function () {
  57. Form.api.bindevent($("form[role=form]"));
  58. }
  59. }
  60. };
  61. return Controller;
  62. });