@extends('vip.layouts')
@section('content')

<div class="layui-row">

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

        <form class="layui-form" action="" eventType=eventForm>
            <div class="layui-form-item">
            <div class="layui-inline"><a href="javascript:patchAdd('/{{ S('MODULE') }}/{{ S('CONTROLLER') }}/insert?role_id={{ Request::get('role_id') }}&id=');" class="layui-btn layui-btn-sm layui-btn-danger">{{ trans('common.addTo') }}</a></div>
                <div class="layui-inline">
                     <label class="layui-form-label">{{ trans('priv_code.priv_name') }}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="priv_name" id="form_role_name" lay-verify="" autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">{{ trans('priv_code.priv_code') }}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="priv_code" id="form_priv_code" lay-verify="" autocomplete="off" class="layui-input">
                    </div>

                    <label class="layui-form-label">{{ trans('priv_code.remark') }}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="remark" id="form_priv_id" lay-verify="" autocomplete="off" class="layui-input">
                    </div>


                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-sm lay-btn-diy"   data-type="reload" style="opacity: 1; pointer-events: auto;">查询</a>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
@push('dataTableJS')
var active = {
    reload: function(){
      //执行重载
      table.reload('{{ $dataId }}', {
        page: {
          curr: 1 //重新从第 1 页开始
        }
        ,where: {

            role_name:$("#form_role_name").val(),

            priv_code:$("#form_priv_code").val(),

            priv_id:$("#form_priv_id").val(),
                    rtoken:''

        }
      });
    }
  };
$('.lay-btn-diy').on('click', function(){
    var type = $(this).data('type');
    active[type] ? active[type].call(this) : '';
  });
@endpush
<script type="text/javascript">
function patchAdd(url)
{
     var ids = g.currentDataTableIds;
      if (ids == '' || ids == undefined) {
        layer.msg('请先选择数据');
        return;
      }
      url=url+ids;
     $.getJSON(url, function(data, textStatus) {
          if (data.status == '1') {
            layer.msg('添加成功');
            setTimeout(function () {
				//window.location.href = "/admin/priv_role/index?id=";
			   window.history.go(-1);
//			   parent.location.reload();
			}, 500);
          } else {
            layer.msg(data.msg);
          }
    });
}
</script>

@include('vip.datatable')
@endsection
