[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>编辑项目信息</title>
<!--框架必需start-->
<script type="text/javascript" src="${ctx}/qui/libs/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/qui/libs/js/framework.js"></script>
<link href="${ctx}/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" id="skin" prePath="${ctx}/qui/"/>
<link rel="stylesheet" type="text/css" id="customSkin"/>
<!--框架必需end-->

<!--基本选项卡start-->
<script type="text/javascript" src="${ctx}/qui/libs/js/nav/basicTab.js"></script>
<!--基本选项卡end-->

<link rel="stylesheet" href="${ctx}/qui/libs/js/form/validform/css/style.css" type="text/css" media="all" />
<script src="${ctx}/qui/libs/js/form/validform/validform.js" type="text/javascript"></script>

<!-- 树组件start -->
<script type="text/javascript" src="${ctx}/qui/libs/js/tree/ztree/ztree.js"></script>
<link type="text/css" rel="stylesheet" href="${ctx}/qui/libs/js/tree/ztree/ztree.css"></link>
<!-- 树组件end --> 

<!-- 树形下拉框start -->
<script type="text/javascript" src="${ctx}/qui/libs/js/form/selectTree.js"></script>
<!-- 树形下拉框end -->

<!-- 异步提交start -->
<script type="text/javascript">
function onSave(){
	$("#myFormId").submit();
}

function customHeightSet(contentHeight){
	$("#scrollContent").height(150);
}

function appButton(){
	var mid=$("#checkId").val();
	if(mid>0){
		//设置下一步的按钮可以操作
		$("#appButton").attr("disabled",false);
	}
}

/**提交审批*/
function submitApproval(){
	var checkId = $("#checkId").val();

	jQuery.post("${ctx}/water/submitApproval.do",
  			{"checkId":$("#checkId").val()},
  			function(responseText){
  				if(responseText.status=="y"){
  					openComplete(responseText.taskId,checkId);
  				}else{
  					top.Dialog.alert(responseText.info);
  				}
			},
			"json");
}

//提交审批
function openComplete(taskId,checkId){
	 top.Dialog.open({
		URL : "${ctx}/task/complete.do?taskId="+taskId+"&checkId="+checkId+"&voteAgree=1",
		Title : "审批",
		Width : 450,
		Height : 300
	});
}
//退回
function onBackTask(taskId){
	 top.Dialog.open({
			URL : "${ctx}/task/backProcessToStartUser.do?taskId="+taskId,
			Title : "退回发起人",
			Width : 450,
			Height : 300
		});
}

function initComplete(){
    //表单提交
	$("#myFormId").Validform({
		tiptype:3,//表示在右边显示
		ajaxPost:true,
		showAllError:true,
		datatype:{
			"zh" : /^[\u4e00-\u9fa5]+$/,
			"en" :/^[a-zA-Z]+$/,
			//固定电话
			"tel" :  /^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$/
			
		},
		callback:function(responseText){

			//alert(responseText.info);
			$.Hidemsg();
			if(responseText.status=="y"){
				
				top.Dialog.alert(responseText.info,function(){
					//alert(responseText.checkId);
					
					$("#checkId").attr("value",responseText.checkId);
					//alert($("#checkId").val());
					appButton();
	            });
				
				//var orgId = responseText.orgId;
				//top.frmright.location.href="${ctx}/water/add.do?orgId="+orgId;
			}else{
				top.Dialog.alert(responseText.info,function(){
	            	return false;
	            });
			}
			
		}
	});
    
	appButton();
}  

function appButton(){
	var mid=$("#checkId").val();
	if(mid>0){
		//设置下一步的按钮可以操作
		$("#appButton").attr("disabled",false);
	}
}

function getValue(){
    //top.Dialog.alert("选中节点文本:"+$("#selectTree-3").attr("relText")+"<br/>选中节点id:"+$("#selectTree-3").attr("relValue"));
    var selvalue = $("#selectTree-3").attr("relValue");
    
    //top.Dialog.alert($("#selectTree-3").attr("relValue"));
    

	var tb = document.getElementById('water');
     var rowNum=tb.rows.length;
     for (i=0;i<rowNum;i++)
     {
         //tb.deleteRow(i);
         //rowNum=rowNum-1;
         //i=i-1;
     }
    
    jQuery.post("${ctx}/quota/getQuotaData.do", 
    		{ "ids": $("#selectTree-3").attr("relValue") },
    		function (json) {  
    			//top.Dialog.alert("执行了");
    			//top.Dialog.alert(json);
    			  json = eval(json);
    			  for(var i=0; i<json.length; i++)  
    			  {  
    				  var j = rowNum*1 + i*1;
    				  var val0="<input type='hidden' value='"+json[i].quotaId+"'  name='quotaId'>";
    				  
    				  var val1="<input type='text' name='descName' value='"+json[i].parName+"  "+json[i].descName+"' style='width:200px' readonly>";

    				  var val2="<input type='text' value='' id='txtAmount"+j+"' name='txtAmount' datatype='n' onblur='cacul()' style='width:60px'>";

    				  var vl3="<input type='text' name='unit0' value='"+json[i].unit0+"' readonly style='width:30px'>×";

    				  var val4="<input type='text' value='"+json[i].unitValue+"' id='txtUnitValue"+j+"' name='unitValue' readonly style='width:30px'>";

    				  var val5="<input type='text' name='unit' value='"+json[i].unit+"' readonly style='width:60px'>×";
    				  
    				  var val6="<input type='text' value='1' id='txtNum"+j+"' name='txtNum'  onblur='cacul()' style='width:30px'>";

    				  var val8="<input type='text' name='timing' value='"+json[i].timing+"' readonly style='width:30px'>=";
    				  
    				  if(json[i].timing!=null&&json[i].timing!="")
    				  {	
    				  }
    				  var val7="<input type='text' value='' id='txtTotal"+j+"' name='txtTotal' readonly style='width:60px'>m³";
    			  
	    			  var $tr=$("<tr><td>"+val1+""+val0+"</td><td>"+val2+"</td><td>"+vl3+"</td><td>"+val4+"</td><td>"+val5+"</td><td>"+val6+""+val8+"</td><td>"+val7+"</td></tr>");
	    			  $("#water").append($tr); 
    			  }   
    			  $("#water").render();
    		});


}
function cacul(){
	var tb = document.getElementById('water');
    var rowNum=tb.rows.length;
    //alert(tb.rows.length)
    for (i=0;i<rowNum;i++)
    {
    	//parseInt
    	document.getElementById('txtTotal'+i).value = document.getElementById('txtAmount'+i).value*document.getElementById('txtUnitValue'+i).value*document.getElementById('txtNum'+i).value;
		//alert(document.getElementById('txtTotal'+i).value);
    	document.getElementById('txtTotal'+i).value = Math.round(document.getElementById('txtTotal'+i).value);
	//alert(document.getElementById('txtTotal'+i).value);
    }
    var a =0; 
    for (i=0;i<rowNum;i++)
    {
    	//parseInt
    	//alert(parseInt(document.getElementById('txtTotal'+i).value));
    	
    	//alert(parseInt(document.getElementById('txtTotal'+i).value));
    	a = parseInt(document.getElementById('txtTotal'+i).value)+a;
    	
    }    
    document.getElementById('total').value = a;
    
}
</script>
<!-- 异步提交end -->				    
</head>
<body>
<div class="box2" panelTitle="编辑用水指标审批信息" statusText="返回列表" panelUrl="${ctx}/task/listTodoTasks.do">
	<div class="box_tool_mid padding_top5 padding_right5">
		<div class="center">
		<div class="left">
		<div class="right">
			<div class="padding_top8 padding_left10">
			<table>
				<tr>
					<td><button onclick="onSave()"><span class="icon_save">保存</span></button></td>
					<td><button id="appButton" disabled="true" onclick="submitApproval()"><span class="icon_ok">提交审批</span></button></td>
				</tr>
			</table>
			</div>			
		</div>		
		</div>	
		</div>
		<div class="clear"></div>
	</div>
	<div class="box1" panelWidth="500">
		<form id="myFormId" action="${ctx}/water/editData.do" method="post">
			<input type="hidden" id="checkId" name="checkId" value='${checkId!""}' />
			<input type="hidden" id="taskId" name="taskId" value='${taskId!""}' />
			<input type="hidden" name="inputUser" value='${inputUser!""}' />
			 <input type="hidden" name="id" value="${plan.id!''}"/>
			 						
			<table class="tableStyle" formMode="line">
				<tr><th colspan="4">南宁市计划用水单位增加用水指标审批表</th></tr>
				<tr>
					<td></td><td>${busOrg.orgName!''}</td><td colspan="2"> ${createTime?substring(0,4)}年${createTime?substring(5,7)}月${createTime?substring(8,10)}日</td>
				</tr>
				<tr>
					<td>水表号:</td><td colspan="3">${busOrg.busOrgMeterNumber!''}</td>
				</tr>
				<tr>
					<td>联系人:</td><td><input type="text" value="${plan.contacts!""}" id="contacts" name="contacts" ></td><td>联系电话:</td><td><input type="text" value="${plan.contactNo!""}" id="contactNo" name="contactNo" ></td>
				</tr>				
				
			  <tr>
			    <td>申请用水内容摘要:</td>
			    <td colspan="3"><textarea name="content"  style="width:85%;"> 业主入住率较2015年提高,共810户。申请增加计划用水量如下:</textarea></td>
			  </tr>
			  <tr>
			    <td> ${createTime?substring(0,4)}年全年原计划量(m3)</td>
			    <td><label name="plan">${plan.planOfWater?string("0")}</label><input type="hidden" value="${plan.planOfWater?string("0")}"  name="plan"></td>
			    <td style="text-align:left;">申请增加至(m3)</td>
			    <td><input type="text" value=""  name="increase" datatype="n"></td>
			  </tr>

			  <tr>
			    <td id="tr-w-c" rowspan="3">用水量核定:</td>
			    <td colspan=2><textarea name="checkInfo" style="width:85%;"> 根据广西壮族自治区地方标准《城镇生活用水定额》(DB45/T 679-2010),和《南宁市用水定额》,进行核算如下:</textarea>
			    <td><div class="selectTree"  name="selectTree-3"   id="selectTree-3"  data='${treeData}' multiMode="true" keepDefaultStyle="true"></div><input type="button" value="获取选择结果" onclick="getValue();"/></td>
			    </td>
			  </tr>			  								

			  <tr>			   
			    <td colspan=3>
			    <table id="water">
			    			    
			    </table>

			    </td>
			  </tr>
			  <tr>			   
			    <td colspan=3>年度最大指标合计:<input type="text" value="0" name="total" id="total" datatype="n">m³</td>
			  </tr>					
			  <tr>
			    <td  align="left">拟同意</td>
			    <td>全年计划用水量增加至<input type="text" value=""  name="trueUp"></td>
			    <td style="width:1px"></td>
			     <td>第一季度<input type="text" value=""  name="true1">,第二季度<input type="text" value=""  name="true2">,第三季度<input type="text" value=""  name="true3">,第四季度<input type="text" value=""  name="true4">,</td>
			  </tr>	
			  			  
			  <tr>			   
			    <td>经办人意见</td><td colspan=3><textarea name="opinion" id="opinion" style="width:85%;"></textarea></td>
			  </tr>

				<input type="hidden" name="orgId" id="orgId" value='${busOrg.orgId!""}'/>
				<input type="hidden" name="processInstanceId"  value='${watercheck.processInstanceId!""}'/>
				<input type="hidden" name="status"value='${watercheck.status!""}'/>
			</table>
		</form>
	</div> 	
</div>
</body>
</html>