1
This commit is contained in:
@@ -0,0 +1,407 @@
|
||||
define(['table', 'upload','form'], function (Table,Upload,Form) {
|
||||
var User = {
|
||||
//Do setup work hereAction
|
||||
index: function () {
|
||||
window.filterData = {
|
||||
};
|
||||
window.groupOption=Config.groupList;
|
||||
window.roleOption=Config.roleList;
|
||||
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: '/app/admin/user/select',
|
||||
add_url: '/app/admin/user/insert',
|
||||
edit_url: '/app/admin/user/update',
|
||||
del_url: '/app/admin/user/delete',
|
||||
multi_url: '/app/admin/user/multi',
|
||||
dragsort_url: '/app/admin/user/weigh',
|
||||
table: 'user',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
var tableOptions = {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
commonSearch: false,
|
||||
search: false,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
filter: "number",
|
||||
sortable: true // 是否排序
|
||||
},
|
||||
{
|
||||
title: "推荐人",
|
||||
field: "parent_id",
|
||||
formatter:function(v,row){
|
||||
return row.referrer ? row.referrer.username : '';
|
||||
},
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "分组",
|
||||
field: "group",
|
||||
formatter:function(v,row){
|
||||
for (let i = 0; i < Config.groupList.length; i++) {
|
||||
if(Config.groupList[i].value == v){
|
||||
return Config.groupList[i].label;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
filter: "select",
|
||||
filterOption:"groupOption",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "角色",
|
||||
field: "role_id",
|
||||
formatter:function(v,row){
|
||||
return row.role ? row.role.name : '用户';
|
||||
},
|
||||
filter: "select",
|
||||
filterOption:"roleOption",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "用户名",
|
||||
field: "username",
|
||||
filter: "string",
|
||||
},
|
||||
{
|
||||
title: "昵称",
|
||||
field: "nickname",
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
field: 'domain',
|
||||
title: '域名',
|
||||
filter: "string",
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
title: "头像",
|
||||
field: "avatar",
|
||||
formatter: function (v,d) {
|
||||
return '<img src="'+encodeURI(d['avatar'])+'" style="max-width:32px;max-height:32px;" alt="" />'
|
||||
},
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
title: "邮箱",
|
||||
field: "email",
|
||||
visible: false
|
||||
},
|
||||
{
|
||||
title: "手机",
|
||||
field: "mobile",
|
||||
visible: false
|
||||
},
|
||||
// {
|
||||
// title: "等级",
|
||||
// field: "level",
|
||||
// visible: false,
|
||||
// },
|
||||
// {
|
||||
// title: "生日",
|
||||
// field: "birthday",
|
||||
// visible: false,
|
||||
// },
|
||||
// {
|
||||
// title: "后缀",
|
||||
// field: "decimal_part",
|
||||
// //visible: false,
|
||||
// },
|
||||
{
|
||||
title: "调研币",
|
||||
field: "money",
|
||||
formatter:Table.api.formatter.number,
|
||||
sortable: true,
|
||||
//visible: false,
|
||||
},
|
||||
{
|
||||
title: "积分",
|
||||
field: "score",
|
||||
sortable: true,
|
||||
visible: false,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "调研豆",
|
||||
field: "currency1",
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "可领取",
|
||||
field: "currency6",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "待分配",
|
||||
field: "currency7",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "已分配",
|
||||
field: "currency8",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "未通过",
|
||||
field: "currency9",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "登录时间",
|
||||
field: "last_time",
|
||||
formatter:Table.api.formatter.datetime,
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "登录ip",
|
||||
field: "last_ip",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "注册时间",
|
||||
field: "join_time",
|
||||
formatter:Table.api.formatter.datetime,
|
||||
filter:'datetime'
|
||||
},
|
||||
{
|
||||
title: "注册ip",
|
||||
field: "join_ip",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
field: "created_at",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "更新时间",
|
||||
field: "updated_at",
|
||||
formatter:Table.api.formatter.datetime,
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
field: "status",
|
||||
formatter: Table.api.formatter.switch
|
||||
},
|
||||
{
|
||||
field: 'operate', title: '操作',
|
||||
table: table, events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate,
|
||||
buttons:[
|
||||
{
|
||||
text:"团队",
|
||||
name:"team",
|
||||
icon:"mdi mdi-account-group-outline",
|
||||
classname:"btn btn-xs btn-info btn-dialog",
|
||||
url:'/app/admin/user/team'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
};
|
||||
// 初始化表格
|
||||
table.bootstrapTable(tableOptions);
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
update:function(){
|
||||
Config['uploadurl'] = '/app/admin/attachment/avatar';
|
||||
var form = $('form');
|
||||
Form.api.bindevent(form)
|
||||
this.getRole();
|
||||
},
|
||||
insert:function(){
|
||||
Config['uploadurl'] = '/app/admin/attachment/avatar';
|
||||
var form = $('form');
|
||||
Form.api.bindevent(form)
|
||||
this.getRole();
|
||||
},
|
||||
getRole:function(){
|
||||
Fast.api.ajax({
|
||||
url: "/app/admin/UserRole/select?format=tree",
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
Layer.closeAll();
|
||||
var html = "";
|
||||
var selected=$('#roles').data('value');
|
||||
for (let index = 0; index < res.data.length; index++) {
|
||||
const element = res.data[index];
|
||||
if(selected == element.id){
|
||||
html+='<option value="'+element.id+'" selected>'+element.name+'</option>';
|
||||
}else{
|
||||
html+='<option value="'+element.id+'">'+element.name+'</option>';
|
||||
}
|
||||
}
|
||||
$('#roles').append(html);
|
||||
}
|
||||
});
|
||||
},
|
||||
team:function(){
|
||||
window.filterData = {
|
||||
"user_id":{value1:Fast.api.query('ids'),symbol:'=','value2':''},
|
||||
'type' : {value1:'child',symbol:'=','value2':''}
|
||||
};
|
||||
|
||||
$('.nav-tabs li').on('click',function(){
|
||||
$('.nav-tabs li').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
window.filterData['type'] = {value1:$(this).data('type'),symbol:'=','value2':''};
|
||||
table.bootstrapTable('selectPage', 1);
|
||||
});
|
||||
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: '/app/admin/team/select',
|
||||
add_url: null,
|
||||
edit_url: null,
|
||||
del_url: null,
|
||||
multi_url: null,
|
||||
dragsort_url: null,
|
||||
table: 'team',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
var tableOptions = {
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
commonSearch: false,
|
||||
search: false,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{
|
||||
title: "深度",
|
||||
field: "depth",
|
||||
},
|
||||
{
|
||||
field: 'id',
|
||||
title: 'ID',
|
||||
filter: "number",
|
||||
sortable: true // 是否排序
|
||||
},
|
||||
{
|
||||
title: "角色",
|
||||
field: "role_id",
|
||||
formatter: function(v,item){
|
||||
return 'V'+v;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "用户名",
|
||||
field: "username",
|
||||
filter: "string",
|
||||
},
|
||||
// {
|
||||
// title: "等级",
|
||||
// field: "level",
|
||||
// visible: false,
|
||||
// },
|
||||
{
|
||||
title: "余额",
|
||||
field: "money",
|
||||
formatter:Table.api.formatter.number,
|
||||
sortable: true,
|
||||
//visible: false,
|
||||
},
|
||||
{
|
||||
title: "积分",
|
||||
field: "score",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "调研币",
|
||||
field: "currency1",
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "可领取",
|
||||
field: "currency6",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "待分配",
|
||||
field: "currency7",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "已分配",
|
||||
field: "currency8",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "未通过",
|
||||
field: "currency9",
|
||||
sortable: true,
|
||||
formatter:Table.api.formatter.number
|
||||
},
|
||||
{
|
||||
title: "登录时间",
|
||||
field: "last_time",
|
||||
formatter:Table.api.formatter.datetime,
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "登录ip",
|
||||
field: "last_ip",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "注册时间",
|
||||
field: "join_time",
|
||||
formatter:Table.api.formatter.datetime,
|
||||
filter:'datetime'
|
||||
},
|
||||
{
|
||||
title: "注册ip",
|
||||
field: "join_ip",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "创建时间",
|
||||
field: "created_at",
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "更新时间",
|
||||
field: "updated_at",
|
||||
formatter:Table.api.formatter.datetime,
|
||||
visible: false,
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
field: "status",
|
||||
formatter: Table.api.formatter.switch
|
||||
}
|
||||
]
|
||||
]
|
||||
};
|
||||
// 初始化表格
|
||||
table.bootstrapTable(tableOptions);
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
}
|
||||
};
|
||||
return User
|
||||
});
|
||||
Reference in New Issue
Block a user