appcomment.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: 'appcomment/index' + location.search,
  8. add_url: 'appcomment/add',
  9. // edit_url: 'appcomment/edit',
  10. del_url: 'appcomment/del',
  11. multi_url: 'appcomment/multi',
  12. import_url: 'appcomment/import',
  13. table: 'app_comment',
  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: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  28. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  29. {field: 'platform', title: __('Platform'), operate: 'LIKE'},
  30. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  31. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  32. {field: 'audittime', title: __('Audittime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. {field: 'auditremark', title: __('Auditremark'), operate: 'LIKE'},
  34. {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  35. {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
  36. {field: 'operate', title: __('Operate'), table: table,
  37. buttons:[
  38. {
  39. name:'audit',
  40. text:'审核',
  41. title:'审核',
  42. icon:'fa fa-exclamation-circle',
  43. classname:'btn btn-xs btn-info btn-dialog',
  44. url:'appcomment/audit/id/{ids}?dialog=1',
  45. target:'_self',
  46. hidden:function($row){
  47. return $row.status == 0 ? false : true;
  48. }
  49. }
  50. ],
  51. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  52. ]
  53. ]
  54. });
  55. // 为表格绑定事件
  56. Table.api.bindevent(table);
  57. },
  58. audit: function () {
  59. Controller.api.bindevent();
  60. },
  61. add: function () {
  62. Controller.api.bindevent();
  63. },
  64. edit: function () {
  65. Controller.api.bindevent();
  66. },
  67. api: {
  68. bindevent: function () {
  69. Form.api.bindevent($("form[role=form]"));
  70. }
  71. }
  72. };
  73. return Controller;
  74. });