platform_article.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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: 'platform_article/index' + location.search,
  8. add_url: 'platform_article/add',
  9. edit_url: 'platform_article/edit',
  10. del_url: 'platform_article/del',
  11. multi_url: 'platform_article/multi',
  12. import_url: 'platform_article/import',
  13. table: 'platform_article',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'type_id', title: __('Type_id')},
  29. {field: 'platform_article_type.title', title: __('Type_title')},
  30. {field: 'title', title: __('Title'), operate: 'LIKE'},
  31. {field: 'desc', title: __('Desc'), operate: 'LIKE'},
  32. {field: 'images', title: __('Images'), operate: false, events: Table.api.events.images, formatter: Table.api.formatter.images},
  33. {field: 'video', title: __('Video'), operate: false, formatter: function(val, row) {
  34. if(val) {
  35. return '<video width="120" height="90" controls>'+'<source src="'+val+'" type="video/ogg">'+'</video>';
  36. } else {
  37. return '暂无';
  38. }
  39. }},
  40. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
  41. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  43. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  44. ]
  45. ]
  46. });
  47. // 为表格绑定事件
  48. Table.api.bindevent(table);
  49. },
  50. add: function () {
  51. Controller.api.bindevent();
  52. },
  53. edit: function () {
  54. Controller.api.bindevent();
  55. },
  56. api: {
  57. bindevent: function () {
  58. Form.api.bindevent($("form[role=form]"));
  59. }
  60. }
  61. };
  62. return Controller;
  63. });