wesley 6 年之前
父节点
当前提交
7b1559dd0f

+ 8 - 2
app/Http/Controllers/Admin/Call/RecordsController.php

xqd xqd
@@ -40,15 +40,20 @@ class RecordsController extends Controller
             $order['id'] = 'DESC';
         }
 
+
         $list = $this->repository->searchRecords($search, $order);
+        $allIds = $list->pluck('id');
+
+        $list = $list->paginate(20);
+
 
         if ($request->ajax()) {
-            $view = view('admin.call.records.data', compact('list'))->render();
+            $view = view('admin.call.records.data', compact('list','allIds'))->render();
 
             return response()->json(['html' => $view]);
 
         }
-        return view('admin.call.records.index', compact('list'));
+        return view('admin.call.records.index', compact('list','allIds'));
     }
 
 
@@ -133,6 +138,7 @@ class RecordsController extends Controller
     public function addCallList(Request $request)
     {
         $ids = $request->get('contact_phones');
+
         $ip = $request->get('ip');
 
         $phones = CallRecordsModel::whereIn('id', $ids)->get();

+ 4 - 3
app/Http/Controllers/Admin/User/ThreadsController.php

xqd
@@ -61,16 +61,17 @@ class ThreadsController extends Controller
             $list = $list->has('progress','=',0);
         }
 
-        $list =  $list->paginate(20);
+        $allIds = $list->pluck('id');
+        $list =  $list->paginate(10);
 
         if ($request->ajax()) {
-            $view = view('admin.user.threads.data', compact('list'))->render();
+            $view = view('admin.user.threads.data', compact('list','allIds'))->render();
 
             return response()->json(['html' => $view]);
 
         }
 
-        return view('admin.user.threads.index', compact('list'));
+        return view('admin.user.threads.index', compact('list','allIds'));
     }
 
 

+ 2 - 2
app/Repositories/Call/RecordsRepository.php

xqd xqd
@@ -20,7 +20,7 @@ class RecordsRepository extends Repository
         return \App\Models\CallRecordsModel::class;
     }
 
-    public function searchRecords(array $search, array $orderby = ['id' => 'desc'], $pagesize = 20)
+    public function searchRecords(array $search, array $orderby = ['id' => 'desc'])
     {
         $currentQuery = $this->model;
         /*企业名称*/
@@ -59,7 +59,7 @@ class RecordsRepository extends Repository
                 $currentQuery = $currentQuery->orderBy($field, $value);
             }
         };
-        $currentQuery = $currentQuery->paginate($pagesize);
+
         return $currentQuery;
     }
 

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

xqd
@@ -43,7 +43,7 @@
                             <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="sync"> 是否同步到拨打列表:</th>
                             <th class="sorting" data-sort="created_at"> 添加时间</th>
                             <th class="sorting" data-sort="updated_at"> 更新时间</th>
                             <th width="22%">相关操作</th>

+ 2 - 1
resources/views/admin/call/records/data.blade.php

xqd
@@ -2,7 +2,8 @@
     <thead>
     <tr>
         <th>
-            <label><input type="checkbox" id="checkAll"> 全选</label>
+            <label><input type="checkbox" id="checkAll"> 本页</label>
+            <label><input type="checkbox" id="checkTotal"> 全部</label>
         </th>
         <th class="sorting" data-sort="id"> ID</th>
         <th class="sorting" data-sort="phone"> 电话号码</th>

+ 25 - 1
resources/views/admin/call/records/index.blade.php

xqd xqd xqd xqd xqd
@@ -139,6 +139,23 @@
 
         })
 
+        $('body').on('click', '#checkTotal', function () {
+            items = $('.contacts');
+
+            isChecked = $(this).prop('checked')
+            items.prop('checked', isChecked)
+
+            if (isChecked == true) {
+                $('.fa-phone').show()
+                checkedIds = [{{ $allIds }}][0]
+                $('#checkAll').prop('checked',true)
+            } else {
+                $('.fa-phone').hide()
+                $('#checkAll').prop('checked', false)
+                checkedIds = []
+            }
+        })
+
         $('body').on('click', '.contacts', function () {
             items = $('.contacts');
 
@@ -149,6 +166,7 @@
                 $('.fa-phone').hide()
             }
             if (items.length == checkedLength) {
+                $('#checkAll').prop('checked', true)
                 $('.fa-phone').show()
             } else {
                 $('#checkAll').prop('checked', false)
@@ -185,7 +203,7 @@
 
         /*保存选中的项*/
         function saveChecked(e) {
-            if (e.is(":checked")) {
+            if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
                 checkedIds.push(e.data("id"));
             } else {
                 for (var i = 0; i < checkedIds.length; i++) {
@@ -195,6 +213,7 @@
                     }
                 }
             }
+
         }
 
         /*翻页后设置选中项*/
@@ -209,6 +228,11 @@
                 }
             })
 
+            checkedLength = $('.contacts:checked').length
+            if(checkedLength == $boxes.length){
+                $('#checkAll').prop('checked', true)
+            }
+
         }
 
 

+ 3 - 1
resources/views/admin/user/threads/data.blade.php

