<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layuiAdmin 管理员 iframe 框</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base"/>
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
    <style>
        .layui-form-radio {
            padding-right: 0px !important;
            margin: 0px !important;
        }
        @font-face {
            font-family: 'iconfont';
            src: url('${ctxPlugin}/lib/font/iconfont.eot');
            src: url('${ctxPlugin}/lib/font/iconfont.eot?#iefix') format('embedded-opentype'),
            url('${ctxPlugin}/lib/font/iconfont.woff2') format('woff2'),
            url('${ctxPlugin}/lib/font/iconfont.woff') format('woff'),
            url('${ctxPlugin}/lib/font/iconfont.ttf') format('truetype'),
            url('${ctxPlugin}/lib/font/iconfont.svg#iconfont') format('svg');
        }
        .iconfont {
            font-family: "iconfont" !important;
            font-size: 16px;
            font-style: normal;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
    </style>
</head>
<body>

<div class="layui-form layui-card mb-0 pr-30" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin">
    <div id="textDiv" class="layui-card-body over">
        <div class="layui-col-xs12 mb-10">
            <label class="layui-form-label">标记图标：</label>
            <div class="layui-input-block">
            <c:forEach var="color" items="${totalColors}">
                    <div class="layui-col-xs2">
                        <input type="radio" name="type" value="${color}" disabled title="" ${color eq record.columns.type ? 'checked':''}>
                        <i class="icon iconfont" style="color: ${color};">&#xe6b0;</i>
                    </div>
            </c:forEach>
            </div>
        </div>
        <div class="layui-col-xs12 mb-10">
            <label class="layui-form-label"><i class="mark">*</i>标记类型：</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input" value="${record.columns.name}">
            </div>
        </div>
        <div class="layui-col-xs12 mb-10">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-block">
                <input type="text" id="sort" name="sort" lay-verify="pass" autocomplete="off" class="layui-input" value="${record.columns.sort}">
            </div>
        </div>
    </div>
    <input type="hidden" name="id" value="${record.columns.id}"/>
   <%-- <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="sureSubmit" id="sureSubmit" value="确认">
    </div>--%>
    <div class="layui-form-item text-c" >
        <button class="layui-btn " lay-submit lay-filter="component-form-element" <%--onclick="addRole()"--%>>保存</button>
        <button class="layui-btn" onclick="cancel()">取消</button>
    </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/font/iconfont.js"></script>
<script>
    layui.use(['form','jquery','layedit'], function () {
        $ = layui.$,
        form = layui.form,
        layer = layui.layer;

        form.verify({
            pass: function(value){
                var te = /^[1-9]\d{0,2}$/;
                if(!isBlank(value) && !te.test(value)){
                    return "排序只能填正整数";
                }
            }
        });

        form.on('submit(component-form-element)',function(data){
            var field = data.field; //获取提交的字段
            $.ajax({
                url: '${ctx}/yangguang/orderMarkSet/updateMark',
                type: 'post',
                data: {
                    id: field.id,
                    name: field.name,
                    sort: field.sort
                },
                success: function (data) {
                    if (data == "200") {
                        var index = parent.layer.getFrameIndex(window.name);
                        layer.msg('编辑成功！', {icon:1,time:1000},function(){
                            parent.layer.close(index);
                            parent.location.reload(); //刷新父页面
                        })
                    } else {
                        layer.msg("编辑失败！");
                    }
                },
                complete: function () {
                    noRepeat = false;
                }
            });
        })
    });

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
    function cancel(){
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html>