283 lines
7.9 KiB
HTML

{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<div class="layui-card border-x border-t" style="margin-bottom:0; box-shadow:0 0 0 0 rgb(5 32 96 / 0%)">
<div class="body-table layui-tab layui-tab-brief" lay-filter="tab">
<ul class="layui-tab-title">
<li class="layui-this">全部客户</li>
<li>我的客户</li>
<li>下属客户</li>
<li>共享客户</li>
</ul>
</div>
</div>
<form class="layui-form gg-form-bar border-x" lay-filter="barsearchform" id="barsearchform">
<div class="layui-input-inline" style="width:150px;">
<select name="grade_id">
<option value="">请选择客户等级</option>
{volist name=":customer_grade()" id="v"}
<option value="{$v.id}">{$v.title}</option>
{/volist}
</select>
</div>
<div class="layui-input-inline" style="width:150px;">
<select name="source_id">
<option value="">请选择渠道来源</option>
{volist name=":customer_source()" id="v"}
<option value="{$v.id}">{$v.title}</option>
{/volist}
</select>
</div>
<div class="layui-input-inline" style="width:150px;">
<select name="type">
<option value="">请选择客户意向</option>
<option value="1">意向不明</option>
<option value="2">意向模糊</option>
<option value="3">意向一般</option>
<option value="4">意向强烈</option>
</select>
</div>
<div class="layui-input-inline" style="width:150px;">
<select name="status">
<option value="">请选择客户状态</option>
<option value="1">新进客户</option>
<option value="2">跟进客户</option>
<option value="3">正式客户</option>
<option value="4">流失客户</option>
<option value="5">已成交客户</option>
</select>
</div>
{eq name="$auth" value="1"}
<div class="layui-input-inline" style="width:120px;">
<input type="text" name="username" placeholder="选择所属员工" class="layui-input" readonly data-event="select"/>
<input type="text" name="uid" value="" style="display:none" />
</div>
{/eq}
<div class="layui-input-inline" style="width:240px;">
<input type="hidden" name="tab" value="0" />
<input type="text" name="keywords" placeholder="输入关键字" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">提交搜索</button>
<button type="reset" class="layui-btn layui-btn-reset" lay-filter="clear">清空</button>
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<span class="layui-btn layui-btn-sm" title="添加客户" lay-event="add">+ 添加客户</span>
</div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool','employeepicker'];
function gouguInit() {
var table = layui.table, tool = layui.tool ,form = layui.form, element = layui.element, employeepicker = layui.employeepicker;
// 选择员工
$('body').on('click','[data-event="select"]',function(){
var that = $(this);
var names = that.val(), ids = $('[name="uid"]').val();
employeepicker.init({
ids: ids,
names: names,
type: 0,
department_url: "/api/index/get_department_tree",
employee_url: "/api/index/get_employee",
callback: function (ids, names, dids, departments) {
$('[name="uid"]').val(ids);
that.val(names);
$('[lay-filter="webform"]').click();
}
})
});
$('[lay-filter="clear"]').on('click',function(){
setTimeout(function(){
$('[lay-filter="webform"]').click();
},10)
})
layui.pageTable = table.render({
elem: '#test',
title: '客户列表',
toolbar: '#toolbarDemo',
defaultToolbar:['filter', {title:'导出EXCEL',layEvent: 'LAYTABLE_EXCEL',icon: 'layui-icon-export'}],
url: "/customer/index/index", //数据接口
cellMinWidth: 80,
page: true, //开启分页
limit: 20,
cols: [
[ //表头
{
field: 'id',title: '编号',align: 'center',width: 80,templet: function (d) {
return'C' + d.id;
}
},{ field: 'status', title: '状态', align: 'center', width: 80, templet: function (d) {
var html = '<span class="layui-btn layui-btn-xs layui-bg-' + d.status + '">' + d.status_name + '</span>';
return html;
}
},{
field: 'name',
title: '客户名称',
templet: '<div><a data-href="/customer/index/view/id/{{d.id}}.html" class="side-a">{{d.name}}</a></div>'
},{
field: 'intent_status_name',
title: '客户意向',
align: 'center',
width: 150,
templet: function (d) {
var html = '<span class="layui-color-' + d.grade_id + '">[' + d.grade + ']</span> '+d.intent_status_name;
return html;
}
},{
field: 'user',
title: '联系人',
align: 'center',
width: 80
},{
field: 'mobile',
title: '手机号码',
align: 'center',
width: 100
},{
field: 'qq',
title: 'QQ号码',
align: 'center',
width: 100
},{
field: 'wechat',
title: '微信号',
align: 'center',
width: 90
},{
field: 'create_time',
title: '创建时间',
align: 'center',
width: 136
},{
field: 'update_time',
title: '最后编辑时间',
align: 'center',
width: 136
},{
field: 'source',
title: '来源渠道',
align: 'center',
width: 100
}, {
field: 'industry',
title: '客户所属行业',
align: 'center',
width: 120
},{
field: 'belong_name',
title: '所属员工',
align: 'center',
width: 80
},{
field: 'belong_department',
title: '所属部门',
align: 'center',
width: 90
}, {
field: 'right',
fixed:'right',
title: '操作',
width: 120,
align: 'center',
templet: function (d) {
var html = '<div class="layui-btn-group">';
var btn0='<span class="layui-btn layui-btn-xs" lay-event="edit">编辑</span>';
var btn1='<span class="layui-btn layui-btn-danger layui-btn-xs" lay-event="remove">移入公海</span>';
if(d.belong_uid == login_admin){
return html+btn0+btn1+'</div>';
}
else{
return btn0;
}
}
}
]
]
});
element.on('tab(tab)', function(data){
$('[name="tab"]').val(data.index);
$("#barsearchform")[0].reset();
layui.pageTable.reload({where:{tab:data.index},page:{curr:1}});
return false;
});
//表头工具栏事件
table.on('toolbar(test)', function(obj){
if (obj.event === 'add') {
tool.side("/customer/index/add");
return;
}
if(obj.event === 'LAYTABLE_EXCEL'){
var formSelect = form.val('barsearchform');
formSelect.limit=99999;
$.ajax({
url: '/customer/index/index',
data: formSelect,
success:function(res){
table.exportFile('test', res.data,'xls');
}
});
return;
}
});
//监听行工具事件
table.on('tool(test)', function(obj) {
var data = obj.data;
if(obj.event === 'edit'){
tool.side('/customer/index/add?id='+data.id);
return;
}
if (obj.event === 'remove') {
layer.confirm('确定要把该客户移入公海吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.post("/customer/index/to_sea", {id: data.id}, callback);
layer.close(index);
});
}
});
//监听搜索提交
form.on('submit(webform)', function(data) {
layui.pageTable.reload({
where: {
tab: data.field.tab,
keywords: data.field.keywords,
grade_id: data.field.grade_id,
source_id: data.field.source_id,
type: data.field.type,
status: data.field.status,
uid: data.field.uid
},
page: {
curr: 1
}
});
return false;
});
}
</script>
{/block}
<!-- /脚本 -->