blacklist.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. $('.refresh-redis').click(function () {
  3. $.ajax({
  4. url:"/admin/domain/blacklist/refreshredis",
  5. type:"post",
  6. dataType:"json",
  7. success:function (data) {
  8. Toastr.success("缓存已刷新");
  9. }
  10. });
  11. });
  12. var Controller = {
  13. index: function () {
  14. // 初始化表格参数配置
  15. Table.api.init({
  16. extend: {
  17. index_url: 'domain/blacklist/index',
  18. add_url: 'domain/blacklist/add',
  19. //edit_url: 'domain/blacklist/edit',
  20. del_url: 'domain/blacklist/del',
  21. table: 'blacklist',
  22. }
  23. });
  24. var table = $("#table");
  25. // 初始化表格
  26. table.bootstrapTable({
  27. url: $.fn.bootstrapTable.defaults.extend.index_url,
  28. search: false,
  29. showToggle:false,
  30. showColumns: false,
  31. showExport: false,
  32. searchFormVisible: false,
  33. columns: [
  34. [
  35. {checkbox: true},
  36. {field: 'id', title: __('Id'),operate:false,},
  37. {field: 'domain', title:'域名'},
  38. {field: 'param', title:'参数'},
  39. {field: 'path', title:'特定路径'},
  40. {field: 'type', title:'类型', operate:false, formatter:Controller.api.formatter.showType},
  41. {field: 'status', title:'状态',operate:false, formatter:Controller.api.formatter.showStatus},
  42. {field: 'operate', title: __('Operate'), table: table,
  43. events: Table.api.events.operate,
  44. formatter: Table.api.formatter.operate}
  45. ]
  46. ]
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. // 弹窗绑定
  51. $(document).on('click','.layer-open',function () {
  52. Fast.api.open($(this).attr('href'), $(this).text(), {});
  53. return false;
  54. });
  55. },
  56. add: function () {
  57. Controller.api.bindevent();
  58. },
  59. edit: function () {
  60. Controller.api.bindevent();
  61. },
  62. api: {
  63. bindevent: function () {
  64. Form.api.bindevent($("form[role=form]"));
  65. },
  66. formatter: {
  67. // 格式化类型
  68. showType:function (value, row, index) {
  69. var type_name = '';
  70. switch (row.type) {
  71. case '0':
  72. type_name = '封整个域名';
  73. break;
  74. case '1':
  75. type_name = '封带有特定参数域名';
  76. break;
  77. default:
  78. type_name = '封特定链接';
  79. }
  80. return type_name;
  81. },
  82. // 格式化状态
  83. showStatus:function (value) {
  84. if(value == "active"){
  85. return "有效";
  86. } else {
  87. return "无效";
  88. }
  89. }
  90. }
  91. }
  92. };
  93. return Controller;
  94. });