<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE html>
<html>
<head lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
 	<%@include file="../../../../frame/assets/header-all.jsp"%>
 	<script type="text/javascript" src="../../js/jquery.form.js"></script>
	<style>
	.form-line .text-content{
		width:120px;
	}
	.form{
		    display: block;
		    float: left;
		    height: 28px;
		    line-height: 28px;
		    font-size: 12px;
		    width: 275px;
		    text-align: right;
	}
	</style>
</head>
<body class="easyui-layout">
<form id="childform" class="easyui-form" data-options="novalidate:true">
	<input id="xh" type="hidden" />
	<div class="form-line clearfix" >
		<div class="fl">
			<span class="text-content"><em class="must">*</em>巡查单名称：</span> 
			<input id="xcdmc" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="巡查单名称必填项" > 
		</div> 
<!-- 		<div class="fl">
			<span class="text-content"><em class="must"></em>服务商编号：</span> 
			<input id="fwsbh" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="服务商编号必填项" > 
		</div>  -->
		<div class="fl">
			<span class="text-content"><em class="must">*</em>服务商名称：</span> 
			<input id="fwsmc" class="easyui-combobox" data-options="valueField:'id', textField:'text',panelHeight:'auto'" missingMessage="服务商名称必填项" > 
		</div> 
	</div>
	<div class="form-line clearfix">
		<!-- <div class="fl">
			<span class="text-content"><em class="must"></em>服务商全称：</span> 
			<input id="fwsqc" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="服务商全称必填项" > 
		</div> --> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>巡查人：</span> 
			<input id="xcr" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="巡查人必填项" > 
		</div> 
		<!-- <div class="fl">
			<span class="text-content"><em class="must"></em>巡查区域：</span> 
			<input id="xcqy" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="巡查区域必填项" > 
		</div> -->
		<div class="fl">
			<span class="text-content"><em class="must"></em>巡查地点：</span> 
			<input id="xcdd" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="巡查地点必填项" > 
		</div> 
	</div>
	<!-- <div class="form-line clearfix">
		 
		
		<div class="fl">
			<span class="text-content"><em class="must"></em>巡查位置经度：</span> 
			<input id="xcwzjd" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="巡查位置经度必填项" > 
		</div>
	</div>
	<div class="form-line clearfix">
		 
		<div class="fl">
			<span class="text-content"><em class="must"></em>巡查位置维度：</span> 
			<input id="xcwzwd" class="easyui-textbox" data-options="required:false,validType:'length[0,40]'" missingMessage="巡查位置维度必填项" > 
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>巡查时间：</span> 
			<input id="xcsj" class="easyui-datetimebox" data-options="required:false,validType:'length[0,40]'" missingMessage="巡查时间必填项" > 
				
		</div> 
	</div> -->
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content"><em class="must"></em>巡查内容：</span> 
			<input id="xcnr" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="巡查内容必填项" > 
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must"></em>巡查结果：</span> 
			<input id="xcjg" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="巡查结果必填项" > 
		</div> 
	</div>
	<div class="form-line clearfix"  >
		<div class="fl">
			<span class="text-content"><em class="must"></em>巡查图片1：</span> 
			<input disabled id="xctp1" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="巡查图片1必填项" >
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must"></em>巡查图片2：</span> 
			<input disabled id="xctp2" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="巡查图片2必填项" > 
		</div>
	</div>
	<div class="form-line clearfix">
		<div class="fl" >
			<span class="text-content"><em class="must"></em>巡查视频：</span> 
			<input disabled id="xcsp" class="easyui-textbox" data-options="required:false,validType:'length[0,128]'" missingMessage="巡查视频必填项" >
		</div> 
		<div class="fl">
			<span class="text-content"><em class="must">*</em>巡查时间：</span> 
			<input id="xcsj" class="easyui-datetimebox" data-options="required:false,validType:'length[0,40]'" missingMessage="巡查时间必填项" > 
		</div>
	</div>
	<div class="form-line clearfix">
		<div class="fl">
			<span class="text-content"><em class="must"></em>备注：</span> 
			<input id="bz" class="easyui-textbox" data-options="required:false,validType:'length[0,80]'" missingMessage="备注必填项" > 
		</div>
	</div>
	<div class="form-line hidden">
		 
	</div>
</form>
<div>
<div class="form-line clearfix">
	<div class="fl">
		<span class="text-content"><em class="must"></em>巡查图片1：</span> 
		<form id="uploadForm1" class="form" action="" method="post" enctype="multipart/form-data">
		    <input type="file" name="myFile" multiple />
		    <input type="button" id="submitPic1" value="上传"/>
		</form>
		<span id="uploadResultPic1" style="color:blue" class="text-content"></span> 
	</div> 