xqd
@@ -1,7 +1,9 @@
 <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
     <thead>
     <tr>
-        <th><label><input type="checkbox" id="checkAll"> 全选</label>
+        <th>
+            <label><input type="checkbox" id="checkAll"> 本页</label>
+            <label><input type="checkbox" id="checkTotal"> 全部</label>
         </th>
         <th class="sorting" data-sort="id"> ID</th>
         <th class="sorting"> 联系方式</th>

+ 45 - 19
resources/views/admin/user/threads/index.blade.php

xqd xqd xqd xqd xqd xqd xqd
@@ -19,7 +19,7 @@
                         @if(role('User/Threads/addCallList'))
                             <div class="col-sm-8 pull-right">
                                     <span class="btn btn-primary pull-right fa fa-phone"
-                                           data-toggle="modal"
+                                          data-toggle="modal"
                                           data-target="#myModal2">添加到电话列表</span>
                                 <span id="export_threads" class="btn btn-success pull-right fa fa-table"
                                       style="display: none">导出到Excel</span>
@@ -76,21 +76,22 @@
                         <div class="modal-body">
                             <div class="ibox float-e-margins">
                                 <div class="ibox-content">
-                                        <select name="ip" class="form-control" id="ip">
-                                            <option value="172.31.20.133">172.31.20.133</option>
-                                            <option value="172.31.20.134">172.31.20.134</option>
-                                            <option value="172.31.20.135">172.31.20.135</option>
-                                            <option value="172.31.20.136">172.31.20.136</option>
-                                            <option value="172.31.20.137">172.31.20.137</option>
-                                        </select>
-
-                                        <div class="form-group">
-                                            <label class="control-label col-sm-3">&nbsp;</label>
-                                            <div class="col-sm-9">
-                                                <input type="submit" class="btn btn-success" style="margin-right:20px;" id="addCallList">
-                                                <input type="reset" class="btn btn-default">
-                                            </div>
+                                    <select name="ip" class="form-control" id="ip">
+                                        <option value="172.31.20.133">172.31.20.133</option>
+                                        <option value="172.31.20.134">172.31.20.134</option>
+                                        <option value="172.31.20.135">172.31.20.135</option>
+                                        <option value="172.31.20.136">172.31.20.136</option>
+                                        <option value="172.31.20.137">172.31.20.137</option>
+                                    </select>
+
+                                    <div class="form-group">
+                                        <label class="control-label col-sm-3">&nbsp;</label>
+                                        <div class="col-sm-9">
+                                            <input type="submit" class="btn btn-success" style="margin-right:20px;"
+                                                   id="addCallList">
+                                            <input type="reset" class="btn btn-default">
                                         </div>
+                                    </div>
 
                                 </div>
                             </div>
@@ -122,19 +123,37 @@
             items.each(function () {
                 saveChecked($(this))
             });
-            if (isChecked == true) {
+            if (checkedIds.length) {
                 $('#addCallList').show();
                 $('#export_threads').show()
             } else {
                 $('#addCallList').hide();
                 $('#export_threads').hide()
             }
-            console.log(checkedIds)
         });
 
+        $('body').on('click', '#checkTotal', function () {
+            items = $('.contacts');
+
+            isChecked = $(this).prop('checked')
+            items.prop('checked', isChecked)
+
+            if (isChecked == true) {
+                $('.fa-phone').show()
+                checkedIds = [{{ $allIds }}][0]
+                $('#export_threads').show()
+                $('#checkAll').prop('checked', true)
+            } else {
+                $('.fa-phone').hide()
+                $('#checkAll').prop('checked', false)
+                checkedIds = []
+            }
+        })
+
         $('body').on('click', '.contacts', function () {
             items = $('.contacts');
             checkedLength = $('.contacts:checked').length
+
             if (checkedLength) {
                 $('#addCallList').show()
                 $('#export_threads').show()
@@ -142,7 +161,9 @@
                 $('#addCallList').hide()
                 $('#export_threads').hide()
             }
+
             if (items.length == checkedLength) {
+                $('#checkAll').prop('checked', true)
                 $('#addCallList').show()
                 $('#export_threads').show()
             } else {
@@ -155,7 +176,7 @@
 
         /*保存选中的项*/
         function saveChecked(e) {
-            if (e.is(":checked")) {
+            if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
                 checkedIds.push(e.data("id"));
             } else {
                 for (var i = 0; i < checkedIds.length; i++) {
@@ -179,6 +200,11 @@
                 }
             })
 
+            checkedLength = $('.contacts:checked').length
+            if(checkedLength == $boxes.length){
+                $('#checkAll').prop('checked', true)
+            }
+
         }
 
         /*添加选择的电话到拨打列表*/
@@ -190,7 +216,7 @@
             $.ajax({
                 type: 'post',
                 url: '{{ U('User/Threads/addCallList') }}',
-                data: {contact_ids: contact_ids, _token: csrf_token,ip:ip},
+                data: {contact_ids: contact_ids, _token: csrf_token, ip: ip},
                 success: function (data) {
                     if (data == 200) {
                         layer.msg('导入成功', {