123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- $(document).on('click','.layer-open',function () {
- Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'全局配置', {});
- return false;
- });
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'postbackkladmin/index?type='+Config.type,
- add_url: 'postbackkladmin/add?type='+Config.type,
- edit_url: 'postbackkladmin/edit',
- del_url: 'postbackkladmin/del?type='+Config.type,
- global_url: 'postbackkladmin/global?type='+Config.type,
- table: 'postback_kl_admin',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'admin_id', title: __('Admin_id')},
- {field: 'nickname', title: '渠道昵称'},
- {field: 'money', title: __('Money')},
- {field: 'kl', title: __('Kl')},
- {field: 'state', title: __('State'), visible:false, searchList: {"show":__('state show'),"hide":__('state hide')}},
- {field: 'state_text', title: __('State'), operate:false, formatter: function(value, row){
- if (value == __('state show')) {
- return value+'<button class="btn btn-success changestate" data-id="'+row.id+'" data-state="'+row.state+'">点击'+__('state hide')+'</button>'
- } else {
- return value+'<button class="btn btn-success changestate" data-id="'+row.id+'" data-state="'+row.state+'">点击'+__('state show')+'</button>'
- }
- }},
- {field: 'createtime', title: __('Createtime'),operate:false,formatter:Table.api.formatter.datetime},
- {field: 'updatetime', title: __('Updatetime'),operate:false,formatter:Table.api.formatter.datetime},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function(value, row){
- var content = '<a href="/admin/postbackkladmin/edit?admin_id='+row.admin_id+'&type='+row.type+'&ids='+row.id+'" class="btn btn-xs btn-success btn-editone" ><i class="fa fa-pencil"></i></a>';
- if (row.admin_id != '-1') {
- content += '<a href="/admin/postbackklreferral/index?admin_id='+row.admin_id+'&type='+row.type+'" class="btn btn-xs btn-success" >推广id配置</a>';
- }
- content += '<a href="javascript:;" class="btn btn-xs btn-danger btn-delone"><i class="fa fa-trash"></i></a>';
- return content;
- }}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- table.delegate('.changestate', 'click', function () {
- var data = $(this).data();
- $.ajax({
- data:data,
- url:'/admin/postbackkladmin/changestate',
- success:function () {
- Layer.alert('修改成功');
- table.bootstrapTable('refresh');
- },
- error: function(){
- Layer.alert('修改失败');
- }
- });
- })
- },
- add: function () {
- Controller.api.bindevent();
- $('input[name="row[channel]"]').click(function(){
- if ($(this).val() == 0) {
- $('.all-channel').show();
- $('.channel').hide();
- $('.channel').find('input').attr('disabled', true);
- } else {
- $('.all-channel').hide();
- $('.channel').show();
- $('.channel').find('input').removeAttr('disabled');
- }
- });
- $('.channel_dis').removeAttr('disabled');
- },
- edit: function () {
- Controller.api.bindevent();
- },
- global: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|