248 lines
13 KiB
JavaScript
Executable File
248 lines
13 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: 'firmcustomer/index' + location.search,
|
||
add_url: 'firmcustomer/add',
|
||
edit_url: 'firmcustomer/edit',
|
||
del_url: 'firmcustomer/del',
|
||
multi_url: 'firmcustomer/multi',
|
||
import_url: 'firmcustomer/import',
|
||
table: 'firmcustomer',
|
||
}
|
||
});
|
||
|
||
var table = $("#table");
|
||
|
||
// 初始化表格
|
||
table.bootstrapTable({
|
||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||
pk: 'id',
|
||
sortName: 'id',
|
||
fixedColumns: true,
|
||
fixedRightNumber: 1,
|
||
columns: [
|
||
[
|
||
{checkbox: true},
|
||
{field: 'id', title: __('Id')},
|
||
{field: 'name', title: __('Customer_name'), operate: 'LIKE'},
|
||
{field: 'age', title: __('Age')},
|
||
{field: 'phone', title: __('Phone'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||
{field: 'rel_wx', title: __('Rel_wx'), operate: 'LIKE'},
|
||
{field: 'rel_group', title: __('Rel_group'), operate: 'LIKE'},
|
||
{field: 'firmtags_ids', title: __('Firmtags_ids'), operate: 'LIKE'},
|
||
{field: 'headimage', title: __('Headimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
||
{field: 'remark', title: __('Remark'), operate: 'LIKE'},
|
||
{field: 'responsible_pm', title: __('Responsible_pm'), operate: 'LIKE'},
|
||
{field: 'status', title: __('Status'), searchList: {"yes":__('Status yes'),"no":__('Status no')}, formatter: Table.api.formatter.status},
|
||
{field: 'firmstoreprojectstwo.name', title: __('Firmstoreprojectstwo.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||
{field: 'firmcustomerorigin.name', title: __('Firmcustomerorigin.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||
{field: 'admin_id', title: __('责任人'), operate: 'LIKE'},
|
||
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
||
|
||
buttons: [
|
||
{
|
||
name: 'addFollwup',
|
||
text: __('新增回访'),
|
||
title: __('新增回访'),
|
||
classname: 'btn btn-xs btn-primary btn-dialog',
|
||
icon: 'fa fa-magic',
|
||
url: 'firmcustomerfollowuprecord/newadd',
|
||
callback: function (data) {
|
||
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
|
||
},
|
||
visible: function (row) {
|
||
//返回true时按钮显示,返回false隐藏
|
||
return true;
|
||
}
|
||
},
|
||
// {
|
||
// name: 'addFollwup',
|
||
// text: __('新增回访'),
|
||
// title: __('新增回访'),
|
||
// classname: 'btn btn-xs btn-primary btn-dialog',
|
||
// icon: 'fa fa-magic',
|
||
// url: 'firmcustomerfollowuprecord/add',
|
||
// callback: function (data) {
|
||
// Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
|
||
// },
|
||
// visible: function (row) {
|
||
// //返回true时按钮显示,返回false隐藏
|
||
// return true;
|
||
// }
|
||
// },
|
||
{
|
||
name: 'follwuplist',
|
||
text: __('回访列表'),
|
||
title: __('回访列表'),
|
||
classname: 'btn btn-xs btn-success btn-dialog',
|
||
icon: 'fa fa-list',
|
||
url: 'firmcustomerfollowuprecord/index?ids={ids}',
|
||
callback: function (data) {
|
||
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
|
||
},
|
||
visible: function (row) {
|
||
//返回true时按钮显示,返回false隐藏
|
||
return true;
|
||
}
|
||
},
|
||
// {
|
||
// name: 'setFollwupPlan',
|
||
// text: __('设置回访计划'),
|
||
// title: __('设置回访计划'),
|
||
// classname: 'btn btn-xs btn-danger btn-dialog',
|
||
// icon: 'fa fa-plus',
|
||
// url: 'firmcustomerfollowuptimelist/add',
|
||
// callback: function (data) {
|
||
// Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
|
||
// },
|
||
// visible: function (row) {
|
||
// //返回true时按钮显示,返回false隐藏
|
||
// return true;
|
||
// }
|
||
// },
|
||
// {
|
||
// name: 'selectSendTime',
|
||
// text: __('查看发送时间'),
|
||
// title: __('查看发送时间'),
|
||
// classname: 'btn btn-xs btn-danger btn-dialog',
|
||
// icon: 'fa fa-list',
|
||
// url: 'firmfollowuptemplatetimelist/index/firmfollowuptemplate_id/{id}',
|
||
// callback: function (data) {
|
||
// Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
|
||
// },
|
||
// visible: function (row) {
|
||
// //返回true时按钮显示,返回false隐藏
|
||
// return true;
|
||
// }
|
||
// },
|
||
]
|
||
}
|
||
]
|
||
]
|
||
});
|
||
|
||
|
||
//当表格数据加载完成时
|
||
table.on('load-success.bs.table', function (e, data) {
|
||
//这里可以获取从服务端获取的JSON数据
|
||
// console.log(data);
|
||
//这里我们手动设置底部的值
|
||
// $("#money").text(data.extend.money);
|
||
// $("#price").text(data.extend.price);
|
||
|
||
//查询并缓存
|
||
// let load_index = layer.load(1);
|
||
// $.post('Gewechatfriends/getFriendList',{},function (res) {
|
||
// layer.close(load_index);
|
||
// },'json');
|
||
|
||
|
||
// $("#c-rel_wx").data("eSelect", function(data){
|
||
// //后续操作
|
||
// console.log(data);
|
||
//
|
||
// });
|
||
|
||
// $(document).on("change", "#c-rel_wx", function(data){
|
||
// //变更后的回调事件
|
||
// // $('input[name="c-rel_wx"]').attr('wx_id');
|
||
// console.log(data);
|
||
// });
|
||
});
|
||
|
||
// 为表格绑定事件
|
||
Table.api.bindevent(table);
|
||
},
|
||
add: function () {
|
||
// $("#c-category").data("format-item", function(row){
|
||
// return row.title + " - " + row.author;
|
||
// });
|
||
//关联微信下拉改变
|
||
$(document).on("change", "#c-rel_wx", function(data){
|
||
// console.log('关联微信下拉改变',$('#c-rel_wx').val());
|
||
//变更后的回调事件
|
||
$('#c-rel_wx').attr('data-wx_id',$('#c-rel_wx').val());
|
||
|
||
|
||
|
||
//同时查询关联群
|
||
let ai_config_id = $('#c-aicustomerservice_ids').val();
|
||
$.get('Gechatroom/getChatroomList',{ai_config_id:ai_config_id},function (res) {
|
||
//动态添加数据
|
||
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_group').append(option);
|
||
}
|
||
},'json');
|
||
});
|
||
// $(document).on("change", "#c-firmfollowuptemplate_id", function(data){
|
||
// //变更后的回调事件
|
||
// // console.log(data.currentTarget.defaultValue);
|
||
// let tmp_id = data.currentTarget.defaultValue;
|
||
// $.get('firmfollowuptemplatetimelist/index',{firmfollowuptemplate_id:tmp_id},function (res) {
|
||
//
|
||
// },'json');
|
||
// });
|
||
|
||
//点击同步按钮
|
||
$('.firmcustomer-sync-info').on('click',function (e){
|
||
//读取下拉框的值
|
||
let wx_id = $('#c-rel_wx').attr('data-wx_id');
|
||
// console.log(wx_id);
|
||
// console.log(e);
|
||
let load_index = layer.load(1);
|
||
$.post('Gewechatfriends/getFriendDetail',{wx_id:wx_id},function (res) {
|
||
layer.close(load_index);
|
||
//回显
|
||
$('#c-headimage').val(res.data.smallHeadImgUrl);
|
||
},'json');
|
||
|
||
});
|
||
//选择AI客服时,获取该客服的微信好友列表并渲染在“关联微信”字段下拉框中
|
||
$(document).on("change", "#c-aicustomerservice_ids", function(data){
|
||
//变更后的回调事件
|
||
// console.log('AI客服:',data.currentTarget.defaultValue);
|
||
let ai_config_id = data.currentTarget.defaultValue;
|
||
$.get('Gewechatfriends/getFriendsByAiConfigId',{ai_config_id:ai_config_id},function (res) {
|
||
//动态添加数据
|
||
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_wx').append(option);
|
||
}
|
||
},'json');
|
||
});
|
||
|
||
// $(document).on("click", ".tag_add_url", function(data){
|
||
// //变更后的回调事件
|
||
// let url = 'firmtags/add';
|
||
// $.get(url,{firm_customer_req:'firm_customer_req'},function (res) {
|
||
// layer.open({
|
||
// title: '在线调试',
|
||
// area: ['80%', '80%'],
|
||
// content: res.html
|
||
// });
|
||
//
|
||
// },'json');
|
||
// });
|
||
|
||
Controller.api.bindevent();
|
||
},
|
||
edit: function () {
|
||
Controller.api.bindevent();
|
||
},
|
||
api: {
|
||
bindevent: function () {
|
||
Form.api.bindevent($("form[role=form]"));
|
||
}
|
||
}
|
||
};
|
||
return Controller;
|
||
});
|