101 lines
5.4 KiB
JavaScript
101 lines
5.4 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'wdsxh/user/user/index',
|
|
del_url: 'wdsxh/user/user/del',
|
|
multi_url: 'wdsxh/user/user/multi',
|
|
table: 'user',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'user.id',
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: __('Id'), sortable: true},
|
|
// {field: 'username', title: __('Username'), operate: 'LIKE'},
|
|
{field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
|
|
{field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
|
|
{field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
|
|
{field: 'channel', title: __('注册来源'), operate: false, searchList: {"1":__('微信小程序'),"2":__('微信公众号')}, formatter: Table.api.formatter.normal},
|
|
{field: 'logintime', title: __('Logintime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
|
{field: 'set_admin', title: __('Set_admin'), operate: false, searchList: {"1":__('Set_admin 1'),"2":__('Set_admin 2')}, formatter: Table.api.formatter.normal},
|
|
{field: 'jointime', title: __('Jointime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
|
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,buttons:[
|
|
{
|
|
name: 'pass_through',
|
|
text: __('设为管理员'),
|
|
title: __('设为管理员'),
|
|
classname: 'btn btn-xs btn-info btn-magic btn-ajax',
|
|
url: 'wdsxh/user/wechat/pass_through',
|
|
confirm: '确认设此用为管理员?',
|
|
visible:function(row){
|
|
if(row['set_admin']==2){
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
},
|
|
success: function (data, ret) {
|
|
$("#table").bootstrapTable('refresh',{});
|
|
},
|
|
error: function (data, ret) {
|
|
Toastr.error(ret.msg);
|
|
return false;
|
|
}
|
|
},
|
|
{
|
|
name: 'cancellation',
|
|
text: __('取消管理员'),
|
|
title: __('取消管理员'),
|
|
classname: 'btn btn-xs btn-info btn-magic btn-ajax',
|
|
url: 'wdsxh/user/wechat/cancellation',
|
|
confirm: '确认并取消此用户的管理权限?',
|
|
visible:function(row){
|
|
if(row['set_admin']==1){
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
},
|
|
success: function (data, ret) {
|
|
$("#table").bootstrapTable('refresh',{});
|
|
},
|
|
error: function (data, ret) {
|
|
Toastr.error(ret.msg);
|
|
return false;
|
|
}
|
|
},
|
|
]}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
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;
|
|
}); |