Files
fast_response/admin/public/assets/js/backend/firmcustomer.js
2025-04-18 09:42:17 +08:00

362 lines
18 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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',
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);
$('#c-wx_nickname').val(res.data.nickName);
},'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();
},
massagesindex: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'firmcustomer/index' + location.search,
add_url: 'firmcustomer/add',
edit_url: 'firmcustomer/edit',
del_url: 'firmcustomer/del',
import_url: 'firmcustomer/import',
massagesindex_url: 'firmcustomer/massagesindex'+ location.search,
table: 'firmcustomer',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.massagesindex_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
pageSize: 200,
pageList:[200,300],
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Customer_name'), operate: 'LIKE'},
{field: 'gm_status', title: '发送状态', },
{field: 'send_time', title: '发送时间',},
{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: '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: 'firmtags_ids', title: __('Firmtags_ids'), operate: 'LIKE'},
{field: 'remark', title: __('Remark'), operate: 'LIKE'},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
$('#submitButton').on('click', function () {
// 获取多选的数据
var rows = $('#table').bootstrapTable('getSelections');
var ids = [];
rows.forEach(function (row) {
ids.push(row.id);
});
var url = 'groupmessages/add?ids=' + ids.join(',');
Fast.api.open(url);
});
},
massagesindexnot: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'firmcustomer/index' + location.search,
add_url: 'firmcustomer/add',
edit_url: 'firmcustomer/edit',
del_url: 'firmcustomer/del',
import_url: 'firmcustomer/import',
massagesindexnot_url: 'firmcustomer/massagesindexnot'+ location.search,
table: 'firmcustomer',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.massagesindexnot_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
pageSize: 200,
pageList:[200,300],
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'name', title: __('Customer_name'), operate: 'LIKE'},
{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: '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: 'firmtags_ids', title: __('Firmtags_ids'), operate: 'LIKE'},
{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: 'admin_id', title: __('责任人'), operate: 'LIKE'},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
$('#submitButton').on('click', function () {
// 获取多选的数据
var mess_id = $('#mess_id').val();
var rows = $('#table').bootstrapTable('getSelections');
var ids = [];
rows.forEach(function (row) {
ids.push(row.id);
});
$.post('groupmessages/addagain', {customer_ids: ids.join(','),mess_id:mess_id}, function (res) {
if (res.code == 1){
layer.msg('发送成功',function (){
location.reload();
},300);
}else {
layer.msg(res.msg);
}
});
});
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});