topicdongtai.js 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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: 'topicdongtai/index' + location.search,
  8. add_url: 'topicdongtai/add',
  9. edit_url: 'topicdongtai/edit',
  10. del_url: 'topicdongtai/del',
  11. multi_url: 'topicdongtai/multi',
  12. import_url: 'topicdongtai/import',
  13. table: 'topic_dongtai',
  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: 2,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. // {field: 'topic_id', title: __('Topic_id')},
  29. {field: 'topichub.name', title: __('Topichub.name'), operate: 'LIKE'},
  30. {field: 'user_id', title: __('User_id')},
  31. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  32. // {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},
  33. {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  34. {field: 'content', title: __('Content'), operate: 'LIKE'},
  35. {field: 'images', title: '图片或视频', operate: false,events: Table.api.events.image,formatter: function (value,row,index){
  36. if (row.type == '0'){
  37. return value;
  38. }
  39. if (row.type == '1'){
  40. return Table.api.formatter.images(value,row,index);
  41. }
  42. if (row.type == '2'){
  43. return Table.api.formatter.video(value,row,index);
  44. }
  45. return value;
  46. },
  47. cellStyle: {css: {
  48. "white-space": "break-spaces",
  49. "max-width": "200px",
  50. "min-width": "200px",
  51. "line-height": "24px",
  52. "text-align": "left !important"
  53. }
  54. }
  55. },
  56. // {field: 'goodnum', title: __('Goodnum')},
  57. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  58. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  59. // {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  60. // {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  61. // {field: 'is_hidden', title: __('Is_hidden'), searchList: {"1":__('Is_hidden 1'),"0":__('Is_hidden 0')}, formatter: Table.api.formatter.normal},
  62. // {field: 'is_show_real', title: __('Is_show_real'), searchList: {"0":__('Is_show_real 0'),"1":__('Is_show_real 1')}, formatter: Table.api.formatter.normal},
  63. {field: 'address', title: __('Address'), operate: 'LIKE'},
  64. {field: 'auit_status', title: __('Auit_status'), searchList: {"0":__('Auit_status 0'),"1":__('Auit_status 1'),"2":__('Auit_status 2')}, formatter: Table.api.formatter.normal},
  65. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  66. ]
  67. ]
  68. });
  69. // 为表格绑定事件
  70. Table.api.bindevent(table);
  71. },
  72. add: function () {
  73. Controller.api.bindevent();
  74. },
  75. edit: function () {
  76. Controller.api.bindevent();
  77. },
  78. api: {
  79. bindevent: function () {
  80. Form.api.bindevent($("form[role=form]"));
  81. }
  82. }
  83. };
  84. return Controller;
  85. });