123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'auth/channelfanstransfer/index',
- add_url: 'auth/channelfanstransfer/add',
- edit_url: 'auth/channelfanstransfer/edit',
- del_url: 'auth/channelfanstransfer/del',
- multi_url: 'auth/channelfanstransfer/multi',
- table: 'channel_fans_transfer',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'),operate: false},
- {field: 'send_channel_id', title: __('Send_channel_id')},
- {field: 'receive_channel_id', title: __('Receive_channel_id')},
- {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,operate: false},
- {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,operate: false},
- {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,operate: false},
- {
- field: 'status',
- title: __('Status'),
- searchList: {
- "1":__('生效'),
- "2":__('失效'),
- },
- formatter: function (value, row, index) {
- if (value == 2) {
- return "失效";
- }else{
- return "生效";
- }
- }
- },
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,formatter:function (value,row) {
- var html = '';
- if(row.status == 1){
- html += '<a href="javascript:;" data-id="'+row.id+'" data-status="'+row.status+'" class="btn btn-xs btn-danger btn-switchstatus" >失效 </a> ';
- }else{
- html += '<a href="javascript:;" data-id="'+row.id+'" data-status="'+row.status+'" class="btn btn-xs btn-success btn-switchstatus" >生效 </a> ';
- }
- return html;
- }
- }
- ]
- ]
- });
- //批量更换状态
- $(document).on('click','.btn-batch-switchstatus',function () {
- var ids = Table.api.selectedids(table).join(",");
- var status = $(this).data("status") == 2 ? 1 :2;
- var status_text = $(this).data("status") == 2 ? '生效' : '失效';
- Layer.confirm(
- '确定要将选中的'+ Table.api.selectedids(table).length +'项改为' + status_text + '吗?',
- {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
- function (index) {
- $.ajax({
- type: 'post',
- data: {ids:ids,status:status},
- url:'/admin/auth/channelfanstransfer/switchstatus',
- success:function () {
- Toastr.success('操作成功');
- table.bootstrapTable('refresh');
- },
- error: function(){
- Toastr.error('操作失败');
- }
- });
- Layer.close(index);
- }
- );
- });
- //更换状态
- $(document).on('click','.btn-switchstatus',function () {
- var ids = $(this).data("id");
- var status = $(this).data("status") == 2 ? 1 :2;
- var status_text = $(this).data("status") == 2 ? '生效' : '失效';
- Layer.confirm(
- '确定要将选中项改为' + status_text + '吗?',
- {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
- function (index) {
- $.ajax({
- type: 'post',
- data: {ids:ids,status:status},
- url:'/admin/auth/channelfanstransfer/switchstatus',
- success:function () {
- Toastr.success('操作成功');
- table.bootstrapTable('refresh');
- },
- error: function(){
- Toastr.error('操作失败');
- }
- });
- Layer.close(index);
- }
- );
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|