product_langs.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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/product_langs/index' + location.search,
  8. add_url: 'product/product_langs/add',
  9. edit_url: 'product/product_langs/edit',
  10. del_url: 'product/product_langs/del',
  11. multi_url: 'product/product_langs/multi',
  12. import_url: 'product/product_langs/import',
  13. table: 'product_langs',
  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: 'product_id', title: __('Product_id')},
  27. {field: 'langlist', title: __('Langlist'), searchList: {"zh-cn":__('Langlist zh-cn'),"en":__('Langlist en'),"es":__('Langlist es')}, formatter: Table.api.formatter.normal},
  28. {field: 'title', title: __('Title'), operate: 'LIKE'},
  29. {field: 'synopsis', title: __('Synopsis'), operate: 'LIKE'},
  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. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  33. ]
  34. ]
  35. });
  36. // 为表格绑定事件
  37. Table.api.bindevent(table);
  38. },
  39. recyclebin: function () {
  40. // 初始化表格参数配置
  41. Table.api.init({
  42. extend: {
  43. 'dragsort_url': ''
  44. }
  45. });
  46. var table = $("#table");
  47. // 初始化表格
  48. table.bootstrapTable({
  49. url: 'product/product_langs/recyclebin' + location.search,
  50. pk: 'id',
  51. sortName: 'id',
  52. columns: [
  53. [
  54. {checkbox: true},
  55. {field: 'id', title: __('Id')},
  56. {field: 'title', title: __('Title'), align: 'left'},
  57. {
  58. field: 'deletetime',
  59. title: __('Deletetime'),
  60. operate: 'RANGE',
  61. addclass: 'datetimerange',
  62. formatter: Table.api.formatter.datetime
  63. },
  64. {
  65. field: 'operate',
  66. width: '130px',
  67. title: __('Operate'),
  68. table: table,
  69. events: Table.api.events.operate,
  70. buttons: [
  71. {
  72. name: 'Restore',
  73. text: __('Restore'),
  74. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  75. icon: 'fa fa-rotate-left',
  76. url: 'product/product_langs/restore',
  77. refresh: true
  78. },
  79. {
  80. name: 'Destroy',
  81. text: __('Destroy'),
  82. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  83. icon: 'fa fa-times',
  84. url: 'product/product_langs/destroy',
  85. refresh: true
  86. }
  87. ],
  88. formatter: Table.api.formatter.operate
  89. }
  90. ]
  91. ]
  92. });
  93. // 为表格绑定事件
  94. Table.api.bindevent(table);
  95. },
  96. add: function () {
  97. Controller.api.bindevent();
  98. },
  99. edit: function () {
  100. Controller.api.bindevent();
  101. },
  102. api: {
  103. bindevent: function () {
  104. Form.api.bindevent($("form[role=form]"));
  105. }
  106. }
  107. };
  108. return Controller;
  109. });