diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 03a4b863..c9a261c9 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -8,6 +8,10 @@ class Clues extends HD_Controller{ public function __construct(){ parent::__construct(); + $this->load->model('receiver/receiver_clues_model', 'clues_model'); + $this->load->model('receiver/receiver_clues_cfrom_model', 'clues_cfrom_model'); + $this->load->model('receiver/receiver_customers_model', 'customers_model'); + $this->load->model('receiver/receiver_clue_oplogs_model', 'mdOplogs'); $this->log_dir = 'receiver_clues'; @@ -46,7 +50,7 @@ class Clues extends HD_Controller{ } } strlen($params['status']) && $where["status"] = $params['status']; - + $count = $this->clues_model->count($where); $lists = []; if($count){ @@ -74,31 +78,47 @@ class Clues extends HD_Controller{ return $this->show_view('receiver/clues/lists', true); } - public function get(){ + public function get() + { $params = $this->input->get(); $id = intval($params['id']); if (!$id) { return $this->show_json(SYS_CODE_FAIL, '非法参数!'); } - $statusList = $logsList = array(); - $re = $this->clues_model->get(array('id'=>$id)); + $statusList = $logsList = $intention = array(); + $re = $this->clues_model->get(array('id' => $id)); $dataInfo = $re; foreach ($this->clues_model->get_status() as $key => $value) { $statusList[] = array("id" => $key, "name" => $value); } $dataInfo['editType'] = 0; - $re_cf = $this->clues_cfrom_model->get(array('id'=>$re['cf_id'])); + $re_cf = $this->clues_cfrom_model->get(array('id' => $re['cf_id'])); $info_show['cfrom_title'] = $re_cf['title'] ? $re_cf['title'] : ''; $info_show['statusList'] = $statusList; - $info_show['status2List'] = array(array("id" => 1, "name" => '未回访'),array("id" => 2, "name" => '已回访')); + $info_show['status2List'] = array(array("id" => 1, "name" => '未回访'), array("id" => 2, "name" => '已回访')); $info_show['c_time'] = date('Y-m-d H:i', $re['c_time']); $info_show['mobile_sub'] = $re['mobile'] ? substr_replace($re['mobile'], '*****', 0, 5) : ''; - $resLogs = $this->mdReceiverOplogs->select(array('clue_id'=>$id), 'id desc', 0, 0); + $resLogs = $this->mdOplogs->select(array('clue_id' => $id), 'c_time desc', 0, 0); foreach ($resLogs as $key => $value) { $setValue = array(); + $setValue['uname'] = $value['uname']; + $setValue['log'] = $value['log']; + $setValue['type_name'] = '小记'; + $setValue['c_time'] = date('Y-m-d H:i', $value['c_time']); $logsList[] = $setValue; } $info_show['logsList'] = $logsList; + //意向信息 + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $re_b = $this->mdAutoBrand->get(array('id' => $re['brand_id']), 'name'); + $re_s = $this->mdAutoSeries->get(array('id' => $re['s_id']), 'name'); + $jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : array(); + $intention['brand_name'] = '品牌:' . ($re_b ? $re_b['name'] : ''); + $intention['s_name'] = '车系:' . ($re_s ? $re_s['name'] : ''); + $intention['v_name'] = '车型:' . ($jsondata['car']['version']['title'] ? $jsondata['car']['version']['title'] : ''); + $intention['cor_name'] = '车身颜色:' . ($jsondata['car']['color']['title'] ? $jsondata['car']['color']['title'] : ''); + $info_show['intention'] = $intention; $this->data['info'] = $dataInfo; $this->data['info_show'] = $info_show; $this->data['_title'] = '线索详情'; @@ -132,7 +152,33 @@ class Clues extends HD_Controller{ return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); } - function add_excel(){ + public function add_log() + { + $params = $this->input->post(); + if (!$params['id']) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + if (!$params['log']) { + return $this->show_json(SYS_CODE_FAIL, '请输入内容!'); + } + $addData = array( + 'clue_id' => $params['id'], + 'uid' => $this->uid, + 'uname' => $this->username, + 'type' => intval($params['type']), + 'log' => $params['log'], + 'c_time' => time() + ); + $id = $this->mdOplogs->add($addData); + if ($id) { + return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); + } else { + return $this->show_json(SYS_CODE_FAIL, '添加失败'); + } + } + + function add_excel() + { require_once COMMPATH . '/third_party/PHPExcel/IOFactory.php'; $res = $this->upload(); if (!$res['code']) { @@ -169,7 +215,33 @@ class Clues extends HD_Controller{ } //编辑单条数据 - public function edit(){ + public function edit() + { + $info = $this->input->post('info'); + $opt_type = $this->input->post('opt_type'); + if (!$info) { + return $this->show_json(SYS_CODE_FAIL, '非法参数!'); + } + $re = $this->clues_model->get(array('id' => $info['id'])); + if (!$re || empty($re)) { + return $this->show_json(SYS_CODE_FAIL, '线索不存在!'); + } + if ($info['editType'] == 1) { + $status_name = $this->clues_model->get_status()[$re['status']]; + $status_name_up = $this->clues_model->get_status()[$info['status']]; + $log = '更新状态(' . $status_name . ')为(' . $status_name_up . ')'; + $addData = array( + 'clue_id' => $info['id'], + 'uid' => $this->uid, + 'uname' => $this->username, + 'type' => 0, + 'log' => $log, + 'c_time' => time() + ); + $this->mdOplogs->add($addData); + } + $this->clues_model->update(array('status' => $info['status']), array('id' => $info['id'])); + return $this->show_json(SYS_CODE_SUCCESS, '成功修改状态!'); } //删除单条数据 diff --git a/admin/views/receiver/clues/edit.php b/admin/views/receiver/clues/edit.php index 6c01dc6d..a513f12e 100644 --- a/admin/views/receiver/clues/edit.php +++ b/admin/views/receiver/clues/edit.php @@ -17,7 +17,7 @@ -
+ @@ -208,7 +197,7 @@ el: '#vue-edit', data: { info: {}, - infoShow: {}, + infoShow: {"intention":{}}, goods: {"imgs_url": [], "imgs": [], "log": ''}, }, mounted: function () { @@ -274,7 +263,7 @@ btn: ['保存', '取消'], yes: function (index) { $.ajax({ - url: '/app/jdb/log/add', + url: '/receiver/clues/add_log', type: 'post', dataType: 'json', data: { @@ -306,9 +295,6 @@ }, saveEdit: function () { var vm = this; - if (vm.info.editType == 6) { - vm.info.visit_time = $('#visit_time_id').val(); - } $.ajax({ url: '/receiver/clues/edit', type: 'post', diff --git a/admin/views/receiver/clues/lists.php b/admin/views/receiver/clues/lists.php index 147050e6..750c95a2 100644 --- a/admin/views/receiver/clues/lists.php +++ b/admin/views/receiver/clues/lists.php @@ -72,7 +72,7 @@
+ data-modal="/receiver/clues/get_add" data-title="新增线索">新增