<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->
<div class="layui-fluid">

  <div class="oe_breadcrumb_box clearfix" style="display:none;">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">情感测试</a><span lay-separator="">/</span>
      <a><cite>添加题目</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="addform">
        添加保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <span class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius"><a href="<!--{$oefile}-->&c=<!--{$c}-->">返回列表</a></span>
    </div> 
  </div>
  
  <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
  <input type="hidden" name="a" id="a" value="saveadd" />
  <div class="layui-card">
    <div class="layui-card-header" style="display:none;">添加题目</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="20%"><font color="red">*</font> 所属测试：</th>
          <td width="80%">
            <input type="text" name="testid" id="testid" class="layui-input input-120" value="<!--{if $testid > 0}--><!--{$testid}--><!--{/if}-->" />
            &nbsp;&nbsp;&nbsp;
            <!--{$test_title}-->
          </td>
        </tr>
        <tr>
          <th>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-120" value="<!--{$orders}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font> 题目名称：</th>
          <td>
            <input type="text" name="subname" id="subname" class="layui-input input-300" /> 
          </td>
        </tr>
        
        <tr>
          <th><font color="red"></font> 选项和分值：</th>
          <td>
            <input type="hidden" name="itemnum" id="itemnum" value="1" />
            <table class="oe_table_wrap" id="item_list" style="width:650px;">
              <tr>
                <th width="10%" class="text_center">序号ID</th>
                <th class="text_center">描述</th>
                <th width="25%" class="text_center">分值</th>
                <th width="15%" class="text_center">操作</th>
              </tr>
              <tr>
                <td class="text_center">
                  <input type="text" name="itemno_1" id="itemno_1" class="layui-input input-120" value="1" />
                </td>
                <td class="text_center">
                  <input type="text" name="text_1" id="text_1" class="layui-input input-200" value="" /> 
                </td>
                <td class="text_center">
                  <input type="text" name="value_1" id="value_1" class="layui-input input-80" value="1" /> 分
                </td>
                <td class="text_center"><a href="javascript:;" onclick="_emSubjectDelTr(this);">移除</a></td>
              </tr>
            </table>
            <table class="oe_table_wrap">
              <tr>
                <td>
                  <span style="color:blue;cursor:pointer;" id="btn_addmore_item">添加更多选项</span>
                </td>
              </tr>
            </table>
            <script type="text/javascript">
            $(function(){
                $(document).on("click", "#btn_addmore_item", function(){
                    _emSubjectAddTr("item_list", "itemnum");
                });
            });
            </script>
          </td>
        </tr>
        
      </table>
    </div>
  </div>
  </form>
  
  <div class="oe_tbl_form_btn">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="addform">
      添加保存
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>

<script type="text/javascript">
$(function(){

    layui.use('form', function(){
        var form = layui.form;
        //保存
        form.on('submit(addform)', function(data){
            var obj_id = data.elem.getAttribute("id");
            if (!$("#"+obj_id).hasClass("forbid_submit")) {
                
                if ($("#testid").val() == '' || $("#testid").val() == '0') {
                    layer.msg("请填写所属测试ID");
                    return false;
                }
                if ($("#subname").val() == '') {
                    layer.msg("请填写题目名称");
                    return false;
                }
                
                $("#"+obj_id).addClass("forbid_submit");
                if ($("#"+obj_id).find("span").length > 0) {
                    $("#"+obj_id).find("span").show();
                }
                $("#myform").submit();
            }
        });   
    });
    
});
</script>
</body>
</html>