{% extends base %}

{% block body_left %}

{% include dict/page/dict_edit_base.html %}

<script>
    $(".save-btn").click(function (e) {
        var params = {};
        params.key = $("[name=name]").val();
        params.value = $("[name=value]").val();
        params.dict_type = "{{dict_type}}";

        xnote.http.post("/api/dict/create", params, function (resp) {
            if (resp.success) {
                xnote.toast("添加成功");
                window.location.href = resp.data.url;
            } else if (resp.code == "302") {
                xnote.toast("添加失败:" + resp.message);
                setTimeout(function() {
                    window.location.href = resp.data.url;
                }, 1000);
            } else {
                xnote.toast("添加失败:" + resp.message);
            }
        }).fail(function (err) {
            xnote.toast("请求失败:" + err);
        })
    });
</script>

{% end %}


{% block body_right %}
    {% include dict/page/dict_sidebar.html %}
{% end %}
