<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>编辑敏感词</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="__CSS__/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__CSS__/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__CSS__/animate.min.css" rel="stylesheet">
    <link href="__JS__/layui/css/layui.css" rel="stylesheet">
    <link href="__CSS__/style.min.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-8">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑敏感词</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t layui-form" id="commentForm" method="post" action="{:url('Sensitivec/editsensitive')}">
                        <input type="hidden" name="sensitivewords_id" value="{$info['sensitivewords_id']}"/>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">敏感词：</label>
                            <div class="input-group col-sm-4">
                                <textarea class="form-control" name="sensitivewords_word" required="" aria-required="true" style="width: 400px;height: 38px;resize:none">{$info['sensitivewords_word']}</textarea>
                            </div>
                        </div>
                        <!--<div class="form-group">
                            <label class="col-sm-3 control-label">选择对象：</label>
                            <input type="hidden" id="sensitivewords_for" name="sensitivewords_for" value="{$info['sensitivewords_for']}"/>
                            <div class="input-group col-sm-4 layui-form">
                                <select lay-verify="required" lay-filter="group">
                                    <option value=""> <?php if($info['sensitivewords_for']==1){echo "用户";}elseif($info['sensitivewords_for']==2){echo "客服";}else{echo "请选择";} ?>  </option>
                                    <option value="1">用户</option>
                                    <option value="2">客服</option>
                                </select>
                            </div>
                        </div>-->
                        <div class="form-group layui-form-item">
                            <label class="col-sm-3 control-label">是否启用：</label>
                            <div class="input-group col-sm-6">
                                {if !empty($status)}
                                {foreach name="status" item="vo" key="key"}
                                <input type="radio" name="sensitivewords_status" value="{$key}" title="{$vo}" {if $key eq $info['sensitivewords_status']}checked{/if}>
                                {/foreach}
                                {/if}
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-6">
                                <button class="btn btn-primary btn-sm" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
<script src="__JS__/jquery.min.js?v=2.1.4"></script>
<script src="__JS__/bootstrap.min.js?v=3.3.6"></script>
<script src="__JS__/content.min.js?v=1.0.0"></script>
<script src="__JS__/plugins/validate/jquery.validate.min.js"></script>
<script src="__JS__/plugins/validate/messages_zh.min.js"></script>
<script src="__JS__/plugins/layer/layer.min.js"></script>
<script src="__JS__/layui/layui.js"></script>
<script src="__JS__/jquery.form.js"></script>
<script type="text/javascript">
    const myHost = "http://" + window.location.host;

    layui.use(['form', 'upload'], function(){
        var form = layui.form;
    });

    var index = '';
    function showStart(){
        index = layer.load(0, {shade: false});
        return true;
    }

    function showSuccess(res){

        layer.ready(function(){
            layer.close(index);
            if(1 == res.code){
                layer.alert(res.msg, {title: '友情提示', icon: 1, closeBtn: 0}, function(){
                    window.location.href = myHost + '/admin/Sensitivec/index';
                });
            }else if(111 == res.code){
                window.location.reload();
            }else{
                layer.msg(res.msg, {anim: 6});
            }
        });
    }

    $(document).ready(function(){
        // 添加管理员
        var options = {
            beforeSubmit:showStart,
            success:showSuccess
        };

        $('#commentForm').submit(function(){
            $(this).ajaxSubmit(options);
            return false;
        });
    });

    // 表单验证
    $.validator.setDefaults({
        highlight: function(e) {
            $(e).closest(".form-group").removeClass("has-success").addClass("has-error")
        },
        success: function(e) {
            e.closest(".form-group").removeClass("has-error").addClass("has-success")
        },
        errorElement: "span",
        errorPlacement: function(e, r) {
            e.appendTo(r.is(":radio") || r.is(":checkbox") ? r.parent().parent().parent() : r.parent())
        },
        errorClass: "help-block m-b-none",
        validClass: "help-block m-b-none"
    });

    layui.use(['form', 'upload'], function(){
        var form = layui.form;

        form.on('select(group)', function(value){
            $("#sensitivewords_for").val(value.value);
        });

        // form.on('select(robotgroups)', function(value){
        //     $("#robotgroups_id").val(value.value);
        // });
    });
</script>
</body>
</html>
