@extends('admin.layout-content')

@section('header')
    <style>

    </style>
@endsection

@section('content')
    <div class="layui-container sg-create-container">
        <div class="layui-col-sm8 layui-col-sm-offset2">
            <form class="layui-form" method="POST" action="{{ $pre_uri . 'store' }}">

                {{ csrf_field() }}
                <input type="hidden" name="data[is_root]" value="1">
                @include('share.layui-form-item', ['type' => 'input', 'name' => 'name', 'label' => '用户名', 'required' => true, 'value' => (old('data') ? old('data')['name'] : '')])
                {{--@include('share.layui-form-item', ['type' => 'select', 'name' => 'admin_role_id', 'label' => '角色', 'selected_id' => (old('data') ? old('data')['admin_role_id'] : ''), 'options' => $admin_role_options])--}}
                {{--@include('share.layui-form-item', ['type' => 'input', 'input_type' => 'input', 'name' => 'mobile', 'label' => '手机号', 'required' => true, 'value' => ''])--}}
                @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'password', 'name' => 'password', 'label' => '密码', 'required' => true, 'value' => ''])
                @include('share.layui-form-item', ['type' => 'input', 'input_type' => 'password', 'name' => 'password_confirmation', 'label' => '确认密码', 'required' => true, 'value' => ''])
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="*">提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
                <div class="layui-form-item">
                </div>
            </form>
        </div>
    </div>
@endsection

@section('footer')
    <script>
        $(function () {
            layui.use(['form', 'laydate'], function(){
                var form = layui.form;
                var laydate = layui.laydate;

                // form.verify({
                //     integer: function (value) {
                //         var pattern = /^[1-9]\d*$/;
                //         if(!(pattern.test(value) || value === '0')) {
                //             return '组员人数必须为大于等于0的整数';
                //         }
                //     }
                // });

                form.on('submit(*)', function(data) {
                    var field = data.field;
                    if(field['data[road_id]'] !== '-1' && field['data[zone_id]'] === '-1') {
                        layer.msg('选择街道前请先选择功能区');
                        return false;
                    }
                });

                laydate.render({
                    elem: '.sg-select-date'
                });
            });
        })
    </script>
@endsection