<!--{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="<!--{$emresult.testid}-->" /> 
            <!--{$emresult.testid}-->
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font> 得分范围：</th>
          <td>
            <input type="text" name="minscore" id="minscore" class="layui-input input-100" value="<!--{doubleval($emresult.minscore)}-->" /> 
            至 
            <input type="text" name="maxscore" id="maxscore" class="layui-input input-100" value="<!--{doubleval($emresult.maxscore)}-->" /> 分
            
            <br />
            <span style="color:gray;">(如果只有一个分值，请填写相同分数即可)</span>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font> 结果描述：</th>
          <td>
            <textarea name="result" id="result" class="layui-textarea" style="width:90%;height:150px;"><!--{$emresult.result}--></textarea>
          </td>
        </tr>
        <tr>
          <th>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-120" value="<!--{$emresult.orders}-->" />
          </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")) {
            
                var id = $("#id").val();
            
                var testid = $("#testid").val();
                if (testid == '' || testid == '0') {
                    layer.msg("请填写所属测试ID");
                    return false;
                }
                var minscore = $("#minscore").val();
                var maxscore = $('#maxscore').val();
                if (minscore == '' || maxscore == '') {
                    layer.msg("请填写得分范围");
                    return false;
                }
                var result = $("#result").val();
                if (result == '') {
                    layer.msg("请填写结果描述");
                    return false;
                }
                var orders = $("#orders").val();
                
                $("#"+obj_id).addClass("forbid_submit");
                $("#"+obj_id).find("span").show();
                $.ajax({
                  type: "POST",
                  url: "<!--{$oefile}-->&c=<!--{$c}-->",
                  cache: false,
                  data: {
                      a:'saveedit', id:id, testid:testid, minscore:minscore, maxscore:maxscore, 
                      result:result, orders:orders
                  },
                  dataType: "json",
                  success: function(data) {
                    var response = data.response;
                    var result = data.result;
                    if (response == '1') {
                      layer.msg("编辑成功");
                      setTimeout(function(){
                        window.parent.location.reload();
                      }, 600);
                    }
                    else {
                      if (result == '' || result == null) {
                        result = '编辑失败，请检查';
                      }
                      layer.msg(result);
                      $("#"+obj_id).removeClass("forbid_submit");
                      $("#"+obj_id).find("span").hide();
                    }
                  },
                  error: function() {
                    layer.msg("系统繁忙，请稍后再试！");
                    $("#"+obj_id).removeClass("forbid_submit");
                    $("#"+obj_id).find("span").hide();
                  }
                });
                //$("#myform").submit();
            }
        });   
    });
    
});
</script>
</body>
</html>