@extends('vip.layouts')
@section('content')
<style type="text/css">
  .loss-input {
    /* display: block; */
    width: 100%;
    padding-left: 10px;
}
.loss-input {
    height: 38px;
    line-height: 1.3;
    line-height: 38px\9;
    border-width: 1px;
    border-style: solid;
    background-color: #fff;
    border-radius: 2px;
}
</style>
<form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
{!! csrf_field() !!}
            <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('lottery_money.name') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="name"   id="name"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($data) {{ $data['name'] }} @endisset" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
            <!-- <label class="layui-form-label">{{ trans('lottery_money.type') }}</label>
            <div class="layui-input-block">
              <select name="type" id="type" class="Selects" lay-filter="testSelect" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                    @foreach(trans('lottery_money.money_C') as $k=>$v)
                      <option @if(isset($data['type'])&& $k == $data['type'])  selected @endif value="{{$k}}">{{$v}}</option>
                    @endforeach
              </select>
              </div>
            </div> -->
            <input type="hidden" name="type" value="upgrade">
            <div class="layui-form-item">
              <label class="layui-form-label">{{ trans('lottery_money.give_type') }}：</label>
              <div class="layui-input-block">
                  <input type="radio" name="setup" value="1" checked="true" title="手动申请" @if(isset($setup) && $setup == 1) checked @endif>
                  <input type="radio" name="setup" value="2" title="自动计算" @if(isset($setup) && $setup == 2) checked @endif>
              </div>
            </div>
            <div class="layui-form-item">
            <label class="layui-form-label">彩金类型:</label>
            <div class="layui-input-block">
              <select name="give_type" id="type" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                    <option value="num" @if(isset($give_type)&&$give_type=='num')selected @endif >赠送金额</option>
              </select>
              </div>
            </div>

            <!-- <div class="layui-form-item single" style="display: none;">
              <label class="layui-form-label">{{ trans('lottery_money.game') }}</label>
              <div class="layui-input-block">
                <select name="game" id="game" lay-verify="" autocomplete="off" class="layui-input" eventType=event-query>
                      <option value="" selected="selected">请选择</option>
                      @foreach($dataed as $k=>$v)
                        <option value="{{$v['gameCode']}}">{{ $v['name'] }}</option>
                      @endforeach
                </select>
              </div>
            </div> -->

            <!-- <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('lottery_money.proportion') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="proportion" id="proportion"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($give_type) {{ $give_type }} @endisset" class="layui-input">
                &nbsp;&nbsp;{{ trans('lottery_money.proportione') }}
                </div>
            </div> -->

            <div class="layui-form-item">
            <label class="layui-form-label">{{ trans('lottery_money.grade') }}</label>
            <div class="layui-input-block">
              @foreach($User_grade as $k=>$v)
                <div style="float: left;margin-right: 20px; width: 150px;"><input type="checkbox" name="grade[]" value="{{$v['id']}}" @if(isset($v['active']) && $v['active'] == 1) checked @endif>{{$v['name']}}</div>
                <input type="text" name="proportion[]" lay-verify="" placeholder="请输入金额" autocomplete="off" value="@isset($v['val']) {{ $v['val'] }} @endisset" class="layui-input" style="width: 300px;">
              @endforeach
              </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">提款倍数:</label>
                <div class="layui-input-block">
                <input type="text" name="multiple"   id="multiple"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($multiple) {{ $multiple }} @endisset" class="layui-input">
                </div>
            </div>
            <!-- <div class="layui-form-item">
                <label class="layui-form-label">{{ trans('lottery_money.sort') }}:</label>
                <div class="layui-input-block">
                <input type="text" name="sort"   id="sort"  required  lay-verify="" placeholder="" autocomplete="off" value="@isset($data) {{ $data['sort'] }} @endisset" class="layui-input">
                </div>
            </div> -->
            <input type="hidden" name="sort" value='1'>
            <div class="layui-form-item">
              <label class="layui-form-label">游戏列表</label>
              <div class="layui-input-block">
                @foreach($dataed as $k=>$v)
                <div style="float: left;margin-right: 20px; width: 150px;"><input type="checkbox" name="gamename[]" value="{{$v['gameCode']}}" @if(isset($v['active']) && $v['active'] == 1) checked @endif>{{$v['name']}}</div>
                @endforeach
              </div>
            </div>
            


