topicdongtai.js 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. cellStyle: {css: {
  36. "white-space": "break-spaces",
  37. "max-width": "240px",
  38. "min-width": "240px",
  39. "line-height": "24px",
  40. "text-align": "left !important"
  41. }
  42. }
  43. },
  44. {field: 'images', title: '图片或视频', operate: false,events: Table.api.events.image,formatter: function (value,row,index){
  45. if (row.type == '0'){
  46. return value;
  47. }
  48. if (row.type == '1'){
  49. return Table.api.formatter.images(value,row,index);
  50. }
  51. if (row.type == '2'){
  52. return Table.api.formatter.video(value,row,index);
  53. }
  54. return value;
  55. },
  56. cellStyle: {css: {
  57. "white-space": "break-spaces",
  58. "max-width": "200px",
  59. "min-width": "200px",
  60. "line-height": "24px",
  61. "text-align": "left !important"
  62. }
  63. }
  64. },
  65. // {field: 'goodnum', title: __('Goodnum')},
  66. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  67. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  68. // {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
  69. // {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
  70. // {field: 'is_hidden', title: __('Is_hidden'), searchList: {"1":__('Is_hidden 1'),"0":__('Is_hidden 0')}, formatter: Table.api.formatter.normal},
  71. // {field: 'is_show_real', title: __('Is_show_real'), searchList: {"0":__('Is_show_real 0'),"1":__('Is_show_real 1')}, formatter: Table.api.formatter.normal},
  72. {field: 'address', title: __('Address'), operate: 'LIKE'},
  73. {field: 'auit_status', title: __('Auit_status'), searchList: {"0":__('Auit_status 0'),"1":__('Auit_status 1'),"2":__('Auit_status 2')}, formatter: Table.api.formatter.normal},
  74. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  75. ]
  76. ]
  77. });
  78. // 为表格绑定事件
  79. Table.api.bindevent(table);
  80. },
  81. add: function () {
  82. Controller.api.bindevent();
  83. },
  84. edit: function () {
  85. Controller.api.bindevent();
  86. },
  87. api: {
  88. bindevent: function () {
  89. Form.api.bindevent($("form[role=form]"));
  90. }
  91. }
  92. };
  93. return Controller;
  94. });