浏览代码

call list

wesley 6 年之前
父节点
当前提交
5cbc3706d9

+ 112 - 0
app/Http/Controllers/Admin/Call/ListController.php

xqd
@@ -0,0 +1,112 @@
+<?php
+/**
+ *  通话列表
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-12-18 16:38:51
+ *
+ */
+namespace App\Http\Controllers\Admin\Call;
+use App\Http\Controllers\Admin\Controller;
+use Illuminate\Http\Request;
+use App\Repositories\Base\Criteria\OrderBy;
+use App\Repositories\Call\Lists\Criteria\MultiWhere;
+use App\Repositories\Call\ListRepository;
+
+class ListController extends Controller
+{
+    private $repository;
+
+    public function __construct(ListRepository $repository) {
+        if(!$this->repository) $this->repository = $repository;
+    }
+
+    /**
+     * 列表页
+     */
+    function index(Request $request) {
+        $search['keyword'] = $request->input('keyword');
+        $query = $this->repository->pushCriteria(new MultiWhere($search));
+
+        if(isset($request['sort_field']) && $request['sort_field'] && isset($request['sort_field_by'])) {
+        $query = $query->pushCriteria(new OrderBy($request['sort_field'],$request['sort_field_by']));
+        }else{
+            $query = $query->pushCriteria(new OrderBy('updated_at','DESC'));
+        }
+        $list = $query->paginate(16);
+        return view('admin.call.list.index',compact('list'));
+    }
+
+
+    /**
+     * 添加
+     */
+    public function create(Request $request)
+    {
+        if($request->method() == 'POST') {
+            return $this->_createSave();
+        }
+        return view('admin.call.list.edit');
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _createSave(){
+        $data = (array) request('data');
+        $id = $this->repository->create($data);
+        if($id) {
+            $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
+            $url[] = array('url'=>U( 'Call/List/create'),'title'=>'继续添加');
+            $this->showMessage('添加成功',$url);
+        }else{
+            $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
+            return $this->showWarning('添加失败',$url);
+        }
+    }
+    
+    /**
+     * 修改
+     */
+    public function update(Request $request) {
+        if($request->method() == 'POST') {
+            return $this->_updateSave();
+        }
+        $data = $this->repository->find($request->get('id'));
+        return view('admin.call.list.edit',compact('data'));
+    }
+
+    /**
+     * 保存修改
+     */
+    private function _updateSave() {
+        $data = (array) request('data');
+        $ok = $this->repository->update(request('id'),$data);
+        if($ok) {
+            $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
+            return $this->showMessage('操作成功',urldecode(request('_referer')));
+        }else{
+            $url[] = array('url'=>U( 'Call/List/index'),'title'=>'返回列表');
+            return $this->showWarning('操作失败',$url);
+        }
+    }
+
+    public function view(Request $request) {
+        $data = $this->repository->find(request('id'));
+        return view('admin.call.list.view',compact('data'));
+    }
+
+
+    
+    /**
+     * 删除
+     */
+    public function destroy(Request $request) {
+        $bool = $this->repository->destroy($request->get('id'));
+        if($bool) {
+            return  $this->showMessage('操作成功');
+        }else{
+            return  $this->showWarning("操作失败");
+        }
+    }
+}

+ 4 - 4
app/Models/CallListModel.php

xqd xqd
@@ -5,10 +5,10 @@ namespace App\Models;
 use App\Models\BaseModel;
 
 /**
- * @description 通话纪录
+ * @description 通话列表
  * @author  system;
  * @version    1.0
- * @date 2018-11-27 03:15:47
+ * @date 2018-12-18 16:38:51
  *
  */
 class CallListModel extends BaseModel
@@ -35,8 +35,8 @@ class CallListModel extends BaseModel
      */
     protected $fillable = [
         'phone',
-        'sync',
-        'ip'
+        'ip',
+        'sync'
     ];
 
 }

+ 21 - 0
app/Repositories/Call/ListRepository.php

xqd
@@ -0,0 +1,21 @@
+<?php
+/**
+ *   通话列表
+ *  @author  system
+ *  @version    1.0
+ *  @date 2018-12-18 16:38:51
+ *
+ */
+namespace App\Repositories\Call;
+
+use App\Repositories\Base\Repository;
+
+
+class ListRepository extends Repository {
+
+    public function model() {
+        return \App\Models\CallListModel::class;
+    }
+
+    
+}

+ 39 - 0
app/Repositories/Call/Lists/Criteria/MultiWhere.php

xqd
@@ -0,0 +1,39 @@
+<?php
+
+namespace App\Repositories\Call\Lists\Criteria;
+
+use App\Repositories\Base\Criteria;
+use App\Repositories\Contracts\RepositoryInterface as Repository;
+
+class MultiWhere extends Criteria
+{
+
+    private $search = [];
+
+    /**
+     * MultiWhere constructor.
+     * @param array $search
+     *
+     */
+    public function __construct(array $search)
+    {
+        $this->search = $search;
+    }
+
+    /**
+     * @param $model
+     * @param RepositoryInterface $repository
+     * @return mixed
+     */
+    public function apply($model, Repository $repository)
+    {
+        if (isset($this->search['keyword']) && $this->search['keyword']) {
+            $model = $model->where('id', 'like', '%' . $this->search['keyword'] . '%')
+                ->orWhere('phone', 'like', '%' . $this->search['keyword'] . '%')
+                ->orWhere('ip', 'like', '%' . $this->search['keyword'] . '%')
+                ->orWhere('sync', 'like', '%' . $this->search['keyword'] . '%');
+        }
+        return $model;
+    }
+
+}

