@extends('vip.layouts')
@section('seo_title')
    {{ trans('menu.remittance') }}
@endsection
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }

        .layui-form-switch em {
            width: auto;
        }

        .layui-form-switch {
            width: 44px;
            line-height: 23px;
        }

        .layui-form-item .checkbox {
            width: auto;
        }

        .red{
            color: red;
        }
        .blue{
            color: #1E9FFF;
        }
        .green{
            color: green;
        }
        .yellow{
            color: #ffca10;
        }
        .bottom-txt{
            padding: 0.5em;
        }
    </style>
	<script type="text/html" id="sendmoney">
	@{{#if(d.status==0){ }}
		@if(checkRriv('/admin/Remittance/save_recharge'))<a class="layui-btn layui-btn-xs lay-btn-diy" href="/admin/Remittance/save_recharge?order_id=@{{d.order_id}}">通过</a>@endif
        <br>
		@if(checkRriv('/admin/Remittance/return_recharge'))<a class="layui-btn layui-btn-xs layui-btn-danger" href="/admin/Remittance/return_recharge?order_id=@{{d.order_id}}">驳回</a>@endif

	@{{#}else{ }}
		@{{#if(d.status==1){ }}
			<p style="color:green;">成功</p>
		@{{#}else{ }}
			失败<br>
		@{{#} }}
        <a href="/admin/Remittance/Sendview?orderid=@{{d.order_id}}">详细</a>
    @{{#} }}

	</script>

	<script type="text/html" id="userrecharge">
		<!-- <a href="javascript:myTab('account_name','@{{ d.account_name}}')">@{{ d.account_name}}</a> -->
        <a href="/admin/Remittance/index?account_name=@{{d.account_name}}&apply_startime=&apply_endtime=">@{{ d.account_name}}</a>
	</script>

    <script type="text/javascript" id="money_aftercash">
        @{{#if(d.status=="0"){ }}
            @{{ Math.floor(100*(parseFloat(d.money_cash)+parseFloat(d.money)))/100 }}
        @{{#}else{ }}
            @{{ d.money_cash }}
        @{{# } }}
	   <div style="color:red;">@{{ d.money}}</div>
     
       <div style="color:green;">
            @{{#if(d.status=="0"){ }}
                @{{ d.money_cash }}
            @{{#}else{ }}
                @{{ Math.floor(100*(parseFloat(d.money_cash)-parseFloat(d.money)))/100 }}
            @{{# } }}
        </div>
    </script>

    <script type="text/html" id="money_user">
		<span style="color:red;">@{{ d.name}}</span><br>@{{ d.recharge_time}}
	</script>



    <script type="text/html" id="taked">
        @{{#if(d.status=="1"){ }}
        <p style="color:red;">汇款成功</p>
        @{{#}else{ }}
        @{{#if(d.status=="0"){ }}
         <p style="color:green;">待审核</p>
        @{{#}else{ }}
          @{{#if(d.status=="2"){ }}
         <p style="color:#00868B;">汇款失败</p>
         @{{#}else{ }}
        @{{#} }}
        @{{#} }}
        @{{#} }}

		@{{#if(d.complete_time==null){ }}

        @{{#}else{ }}
			@{{d.complete_time}}
		@{{#} }}
    </script>

<div class="layui-row">

    <div class="layui-col-xs12">

		<form class="layui-form rewrite" action="" eventType=eventForm>
            <div class="layui-form-item">
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.account_name') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="account_name" id="form_account_name" lay-verify="required" autocomplete="off" class="layui-input" value="{{Request::get('account_name')?Request::get('account_name'):$account_name}}"  eventType=event-query>
					</div>
					<div class="layui-input-inline checkbox">
						<input type="checkbox" name="sureblur" id="sureblur" lay-skin="switch" lay-text="精确|模糊" checked>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.order_id') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="order_id"  id="form_order_id"  lay-verify="" autocomplete="off" class="layui-input"
                        value="{{$order_id}}" eventType=event-query>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.recharge_type') }}</label>
					<div class="layui-input-inline" style="width: 200px">
						<select name="recharge_type"  id="form_recharge_type"  lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
							<option value="">{{ trans('money.select_rechargetype') }}</option>
							@foreach(trans('status.money_recharge.send_type') as $k=>$v)
                                @if($recharge_type==$k)
                                    <option value={{$k}} selected>{{$v}}</option>
                                    @else
                                    <option value={{$k}}>{{$v}}</option>
                                @endif

                            @endforeach
						</select>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.status') }}</label>
					<div class="layui-input-inline" style="width: 200px">
						<select name="status"  id="form_status"  lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                            @foreach(trans('status.money_recharge.send_status') as $k=>$v):
								 @if($status==$k)
                                <option  value="{{$k}}" selected>{{$v}}</option>
                                @else
                                <option  value="{{$k}}">{{$v}}</option>
                                @endif >
							@endforeach                
						</select>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.money_area') }}</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text" name="money_small" id="money_small" placeholder="￥0" autocomplete="off" class="layui-input"
                        value="{{$money_small}}" eventType=event-query>
                    </div>
					<div class="layui-form-mid">-</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="text" name="money_big" id="money_big" placeholder="￥0" autocomplete="off" class="layui-input"
                        value="{{$money_big}}" eventType=event-query>
                    </div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.apply_startime') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="apply_startime"  id="form_apply_startime" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item"
                        value="{{$apply_startime?$apply_startime:trans('status.default_time.atime')}}" eventType=event-query>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.apply_endtime') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="apply_endtime"  id="form_apply_endtime" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item"
                        value="{{$apply_endtime?$apply_endtime:trans('status.default_time.etime')}}" eventType =event-query>
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.haddle_startime') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="haddle_startime"  id="form_haddle_startime" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item" value="{{$haddle_startime}}">
					</div>
                </div>
                <div class="layui-inline">
					<label class="layui-form-label">{{ trans('money.haddle_endtime') }}</label>
					<div class="layui-input-inline">
						<input type="text" name="haddle_endtime"  id="form_haddle_endtime" placeholder=" - "  lay-verify="" autocomplete="off" class="layui-input test-item" value="{{$haddle_endtime}}" eventType =event-query>
					</div>

                </div>

                <div class="layui-inline">
                <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" style="opacity: 1; pointer-events: auto;" eventType="event-query-submit">提交</a>
				<a  class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload" style="opacity: 1; pointer-events: auto;">重置</a>
                <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload" style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
               </div>

            </div>

		</form>
    </div>
    </div>
@push('dataTableJS')
/*var active = {
    reload: function(){
      //执行重载
      table.reload('{{ $dataId }}', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {
            account_name:$("#form_account_name").val(),
            order_id:$('#form_order_id').val(),
            recharge_type:$('#form_recharge_type').val(),
            status:$('#form_status').val(),
            apply_startime:$('#form_apply_startime').val(),
            apply_endtime:$('#form_apply_endtime').val(),
            haddle_startime:$('#form_haddle_startime').val(),
            haddle_endtime:$('#form_haddle_endtime').val(),
            money_small:$('#form_money_small').val(),
            money_big:$('#form_money_big').val(),
			sureblur:$('.layui-form-switch').text(),
        }
      });
    }
  };*/
//$('.lay-btn-diy').on('click', function(){
//    var type = $(this).data('type');
//    active[type] ? active[type].call(this) : '';
//  });

  //重置表单
  $('.reset').on('click',function(){
	  $('input').val('');
	  $('#form_status').val('3');
	  $('.layui-form-select:eq(1) input').val('待审核');	
	  $('#form_recharge_type').val('');
	 // var type = $(this).data('type');
	//  active[type] ? active[type].call(this) : '';
  });

  //刷新表单
    $('.set').on('click',function(){
   // var type = $(this).data('type');
   // active[type] ? active[type].call(this) : '';
    });

function dataTableLoadFinished(res,curr,count){
var str='';
if(document.getElementById("statistics")){

}else{
$('.layui-table-page').after('<div id="statistics"></div>');
}
$.ajax({
type: 'get',
url: '/admin/money/sendMoneyCount',
data: {where:res.extras},
dataType: 'json',
//async: false,
success: function (data) {
var data=data.data;
for(var i in data){
data[i]=parseFloat(data[i]);
}
str+='<p class="bottom-txt">总金额：<span class="blue">'+data.all_money+'</span> , 成功：<span class="green">'+data.success_money+'</span> , 赠送金额：<span class="red">'+data.give_money+'</span> , 待审核金额：<span class="yellow">'+data.fail_money+'</span></p>'
$('#statistics').html(str);

var height1=$('.layui-table-view').height();
var height2=$('#statistics').height();

$('.layui-table-view').css({height:(height1+height2)});
}
});


}
@endpush
    <script>
        function myTab(name,value){
            $('*[name='+name+"]").val(value);
            $('#apply_startime').val('');
            $('#apply_endtime').val('');
            {{--  $('*[eventType=event-query-submit]').click();  --}}
        }
		/*window.onload = function () {
			$.ajax({
                type: 'get',
                url: '/admin/money/getNum',
                data: {},
                async: false,
                dataType: 'json',
                success: function (json) {
                    console.log('获取提现汇款信息');

                    console.log(json);
					console.log($('*[lay-filter=side-top-right] > li:eq(0) > a'));
                    var val = json.data;
                    if (val.rimit > 0) {
                        try {
							console.log(1);
							$('*[lay-filter=side-top-right] > li:eq(0) > a span.layui-badge',windows.parent.document).remove();
						} catch (ex) {}
						try {
							console.log(2);
							$('*[lay-filter=side-top-right] > li:eq(0) > a',windows.parent.document).append('<span class=layui-badge>' + val.rimit + '</span>');
						} catch (ex) {}
                    }
                    if (val.take > 0) {
                        try {
							console.log(3);
							$('*[lay-filter=side-top-right] > li:eq(1) > a span.layui-badge',windows.parent.document).remove();
						} catch (ex) {}
						try {
							console.log(4);
							$('*[lay-filter=side-top-right] > li:eq(1) > a',windows.parent.document).append('<span class=layui-badge>' + val.take + '</span>');
						} catch (ex) {}
                    }
                }
            });
			
		}*/
    </script>
@include('vip.datatable')
@endsection
