usergreetcontent.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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: 'usergreetcontent/index' + location.search,
  8. add_url: 'usergreetcontent/add',
  9. // edit_url: 'usergreetcontent/edit',
  10. del_url: 'usergreetcontent/del',
  11. multi_url: 'usergreetcontent/multi',
  12. import_url: 'usergreetcontent/import',
  13. table: 'user_greet_content',
  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: 'user_id', title: __('User_id')},
  27. {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  28. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  29. {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  30. {field: 'title', title: __('Title'), operate: 'LIKE'},
  31. {field: 'content', title: __('Content'), operate: 'LIKE',events: Table.api.events.image,formatter: function (value,row,index){
  32. if (row.type == 0){
  33. return value;
  34. }
  35. if (row.type == 1){
  36. return Table.api.formatter.audio(value,row,index);
  37. }
  38. if (row.type == 2){
  39. return Table.api.formatter.image(value,row,index);
  40. }
  41. if (row.type == 'images'){
  42. return Table.api.formatter.images(value,row,index);
  43. }
  44. if (row.type == 'video'){
  45. return Table.api.formatter.video(value,row,index);
  46. }
  47. return '';
  48. }},
  49. {field: 'duration', title: __('Duration')},
  50. {field: 'is_default', title: __('Is_default'), searchList: {"0":__('Is_default 0'),"1":__('Is_default 1')}, formatter: Table.api.formatter.normal},
  51. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  52. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  53. ]
  54. ]
  55. });
  56. // 为表格绑定事件
  57. Table.api.bindevent(table);
  58. },
  59. add: function () {
  60. Controller.api.bindevent();
  61. },
  62. edit: function () {
  63. Controller.api.bindevent();
  64. },
  65. api: {
  66. bindevent: function () {
  67. Form.api.bindevent($("form[role=form]"));
  68. }
  69. }
  70. };
  71. return Controller;
  72. });