113 lines
4.3 KiB
Smarty
113 lines
4.3 KiB
Smarty
|
|
define(['table', 'upload','form'], function (Table,Upload,Form) {
|
||
|
|
var {$controllerClass} = {
|
||
|
|
index: function () {
|
||
|
|
|
||
|
|
Table.api.init({
|
||
|
|
extend: {
|
||
|
|
index_url: '/app/admin/{$controllerLower}/select',
|
||
|
|
add_url: '/app/admin/{$controllerLower}/insert',
|
||
|
|
edit_url: '/app/admin/{$controllerLower}/update',
|
||
|
|
del_url: '/app/admin/{$controllerLower}/delete',
|
||
|
|
multi_url: '/app/admin/{$controllerLower}/multi',
|
||
|
|
dragsort_url: '/app/admin/{$controllerLower}/weigh',
|
||
|
|
table: 'admin',
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
var table = $("#table");
|
||
|
|
var tableOptions = {
|
||
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||
|
|
pk: 'id',
|
||
|
|
sortName: 'id',
|
||
|
|
pagination: false,
|
||
|
|
commonSearch: false,
|
||
|
|
search: false,
|
||
|
|
columns: [
|
||
|
|
[
|
||
|
|
{checkbox: true},
|
||
|
|
{
|
||
|
|
field: 'id',
|
||
|
|
title: 'ID',
|
||
|
|
filter: "number",
|
||
|
|
sortable: true // 是否排序
|
||
|
|
},
|
||
|
|
{
|
||
|
|
field: 'username',
|
||
|
|
title: '用户名',
|
||
|
|
filter: "string",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
field: 'role_name',
|
||
|
|
title: '角色',
|
||
|
|
filter: "string",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
field: 'mobile',
|
||
|
|
title: '手机',
|
||
|
|
filter: "string",
|
||
|
|
},
|
||
|
|
{
|
||
|
|
field: 'email',
|
||
|
|
title: '邮箱',
|
||
|
|
filter: "string"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
field: 'login_at',
|
||
|
|
title: '最后登录',
|
||
|
|
filter: "date",
|
||
|
|
visible:false
|
||
|
|
},
|
||
|
|
{
|
||
|
|
field: 'created_at',
|
||
|
|
title: '注册时间',
|
||
|
|
filter: "date",
|
||
|
|
visible:false
|
||
|
|
},
|
||
|
|
{
|
||
|
|
field: 'status',
|
||
|
|
title: '状态',
|
||
|
|
formatter:Table.api.formatter.switch
|
||
|
|
},
|
||
|
|
{field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||
|
|
]
|
||
|
|
]
|
||
|
|
};
|
||
|
|
// 初始化表格
|
||
|
|
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/adminrole/select?format=select",
|
||
|
|
dataType: "json",
|
||
|
|
success: function (res) {
|
||
|
|
var html = "";
|
||
|
|
var selected=$('#roles').data('value');
|
||
|
|
for (let index = 0; index < res.data.length; index++) {
|
||
|
|
const element = res.data[index];
|
||
|
|
if(selected == element.value){
|
||
|
|
html+='<option value="'+element.value+'" selected>'+element.name+'</option>';
|
||
|
|
}else{
|
||
|
|
html+='<option value="'+element.value+'">'+element.name+'</option>';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$('#roles').append(html);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
};
|
||
|
|
return {$controllerClass}
|
||
|
|
});
|