From 6e41c09e1a619f775eb21d026e2e311e2a0971e6 Mon Sep 17 00:00:00 2001 From: "HDM58\\hdm58" Date: Wed, 15 Nov 2023 14:51:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=A8=A1=E5=9D=97=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E8=B7=9F=E8=BF=9B=E8=AE=B0=E5=BD=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/customer/common.php | 2 +- app/customer/controller/Api.php | 3 + app/customer/controller/Trace.php | 83 +++++++++++++++++++ app/customer/model/CustomerTrace.php | 7 +- app/customer/view/api/add_trace.html | 68 +++++++++------ app/customer/view/api/edit_trace.html | 64 +++++++++----- app/customer/view/api/view_trace.html | 29 ++++--- app/customer/view/trace/index.html | 115 ++++++++++++++++++++++++++ app/install/data/gouguoa.sql | 7 +- 9 files changed, 312 insertions(+), 66 deletions(-) create mode 100644 app/customer/controller/Trace.php create mode 100644 app/customer/view/trace/index.html diff --git a/app/customer/common.php b/app/customer/common.php index 433f0d0..3bc4191 100644 --- a/app/customer/common.php +++ b/app/customer/common.php @@ -84,7 +84,7 @@ function trace_type() //跟进阶段 function trace_stage() { - $stage = ['未设置','立项评估','初期沟通','需求分析','方案制定','商务谈判','合同签订','失单']; + $stage = ['未设置','立项评估','初期沟通','需求分析','商务谈判','方案制定','合同签订','失单']; return $stage; } diff --git a/app/customer/controller/Api.php b/app/customer/controller/Api.php index 6ea337b..a4aa242 100644 --- a/app/customer/controller/Api.php +++ b/app/customer/controller/Api.php @@ -96,6 +96,9 @@ class Api extends BaseController $param['admin_id'] = $this->uid; $tid = CustomerTrace::strict(false)->field(true)->insertGetId($param); if ($tid) { + if(!empty($param['chance_id'])){ + Db::name('CustomerChance')->where('id',$param['chance_id'])->update(['stage'=>$param['stage']]); + } add_log('add', $tid, $param,'客户跟进记录'); $log_data = array( 'field' => 'new', diff --git a/app/customer/controller/Trace.php b/app/customer/controller/Trace.php new file mode 100644 index 0000000..f3b96d6 --- /dev/null +++ b/app/customer/controller/Trace.php @@ -0,0 +1,83 @@ +isAjax()) { + $param = get_params(); + $where = array(); + $whereOr = array(); + if (!empty($param['keywords'])) { + $where[] = ['a.id|a.title|c.name', 'like', '%' . $param['keywords'] . '%']; + } + if (!empty($param['stage'])) { + $where[] = ['a.stage', '=', $param['stage']]; + } + //按时间检索 + if (!empty($param['diff_time'])) { + $diff_time =explode('~', $param['diff_time']); + $where[] = ['a.expected_time', 'between', [strtotime(urldecode($diff_time[0])),strtotime(urldecode($diff_time[1]))]]; + } + $where[] = ['a.delete_time', '=', 0]; + + $uid = $this->uid; + $auth = isAuth($uid,'customer_admin'); + + if (empty($param['uid'])) { + if($auth==0){ + $dids = get_department_role($this->uid); + if(!empty($dids)){ + $whereOr[] =['c.belong_did', 'in', $dids]; + } + $whereOr[] =['c.belong_uid', '=', $uid]; + $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',c.share_ids)")]; + } + } + else{ + $where[] = ['a.belong_uid', '=', $param['uid']]; + } + + $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit']; + $content = CustomerTrace::where($where) + ->where(function ($query) use($whereOr) { + $query->whereOr($whereOr); + }) + ->field('a.*,c.name as customer') + ->alias('a') + ->join('customer c', 'a.cid = c.id') + ->order('a.create_time desc') + ->paginate($rows, false, ['query' => $param]) + ->each(function ($item, $key) { + $item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name'); + $item->create_time = date('Y-m-d H:i:s', (int) $item->create_time); + $item->follow_time = date('Y-m-d H:i', (int) $item->follow_time); + $item->next_time = date('Y-m-d H:i', (int) $item->next_time); + $item->stage_name = CustomerTrace::$Stage[(int) $item->stage]; + $item->type_name = CustomerTrace::$Type[(int) $item->type]; + $item->chance='-'; + if($item->chance_id>0){ + $item->chance=Db::name('CustomerChance')->where(['id' => $item->chance_id])->value('title'); + } + }); + return table_assign(0, '', $content); + } else { + return view(); + } + } +} diff --git a/app/customer/model/CustomerTrace.php b/app/customer/model/CustomerTrace.php index 33edb6f..3aa0eb6 100644 --- a/app/customer/model/CustomerTrace.php +++ b/app/customer/model/CustomerTrace.php @@ -22,7 +22,7 @@ class CustomerTrace extends Model const SEVEN = 7; public static $Type = [ - self::ZERO => '未设置', + self::ZERO => '其他', self::ONE => '电话', self::TWO => '微信', self::THREE => 'QQ', @@ -44,6 +44,11 @@ class CustomerTrace extends Model { $detail = Db::name('CustomerTrace')->where(['id' => $id])->find(); if (!empty($detail)) { + $detail['chance_name'] ='-'; + if($detail['chance_id'] >0){ + $detail['chance_name'] =Db::name('CustomerChance')->where(['id' => $detail['chance_id']])->value('title'); + } + $detail['contact_name'] =Db::name('CustomerContact')->where(['id' => $detail['contact_id']])->value('name'); $detail['stage_name'] = self::$Stage[(int) $detail['stage']]; $detail['type_name'] = self::$Type[(int) $detail['type']]; $detail['create_time'] = date('Y-m-d H:i:s', $detail['create_time']); diff --git a/app/customer/view/api/add_trace.html b/app/customer/view/api/add_trace.html index b5d3a22..ff39922 100644 --- a/app/customer/view/api/add_trace.html +++ b/app/customer/view/api/add_trace.html @@ -1,23 +1,23 @@ {extend name="../../base/view/common/base" /} {block name="body"} -
+

