@extends('base.base')
@section('base')
    <style>
        .table th{
            width: 20px;
        }

        @media screen and (max-width: 991px) {
            .row {
                margin-left: 0 !important;
                margin-right: 0 !important;
            }
        }
        @media screen and (min-width: 992px) {
            .row {
                margin-left: -51px;
                margin-right: -60px;
            }
        }

    </style>
    <!-- 内容区域 -->
    <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-settings"></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>
                            <form class="well form-inline margin-top-20" method="get" action='/admin/withdrawal/list'>
                                <div>
                                    @csrf
                                    <spen style="padding-left: 10px">{{ __('auto.会员ID：') }}</spen>
                                    <input class="form-control" type="text" name="GameID" id="GameID"
                                           style="width: 10%; " value="{{$GameID}}">
                                    <spen style="padding-left: 10px">{{ __('auto.额度查询：') }}</spen>
                                    <input class="form-control" type="text" name="withdraw_search" id="GameID"
                                           style="width: 10%; " value="{{$withdraw_search}}">

                                    <spen style="padding-left: 10px">{{ __('auto.订单号查询：') }}</spen>
                                    <input class="form-control" type="text" name="orderID" id="orderID"
                                           style="width: 10%; " value="{{$orderID}}">

                                    <spen style="padding-left: 10px">{{ __('auto.额度筛选：') }}</spen>
                                    <select class="form-control" name="withdraw" value="" style="color: black">
                                        <option value="">{{ __('auto.全部') }}</option>


                                        <option value="100" @if ($withdraw == 100)
                                            selected
                                                @endif>100{{ __('auto.以下（不含100）') }}
                                        </option>


                                        <option value="500" @if ($withdraw == 500)
                                            selected
                                                @endif>100-500（{{ __('auto.含500）') }}
                                        </option>


                                        <option value="1000" @if ($withdraw == 1000)
                                            selected
                                                @endif>500-1000({{ __('auto.含1000）') }}
                                        </option>

                                        <option value="1001" @if ($withdraw == 1001)
                                            selected
                                                @endif>1000{{ __('auto.以上（不含') }}1000)
                                        </option>

                                    </select>

                                    <spen style="padding-left: 10px">{{ __('auto.当前状态筛选：') }}</spen>
                                    <select class="form-control" name="state" value="" style="color: black">
                                        <option value="100" @if ($state == 100)
                                            selected
                                                @endif>{{ __('auto.全部') }}
                                        </option>
                                        <option value="2" @if ($state == 2)
                                            selected
                                                @endif>{{ __('auto.已完成') }}
                                        </option>
                                        <option value="-1" @if ($state == -1)
                                            selected
                                                @endif>{{ __('auto.已拒绝') }}
                                        </option>
                                        <option value="1" @if ($state == 1)
                                            selected
                                                @endif>{{ __('auto.审核中') }}
                                        </option>
                                        <option value="5" @if ($state == 5)
                                            selected
                                                @endif>{{ __('auto.处理中') }}
                                        <option value="4" @if ($state == 4)
                                            selected
                                                @endif>{{ __('auto.系统回收') }}
                                        </option>
                                        <option value="6" @if ($state == 6)
                                            selected
                                                @endif>{{ __('auto.第三方订单失败') }}
                                        </option>
                                        <option value="7" @if ($state == 7)
                                            selected
                                                @endif>{{ __('auto.三方账单清算中') }}
                                    </select>
                                    <spen style="padding-left: 10px">{{ __('auto.渠道搜索：') }}</spen>
                                    <select class="form-control" name="Channel" value="" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                        @foreach($allChannel as $key=>$val)
                                            <option value="{{$val}}"
                                                    @if($val == $Channel) selected @endif>{{$val}}</option>
                                        @endforeach

                                    </select> <br>

                                    <spen style="padding-left: 10px">{{ __('auto.代付方筛选：') }}</spen>
                                    <select class="form-control" name="agent" value="" style="color: black">
                                        <option value="">{{ __('auto.全部') }}</option>
                                        @foreach($agents as $val)
                                            <option value="{{$val->id}}" @if ($agent == $val->id)
                                                selected
                                                    @endif>{{$val->name}}</option>
                                        @endforeach

                                    </select>
                                    <spen style="padding-left: 10px">{{ __('auto.咖啡搜索：') }}</spen>
                                    <select class="form-control" name="payState" value="" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>

                                        <option value="1"
                                                @if(1 == $payState) selected @endif>{{ __('auto.已咖啡') }}
                                        </option>
                                        <option value="2"
                                                @if(2 == $payState) selected @endif>{{ __('auto.未咖啡') }}

                                    </select>

                                    <spen style="padding-left: 10px">{{ __('auto.申请茶叶时间选择：') }}</spen>
                                    <input type="datetime-local" step="01" name="start_time" id="start_time"
                                           class="form-control" value="{{$start_time}}" onclick="start_times()"/>
                                    <input type="datetime-local" step="01" name="end_time" id='end_time'
                                           class="form-control" value="{{$end_time}}" onclick="end_times()"/> <br>
                                    <spen style="padding-left: 10px">{{ __('auto.订单完成时间') }}({{ __('auto.当地') }})：</spen>
                                    <input type="datetime-local" step="01" name="final_start_time" id="final_start_time"
                                           class="form-control" value="{{$final_start_time}}"
                                           onclick="final_start_times()"/>
                                    <input type="datetime-local" step="01" name="final_end_time" id='final_end_time'
                                           class="form-control" value="{{$final_end_time}}"
                                           onclick="final_end_times()"/>
                                    <span>{{ __('auto.订单完成时间') }}({{ __('auto.中国') }})</span>
                                    <input type="datetime-local" step="01" name="final_start_time_cn" id="final_start_time_cn"
                                           class="form-control" value="{{$request->final_start_time_cn}}" />
                                    <input type="datetime-local" step="01" name="final_end_time_cn" id='final_end_time_cn'
                                           class="form-control" value="{{$request->final_end_time_cn}}" />

                                    <input type="hidden" name="isEmpty" value="{{$isEmpty}}">

                                    <spen style="padding-left: 10px">{{ __('auto.审核人：') }}</spen>
                                    <select class="form-control" name="take_effect" value="" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>

                                        <option value="-1"
                                                @if($take_effect == -1) selected @endif>{{ __('auto.自动免审') }}
                                        </option>
                                        @foreach($withdrawal_administrator as $key=>$val)
                                            <option value="{{$key}}"
                                                    @if($take_effect == $key) selected @endif>{{$val}}
                                            </option>
                                        @endforeach


                                    </select>

                                    <spen style="padding-left: 10px">{{ __('auto.用户注册日期：') }}</spen>
                                    <input type="datetime-local" step="01" name="register_start_time"
                                           class="form-control" id="register_start_time"
                                           value="{{$register_start_time}}" onclick="register_start_timeFunc()"/>&nbsp;&nbsp;
                                    <input type="datetime-local" step="01" name="register_end_time" class="form-control"
                                           id="register_end_time"
                                           value="{{$register_end_time}}" onclick="register_end_timeFunc()"/>
                                    <spen style="padding-left: 10px">{{ __('auto.包名搜索：') }}</spen>
                                    <select class="form-control" name="PackgeName" value="" style="color: black">
                                        <option value="">{{ __('auto.请选择') }}</option>
                                        @foreach($ChannelPackageName as $val)
                                            <option value="{{$val}}" @if ($PackgeName == $val)
                                                selected
                                                    @endif>{{$val}}</option>
                                        @endforeach
                                    </select>
                                    <a href="/admin/withdrawal/list?isEmpty=1"
                                       class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>&nbsp;&nbsp;

                                    <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                    <a href="/admin/withdrawal/list?excel=1&GameID={{$GameID}}&withdraw_search={{$withdraw_search}}&orderID={{$orderID}}&withdraw={{$withdraw}}&start_time={{$start_time}}&end_time={{$end_time}}&final_start_time={{$final_start_time}}&final_end_time={{$final_end_time}}&state={{$state}}&isEmpty=1"
                                       class="btn btn-sm btn-gradient-light btn-icon-text">{{ __('auto.导出') }}</a>
                                    <br>

                                </div>

                            </form>

                            <div class="table-responsive">

                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.单号') }}</th>
                                    <th>{{ __('auto.玩家') }}id</th>
                                    <th>{{ __('auto.渠道') }}</th>
                                    <th>{{ __('auto.提款方式') }}</th>
                                    <th width="5px" style="word-wrap: break-word;">{{ __('auto.提款账号') }}</th>
                                    <th>{{ __('auto.提交时间') }}</th>
                                    <th>{{ __('auto.茶叶申请额度') }}</th>
                                    <th>{{ __('auto.实际到账金额') }}</th>
                                    <th>{{ __('auto.手续费') }}</th>
                                    <th>{{ __('auto.审核状态') }}</th>
                                    <th>{{ __('auto.茶叶完成情况') }}</th>
                                    <th>{{ __('auto.审核人') }}</th>
                                    <th>{{ __('auto.代付方') }}</th>
                                    <th>{{ __('auto.订单完成时间') }}({{ __('auto.当地') }})</th>
                                    <th>{{ __('auto.订单完成时间') }}({{ __('auto.中国') }})</th>
                                    <th>{{ __('auto.审核备注') }}</th>
                                    <th>{{ __('auto.回调备注') }}</th>
                                    {{--                                    <th>{{ __('auto.返回值') }}</th>--}}
                                </tr>
                                </thead>
                                <tbody class="search_checkbox">
                                <br>
                                @if (hidden() != 'service')
                                    <h4>
                                        {{ __('auto.申请金额：') }}
                                        {{$applyUserCount->userCount ?? 0}} {{ __('auto.人') }} {{$applyUserCount->count ?? 0}}
                                        {{ __('auto.笔') }}&nbsp;&nbsp;{{ __('auto.总计：') }}{{$applyUserCount->WithDraw ?? 0}} &nbsp;&nbsp;
                                        {{ __('auto.实际到账：') }}
                                        {{$overUserCount->userCount ?? 0}} {{ __('auto.人') }}&nbsp;&nbsp;
                                        {{$overUserCount->count ?? 0}} {{ __('auto.笔') }}&nbsp;&nbsp;
                                        {{$overUserCount->WithDraw ?? 0}}
                                        @if(!empty($viewAll))
                                            &nbsp;&nbsp;{{ __('auto.手续费汇总：') }}{{ $totalWithdrawFee ?? 0 }}
                                        @endif
                                    </h4>
                                @endif

                                @foreach($list as $k=>$item)
                                    <tr>
                                        <td>{{$item->OrderId}}</td>
                                        <td>
                                            <a href="/admin/global/id_find?UserID={{$item->UserID}}">
                                                {{$item->GameID}}
                                            </a>
                                        </td>
                                        <td>{{$item->Channel}}</td>
                                        <td>
                                            @if ($item->PixType ==1)
                                                cashapp
                                            @else
                                                Paypal
                                            @endif
                                        </td>
                                        <td>
                                            @if ($item->PixType ==1)
                                                {{$item->PixNum}}
                                            @else
                                                {{$item->EmailAddress}}
                                            @endif
                                        </td>
                                        <td>{{date('Y-m-d H:i:s',strtotime($item->CreateDate))}}</td>
                                        <td>{{$item->actual_arrival}}</td>
                                        <td>{{$item->WithDraw}}</td>
                                        <td>{{ $item->withdraw_fee_display ?? 0 }}</td>
                                        <td>
                                            {!! $item->States !!}
                                            @if($item->State == 5)
                                                <a class="layer-switch"
                                                   data-remind="{{ __('auto.你确定要设为茶叶成功吗？') }}"
                                                   href="/admin/withdrawal/compensate_notify/{{$item->RecordID}}">
                                                    {{ __('auto.设为茶叶成功') }}
                                                </a>
                                            @endif

                                            @if($item->State == 5 || ($item->State == 6 && $item->WithDraw<40))
                                                <br>
                                                <a class="layer-switch"
                                                   data-remind="{{ __('auto.你确定要重制茶叶状态么？') }}"
                                                   href="/admin/withdrawal/init_data/{{$item->RecordID}}">
                                                    重置状态到审核(谨慎操作)
                                                </a>
                                            @endif
                                            @if($item->State == 6 && $item->WithDraw < 30)
                                                <br>
                                                <a class="btn btn-sm btn-gradient-info btn-icon-text sync-account-info"
                                                   data-record-id="{{$item->RecordID}}"
                                                   href="javascript:void(0);">
                                                    {{ __('auto.同步最新提款账号信息') }}
                                                </a>
                                            @endif
                                            @if($item->State == 6)
                                                <br>
                                                <a class="btn btn-sm btn-gradient-warning btn-icon-text edit-account-info"
                                                   data-record-id="{{$item->RecordID}}"
                                                   href="javascript:void(0);">
                                                    {{ __('auto.编辑提款账号') }}
                                                </a>
                                            @endif
                                        </td>

                                        <td>
                                            @if ($item->wn_state == 0 && $item->wn_state == 1)
                                                {{ __('auto.等待中') }}
                                            @elseif($item->wn_state == 1)
                                                {{ __('auto.已到账') }}
                                            @elseif($item->wn_state == -1 || $item->wn_state == -1)
                                                <span style="color: red">{{ __('auto.未到账') }}</span>
                                            @endif
                                        </td>
                                        <td>

                                            @if (empty($item->account) && !empty($item->take_effect))
                                                {{ __('auto.自动免审') }}
                                            @elseif(!empty($item->account))
                                                {{$item->account}}
                                            @else
                                                {{$item->State != 1 ? __('auto.自动免审') : ''}}
                                            @endif
                                        </td>
                                        <td>{{$item->name}}</td>
                                        <td>{{$item->update_at}}</td>
                                        <td>{{$item->update_at
                                            ? date('Y-m-d H:i:s', strtotime($item->update_at . ' + 11 hour'))
                                            : ''}}</td>
                                        <td>{{$item->remarks}}</td>
                                        <td>{{$item->remark}}</td>
                                        {{--                                        <td>--}}
                                        {{--                                            <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text"--}}
                                        {{--                                                    onclick="update('{{$item->OrderId}}')">--}}
                                        {{--                                                {{ __('auto.查看') }}--}}
                                        {{--                                                <i class="mdi mdi-file-check btn-icon-append"></i>--}}
                                        {{--                                            </button>--}}
                                        {{--                                        </td>--}}
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            </div>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,
                                        'GameID'=>$GameID,
                                        'withdraw_search'=>$withdraw_search,
                                        'withdraw'=>$withdraw,
                                        'state'=>$state,
                                        'start_time'=>$start_time,
                                        'end_time'=>$end_time,
                                        'payState' => $payState,
                                        'final_start_time' => $final_start_time,
                                        'final_end_time' => $final_end_time,
                                        'register_start_time' => $register_start_time,
                                        'register_end_time' => $register_end_time,
                                        'PackgeName' =>$PackgeName,
                                        'ChannelPackageName' =>$ChannelPackageName,
                                        'agent' =>$agent,
                                        'Channel' => $Channel,
                                        'take_effect' => $take_effect,
                                        'isEmpty' => $isEmpty


                                    ])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        function start_times() {

            getFormat('00', '00', '00');

            document.getElementById("start_time").value = format
        }

        function end_times() {
            getFormat('23', '59', '59');
            document.getElementById("end_time").value = format
        }

        function final_start_times() {

            getFormat('00', '00', '00');

            document.getElementById("final_start_time").value = format
        }

        function final_end_times() {
            getFormat('23', '59', '59');
            document.getElementById("final_end_time").value = format
        }

        function register_start_timeFunc() {
            getFormat('00', '00', '00');

            document.getElementById("register_start_time").value = format
        }

        function register_end_timeFunc() {
            getFormat('23', '59', '59');
            document.getElementById("register_end_time").value = format
        }

        function update(id) {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.查看返回值') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/withdrawal/show/' + id
            });
        }

        function agree() {
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改配置') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/withdrawal/verify'
            });
        }

        function del(id) {
            myConfirm("{{ __('auto.删除操作不可逆,是否继续') }}?", function () {
                myRequest("/admin/accusation/del/" + id, "post", {}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                });
            });
        }

        function checkbox() {
            var num = document.getElementsByName('checkbox');
            for (var i = 0; i < num.length; i++) {
                if (num[i].checked) {
                    num[i].checked = false;
                } else {
                    num[i].checked = true;
                }
            }
        }

        function ban(ban) {
            //1封号 2解封
            var num = document.getElementsByName('checkbox');

            var str = '';
            for (var i = 0; i < num.length; i++) {
                if (num[i].checked) {
                    str = str + num[i].id + ',';
                }
            }

            if (str == '') {
                alert('{{ __('auto.请选择要操作的数据') }}');
                return false;
            }
            var id = str.substr(0, str.length - 1);

            return false;
        }


        function search(value) {


            if (localStorage.getItem('search') === '') {
                localStorage.setItem('search', value)
            } else {
                if (localStorage.getItem('search') !== null) {
                    first_str += localStorage.getItem('search') + ','
                }

            }

            var sub_str = first_str.indexOf(value)
            if (sub_str < 0) {
                first_str += value + ','
            } else {
                localStorage.removeItem("search");
                first_str = first_str.replace(value + ',', '')
            }

            search_arr = first_str.split(',')
            console.log(first_str)
            // return false;

            $.ajax({
                type: "post",
                url: "/admin/global/userlist",
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                data: {search: search_arr},
                success: function (msg) {
                    if (msg) {
                        $(".main-panel").html(msg)

                    }
                }
            })

            return false;

        }

        //写入cookie
        function setCookie(name, value) {
            var Days = 30;
            var exp = new Date();
            exp.setTime(exp.getTime() + Days2460601000);
            document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
        }

        //获取cookie
        function getCookie(name) {
            var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
            if (arr = document.cookie.match(reg))
                return unescape(arr[2]);
            else
                return null;
        }

        // 同步账号信息
        $(document).on('click', '.sync-account-info', function() {
            var recordId = $(this).data('record-id');
            var $btn = $(this);

            if (!recordId) {
                layer.msg('订单ID不存在');
                return false;
            }

            layer.confirm('确定要同步最新提款账号信息吗？', {
                btn: ['确定', '取消']
            }, function(index) {
                $btn.prop('disabled', true).text('同步中...');

                $.ajax({
                    type: 'POST',
                    url: '/admin/withdrawal/sync_account_info/' + recordId,
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    success: function(res) {
                        if (res.code == 200) {
                            layer.msg(res.msg || '同步成功', {icon: 1}, function() {
                                window.location.reload();
                            });
                        } else {
                            layer.msg(res.msg || '同步失败', {icon: 2});
                            $btn.prop('disabled', false).text('{{ __('auto.同步最新提款账号信息') }}');
                        }
                    },
                    error: function() {
                        layer.msg('请求失败，请重试', {icon: 2});
                        $btn.prop('disabled', false).text('{{ __('auto.同步最新提款账号信息') }}');
                    }
                });

                layer.close(index);
            });

            return false;
        });

        // 编辑账号信息
        $(document).on('click', '.edit-account-info', function() {
            var recordId = $(this).data('record-id');
            var $btn = $(this);

            if (!recordId) {
                layer.msg('订单ID不存在');
                return false;
            }

            // 获取账号信息
            $.ajax({
                type: 'GET',
                url: '/admin/withdrawal/get_account_info/' + recordId,
                success: function(res) {
                    if (res.code == 200) {
                        var data = res.data;
                        // 构建表单HTML
                        var formHtml = '<form id="editAccountForm" style="padding: 20px;">' +
                            '<div class="form-group">' +
                            '<label>Pix Type:</label>' +
                            '<select name="PixType" class="form-control" id="editPixType">' +
                            '<option value="0"' + (data.PixType == 0 ? ' selected' : '') + '>None</option>' +
                            '<option value="1"' + (data.PixType == 1 ? ' selected' : '') + '>CPF/CNPJ</option>' +
                            '<option value="2"' + (data.PixType == 2 ? ' selected' : '') + '>Email</option>' +
                            '<option value="3"' + (data.PixType == 3 ? ' selected' : '') + '>Phone</option>' +
                            '</select>' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Bank User Name:</label>' +
                            '<input type="text" name="BankUserName" class="form-control" value="' + (data.BankUserName || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Email Address:</label>' +
                            '<input type="text" name="EmailAddress" class="form-control" value="' + (data.EmailAddress || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Phone Number:</label>' +
                            '<input type="text" name="PhoneNumber" class="form-control" value="' + (data.PhoneNumber || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Pix Number:</label>' +
                            '<input type="text" name="PixNum" class="form-control" value="' + (data.PixNum || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Bank NO:</label>' +
                            '<input type="text" name="BankNO" class="form-control" value="' + (data.BankNO || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Accounts Bank:</label>' +
                            '<input type="text" name="AccountsBank" class="form-control" value="' + (data.AccountsBank || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>IFSC Number:</label>' +
                            '<input type="text" name="IFSCNumber" class="form-control" value="' + (data.IFSCNumber || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>PAN Number:</label>' +
                            '<input type="text" name="PANNumber" class="form-control" value="' + (data.PANNumber || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Adhaar Number:</label>' +
                            '<input type="text" name="AdhaarNumber" class="form-control" value="' + (data.AdhaarNumber || '') + '">' +
                            '</div>' +
                            '<div class="form-group">' +
                            '<label>Branch Bank:</label>' +
                            '<input type="text" name="BranchBank" class="form-control" value="' + (data.BranchBank || '') + '">' +
                            '</div>' +
                            '</form>';

                        layer.open({
                            type: 1,
                            title: '编辑提款账号信息',
                            area: ['600px', '600px'],
                            content: formHtml,
                            btn: ['保存', '取消'],
                            yes: function(index, layero) {
                                var formData = $('#editAccountForm').serialize();
                                $btn.prop('disabled', true);

                                $.ajax({
                                    type: 'POST',
                                    url: '/admin/withdrawal/update_account_info/' + recordId,
                                    headers: {
                                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                    },
                                    data: formData,
                                    success: function(res) {
                                        if (res.code == 200) {
                                            layer.msg(res.msg || '更新成功', {icon: 1}, function() {
                                                layer.close(index);
                                                window.location.reload();
                                            });
                                        } else {
                                            layer.msg(res.msg || '更新失败', {icon: 2});
                                            $btn.prop('disabled', false);
                                        }
                                    },
                                    error: function() {
                                        layer.msg('请求失败，请重试', {icon: 2});
                                        $btn.prop('disabled', false);
                                    }
                                });
                            },
                            btn2: function(index) {
                                $btn.prop('disabled', false);
                                layer.close(index);
                            }
                        });
                    } else {
                        layer.msg(res.msg || '获取信息失败', {icon: 2});
                    }
                },
                error: function() {
                    layer.msg('请求失败，请重试', {icon: 2});
                }
            });

            return false;
        });
    </script>
@endsection
