<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>
<@defaultLayout.layout>
    <link rel="stylesheet" href="${base}/assets/css/amazeui.switch.css"/>
    <script type="text/javascript">
        var base = '${base}';
    </script>
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding">
                <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">配置管理</strong> /
                    <small>采购类型配置</small>
                </div>
            </div>

            <form method="post" class="am-form" id="tmpForm"
                  action="${base}/procurement/type/save">
                <input name="procurementTypeId" id="procurementTypeId" type="hidden" value="${procurementTypeId!}"/>
                <div class="am-tabs am-margin" data-am-tabs>
                    <ul class="am-tabs-nav am-nav am-nav-tabs">
                        <li class="am-active"><a href="#tab1">新增/编辑</a></li>
                    </ul>
                    <div class="am-tabs-bd">
                        <div class="am-tab-panel am-fade am-in am-active" id="tab1">
                            <div class="am-g am-form-group am-margin-top" style="display: flex;">
                                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                    <span style="color: red;">*</span>采购类型名称</div>
                                <div class="am-u-sm-6 am-u-md-6">
                                    <input class="js-ajax-validate" name="name" data-validation-message="请输入告警类型名称（20字符以内）"
                                           minlength="1" maxlength="10"
                                           value="${procurementType.name!}" type="text" required/>
                                </div>
                                <div class="am-u-sm-2 am-u-md-4 input-msg"></div>
                            </div>

                            <div class="am-g am-form-group am-margin-top" style="display: flex;">
                                <div class="am-u-sm-4 am-u-md-2 am-text-right">
                                    <span style="color: red;">*</span>所属大类</div>
                                <div class="am-u-sm-6 am-u-md-6">
                                    <select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="type" name="type">
                                        <option value="1" <#if procurementType.type! ==1>selected</#if> >设备</option>
                                        <option value="2" <#if procurementType.type! ==2>selected</#if> >服务</option>
                                        <option value="3" <#if procurementType.type! ==3>selected</#if> >施工</option>
                                        <option value="4" <#if procurementType.type! ==4>selected</#if> >其他</option>
                                    </select>
                                </div>
                                <div class="am-u-sm-2 am-u-md-4 input-msg"></div>
                            </div>

                            <div class="am-g am-form-group am-margin-top">
                                <div class="am-u-sm-4 am-u-md-2 am-text-right">启用/禁用</div>

                                <div class="am-u-sm-12 am-u-md-4 switch-button" style="height: 25px;">
                                    <input id="switch" name="switch" type="checkbox" data-size='xs'
                                           data-am-switch data-off-text="禁用" data-on-text="启用"
                                           <#if procurementType.enabled==1 >checked</#if>
                                    />
                                    <input type="hidden" class="am-input-sm" name="enabled" id="enabled"
                                           value="${procurementType.enabled!1}"/>
                                </div>

                                <div class="am-hide-sm-only am-u-md-1" style="color: red;"></div>
                                <div class="am-u-sm-2 am-u-md-5 input-msg"></div>
                            </div>

                        </div>
                    </div>
                </div>

                <!--选项卡（tabs）end-->
                <div class="am-margin">
                    <button type="submit" id="submitBtn" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
                    <button type="button" class="am-btn am-btn-warning am-btn-xs"
                            onclick="javascript:history.go(-1);">返回上一级
                    </button>
                </div>
            </form>
        </div>
    </div>

</@defaultLayout.layout>
<script src="${base}/common/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="${base}/common/jQuery-File-Upload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="${base}/common/jQuery-File-Upload/js/jquery.fileupload.js"></script>
<script src="${base}/common/jQuery-File-Upload/js/jquery.fileupload-process.js"></script>
<script src="${base}/common/jQuery-File-Upload/js/jquery.fileupload-validate.js"></script>
<script src="${base}/assets/js/amazeui.switch.js"></script>

<script>
    var $mycheckbox = $('.switch-button');
    $mycheckbox.each(function () {
        $("#switch").on({
            'switchChange.bootstrapSwitch': function (event, state) {
                if (state.toString() == "true") {
                    $("#enabled").val("1");
                } else {
                    $("#enabled").val("0");
                }
            }
        });
    });

</script>