Bläddra i källkod

【Add】增加客户城市筛选以及显示

liuxiangxin 6 månader sedan
förälder
incheckning
d1ba222736
2 ändrade filer med 22 tillägg och 1 borttagningar
  1. 9 1
      app/Http/Controllers/Admin/Custom.php
  2. 13 0
      resources/views/admin/custom/index.blade.php

+ 9 - 1
app/Http/Controllers/Admin/Custom.php

@@ -28,12 +28,13 @@ class Custom extends Auth{
 	 * 列表页
 	 * 
 	 * */
-    public function index(Model $Model,CustomScore $CustomScore,WeiBanFollow $WeiBanFollow){
+    public function index(Model $Model,CustomScore $CustomScore,WeiBanFollow $WeiBanFollow,City $City){
  		// 接受参数
 		$code					= request('custom_code','');
 		$phone					= request('phone','');
 		$username				= request('username','');
 		$weibanId				= request('weiban_extid','');
+		$cityId					= request('city_id',0);
 		$status					= request('status');
 		$startTime				= request('start_time','');
 		// 编码转ID
@@ -44,6 +45,7 @@ class Custom extends Auth{
 		if( $uid )				$map[] = ['uid','=',$uid];
 		if( $phone )			$map[] = ['phone','=',$phone];
 		if( $username )			$map[] = ['username','=',$username];
+		if( $cityId )			$map[] = ['city_id','=',$cityId];
 		if( $weibanId )			$map[] = ['weiban_extid','=',$weibanId];
 		if( $startTime )		$map[] = ['insert_time','>=',Carbon::createFromFormat('Y-m-d',$startTime)->startOfDay()->getTimestamp()];
 		if( $startTime )		$map[] = ['insert_time','<=',Carbon::createFromFormat('Y-m-d',$startTime)->endOfDay()->getTimestamp()];
@@ -52,6 +54,8 @@ class Custom extends Auth{
 		$list					= $Model->query()->where($map)->orderByDesc('uid')->paginate(config('page_num',10))->appends(request()->all());
 		// 循环处理数据
 		foreach ($list as $key => $value) {
+			// 城市名
+			$value['city_name'] 	= $value['city_id'] ? $City->getOne($value['city_id'],'name') : '';
 			// id转编号
 			$value['custom_code'] 	= $Model->idToCode($value['uid']);
 			// id转编号
@@ -66,6 +70,10 @@ class Custom extends Auth{
 			// 重组
 			$list[$key]				= $value;
 		}
+		// 获取列表
+		$cityList					= $City->getCityList();
+		// 分配数据
+		$this->assign('cityList',$cityList);
 		// 分配数据
 		$this->assign('empty', '<tr><td colspan="20">~~暂无数据</td></tr>');
 		$this->assign('list',$list);

+ 13 - 0
resources/views/admin/custom/index.blade.php

@@ -32,6 +32,17 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 			<option value="1" @if (request('status') === '1' ) selected="selected" @endif >禁用</option>
 		</select>
 	</div>
+	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
+	<select name="city_id" class="form-control selectpicker" data-live-search="true" data-live-search-placeholder="搜索城市" data-none-results-text="未搜索到 {0}" title="选择城市">
+			@foreach ($cityList as $group)
+			<optgroup label="{{$group['name']}}">
+				@foreach ($group['city'] as $city)
+				<option value="{{$city['id']}}" @if( $city['id'] == request('city_id',0) ) selected @endif >{{$city['name']}}</option>
+				@endforeach
+			</optgroup>
+			@endforeach
+		</select>
+	</div>
 	<div class="form-group col col-lg-2 col-md-2 col-sm-2 col-xs-2" style="margin-right: 2px;">
 		<input type="date" class="form-control" name="start_time" value="{{request('start_time','')}}" placeholder="请输入创建时间查询" />
 	</div>
@@ -50,6 +61,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 						<th>联系方式</th>
 						<th>客户积分</th>
 						<th>微伴ID</th>
+						<th>客户城市</th>
 						<th>客户状态</th>
 						<th>创建时间</th>
 						<th>更新时间</th>
@@ -65,6 +77,7 @@ style="margin: 0 auto;width: 96%;padding: 30px 0px;"
 							<td> {{$a['phone']}} </td>
 							<td> {{$a['custom_score']['score']}} </td>
 							<td> <a href="{{url('admin/weiban_external/index?'.http_build_query(['id'=>$a['weiban_extid']]))}}">{{$a['weiban_extid']}}</a></td>
+							<td> {{$a['city_name']}} </td>
 							<td> {{$a['status']?'禁用':'正常'}} </td>
 							<td> {{date('Y/m/d H:i:s',$a['insert_time'])}}</td>
 							<td> {{date('Y/m/d H:i:s',$a['update_time'])}}</td>