From a3bdddb17a40772d59cc3f33f218de456acf0764 Mon Sep 17 00:00:00 2001 From: dengbw Date: Wed, 15 Sep 2021 15:57:04 +0800 Subject: [PATCH] admin_clues_915 --- admin/controllers/receiver/Clues.php | 76 ++++++++-- admin/views/receiver/clues/edit.php | 89 +++++------ admin/views/receiver/clues/lists.php | 138 +++++++++++------- .../models/receiver/Receiver_clues_model.php | 41 ++++-- 4 files changed, 225 insertions(+), 119 deletions(-) diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 96bb5061..b3e62fea 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -32,7 +32,7 @@ class Clues extends HD_Controller public function lists($where = array()) { - $status_arr = $this->clues_model->get_status(); + $statusAry = $this->clues_model->statusAry(); $params = $this->input->get(); $this->data['city_id'] = $city_id = intval($params['city_id']); @@ -69,6 +69,7 @@ class Clues extends HD_Controller } } strlen($params['status']) && $where["status"] = $params['status']; + strlen($params['status2']) && $where["status2"] = $params['status2']; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; if ($params['cfrom_id'] || $params['cfrom_id2']) { @@ -85,7 +86,7 @@ class Clues extends HD_Controller $count = $this->clues_model->count($where); $lists = []; if ($count) { - $fileds = 'id,name,mobile,cf_id,status_id,c_time,admin_id,status,en_time'; + $fileds = 'id,name,mobile,cf_id,c_time,admin_id,status,status2,en_time'; $rows = $this->clues_model->select($where, 'en_time desc,id desc', $page, $size, $fileds); //获取来源 $cf_id_arr = array_unique(array_column($rows, 'cf_id')); @@ -100,9 +101,11 @@ class Clues extends HD_Controller } foreach ($rows as $key => $val) { $val['cf_title'] = isset($cf_rows[$val['cf_id']]) ? $cf_rows[$val['cf_id']][0]['title'] : ''; - $val['status_name'] = $status_arr[$val['status']]; + $status_name = $statusAry[$val['status']]['name']; + $val['status2'] && $status_name .= '‒' . $statusAry[$val['status']]['list'][$val['status2']]; + $val['status_name'] = $status_name; $val['admin_name'] = isset($map_admin[$val['admin_id']]) ? $map_admin[$val['admin_id']] : ''; - if(SUPER_ADMIN == $this->role){ + if (SUPER_ADMIN == $this->role) { $val['mobile_sub'] = $val['mobile']; } else { $val['mobile_sub'] = $val['mobile'] ? substr_replace($val['mobile'], '*****', 0, 5) : ''; @@ -110,11 +113,25 @@ class Clues extends HD_Controller $lists[] = $val; } } + $statusList = array(); + foreach ($this->clues_model->statusAry() as $key => $value) { + $cate = array(); + $where = array("status" => $key); + $count1 = $this->clues_model->count($where); + if ($value['list']) { + foreach ($value['list'] as $key2 => $value2) { + $where['status2'] = $key2; + $count2 = $this->clues_model->count($where); + $cate[] = array("id" => $key2, "name" => $value2, "count" => $count2); + } + } + $statusList[] = array("id" => $key, "name" => $value['name'], "cate" => $cate, "count" => $count1); + } $this->data['lists'] = $lists; $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); $this->data['searchTpAry'] = $this->searchTpAry; $this->data['params'] = $params; - $this->data['status_arr'] = $status_arr; + $this->data['statusList'] = $statusList; $this->data['_title'] = '线索池列表'; return $this->show_view('receiver/clues/lists', true); } @@ -126,23 +143,28 @@ class Clues extends HD_Controller if (!$id) { return $this->show_json(SYS_CODE_FAIL, '非法参数!'); } - $statusList = $logsList = $intention = $autoList = array(); + $statusList = $status2List = $logsList = $intention = $autoList = array(); $re = $this->clues_model->get(array('id' => $id)); if (!$re || empty($re)) { return $this->show_json(SYS_CODE_FAIL, '线索不存在!'); } $dataInfo = $re; - foreach ($this->clues_model->get_status() as $key => $value) { - $statusList[] = array("id" => $key, "name" => $value); + foreach ($this->clues_model->statusAry() as $key => $value) { + $statusList[] = array("id" => $key, "name" => $value['name']); + } + if (strlen($re['status'])) { + foreach ($this->clues_model->statusAry($re['status'])['list'] as $key => $value) { + $status2List[] = array("id" => $key, "name" => $value); + } } $dataInfo['editType'] = 0; $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'] = $status2List; $info_show['c_time'] = date('Y-m-d H:i', $re['c_time']); $info_show['en_time'] = $re['en_time']; - if(SUPER_ADMIN == $this->role){ + if (SUPER_ADMIN == $this->role) { $info_show['mobile_sub'] = $re['mobile']; } else { $info_show['mobile_sub'] = $re['mobile'] ? substr_replace($re['mobile'], '*****', 0, 5) : ''; @@ -217,6 +239,26 @@ class Clues extends HD_Controller return $this->show_view('receiver/clues/edit', true); } + /** + * Notes:二级分类 + * Created on: 2021/9/15 14:16 + * Created by: dengbw + * @return bool + */ + public function get_status2() + { + $params = $this->input->post(); + $status = $params['status']; + $status2List = array(); + if (strlen($status)) { + foreach ($this->clues_model->statusAry($status)['list'] as $key => $value) { + $status2List[] = array("id" => $key, "name" => $value); + } + } + $this->data = $status2List; + return $this->show_json(SYS_CODE_SUCCESS); + } + /** * 新增 * @return bool @@ -386,10 +428,18 @@ class Clues extends HD_Controller $msg = '修改成功'; $code = SYS_CODE_SUCCESS; if ($info['editType'] == 1) { - $status_name = $this->clues_model->get_status()[$re['status']]; - $status_name_up = $this->clues_model->get_status()[$info['status']]; + $statusAry = $this->clues_model->statusAry(); + if ($info['status'] == $re['status'] && $info['status2'] == $re['status2']) { + return $this->show_json(SYS_CODE_FAIL, '状态未修改!'); + } + $status_name = $statusAry[$re['status']]['name']; + $status_name_up = $statusAry[$info['status']]['name']; + if ($info['status2']) { + $status_name .= '-' . $statusAry[$re['status']]['list'][$re['status2']]; + $status_name_up .= '-' . $statusAry[$info['status']]['list'][$info['status2']]; + } $log = '更新状态(' . $status_name . ')为(' . $status_name_up . ')'; - $ret = $this->clues_model->update(array('status' => $info['status']), array('id' => $info['id'])); + $ret = $this->clues_model->update(array('status' => $info['status'], 'status2' => $info['status2']), array('id' => $info['id'])); if (!$ret) { $code = SYS_CODE_FAIL; $msg = '修改状态失败'; diff --git a/admin/views/receiver/clues/edit.php b/admin/views/receiver/clues/edit.php index 9267af3b..00aba13c 100644 --- a/admin/views/receiver/clues/edit.php +++ b/admin/views/receiver/clues/edit.php @@ -8,7 +8,7 @@ 状态
-