123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'channelfufen/index',
- multi_url: 'channelfufen/show',
- table: 'admin',
- },
- search:false
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url + '?ids='+Config.data.fufenid,
- pk: 'id',
- sortName: 'admin.id',
- sortOrder: 'desc',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'username', title: '账号', operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'appid', title: __('Appid'), operate: false},
- {field: 'c_nickname', title: '开户人', operate: false},
- {field: 'operate', title: __('Operate'), formatter: function (value, row) {
- return "<a href='javascript:;' class='batch_relation' data-channel_id='"+row.id+"'>关联</a>";
- }}
- ]
- ]
- });
- $(document).delegate('.batch_relation', 'click', function () {
- var ids = [];
- if ($(this).data('channel_id')) {
- ids.push($(this).data('channel_id'));
- } else {
- ids = Table.api.selectedids(table);
- }
- Controller.api.batchrelation(ids, 'add', table)
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- show: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'channelfufen/show',
- multi_url: 'channelfufen/del',
- table: 'admin',
- },
- search:false
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url + '?ids='+Config.data.fufenid,
- pk: 'id',
- sortName: 'admin.id',
- sortOrder: 'desc',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'username', title: '账号', operate: 'LIKE'},
- {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
- {field: 'appid', title: __('Appid'), operate: false},
- {field: 'c_nickname', title: '开户人', operate: false},
- {field: 'operate', title: __('Operate'), formatter: function (value, row) {
- return "<a href='javascript:;' class='batch_relation' data-channel_id='"+row.id+"'>删除</a>";
- }}
- ]
- ]
- });
- $(document).delegate('.batch_relation', 'click', function () {
- var ids = [];
- if ($(this).data('channel_id')) {
- ids.push($(this).data('channel_id'));
- } else {
- ids = Table.api.selectedids(table);
- }
- Controller.api.batchrelation(ids, 'remove', table)
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- batchrelation: function (ids, action, table) {
- Layer.confirm(
- __('已选中条数:%s', ids.length),
- {icon: 3, title: __('Warning'), offset: 0, shadeClose: true},
- function (index) {
- var url = 'channelfufen/batch_relation';
- var options = {url: url, data: { channel_ids: ids.join(","), fufen_id: Config.data.fufenid, action: action}};
- Fast.api.ajax(options, function (data, ret) {
- Layer.msg('处理成功!');
- table.bootstrapTable('refresh');
- parent.layer.close(this);
- }, function (data, ret) {
- });
- Layer.close(index);
- }
- );
- }
- }
- };
- return Controller;
- });
|