<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
>
<head>
    <meta charset="UTF-8">
    <title>数据字典编辑</title>
    <link rel="stylesheet" href="/css/metroStyle/metroStyle.css">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css">
    <link rel="stylesheet" href="/css/public.css">
    <style type="text/css">
        .layui-form-label {
            width: 100px;
        }
    </style>
</head>
<body class="child-body">
<div class="child-nav">
    <span class="layui-breadcrumb">
         <a>系统管理</a>
         <a href="/admin/dataDictionary/list">数据字典列表</a>
         <a><cite th:text="${#strings.equals(dataDictionary.id,null)?'新增数据字典':'修改数据字典'}"></cite></a>
    </span>
    <a class="layui-btn layui-btn-sm" href="javascript:location.replace(location.href);" title="刷新"
       style="float:right;margin-top: 3px"><i class="layui-icon" style="line-height:30px">&#x1002;</i></a>
</div>
<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-header" th:text="${#strings.equals(dataDictionary.id,null)?'新增数据字典':'修改数据字典'}"></div>
        <div class="layui-card-body">
            <form class="layui-form" action="/admin/dataDictionary/save" method="post">
                <input type="hidden" id="dataDictionaryId" name="id" th:value="${dataDictionary.id}">
                <div class="layui-form-item">
                    <label class="layui-form-label">数据类型代码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="code" th:value="${dataDictionary.code}" lay-verify="required"
                               lay-vertype="tips" class="layui-input" th:readonly="${!#strings.equals(dataDictionary.id,null)}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">数据键</label>
                    <div class="layui-input-inline">
                        <input type="text" name="dataKey" th:value="${dataDictionary.dataKey}" lay-verify="required"
                               lay-vertype="tips" class="layui-input" th:readonly="${!#strings.equals(dataDictionary.id,null)}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">数据值</label>
                    <div class="layui-input-inline">
                        <input type="text" name="dataValue" th:value="${dataDictionary.dataValue}" lay-verify="required"
                               lay-vertype="tips" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-inline">
                        <input type="text" name="description" th:value="${dataDictionary.description}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">参数1</label>
                    <div class="layui-input-inline">
                        <input type="text" name="param1" th:value="${dataDictionary.param1}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">参数2</label>
                    <div class="layui-input-inline">
                        <input type="text" name="param2" th:value="${dataDictionary.param2}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">参数3</label>
                    <div class="layui-input-inline">
                        <input type="text" name="param3" th:value="${dataDictionary.param3}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="save"
                                th:text="${#strings.equals(dataDictionary.id,null)?'保存':'修改'}"></button>
                        <a href="javascript:history.back()" type="button" class="layui-btn layui-btn-primary">返回</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="/plugins/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['element', 'form', 'laydate', 'upload'], function () {
        var form = layui.form, $ = layui.jquery;

        //监听提交
        form.on('submit(save)', function (data) {
            var headers = {};
            headers['X-CSRF-TOKEN'] = "[[${_csrf.token}]]";
            $.ajax({
                url: data.form.action,
                type: data.form.method,
                headers: headers,
                data: data.field,
                dataType: 'json',
                success: function (data) {
                    if (data.code == 0) {
                        layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                            location.href = "/admin/dataDictionary/list";
                        });
                    } else {
                        layer.msg(data.msg, {time: 1000});
                    }
                }
            });
            return false;
        });

        form.render();
    });
</script>
</body>
</html>