@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="page-header">
                <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                <i class="mdi mdi-wrench"></i>
              </span>
                    {{ __('auto.短信通道切换开关') }}
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">{{ __('auto.短信通道切换开关') }}</a></li>
                        <li class="breadcrumb-item active" aria-current="page">{{ __('auto.短信通道切换开关') }}</li>
                    </ol>
                </nav>
            </div>
            <div class="row">
                <div class="col-lg-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.短信通道切换开关') }}</h4>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.短信通道名称') }}</th>
                                    <th>{{ __('auto.最新操作人') }}</th>
                                    <th>{{ __('auto.日期') }}</th>
                                    <th>{{ __('auto.当前状态') }}</th>
                                    <th>{{ __('auto.备注') }}</th>
                                    <th>{{ __('auto.操作') }}</th>
                                </tr>
                                </thead>
                                <tbody>

                                @foreach($list as $val)
                                <tr>
                                    <td style="width: 15%">
                                        {{$val->Name}}
                                    </td>
                                    <td>{{$val->account}}</td>
                                    <td>{{$val->LastTime}}</td>
                                    <td style="width: 15%">
                                        @if ($val->Status == 1)
                                            {{ __('auto.已开启') }}
                                            <button class="btn btn-sm btn-gradient-dark"
                                                    onclick="updateStatusFunc({{$val->ID}},2)">
                                                {{ __('auto.关闭') }}
                                            </button>
                                        @else
                                            {{ __('auto.已关闭') }}
                                            <button class="btn btn-sm btn-gradient-dark"
                                                    onclick="updateStatusFunc({{$val->ID}},1)">
                                                {{ __('auto.开启') }}
                                            </button>
                                        @endif
                                    </td>
                                    <td  contentEditable="true"
                                         onblur="remarks(this,{{$val->ID}})" style="vertical-align: top">{{$val->Remarks}}</td>
                                    <td>
                                        <button class="btn-sm btn-gradient-dark" onclick="updateFunc({{$val->ID}})">{{ __('auto.修改') }}</button>
                                    </td>
                                </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        function updateStatusFunc(id, statusVal) {
            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?", function () {
                myRequest('/admin/sys_sms_config/update_status/'+id, 'post', {statusVal}, function (response) {
                    layer.msg(response.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                })
            })
        }

        function remarks(obj,id) {
            remark = $(obj).html();
            myRequest("/admin/sys_sms_config/remarks/" + id, "post", {remark}, function (res) {
                layer.msg(res.msg)
                setTimeout(function () {
                    window.location.reload();
                }, 1500)
            });
        }

        function updateFunc(id) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['60%', '70%'],
                content: '/admin/sys_sms_config/update/' + id
            });
        }

    </script>
@endsection
