From 43f290020f74c2098611ab296dafc21ebab94567 Mon Sep 17 00:00:00 2001 From: xxb Date: Thu, 19 Aug 2021 16:53:21 +0800 Subject: [PATCH] liche update for admin clues edit city_code --- admin/controllers/Common.php | 2 +- admin/controllers/receiver/Clues.php | 23 +++++++++ admin/views/receiver/clues/edit.php | 71 +++++++++++++++++++++++++++- common/models/Area_model.php | 4 +- 4 files changed, 96 insertions(+), 4 deletions(-) diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index a264aa63..9b41c4d2 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -35,7 +35,7 @@ class Common extends CI_Controller $this->data = $city; break; case 'county': - $this->data = $this->area_model->county($id); + $this->data = $this->area_model->county($id, $type); break; default: $this->data = $this->area_model->province(); diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 34dd9e1c..e8d2457f 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -136,6 +136,21 @@ class Clues extends HD_Controller $intention['cor_name'] = '车身颜色:' . ($jsondata['car']['color']['title'] ? $jsondata['car']['color']['title'] : ''); $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; + $autoList[1] = $this->mdAutoBrand->select(array('status' => 1), 'id desc', 0, 0, 'id,name'); if ($re['brand_id']) { $autoList[2] = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $re['brand_id']), 'id desc', 0, 0, 'id,name'); @@ -331,6 +346,14 @@ class Clues extends HD_Controller $jsondata = $re['jsondata'] ? json_decode($re['jsondata'], true) : array(); $jsondata['car']['version']['id'] = intval($info['v_id']); $jsondata['car']['color']['id'] = intval($info['cor_id']); + if($info['city_id'] || $info['county_id']){ + $jsondata['info']['city_code'] = $info['county_id'] ? $info['county_id'] : $info['city_id']; + } else { + if($jsondata['info'] && $jsondata['info']['city_code']){ + unset($jsondata['info']['city_code']); + } + } + $ret = $this->clues_model->update(array('brand_id' => $info['brand_id'], 's_id' => $info['s_id'], 'jsondata' => json_encode($jsondata, JSON_UNESCAPED_UNICODE)), array('id' => $info['id'])); if (!$ret) { diff --git a/admin/views/receiver/clues/edit.php b/admin/views/receiver/clues/edit.php index c915a8f7..60482e45 100644 --- a/admin/views/receiver/clues/edit.php +++ b/admin/views/receiver/clues/edit.php @@ -68,7 +68,7 @@
-
业主电话:
+
客户电话:
{{infoShow.mobile_sub}}
@@ -175,6 +175,25 @@ + + +
+
城市:
+ + +
+ +
@@ -262,11 +281,14 @@ info: {}, infoShow: {"intention": {}, 'autoList': []}, goods: {"imgs_url": [], "imgs": [], "log": ''}, + cityAry:[], + countyAry:[] }, mounted: function () { var that = this; that.info = ; that.infoShow = ; + that.init_citys(); }, computed: {}, created: function () { @@ -274,6 +296,24 @@ updated: function () { }, methods: { + init_citys:function(){ + var vm = this; + $.ajax({ + type: 'get', + url: '/common/area', + dataType: 'json', + data: { + id: '350', + key:'city', + type:1 + }, + success:function(response){ + if (response.code == 1) { + vm.cityAry = response.data; + } + } + }); + }, editType: function (index) { var vm = this; if (index == 1) { @@ -441,6 +481,35 @@ }, }); }, + }, + watch:{ + 'info.city_id':function(nv, ov){ + var that = this; + console.log(that.info); + if(nv == ''){ + that.countyAry = []; + that.info.county_id = ''; + } else { + if(nv.substring(0,4) != that.info.county_id.substring(0, 4)){ + that.info.county_id = ''; + } + $.ajax({ + type: 'get', + url: '/common/area', + dataType: 'json', + data: { + id: nv, + key:'county', + type:1 + }, + success:function(response){ + if (response.code == 1) { + that.countyAry = response.data; + } + } + }); + } + } } }); }); diff --git a/common/models/Area_model.php b/common/models/Area_model.php index 988f0f71..c56fe7d4 100755 --- a/common/models/Area_model.php +++ b/common/models/Area_model.php @@ -57,11 +57,11 @@ class Area_model extends HD_Model return $result; } - public function county($city_id = '') + public function county($city_id = '', $type = 0) { $result = array(); $list = $this->select(array('city_id' => $city_id), null, null, null, 'distinct(county_id), county_name'); - $result[] = array('name'=>'行政区','id'=>''); + $type == 0 && $result[] = array('name'=>'行政区','id'=>''); if($list) { foreach ($list as $v)