synthesis.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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: 'operate', title: __('Operate'),
  40. buttons:[
  41. {
  42. classname: 'btn btn-xs btn-info btn-dialog',
  43. name: '合成记录',
  44. text: __('合成记录'),
  45. title: __('合成记录'),
  46. url: 'user/synthesis/index',
  47. extend:'data-area=["90%","85%"]',
  48. //refresh:true,
  49. },
  50. ],
  51. table: table, events: Table.api.events.operate,
  52. formatter: Table.api.formatter.operate
  53. }
  54. ]
  55. ]
  56. });
  57. // 为表格绑定事件
  58. Table.api.bindevent(table);
  59. $(".btn-add").data("area", ["80%", "80%"]);
  60. table.on('post-body.bs.table', function () {
  61. $('.btn-editone').data("area", ["80%", "80%"]);
  62. });
  63. },
  64. add: function () {
  65. Controller.api.bindevent();
  66. },
  67. edit: function () {
  68. Controller.api.bindevent();
  69. },
  70. api: {
  71. bindevent: function () {
  72. Form.api.bindevent($("form[role=form]"));
  73. }
  74. }
  75. };
  76. return Controller;
  77. });