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

  <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post">
  <input type="hidden" name="a" id="a" value="saveedit" />
	<input type="hidden" name="id" id="id" value="<!--{$id}-->" />
  <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="hidden" name="testid" id="testid" value="<!--{$emsubject.testid}-->" /> 
            <!--{$emsubject.title}-->/id:<!--{$emsubject.testid}-->
          </td>
        </tr>
        <tr>
          <th>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-120" value="<!--{$emsubject.orders}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font> 题目名称：</th>
          <td>
            <input type="text" name="subname" id="subname" class="layui-input input-300" value="<!--{$emsubject.subname}-->" /> 
          </td>
        </tr>
        
        <tr>
          <th><font color="red"></font> 选项和分值：</th>
          <td>
            <!--{if !empty($emsubject.itemlist)}-->
            <input type="hidden" name="itemnum" id="itemnum" value="<!--{count($emsubject.itemlist)}-->" />
            <!--{else}-->
            <input type="hidden" name="itemnum" id="itemnum" value="0" />
            <!--{/if}-->
            <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>
              <!--{if !empty($emsubject.itemlist)}-->
              <!--{foreach $emsubject.itemlist as $val}-->
              <tr>
                <td class="text_center">
                  <input type="text" name="itemno_<!--{$val.itemno}-->" id="itemno_<!--{$val.itemno}-->" class="layui-input input-120" value="<!--{$val.itemno}-->" />
                </td>
                <td class="text_center">
                  <input type="text" name="text_<!--{$val.itemno}-->" id="text_<!--{$val.itemno}-->" class="layui-input input-200" value="<!--{$val.text}-->" /> 
                </td>
                <td class="text_center">
                  <input type="text" name="value_<!--{$val.itemno}-->" id="value_<!--{$val.itemno}-->" class="layui-input input-80" value="<!--{$val.value}-->" /> 分
                </td>
                <td class="text_center"><a href="javascript:;" onclick="_emSubjectDelTr(this);">移除</a></td>
              </tr>
              <!--{/foreach}-->
              <!--{/if}-->
            </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="editform">
      编辑保存
      <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(editform)', 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>