<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
<title>编辑</title>
<%@ include file="/include/header.jsp"%>
<link type="text/css" rel="stylesheet" href="${ctx}/css/baseFrame.css" />
<style>
	.page a {
		color: #333;
	}
	input.page_input{
		border:1px solid #ddd;
	}
</style>
</head>
<body >
	<div>
		<div class="b_box">
			<form id="sysRoleForm" action="post">
				<input type="hidden" name="Itemaval" value="${Itemaval}" />
				<input type="hidden" name="Itemaval" value="${ItemName}" />
				<table class="c_table m_t10">
					<tr>
						<td class="t_tit">申请名称</td>
						<td><input type="text" id="ItemName" name="ItemName" disabled="disabled" data-validaterole="ItemName" data-rule="ItemName"  value="${ItemName}" /></td>
					</tr>
					<tr>
						<td class="t_tit">准确率</td>
						<td><input type="text" id="Itemaval" name="Itemaval" value="${Itemaval}"/></td>
					</tr>
				</table>			
			</form>
		</div>
		<div class="action_box m_t10 t_c">
			<input type="button" class="b_btn" id="editBtn" value="保存" />
		</div>
	</div>

	<script type="text/javascript">
	// 验证
	seajs.use(["component/validate", "component/tip"], function(validate, tip) {
		var ntip = function() {
			// 定义一个提示对象
			return new tip({});
		};

		// 定义一个验证对象
		var d = new validate({
			con: "#adminRankForm",
			// 验证容器
			ntip: ntip,
			onSubmit: "#editBtn" // 提交按钮
		});

		// 设置拼装规则: 这里加上各个验证规则
		//d.setValidateRule({ ItemName: ["isBlank", "checkLen"] });
		d.setValidateRule({ Itemaval: ["isBlank", "checkLen"] });
	
		// 注册保存按钮事件
		d.bind("onsubmit", function() {
			if (confirm('确定提交审批？')) {
				// 序列化表单参数
				var num = $("#Itemaval").val();
				var strNum=num+"";
				var len=strNum.lastIndexOf("%")-strNum.lastIndexOf(".");
				if(num==''||Number(num.substring(0,strNum.length-1))<=0){
					alert("申请准确率不能为空或小于等于0!");
					return;
				}else if(strNum.lastIndexOf("%")!=strNum.length-1){
					alert("申请准确率应为百分数!");
					return;
				}else if(isNaN(num.substring(0,strNum.length-1))){
					alert("请输入百分数");
					return;
				}else if(Number(num.substring(0,strNum.length-1))>100){
					alert("申请准确率不能大于100%!");
					return;
				}else if(len>3){
					alert("申请准确率只可保留2位小数");
					return;
				}

				$.post("${ctx}/sysTaskPlus/updateMachine.do", {num:num}, function(result) {
					if ("succ" == result.isSucc) {
						alert("操作成功");
						// 刷新列表页面
						parent.location.replace("${ctx}/sysPara/machinePara.do?ts=" + new Date().getTime()); //如果发表成功则跳到列表界面 
						// 关闭弹窗窗口
						parent.sysRoleDialog.close();
					} else if ("notThroughSecurityCheck" == result["isThroughSecurityCheck"]) { // 如果不通过安全检查
						var mess = result["mess"];
						$.post("${ctx}/common/notThroughSecurityCheck.do?ts=" + new Date().getTime(), mess, function(res) {
							alert(res);
						}, "json");

					} else {
						alert(result);
					}
				},
				"json");
			}
	
		});
	});
	</script>
</body>
</html>