新增跟进记录

- - - - + + + + - + - + + + - - - - +
客户名称{$customer_name}
联 系 人*{$customer_name}客户联系人* - {volist name=":customer_contact($customer_id)" id="v"} {/volist}
跟进方式* 跟进时间*跟进时间* - +
下次沟通时间* + +
沟通内容* @@ -39,27 +43,23 @@
当前阶段* - - 销售机会 - + 下次沟通时间*当前阶段 - +
@@ -80,15 +80,35 @@ var form = layui.form,tool=layui.tool,laydate = layui.laydate; laydate.render({ elem: '#follow_time' + ,fullPanel:true ,type: 'datetime' }); laydate.render({ elem: '#next_time' + ,fullPanel:true ,min: 0 ,type: 'datetime' }); + + form.on('select(chance)', function(data){ + var check_type = data.elem[data.elem.selectedIndex].title; + if(check_type == 0){ + form.val('demo-val-filter', { + "stage": "" + }); + $("#stage").attr("disabled",true); + } + else{ + $("#stage").removeAttr("disabled"); + } + form.render(); + }); //监听提交 form.on('submit(webform)', function (data) { + if(data.field.chance_id!='' && data.field.stage==''){ + layer.msg('请选择当前阶段'); + return false; + } let callback = function (e) { layer.msg(e.msg); if (e.code == 0) { diff --git a/app/customer/view/api/edit_trace.html b/app/customer/view/api/edit_trace.html index 6663eb7..7211742 100644 --- a/app/customer/view/api/edit_trace.html +++ b/app/customer/view/api/edit_trace.html @@ -1,14 +1,12 @@ {extend name="../../base/view/common/base" /} {block name="body"} - -

新增跟进记录

+ +

编辑跟进记录

