123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- $('.refresh-redis').click(function () {
- $.ajax({
- url:"/admin/domain/blacklist/refreshredis",
- type:"post",
- dataType:"json",
- success:function (data) {
- Toastr.success("缓存已刷新");
- }
- });
- });
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'domain/blacklist/index',
- add_url: 'domain/blacklist/add',
- //edit_url: 'domain/blacklist/edit',
- del_url: 'domain/blacklist/del',
- table: 'blacklist',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- search: false,
- showToggle:false,
- showColumns: false,
- showExport: false,
- searchFormVisible: false,
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'),operate:false,},
- {field: 'domain', title:'域名'},
- {field: 'param', title:'参数'},
- {field: 'path', title:'特定路径'},
- {field: 'type', title:'类型', operate:false, formatter:Controller.api.formatter.showType},
- {field: 'status', title:'状态',operate:false, formatter:Controller.api.formatter.showStatus},
- {field: 'operate', title: __('Operate'), table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- // 弹窗绑定
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).text(), {});
- return false;
- });
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- // 格式化类型
- showType:function (value, row, index) {
- var type_name = '';
- switch (row.type) {
- case '0':
- type_name = '封整个域名';
- break;
- case '1':
- type_name = '封带有特定参数域名';
- break;
- default:
- type_name = '封特定链接';
- }
- return type_name;
- },
- // 格式化状态
- showStatus:function (value) {
- if(value == "active"){
- return "有效";
- } else {
- return "无效";
- }
- }
- }
- }
- };
- return Controller;
- });
|