<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <meta name="renderer" content="webkit">
    <!-- 移动设备 viewport -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <jsp:include page="../../common.jsp" />
    <style>
    </style>
</head>
<body>
<div class="layui-container">
    <form class="layui-form" action="" style="margin-top: 10px" lay-filter="formDemo">
        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" required  lay-verify="required" placeholder="请输入名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">编码</label>
            <div class="layui-input-block">
                <input type="text" name="code" required  lay-verify="required" placeholder="请输入编码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">版本</label>
            <div class="layui-input-block">
                <input type="text" name="title" required  lay-verify="required" placeholder="请输入版本号" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">私钥</label>
            <div class="layui-input-block">
                <textarea name="priKey" placeholder="请输入私钥" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">公钥</label>
            <div class="layui-input-block">
                <textarea name="pubKey" placeholder="请输入公钥" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否生效</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="生效" checked>
                <input type="radio" name="status" value="0" title="不生效">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
</body>

<script>
    //Demo
    layui.use(['form', 'layer'], function(){
        var form = layui.form;
        var layer = layui.layer;

        //监听提交
        form.on('submit(formDemo)', function(data){
            let index = layer.load(1, {shade: [0.1, '#000']});

            $.ajax({
                url: ctx + "/encryptKey/save"
                , type: 'POST'
                , data: form.val("formDemo")
                , success: function(d) {
                    if (d.code == 200) {
                        parent.layer.closeAll()
                    } else {
                        layer.close(index);
                    }
                    parent.layer.msg(d.message);
                }
            })

            return false;
        });
    });
</script>
</html>