- - - + + + - + + + - + + + - - - -
客户名称{$detail.customer}
{$detail.customer} 联 系 人*
跟进方式* 跟进时间* - +
下次沟通时间* + +
沟通内容* @@ -39,27 +43,23 @@
当前阶段*销售机会 + + 当前阶段 - {volist name=":trace_stage()" id="v"} {/volist} - 销售机会 - - 下次沟通时间* -
@@ -80,15 +80,35 @@ var form = layui.form,tool=layui.tool,laydate = layui.laydate; laydate.render({ elem: '#follow_time' + ,fullPanel:true ,type: 'datetime' }); laydate.render({ elem: '#next_time' + ,fullPanel:true ,min: 0 ,type: 'datetime' }); + + form.on('select(chance)', function(data){ + var check_type = data.elem[data.elem.selectedIndex].title; + if(check_type == 0){ + form.val('demo-val-filter', { + "stage": "" + }); + $("#stage").attr("disabled",true); + } + else{ + $("#stage").removeAttr("disabled"); + } + form.render(); + }); //监听提交 form.on('submit(webform)', function (data) { + if(data.field.chance_id!='' && data.field.stage==''){ + layer.msg('请选择当前阶段'); + return false; + } let callback = function (e) { layer.msg(e.msg); if (e.code == 0) { diff --git a/app/customer/view/api/view_trace.html b/app/customer/view/api/view_trace.html index ba399bb..acda783 100644 --- a/app/customer/view/api/view_trace.html +++ b/app/customer/view/api/view_trace.html @@ -6,36 +6,32 @@ - + + + - - + + + {gt name="$detail.chance_id" value="0"} + + - - - - + {/gt}
客户名称{$detail.customer}{$detail.customer}联 系 人{$detail.contact_name}
联 系 人 - {volist name=":customer_contact($detail.cid)" id="v"} - {eq name="$v.id" value="$detail.contact_id"}{$v.name}{/eq} - {/volist} - 跟进方式 {$detail.type_name} 跟进时间 {$detail.follow_time}下次沟通时间{$detail.next_time}
沟通内容 {$detail.content}
销售机会 + {$detail.chance_name} + 当前阶段 {$detail.stage_name}销售机会 - {volist name=":customer_chance($detail.cid)" id="v"} - {eq name="$v.id" value="$detail.chance_id"}{$v.title}{/eq} - {/volist} - 下次沟通时间{$detail.next_time}
{/block} @@ -44,7 +40,10 @@ {block name="script"} {/block} \ No newline at end of file diff --git a/app/customer/view/trace/index.html b/app/customer/view/trace/index.html new file mode 100644 index 0000000..bc14a0b --- /dev/null +++ b/app/customer/view/trace/index.html @@ -0,0 +1,115 @@ +{extend name="../../base/view/common/base" /} + +{block name="body"} +
+
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ + +
+
+
+
+{/block} + + + +{block name="script"} + +{/block} + \ No newline at end of file diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql index f9682ab..4759d4f 100644 --- a/app/install/data/gouguoa.sql +++ b/app/install/data/gouguoa.sql @@ -383,6 +383,7 @@ INSERT INTO `oa_admin_rule` VALUES (201, 196, 'home/files/add_group', '新建/ INSERT INTO `oa_admin_rule` VALUES (202, 196, 'home/files/del_group', '删除附件分组','附件分组', 'home', '', 2, 1, 1, 0, 0); INSERT INTO `oa_admin_rule` VALUES (203, 76, 'user/personal/leave_check', '资料交接', '离职资料', 'user', '', 2, 1, 1, 0, 0); +INSERT INTO `oa_admin_rule` VALUES (204, 136, 'customer/trace/index', '跟进记录', '跟进记录', 'customer', '', 1, 0, 1, 1656143065, 0); -- ---------------------------- -- Table structure for oa_admin_group -- ---------------------------- @@ -403,9 +404,9 @@ CREATE TABLE `oa_admin_group` ( -- ---------------------------- -- Records of oa_admin_group -- ---------------------------- -INSERT INTO `oa_admin_group` VALUES (1, '超级员工权限', 1, '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203', '1,2,3,4,5,6,7,8,9,10,11,12','超级员工权限,拥有系统的最高权限,不可修改。', 0, 0); -INSERT INTO `oa_admin_group` VALUES (2, '总经理权限', 1, '1,9,13,17,20,23,25,26,30,2,34,37,41,44,47,50,53,56,59,3,62,65,68,69,71,74,76,4,79,82,85,5,88,91,92,93,94,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203','1,2,3,4,5,6,7,8,9,10,11,12', '总经理的管理权限,可根据公司的具体需求调整。', 0, 0); -INSERT INTO `oa_admin_group` VALUES (3, '普通员工权限', 1, '5,88,91,92,93,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203','1,2,3,4,5,6,7,8,9,10,11,12', '普通员工管理权限,可根据公司的具体需求调整。', 0, 0); +INSERT INTO `oa_admin_group` VALUES (1, '超级员工权限', 1, '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204', '1,2,3,4,5,6,7,8,9,10,11,12','超级员工权限,拥有系统的最高权限,不可修改。', 0, 0); +INSERT INTO `oa_admin_group` VALUES (2, '总经理权限', 1, '1,9,13,17,20,23,25,26,30,2,34,37,41,44,47,50,53,56,59,3,62,65,68,69,71,74,76,4,79,82,85,5,88,91,92,93,94,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204','1,2,3,4,5,6,7,8,9,10,11,12', '总经理的管理权限,可根据公司的具体需求调整。', 0, 0); +INSERT INTO `oa_admin_group` VALUES (3, '普通员工权限', 1, '5,88,91,92,93,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204','1,2,3,4,5,6,7,8,9,10,11,12', '普通员工管理权限,可根据公司的具体需求调整。', 0, 0); -- ---------------------------- -- Table structure for oa_data_auth