+ 88 - 0
resources/views/admin/call/list/edit.blade.php

xqd
@@ -0,0 +1,88 @@
+@extends('admin.layouts.app')
+
+@section('content')
+
+    <?php
+    if (!isset($data)) $data = array();
+    if (!$data && session("data")) {
+        $data = session("data");
+    }
+    if (!$data && session('_old_input')) {
+        $data = session("_old_input");
+    }
+    ?>
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>通话列表</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+                        </a>
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    @if(role('Call/List/index'))
+                        <div class="row">
+                            <div class="col-sm-10 pull-right">
+                                <a href="{{ U('Call/List/index')}}" class="btn btn-sm btn-primary pull-right">返回列表</a>
+                            </div>
+                        </div>
+                    @endif
+
+                    <div class="row">
+                        <div class="col-lg-10">
+                            <form name="form_product" id="form-validation" action=""
+                                  class="form-horizontal form-validation" accept-charset="UTF-8" method="post">
+
+                                    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">电话号码</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_phone" name="data[phone]" class="form-control" value="{{ $data['phone'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">拨打IP</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_ip" name="data[ip]" class="form-control" value="{{ $data['ip'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>    
+                <div class="form-group row">
+                                    
+                 <label class="col-form-label col-sm-3">是否拨打:1:是;0:否</label>
+                                    
+                   <div class="col-sm-9">
+                     <input id="data_sync" name="data[sync]" class="form-control" value="{{ $data['sync'] or ''}}" required="" aria-required="true"  placeholder=""> 
+                    </div>
+                                
+                </div>
+
+                                <div class="form-group row">
+                                    <label class="col-form-label col-sm-3">&nbsp;</label>
+                                    <div class="col-sm-9">
+                                        <input type="hidden" name="_referer"
+                                               value="<?php echo urlencode(request()->server('HTTP_REFERER'));?>"/>
+                                        <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>"/>
+                                        <input type="submit" class="btn btn-success" style="margin-right:20px;">
+                                        <input type="reset" class="btn btn-default">
+                                    </div>
+                                </div>
+
+                            </form>
+                        </div>
+                        <!-- /.col-lg-10 -->
+                    </div>
+                    <!-- /.row -->
+                </div>
+            </div>
+        </div>
+    </div>
+
+@endsection

+ 93 - 0
resources/views/admin/call/list/index.blade.php

xqd
@@ -0,0 +1,93 @@
+@extends('admin.layouts.app')
+
+@section('content')
+    <div class="row">
+        <div class="col-sm-12">
+            <div class="ibox float-e-margins">
+                <div class="ibox-title">
+                    <h5>通话列表</h5>
+                    <div class="ibox-tools">
+                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
+                        </a>
+                    </div>
+                </div>
+                <div class="ibox-content">
+                    <div class="form-group">
+                        <div class="row">
+                            <div class="col-sm-4">
+                                <form method="GET" action="" accept-charset="UTF-8">
+                                    <div class="input-group">
+                                        <input type="text" class="form-control" value="{{Request::get('keyword')}}"
+                                               placeholder="请输入关键词"
+                                               name="keyword">
+                                        <span class="input-group-append">
+                                                <button type="submit" class="btn btn-primary"
+                                                        style="height: 100%">搜索</button>
+                                            </span>
+                                    </div>
+                                </form>
+                            </div>
+
+                            @if(role('Call/List/create'))
+                                <div class="col-sm-8 pull-right">
+                                    <a href="{{ U('Call/List/create')}}" class="btn btn-primary pull-right">添加</a>
+                                </div>
+                            @endif
+                        </div>
+                    </div>
+
+                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
+                        <thead>
+                        <tr>
+
+                            <th class="sorting" data-sort="id"> ID</th>
+                            <th class="sorting" data-sort="phone"> 电话号码</th>
+                            <th class="sorting" data-sort="ip"> 拨打IP</th>
+                            <th class="sorting" data-sort="sync"> 是否拨打:</th>
+                            <th class="sorting" data-sort="created_at"> 添加时间</th>
+                            <th class="sorting" data-sort="updated_at"> 更新时间</th>
+                            <th width="22%">相关操作</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        @if(isset($list))
+                            @foreach($list as $key => $item)
+                                <tr>
+
+                                    <td>{{ $item->id }}</td>
+                                    <td>{{ $item->phone }}</td>
+                                    <td>{{ $item->ip }}</td>
+                                    <td>{{ dict()->get('call_list','sync',$item->sync) }}</td>
+                                    <td>{{ $item->created_at }}</td>
+                                    <td>{{ $item->updated_at }}</td>
+                                    <td>
+                                        @if(role('Call/List/destroy'))
+                                            <a class="btn btn-sm btn-danger"
+                                               href="{{ U('Call/List/destroy',['id'=>$item->id])}}"
+                                               onclick="return confirm('你确定执行删除操作?');">删除</a>
+                                        @endif
+                                    </td>
+                                </tr>
+                            @endforeach
+                        @endif
+
+                        </tbody>
+                    </table>
+                    <div class="row">
+                        <div class="col-sm-6">
+                            <div class="dataTables_info" id="DataTables_Table_0_info"
+                                 role="alert" aria-live="polite" aria-relevant="all">每页{{ $list->count() }}
+                                条,共{{ $list->lastPage() }}页,总{{ $list->total() }}条。
+                            </div>
+                        </div>
+                        <div class="col-sm-6">
+                            <div class="dataTables_paginate paging_simple_numbers" id="DataTables_Table_0_paginate">
+                                {!! $list->setPath('')->appends(Request::all())->render() !!}
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+@endsection