90 lines
4.2 KiB
JavaScript
Executable File
90 lines
4.2 KiB
JavaScript
Executable File
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'auth/admin/index',
|
|
add_url: 'auth/admin/add',
|
|
edit_url: 'auth/admin/edit',
|
|
del_url: 'auth/admin/del',
|
|
multi_url: 'auth/admin/multi',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
//在表格内容渲染完成后回调的事件
|
|
table.on('post-body.bs.table', function (e, json) {
|
|
$("tbody tr[data-index]", this).each(function () {
|
|
if (parseInt($("td:eq(1)", this).text()) == Config.admin.id) {
|
|
$("input[type=checkbox]", this).prop("disabled", true);
|
|
}
|
|
});
|
|
});
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
columns: [
|
|
[
|
|
{field: 'state', checkbox: true, },
|
|
{field: 'id', title: 'ID'},
|
|
{field: 'username', title: __('Username')},
|
|
{field: 'nickname', title: __('Nickname')},
|
|
{field: 'role', title: __('角色'), searchList: {"admin":__('系统管理员'),"firm":__('企业管理员')}, formatter: Table.api.formatter.label },
|
|
{field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},
|
|
{field: 'email', title: __('Email')},
|
|
{field: 'mobile', title: __('Mobile')},
|
|
{field: 'status', title: __("Status"), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
|
|
{field: 'logintime', title: __('Login time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
|
|
if(row.id == Config.admin.id){
|
|
return '';
|
|
}
|
|
return Table.api.formatter.operate.call(this, value, row, index);
|
|
}}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
$(document).on("change", "#c-aicustomerservice_id", function(data){
|
|
let ai_config_id = $('#c-aicustomerservice_id').val();
|
|
let index = layer.load(1);
|
|
$.get('Gewechatfriends/getFriendList',{ai_config_id:ai_config_id},function (res) {
|
|
layer.close(index);
|
|
//动态添加数据
|
|
let list = res.list;
|
|
for(let i=0;i<list.length;i++){
|
|
let option = '<option value="'+list[i].id+'">'+list[i].name+'</option>';
|
|
$('#c-rel_wxid').append(option);
|
|
}
|
|
},'json');
|
|
});
|
|
Form.api.bindevent($("form[role=form]"));
|
|
},
|
|
edit: function () {
|
|
$(document).on("change", "#c-aicustomerservice_id", function(data){
|
|
let ai_config_id = $('#c-aicustomerservice_id').val();
|
|
let index = layer.load(1);
|
|
$.get('Gewechatfriends/getFriendList',{ai_config_id:ai_config_id},function (res) {
|
|
layer.close(index);
|
|
//动态添加数据
|
|
let list = res.list;
|
|
for(let i=0;i<list.length;i++){
|
|
let option = '<option value="'+list[i].id+'">'+list[i].name+'</option>';
|
|
$('#c-rel_wxid').append(option);
|
|
}
|
|
},'json');
|
|
});
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|