</div>
<div class="form-line clearfix">
	<div class="fl">
		<span class="text-content"><em class="must"></em>巡查图片2：</span> 
		<form id="uploadForm2" class="form" action="" method="post" enctype="multipart/form-data">
		    <input type="file" name="myFile" multiple />
		    <input type="button" id="submitPic2" value="上传"/>
		</form>
		<span id="uploadResultPic2" style="color:blue" class="text-content"></span> 
	</div>
</div>
<div class="form-line clearfix">
	<div class="fl">
		<span class="text-content"><em class="must"></em>巡查视频：</span> 
		<form id="uploadFormVideo" class="form" action="" method="post" enctype="multipart/form-data">
		    <input type="file" name="myFile" id="xxxxx"  multiple />
		    <input type="button" id="submitVideo" value="上传"/>
		</form>
		<span id="uploadResultVideo" class="text-content" style="color:blue"></span> 
	</div> 
</div>
</div>
</body>
</html>
<script type="text/javascript">
var winId	= $.getUrlParam("winId");
var records = top.$("#"+winId).panel("options").data;
$(function(){
	//加载下拉选项
	setTimeout(loadValue,500);
});
function loadValue(){
	//加载下拉框
	$.ajax({
		url:"nhywgysxxAction!listNhywgysxxByPage.do",
		type:"post",
		dataType:"JSON",
		async:false,
		data : {"page":1,"rows":1000,"gyslb":"1","order":" order by cjrq desc "},
		success:function(res){
			if(res && res.rows.length>0){
				var rows = res.rows;
				var fwsArr = [{"id":rows[0].xh+"-"+rows[0].gysjc+"-"+rows[0].gysmc,"text":rows[0].gysmc,"selected":true}];
				for(var i=1;i<rows.length;i++){
					fwsArr.push({"id":rows[i].xh+"-"+rows[i].gysjc+"-"+rows[i].gysmc,"text":rows[i].gysmc})
				}
				$("#fwsmc").combobox("loadData",fwsArr);
			}
		}
	});
	if(records){
		console.log(records)
		$("#xh").val(records.xh);
		//$("#fwsbh").textbox("setValue",records.fwsbh);
		$("#xcdmc").textbox("setValue",records.xcdmc);
		$("#fwsmc").combobox("setValue",records.fwsbh+"-"+records.fwsmc+"-"+records.fwsqc);
		//$("#fwsqc").textbox("setValue",records.fwsqc);
		$("#xcr").textbox("setValue",records.xcr);
		$("#xcqy").textbox("setValue",records.xcqy);
		$("#xcdd").textbox("setValue",records.xcdd);
		$("#xcwzjd").textbox("setValue",records.xcwzjd);
		$("#xcwzwd").textbox("setValue",records.xcwzwd);
		$("#xcsj").datetimebox("setValue",records.xcsj);
		$("#xcnr").textbox("setValue",records.xcnr);
		$("#xcjg").textbox("setValue",records.xcjg);
		$("#xctp1").textbox("setValue",records.xctp1);
		$("#xctp2").textbox("setValue",records.xctp2);
		$("#xcsp").textbox("setValue",records.xcsp);
		//$("#xcpjxj").textbox("setValue",records.xcpjxj);
		//$("#xcpjnr").textbox("setValue",records.xcpjnr);
		//$("#xcpjr").textbox("setValue",records.xcpjr);
		//$("#xcpjdw").textbox("setValue",records.xcpjdw);
		//$("#xcpjsj").textbox("setValue",records.xcpjsj);
		//$("#cjry").textbox("setValue",records.cjry);
		//$("#cjrq").textbox("setValue",records.cjrq);
		//$("#xgry").textbox("setValue",records.xgry);
		//$("#xgrq").textbox("setValue",records.xgrq);
		$("#bz").textbox("setValue",records.bz);
		//$("#kz1").textbox("setValue",records.kz1);
		//$("#kz2").textbox("setValue",records.kz2);
		//$("#kz3").textbox("setValue",records.kz3);
		//$("#kz4").textbox("setValue",records.kz4);

	}else{
		$("#xcsj").datetimebox("setValue",getCurrtentTime());
	}
}
/*
var xx1 = $("#xx1").textbox("getValue");//文本
var xx2 = $("#xx2").combobox("getValue");//下拉
var xx3 = $("#xx3").datetimebox("getValue");//日期
var xx4 = $("#xx4").numberbox("getValue");//数字
$('#xx5').combobox({  
	url:'xtclAction!select_Xtcl.do?csdl=xx5&page=1&rows=1000', 
	textField:"csmc",  
	valueField:"csdm",
	panelWidth:148,
	loadFilter:function(data){
		//data.unshift({"csmc":"选择","csdm":""});
		return data;
	}
});
$("#xx6").textbox("setValue",records.xx6);
$("#xx7").combobox("setValue",records.xx7);
$("#xx8").combobox("setValue",records.xx8);
$("#xx9").datetimebox("setValue",$.getNowTime());
$("#xx10").datetimebox("setValue",$.getTodayStart('00:00:00',-3));//往前推3天  +'00:00:00'
$("#xx11").datetimebox("setValue",$.getTodayEnd());//当天 +'23:59:59'	
$("#xx12").datetimebox("setValue",$.getDateNumToStr(records.xx12));
$("#xx13").numberbox("setValue",records.xx13);
*/
function getCurrtentTime(){
	var date = new Date();
	var year = date.getFullYear();
	var month = date.getMonth()+1;
	var day = date.getDate();
	var hour = date.getHours();
	var minute = date.getMinutes();
	var second = date.getSeconds();
	if(month<10){
		month = "0"+month;
	}
	if(day<10){
		day = "0"+day;
	}
	if(hour<10){
		hour = "0"+hour;
	}
	if(minute<10){
		minute = "0"+minute;
	}
	if(second<10){
		second = "0"+second;
	}
	//console.log(year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second);
	return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second; 
}
$("#submitPic1").on('click',function(){
	$.ajax({  
	    url : "uploadPictureAction!uploadPicture.do",  
	    type : "POST",  
	    data : new FormData($('#uploadForm1')[0]),//$( '#uploadForm1').serialize(),    //表单序列化 ,【注意】上传文件的文件流是无法被序列化并传递的
	    processData:false,   //  告诉jquery不要处理发送的数据
	    contentType:false,    // 告诉jquery不要设置content-Type请求头     
	    success : function(data) {  
			if(data && data!="error"){
				$.showMsg("上传成功");
				$("#xctp1").textbox("setValue",data);
				$("#uploadResultPic1").text("上传成功");
			}else{
				$.showMsg("上传失败");
				$("#uploadResultPic1").text("上传失败");
			}
			//$("#uploadForm1").resetForm();
	    }
	}); 
	/* $("#uploadForm1").ajaxSubmit({
		type: 'post', // 提交方式 get/post
        url: 'uploadPictureAction', // 需要提交的 url
         data: {
            'title': title,
            'content': content
        }, 
        success: function(data) { // data 保存提交后返回的数据，一般为 json 数据
            // 此处可对 data 作相关处理
            alert('提交成功！');
        }
       // $(this).resetForm(); // 提交后重置表单
	}) ; */
	
});
$("#submitPic2").on('click',function(){
	$.ajax({  
	    url : "uploadPictureAction!uploadPicture.do",  
	    type : "POST",  
	    data : new FormData($('#uploadForm2')[0]),//$( '#uploadForm1').serialize(),    //表单序列化 ,【注意】上传文件的文件流是无法被序列化并传递的
	    processData:false,   //  告诉jquery不要处理发送的数据
	    contentType:false,    // 告诉jquery不要设置content-Type请求头     
	    success : function(data) {  
			if(data && data!="error"){
				$.showMsg("上传成功");
				$("#xctp2").textbox("setValue",data);
				$("#uploadResultPic2").text("上传成功");
			}else{
				$.showMsg("上传失败");
				$("#uploadResultPic2").text("上传失败");
			}
			//$("#uploadForm2").resetForm();
	    }
	}); 
});
$("#submitVideo").on('click',function(){
	$.ajax({  
	    url : "uploadPictureAction!uploadPicture.do",  
	    type : "POST",  
	    data : new FormData($('#uploadFormVideo')[0]),//$( '#uploadForm1').serialize(),    //表单序列化 ,【注意】上传文件的文件流是无法被序列化并传递的
	    processData:false,   //  告诉jquery不要处理发送的数据
	    contentType:false,    // 告诉jquery不要设置content-Type请求头     
	    success : function(data) {  
			if(data && data!="error"){
				$.showMsg("上传成功");
				$("#xcsp").textbox("setValue",data);
				$("#uploadResultVideo").text("上传成功");
			}else{
				$.showMsg("上传失败");
				$("#uploadResultVideo").text("上传失败");
			}
			//$("#uploadFormVideo").resetForm();
	    }
	}); 
	
});
$("#xxxxx").on("change", function () {
    console.log($("#xxxxx"))
});
</script>
