@extends('admin.layout-content')

@section('header')
    <style>

    </style>
@endsection

@section('content')
    <div class="layui-card">
        <div class="layui-card-header sg-card-header">
            创建设备
            <div class="sg-card-create">
                <button id="sg-back-btn" class="layui-btn layui-btn-sm">返回</button>
            </div>
        </div>
        <div class="layui-card-body">
            <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() }}
                        @include('share.name-select-form', ['device_name_id' => '', 'options' => $options])
                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'spec_name', 'label' => '规格型号', 'required' => true, 'value' => (old('data') ? old('data')['spec_id'] : '')])
                        @include('share.layui-form-item', ['type' => 'radio', 'name' => 'status', 'label' => '状态', 'selected_id' => (old('data') ? old('data')['status'] : ''), 'options' => $status_options])
                        @include('share.project-select-form', ['project_id' => '', 'options' => $project_options])
                        {{--@include('share.project-work-point-select-form', ['project_id' => '', 'work_point_id' => '', 'options' => $project_work_point_options])--}}
                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'number', 'label' => '固定资产编号', 'required' => true, 'value' => (old('data') ? old('data')['number'] : '')])
                        @include('share.layui-form-item', ['id' => 'sg-produce-date', 'type' => 'date', 'name' => 'produce_date', 'label' => '出厂日期', 'required' => true, 'value' => (old('data') ? old('data')['produce_date'] : '')])
                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'shape', 'label' => '外形尺寸', 'required' => true, 'value' => (old('data') ? old('data')['shape'] : '')])
                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'buy_origin', 'label' => '采购原值', 'required' => true, 'value' => (old('data') ? old('data')['buy_origin'] : '')])
                        @include('share.layui-form-item', ['type' => 'input', 'name' => 'manufacturer', 'label' => '生产厂家', 'required' => true, 'value' => (old('data') ? old('data')['manufacturer'] : '')])
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button id="btnSubmit" class="layui-btn" lay-submit lay-filter="formDemo">提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </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的整数';
                //         }
                //     }
                // });

                $('#sg-back-btn').on('click', function () {
                    window.history.go(-1);
                });

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