synthesis.js 3.4 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/synthesis/index' + location.search,
  8. add_url: 'product/synthesis/add',
  9. edit_url: 'product/synthesis/edit',
  10. del_url: 'product/synthesis/del',
  11. multi_url: 'product/synthesis/multi',
  12. import_url: 'product/synthesis/import',
  13. table: 'product_synthesis',
  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: 'productlists.zh_name', title: __('Product_id')},
  29. {field: 'title', title: __('Title')},
  30. {field: 'announcement.title', title: __('导读信息'), operate: false}, //announcement, productLists'
  31. {field: 'to_lang', title: __('To_lang'), operate: false, searchList: {'zh':__('中文'), 'en':__('英文')}, formatter: Table.api.formatter.flag},
  32. {field: 'stock', title: __('发行数量'), operate: false},
  33. {field: 'num', title: __('流通数量'), operate: false},
  34. {field: 'weigh', title: __('Weigh'), operate: false},
  35. {field: 'status', title: __('Status'), searchList: {"1":__('上架'),"0":__('下架')}, formatter: Table.api.formatter.toggle},
  36. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  41. ]
  42. ]
  43. });
  44. // 为表格绑定事件
  45. Table.api.bindevent(table);
  46. $(".btn-add").data("area", ["80%", "80%"]);
  47. table.on('post-body.bs.table', function () {
  48. $('.btn-editone').data("area", ["80%", "80%"]);
  49. });
  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. });