123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- @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" id="filter_list">
- <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>
- <div class="col-sm-8 pull-right">
- @if(role('Call/List/create'))
- <a href="{{ U('Call/List/create')}}" class="btn btn-primary pull-right">添加</a>
- @endif
- @if(role('Call/List/alldelete'))
- <button class="btn btn-danger pull-right" id="alldelete" style="display: none">批量删除</button>
- @endif
- </div>
- </div>
- </div>
- <div id="call-list">
- @include('admin.call.list.data')
- </div>
- </div>
- </div>
- </div>
- </div>
- @endsection
- @section('js')
- <script type="text/javascript">
- var checkedIds = []
- /*电话全选功能*/
- $('body').on('click', '#checkAll', function () {
- items = $('.calllist');
- isChecked = $(this).prop('checked')
- items.prop('checked', isChecked)
- items.each(function () {
- saveChecked($(this))
- });
- if (checkedIds.length) {
- $('#alldelete').show()
- } else {
- $('#alldelete').hide()
- }
- })
- $('body').on('click', '#checkTotal', function () {
- items = $('.calllist');
- isChecked = $(this).prop('checked')
- items.prop('checked', isChecked)
- if (isChecked == true) {
- $('#alldelete').show()
- checkedIds = [{{ $allIds }}][0]
- $('#checkAll').prop('checked', true)
- } else {
- $('#alldelete').hide()
- $('#checkAll').prop('checked', false)
- checkedIds = []
- }
- })
- $('body').on('click', '.calllist', function () {
- items = $('.calllist');
- checkedLength = $('.calllist:checked').length
- if (checkedLength) {
- $('#alldelete').show()
- } else {
- $('#alldelete').hide()
- }
- if (items.length == checkedLength) {
- $('#checkAll').prop('checked', true)
- $('#alldelete').show()
- } else {
- $('#checkAll').prop('checked', false)
- }
- saveChecked($(this))
- });
- /*批量删除*/
- $('#alldelete').click(function () {
- layer.confirm('你确定要删除选择的待导入电话吗?', {
- btn: ['确定', '取消']//按钮
- }, function (index) {
- layer.close(index);
- list_ids = checkedIds;
- csrf_token = "{{ csrf_token() }}";
- $.ajax({
- type: 'post',
- url: '{{ U('Call/list/alldelete') }}',
- data: {list_ids: list_ids, _token: csrf_token},
- success: function (data) {
- if (data == 200) {
- layer.msg('删除成功', {
- icon: 1,
- time: 2000 //2秒关闭(如果不配置,默认是3秒)
- }, function () {
- window.location.href = window.location.href
- });
- }
- }
- })
- });
- });
- /*保存选中的项*/
- function saveChecked(e) {
- 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++) {
- if (e.data("id") == checkedIds[i]) {
- checkedIds.splice(i, 1);
- break;
- }
- }
- }
- }
- /*翻页后设置选中项*/
- function setChecked() {
- var $boxes = $('.calllist');
- $boxes.each(function () {
- id = $(this).data('id')
- if (checkedIds.indexOf(id, 0) != -1) {
- $(this).prop('checked', true)
- } else {
- $(this).prop('checked', false)
- }
- })
- checkedLength = $('.calllist:checked').length
- if (checkedLength == $boxes.length) {
- $('#checkAll').prop('checked', true)
- }
- }
- /*通话纪录筛选*/
- function filter_records() {
- data = $('#filter_list').serialize();
- $.ajax({
- type: 'get',
- data: data,
- }).done(function (data) {
- $('#call-list').html(data.html)
- })
- }
- /*Ajax分页*/
- $('body').on('click', '.pagination a', function (e) {
- e.preventDefault();
- if ($(this).attr('href') != '#') {
- data = $('#filter_list').serialize()
- $.ajax({
- url: $(this).attr('href'),
- type: 'get',
- data: data,
- }).done(function (data) {
- $('#call-list').html(data.html)
- setChecked()
- })
- }
- });
- </script>
- @endsection
|