You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.7 KiB

  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: 'qa/index' + location.search,
  8. add_url: 'qa/add',
  9. edit_url: 'qa/edit',
  10. del_url: 'qa/del',
  11. multi_url: 'qa/multi',
  12. table: 'qa',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'title', title: __('商品')},
  26. {field: 'question', title: __('Question')},
  27. {field: 'answer', title: __('Answer')},
  28. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  29. ]
  30. ]
  31. });
  32. // 为表格绑定事件
  33. Table.api.bindevent(table);
  34. },
  35. add: function () {
  36. Controller.api.bindevent();
  37. },
  38. edit: function () {
  39. Controller.api.bindevent();
  40. },
  41. api: {
  42. bindevent: function () {
  43. Form.api.bindevent($("form[role=form]"));
  44. }
  45. }
  46. };
  47. return Controller;
  48. });