From dee4fa0ea5c8e1b2a3a087d5c70bc21b90267b53 Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Thu, 26 Aug 2021 13:56:52 +0800 Subject: [PATCH] edit-admin-clues-cfrom --- admin/controllers/receiver/Clues.php | 94 ++++++++++++++++++++-------- admin/views/app/liche/cms/edit.php | 5 +- admin/views/receiver/clues/lists.php | 60 ++++++++++++++---- 3 files changed, 117 insertions(+), 42 deletions(-) diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index dd0ef779..913b84c6 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -35,22 +35,18 @@ class Clues extends HD_Controller $status_arr = $this->clues_model->get_status(); $params = $this->input->get(); - $this->data['province_id'] = $province_id = 350;//默认福建城市 $this->data['city_id'] = $city_id = intval($params['city_id']); $this->data['county_id'] = $county_id = intval($params['county_id']); - $this->data['provinces'] = $this->area_model->select(array(), '', 0, 0, 'distinct(province_id), province_name'); - if($province_id){ - //获取系统配置的城市 - $map_city = $this->city_ary(); - $rows_city = array(); - foreach($map_city as $k => $v){ - $rows_city[] = array( - 'city_id' => $k, - 'city_name' => $v - ); - } - $this->data['citys'] = $rows_city; + //获取系统配置的城市 + $map_city = $this->city_ary(); + $rows_city = array(); + foreach($map_city as $k => $v){ + $rows_city[] = array( + 'city_id' => $k, + 'city_name' => $v + ); } + $this->data['citys'] = $rows_city; if($city_id){ $this->data['countys'] = $this->area_model->select(array('city_id' => $city_id)); } @@ -76,7 +72,17 @@ class Clues extends HD_Controller strlen($params['status']) && $where["status"] = $params['status']; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; - + if($params['cfrom_id']||$params['cfrom_id2']){ + if($params['cfrom_id2']){ + $where['cf_id'] = $params['cfrom_id2']; + }else{ + $cf_rows = $this->clues_cfrom_model->select(['pid'=>$params['cfrom_id']],'','','','id'); + $cf_ids = array_column($cf_rows,'id'); + $cf_ids[] = $params['cfrom_id']; + $cf_str_ids = implode(',',array_filter($cf_ids)); + $cf_str_ids && $where["cf_id in ({$cf_str_ids})"] = null; + } + } $count = $this->clues_model->count($where); $lists = []; if ($count) { @@ -165,19 +171,8 @@ class Clues extends HD_Controller $info_show['intention'] = $intention; //获取城市区域 - $city_id = ''; - $county_id = ''; - if($jsondata['info'] && $jsondata['info']['city_code']){ - $city_code = $jsondata['info']['city_code']; - if('0' === $city_code[5]){ - $city_id = $city_code; - } else { - $county_id = $city_code; - $city_id = substr_replace($county_id, '00', 4, 2); - } - } - $dataInfo['city_id'] = $city_id; - $dataInfo['county_id'] = $county_id; + $dataInfo['city_id'] = $re['city_id']; + $dataInfo['county_id'] = $re['county_id']; $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); if ($re['brand_id']) { @@ -736,5 +731,50 @@ class Clues extends HD_Controller return $done; } + //获取线索来源 + public function get_cfroms(){ + $id = $this->input->get('id'); + $where = [ + 'status' => 1, + 'pid' => 0 + ]; + $id && $where['pid'] = $id; + $rows = $this->clues_cfrom_model->select($where,'id desc','','','id,title'); + $this->data['data'] = $rows; + return $this->show_json(SYS_CODE_SUCCESS); + } + public function get_change(){ + $page = $this->input->get('page'); + $size = $this->input->get('size'); + !$page && $page = 1; + !$size && $size = 20; + + $where = [ + 'c_time<' => 1629907200, + ]; + $rows = $this->clues_model->select($where,'id desc',$page,$size,'id,jsondata'); + if($rows){ + $this->load->model('sys/sys_area_model'); + $up_ids = []; + foreach($rows as $key => $val){ + $jsondata = json_decode($val['jsondata'],true); + if($jsondata['info']['city_code']){ + $city_code = $jsondata['info']['city_code']; + $city = $this->sys_area_model->get(['county_id'=>$city_code],'city_id,county_id'); + if($city){ + $update = [ + 'city_id' => $city['city_id'], + 'county_id' => $city['county_id'] + ]; + $this->clues_model->update($update,['id'=>$val['id']]); + $up_ids[] = $val['id']; + } + } + } + echo "do up ids: ".implode(',',$up_ids); + }else{ + echo 'finish'; + } + } } diff --git a/admin/views/app/liche/cms/edit.php b/admin/views/app/liche/cms/edit.php index c69a5661..a98bd34d 100755 --- a/admin/views/app/liche/cms/edit.php +++ b/admin/views/app/liche/cms/edit.php @@ -340,8 +340,7 @@ var vm = this; if (vm.itemsPage.page == 1) { layer.msg("已经是第一页了"); - return; - } + return; } vm.itemsPage.page--; vm.getItems(vm.itemsPage.page); }, @@ -377,7 +376,7 @@ methods: { getCfroms: function(){ var that = this - if(that.info.cfrom_id){ + if(that.info.cfrom_id>0){ $.get('/app/liche/cms/get_cfroms',{'id':that.info.cfrom_id},function(result){ that.cfroms2 = result.data.data }); diff --git a/admin/views/receiver/clues/lists.php b/admin/views/receiver/clues/lists.php index 47cbf1fb..2449fc94 100644 --- a/admin/views/receiver/clues/lists.php +++ b/admin/views/receiver/clues/lists.php @@ -39,18 +39,6 @@
-
+
+ +
+ +
+
+ +
+
@@ -282,6 +289,35 @@ } }); }); + vue_obj = new Vue({ + el: '#cfrom_app', + data: { + cfrom_id:, + cfrom_id2:, + cfroms:[], + cfroms2:[], + }, + mounted: function(){ + this.getCfroms() + this.getCfroms2() + }, + methods: { + getCfroms: function(){ + var that = this + $.get('/receiver/clues/get_cfroms',function(result){ + that.cfroms = result.data.data + }); + }, + getCfroms2: function(){ + var that = this + if(that.cfrom_id>0){ + $.get('/receiver/clues/get_cfroms',{'id':that.cfrom_id},function(result){ + that.cfroms2 = result.data.data + }); + } + }, + } + }) });