@if(S('ACTION')!='view')
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-green">重置</button>
    </div>
  </div>
@endif
</form>

<script>
//Demo

  var condiloss_money = $('.loscon').html();
  var condilucky_money = $('.luccon').html();
var dt = '';

//添加条件
function addcondi(){
  var did = $('.addcondi').attr('data-id');
  if(did>=10){
    layer.msg('最多添加十项条件');
    return false;
  }
  var mat = parseInt(did)-1;
  var ac = $('.addcondi').attr('data-type');
  if(dt==''){
    if(ac=='loss_money'){
      condiloss_moneyt = condiloss_money.replace(/-0/g, "-"+did);
      $('.addbut').before(condiloss_moneyt);
    }else if(ac=='lucky_money'){
      condilucky_moneyt = condilucky_money.replace(/-0/g, "-"+did);
      $('.addbut').before(condilucky_moneyt);
    }
  }else if(dt=='loss_money'){
      condiloss_moneyt = condiloss_money.replace(/-0/g, "-"+did);
    $('.addbut').before(condiloss_moneyt);
  }else if(dt=='lucky_money'){
      condilucky_moneyt = condilucky_money.replace(/-0/g, "-"+did);
    $('.addbut').before(condilucky_moneyt);
  }
  $('.addcondi').attr('data-id',parseInt(did)+1);
}

//删除条件
function delcondi(){
  var did = $('.addcondi').attr('data-id');
  if(did<=1){
    layer.msg('至少包含一项条件');
    return false;
  }
  var mat = parseInt(did)-1;
  var dstr = '-'+mat;
  $("input[id$='"+dstr+"']").parent().parent().remove();
  
  $('.addcondi').attr('data-id',mat);
  $('.delcondi').attr('data-id',mat);
}

layui.use(['form'], function(){
  var form = layui.form;
  $('.loscon').remove();
  $('.luccon').remove();
  var codistr = '';
  form.on('select(testSelect)', function(data){
     console.log(data.value);
     dt = data.value;
     if (data.value=='join' || data.value=='month_join' || data.value=='week_join' || data.value=='loss_money'|| data.value=='day_join') {
          $('.single').show();
          // $('#labels').hide();
     }else{
         $('.single').hide();
         // $('#labels').show();
     }
     if(data.value=='sign_money'){
         $('.sign_money').show();
     }else{
         $('.sign_money').hide();
     }
     if(data.value=='night_join'){
        $('.night_join').show();
     }else{
        $('.night_join').hide();
     }
     
     if (data.value=='loss_money') {
          $('.loss_money').show();
          $('.extrcon').after(condiloss_money);
     }else{
         $('.condiloss_money').remove();
         $('.loss_money').hide();
     }
     if (data.value=='lucky_money') {
          $('.lucky_money').show();
          $('.extrcon').after(condilucky_money);
     }else{
          $('.condilucky_money').remove();
         $('.lucky_money').hide();
     }
     if (data.value=='lucky_money' || data.value=='loss_money') {
          $('.addcondi').show();
          $('.addbut').show();
          $('.extrcon').show();
     }else{
          $('.extrcon').hide();
          $('.addbut').hide();
         $('.addcondi').hide();
     }
  });

  //监听提交
  form.on('submit(submitForm)', function(data){
    return true;
  });
});
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  //时间选择器
  laydate.render({
    elem: '#cd1-star_time'
    ,type: 'time'
  });

  //时间选择器
  laydate.render({
    elem: '#cd1-end_time'
    ,type: 'time'
  });
});

/*lay('.test-item').each(function(){
    laydate.render({
        elem: this
        ,type: 'datetime'
        ,trigger: 'click'
    });
});*/
</script>
@endsection
