<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
%>
<jsp:include page="../../../common/admin/modal_content_pre.jsp"><jsp:param name="modal_title" value="新增"/></jsp:include>
<form id="formAdd" action="<%=basePath%>/ms/atmosphere/addAtmosphereYear.action" method="post" role="form">
    <input type="hidden" id="editYear" value="${outputModel.dataYear}">
    <input type="hidden" id="id" name="id" value="${outputModel.id}">
    <div class="form-group">
        <label for="dataYear">年份</label>
        <select id="dataYear" name="dataYear" class="form-control">
        </select>
        <span class="field-validation-valid help-block"></span>
    </div>
    <div class="form-group">
        <label for="quality">空气质量</label>
        <input type="text" id="quality" name="quality" class="form-control" value="${outputModel.quality}"/>
        <span class="field-validation-valid help-block"></span>
    </div>
    <div class="form-group">
        <label for="grade">等级</label>
        <input type="text" id="grade" name="grade" class="form-control" value="${outputModel.grade}"/>
        <span class="field-validation-valid help-block"></span>
    </div>
</form>
<jsp:include page="../../../common/admin/modal_content_post.jsp"></jsp:include>
<jsp:include page="../../../common/admin/modal_footer_pre.jsp"></jsp:include>
<button type="button" class="btn btn-default" data-dismiss="modal"><i class="fa fa-close"></i>取消</button>
<button type="button" id="btnSave" class="btn btn-primary"><i class="fa fa-check"></i>保存</button>
<script type="text/javascript">
    $("#btnSave").click(function() {
        /*var qua=$('#quantity').val();
        if(qua ==null ||qua ==''){
            alert("等级值不能为空！！");
            return;
        }
        if(qua<0 || qua>100){
            alert("等级值必须在0到100之间！！");
            return;
        }*/
        $('#formAdd').ajaxSubmitCloseRefresh();
    });
    /*年份选择*/
    function chooseYear() {
        var myDate = new Date();
        var startYear = myDate.getFullYear() - 30;
        var endYear = myDate.getFullYear() + 30;
        var obj=document.getElementById('dataYear');
        for(var i=startYear;i<=endYear;i++){
            obj.options.add(new Option(i,i));
        }
        if(!yearIsSelected()){
            obj.options[obj.options.length-31].selected=1;
        }
    }
    chooseYear();

    function yearIsSelected() {
        var selectYear = $('#editYear').val();
        var years=$('#dataYear').find("option");
        for(var j=0;j<years.length;j++){
            if(years[j].value==selectYear){
                $(years[j]).attr("selected","selected");
                return true;
            }
        }
        return false;
    }
</script>
<jsp:include page="../../../common/admin/modal_footer_post.jsp"></jsp:include>