83 lines
3.3 KiB
JavaScript
Executable File
83 lines
3.3 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: 'aicustomerservice/index' + location.search,
|
|
add_url: 'aicustomerservice/add',
|
|
edit_url: 'aicustomerservice/edit',
|
|
del_url: 'aicustomerservice/del',
|
|
multi_url: 'aicustomerservice/multi',
|
|
import_url: 'aicustomerservice/import',
|
|
table: 'aicustomerservice',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: __('Id')},
|
|
{field: 'name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
{field: 'wxid', title: __('Wxid'), operate: 'LIKE'},
|
|
{field: 'server_url', title: __('Server_url'), operate: 'LIKE', formatter: Table.api.formatter.url},
|
|
{field: 'apikey', title: __('Apikey'), operate: 'LIKE'},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
$(document).on("click", ".wxidSyncGet", function(data){
|
|
let base_url = $('#c-server_url').val();
|
|
if(!base_url){
|
|
return layer.msg('请先填写服务地址');
|
|
}
|
|
let index = layer.load(1);
|
|
$.post('Wxperson/getProfile',{base_url:base_url},function (res) {
|
|
layer.close(index);
|
|
//动态添加数据
|
|
$('#c-wxid').val(res.data.wxid);
|
|
$('#c-name').val(res.data.nickName);
|
|
|
|
},'json');
|
|
});
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
$(document).on("click", ".wxidSyncGet", function(data){
|
|
let base_url = $('#c-server_url').val();
|
|
if(!base_url){
|
|
return layer.msg('请先填写服务地址');
|
|
}
|
|
let index = layer.load(1);
|
|
$.post('Wxperson/getProfile',{base_url:base_url},function (res) {
|
|
layer.close(index);
|
|
//动态添加数据
|
|
$('#c-wxid').val(res.data.wxid);
|
|
$('#c-name').val(res.data.nickName);
|
|
|
|
},'json');
|
|
});
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|