questionadd.html 8.1 KB
<include file="public@header" />
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('Question/question')}">评分题目列表</a></li>
        <li class="active"><a href="#">添加评分题目</a></li>
    </ul>
<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('Question/questionAddPost')}">
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>上级</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" name="parent_id" id="parent_id">
                    <option value="0">作为一级菜单</option>
                    <foreach name="select" item="vo">
                        <option value="{$vo.id}" <eq name="$parent_id" value="$vo['id']">selected</eq>>{$vo.title}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>标题</label>
            <div class="col-md-6 col-sm-10">
                <textarea rows="10" class="form-control" name="title" required></textarea>
            </div>
        </div>
        <div id="fen" class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>是否开启单独评分</label>
            <div class="col-md-6 col-sm-10">
                <input type="radio" id="thistype" name="type" value="0" checked>不开启
                <input type="radio" name="type" value="1">开启
            </div>
        </div>
        <div id="fen1" class="form-group hidden">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>单独评分分数区间</label>
            <div class="col-md-6 col-sm-10">
                </span><input type="number" class="form-control" style="width: 100px; float: left" name="min" placeholder="最低分">
                <span style="float: left; margin-left: 5px; margin-top: 5px">——</span>
                <input type="number" class="form-control" style="width: 100px; float: left; margin-left: 10px" name="max" placeholder="最高分">
            </div>
        </div>
        <div id="fen2" class="form-group hidden">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>单独评分内容</label>
            <div class="col-md-6 col-sm-10">
                <textarea rows="10" type="text" class="form-control" name="content"></textarea>
            </div>
        </div>
        <div id="ti" class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>是否有提示信息</label>
            <div class="col-md-6 col-sm-10">
                <input type="radio" id="thishint" name="hint_type" value="0" checked>无提示信息
                <input type="radio" name="hint_type" value="1">有提示信息
            </div>
        </div>
        <div id="ti3" class="form-group hidden">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>提示信息标题</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="hint_text">
            </div>
        </div>
        <div id="ti1" class="form-group hidden">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>提示信息标题</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" name="hint_title">
            </div>
        </div>
        <div id="ti2" class="form-group hidden">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>提示信息内容</label>
            <div class="col-md-6 col-sm-10">
                <textarea rows="10" class="form-control" name="hint_content"></textarea>
            </div>
        </div>
        <div id="xuan" class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>本选项分数</label>
            <div class="col-md-6 col-sm-10">
                <input type="number" class="form-control" name="score">
            </div>
        </div>
        <div id="xuan1" class="form-group">
            <label class="col-sm-2 control-label"><span class="form-required">*</span>本选项排序</label>
            <div class="col-md-6 col-sm-10">
                <input type="number" class="form-control" name="order_id" value="10">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $(function () {
        //按默认parent_id显示页面信息
        var question_type = $('#parent_id').val();
        if(question_type == 0){
            $('#xuan').attr('class','form-group hidden');
            $('#xuan1').attr('class','form-group hidden');
            $('#fen').attr('class','form-group');
            $('#ti').attr('class','form-group');
        } else {
            $('#xuan').attr('class','form-group');
            $('#xuan1').attr('class','form-group');
            $('#fen').attr('class','form-group hidden');
            $('#fen1').attr('class','form-group hidden');
            $('#fen2').attr('class','form-group hidden');
            $('#ti').attr('class','form-group hidden');
            $('#ti1').attr('class','form-group hidden');
            $('#ti2').attr('class','form-group hidden');
            $('#ti3').attr('class','form-group hidden');
        }
        //动态改变页面信息
        $('#parent_id').on('change',function () {
            var question_type = $('#parent_id').val();
            if(question_type == 0){
                $('#xuan').attr('class','form-group hidden');
                $('#xuan1').attr('class','form-group hidden');
                $('#fen').attr('class','form-group');
                $('#ti').attr('class','form-group');
                $('input[type=radio]').removeAttr('checked');
                $('#thishint').prop('checked',true);
                $('#thistype').prop('checked',true);
            } else {
                $('#xuan').attr('class','form-group');
                $('#xuan1').attr('class','form-group');
                $('#fen').attr('class','form-group hidden');
                $('#fen1').attr('class','form-group hidden');
                $('#fen2').attr('class','form-group hidden');
                $('#ti').attr('class','form-group hidden');
                $('#ti1').attr('class','form-group hidden');
                $('#ti2').attr('class','form-group hidden');
                $('#ti3').attr('class','form-group hidden');
                $('input[type=radio]').removeAttr('checked');
                $('#thishint').prop('checked',true);
                $('#thistype').prop('checked',true);
            }
        });

        //动态显示单独评分组信息
        $('input[name=type]').on('click',function(){
            var fen = $('input[name=type]:checked').val();
            console.log(fen)
            if(fen == 0){
                $('#fen1').attr('class','form-group hidden');
                $('#fen2').attr('class','form-group hidden');
            } else {
                $('#fen1').attr('class','form-group');
                $('#fen2').attr('class','form-group');
            }
        });

        //动态显示提示组信息
        $('input[name=hint_type]').on('click',function(){
            var ti = $('input[name=hint_type]:checked').val();
            console.log(fen)
            if(ti == 0){
                $('#ti1').attr('class','form-group hidden');
                $('#ti2').attr('class','form-group hidden');
                $('#ti3').attr('class','form-group hidden');
            } else {
                $('#ti1').attr('class','form-group');
                $('#ti2').attr('class','form-group');
                $('#ti3').attr('class','form-group');
            }
        })

    })
</script>
</body>
</html>