category_langs.js 4.6 KB

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