<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>私塾家</title>
<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
<script th:include="sys/common/metaJS" th:remove="tag"></script> 
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
<link rel="stylesheet" th:href="@{/static/sys/css/home.css}">
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
	.select_width{
	     width: 220px;
	}
	.date_width{
	     width: 150px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">库存管理</a></li>
		<li><a href="#">所有设备</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/fx/deviceAllList.html}" method="post">
	  <input type="hidden" name="reportType" id="reportType" />
	  
	   <ul class="seachform">
	  		<li style="width: 100%">
				<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;小塾编号</label>
				<input style="width: 50%" type="text" id="imei1" name="LIKE_deviceNumber" th:value="${search.get('LIKE_deviceNumber')}" class="scinput date_width " placeholder="小塾编号，支持多编号查询，空格分隔">
			</li>
		 
		</ul>
		
		<ul class="seachform">
		  	<li style="width: 100%">
				<label>实际小塾编号</label>
				<input style="width: 50%" type="text" id="imei1" name="LIKE_deviceRealNumber" th:value="${search.get('LIKE_deviceRealNumber')}" class="scinput date_width " placeholder="实际小塾编号，支持多编号查询，空格分隔">
			</li>
		</ul>
	  
	<ul class="seachform">
			<li>
				<label>IMEI号</label>
				<input type="text" id="imei1" name="LIKE_imei" th:value="${search.get('LIKE_imei')}" class="scinput date_width " placeholder="IMEI号">
			</li>
			
			<li>
				<label>ICCID编号</label>
				<input type="text" id="imei1" name="LIKE_deviceModel" th:value="${search.get('LIKE_deviceModel')}" class="scinput date_width " placeholder="ICCID编号">
			</li>
			
			<li>
				<label>SIM卡号</label>
				<input type="text" id="imei1" name="LIKE_deviceCode" th:value="${search.get('LIKE_deviceCode')}" class="scinput date_width " placeholder="SIM卡号">
			</li>
				
			<li>
			 <label>批次编号</label>
			  <input name="EQ_batchCode" type="text"  th:value="${search.get('EQ_batchCode')}" class="scinput date_width " placeholder="批次编号"/>
		    </li>
		    
		    <li>
			 <label>快递单号</label>
			  <input name="EQ_emsNumber" type="text"  th:value="${search.get('EQ_emsNumber')}" class="scinput date_width " placeholder="快递单号"/>
		    </li>
		    
		    <li>
			 <label>备注</label>
			  <input name="LIKE_remarks" type="text"  th:value="${search.get('LIKE_remarks')}" class="scinput date_width " placeholder="备注"/>
		    </li>

	</ul>
	
		<ul class="seachform">
		
			<li>
				<label>确认状态</label>
				<select class="scinput select_width"  name="EQ_status"   style="width: 150px;" >
					<option value="">全部</option>
					<option th:selected="${search.get('EQ_status') eq '1' ? true : false}" value="1">待收货(现商户)</option>
					<option th:selected="${search.get('EQ_status') eq '2' ? true : false}" value="2">已收货(现商户)</option>
					<option th:selected="${search.get('EQ_status') eq '3' ? true : false}" value="3">待收货(退回)</option>
					<option th:selected="${search.get('EQ_status') eq '4' ? true : false}" value="4">已收货(退回)</option>
					<option th:selected="${search.get('EQ_status') eq '5' ? true : false}" value="5">无效</option>
				</select>
			</li>
		
		     <li>
				<label>流通状态</label>
				<select class="scinput select_width"  name="EQ_type"   style="width: 150px;" >
					<option value="">全部</option>
					<option th:selected="${search.get('EQ_type') eq '1' ? true : false}" value="1">出售</option>
					<option th:selected="${search.get('EQ_type') eq '2' ? true : false}" value="2">租赁</option>
					<option th:selected="${search.get('EQ_type') eq '3' ? true : false}" value="3">损坏</option>
					<option th:selected="${search.get('EQ_type') eq '4' ? true : false}" value="4">留存</option>
				</select>
			</li>
		    
		     <li>
				<label>是否跨区</label>
				<select class="scinput select_width"  name="EQ_isSpan"   style="width: 150px;" >
					<option value="">全部</option>
					<option value="1"  th:selected="${search.get('EQ_isSpan') eq '1' ? true : false}">未跨</option>
					<option value="2"  th:selected="${search.get('EQ_isSpan') eq '2'  ? true : false}">已跨</option>
				</select>
			</li>
			
			<li>
				<label>所有商户</label>
				<select class="scinput select_width"  name="EQ_orgCode"   style="width: 150px;" >
					<option value="">全部</option>
					<option th:each="item:${poslist}"  th:selected="${search.get('EQ_orgCode') eq item.orgCode ? true : false}" th:value="${item.orgCode}">[[${item.unitName}]]</option>
				</select>
			</li>
			
			<li>
				<label>输出条数</label>
				<input name="pageSize" type="number" class="scinput" th:value="${page.pageSize}"/>
			</li>
			
		<li>
			<input type="button" class="scbtn" value="查询" />
		</li>

	</ul>
	</form>
	
	<ul class="seachform">
		
		<li>
			<input type="file" name="importdevice" id="importdevice" style="width: 150px" />
			<input type="button" class="scbtn" id="importdevicefile" value="导入设备" />
		</li>
		
		<li>
			 <a th:href="@{/static/sys/excel/importDeviceData.xlsx}" download="导入设备模板.xlsx">
				<input type="button" class="scbtn" value="下载模板" />
			</a>
			
		</li>
		
		<li>
			<input type="button" class="scbtn adddevice" value="添加购物车" />
		</li>
		
		<li>
			<input type="button" class="scbtn matchdevice" value="分配设备" />
		</li>
		
<!-- 		<li> -->
<!-- 			<input type="button" class="scbtn updatedevices" value="批量接收" /> -->
<!-- 		</li> -->
		
		<li>
			<input type="button" id="button" class="scbtn" value="导出设备" />
		</li>
	</ul>
	

	

	<table class="tablelist">
		<thead>
		    <tr>
				<th style="width: 50px;"><input id="basecheckbox"  type="checkbox"></th>
				<th>imei号</th>
				<th>实际小塾编号</th>
				<th>小塾编号</th>
				<th>ICCID编号</th>
				<th>SIM卡号</th>
		        <th>现商户</th>
		        <th>现商户名称</th>
		        <th>现状态</th>
		    	<th>设备名称</th>
<!--  		    	<th>小塾编号</th> -->
		        <th>设备颜色</th>
<!-- 		        <th>设备SN</th> -->
		     <!--   <th>是否跨区</th>-->
		        <th>批次编号</th>
		        <th>快递单号</th>
		        <th>流通类型</th>
		        <th>更变时间</th> 
		        <th>备注</th> 
		        <th>操作</th> 
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
					<td ><input type="checkbox" name="imeicheckbox" class="imeicheckbox"  th:data-imei="${item.imei}" th:value="${item.id}"></td>
					<td th:text="${item.imei}"></td>
					<td th:text="${item.deviceRealNumber}"></td>
					<td th:text="${item.deviceNumber}"></td>

					<td th:text="${item.deviceModel}"></td>
					<td th:text="${item.deviceCode}"></td>
					
					<td th:text="${item.posCode}"></td>
					<td th:text="${item.merchant.unitName}"></td>
					<td  th:switch="${item.status}">
					   <span th:case="1">待收货(现商户)</span>
					   <span th:case="2">已收货(现商户) </span>
					   <span th:case="3" style="color: red">待收货(退回)</span>
					   <span th:case="4" style="color: red">已收货(退回)</span>
					   <span th:case="5">无效</span>
					</td>
					<td th:text="${item.deviceName}"></td>
<!--  					<td th:text="${item.deviceNumber}"></td> -->
					
					<td th:text="${item.deviceColor}"></td>
					
<!-- 					<td th:text="${item.deviceSn}"></td> -->
					
					<!--<td  th:switch="${item.isSpan}">
					   <span th:case="1">无</span>
					   <span th:case="2" style="color:  red;">已跨</span>  
					</td>-->
					<td th:text="${item.batchCode}"></td>
					<td th:text="${item.emsNumber}"></td>
					<td style="color: red" th:switch="${item.type}">
					   <span th:case="1">出售</span>
					   <span th:case="2">租赁 </span>
					   <span th:case="3">损坏</span>
					   <span th:case="4">留存 </span>
					</td>
					<td th:text="${#calendars.format(item.updateTime,'yyyy-MM-dd HH:mm')}" ></td>  
					<td th:text="${item.remarks}"></td>
					<td>   
						<a href="javascript:;"  th:onclick="'updatedevice(\''+${item.id}+'\',\'5\')'"   class="tablelink">删除</a>
						<a href="javascript:;"  th:onclick="'editdevice(\''+${item.id}+'\')'"  	class="tablelink">修改</a>
					 </td>  
					
			</tr>
		</tbody>
	</table>
	
	
	
	<div id="lowermerchants" style="display: none; width: 100%;height: 100%;" >
		<div id="imeis" style="margin-left:23px;font-size:10pt;line-height: 34px;color: red"></div>
		<div style="width: 100%;margin-bottom: 10px">
			<ul class="forminfo">
				<li style="margin-bottom:3px">
					<label>快递单号：<b></b></label>
					<input type="text" id="match_emsnumber" class="dfinput fl"/>
				</li>
				<li style="margin-bottom:3px">
					<label>快递地址：<b></b></label>
					<input type="text" id="match_emsaddress" class="dfinput fl"  />
				</li>
				<li style="margin-bottom:3px">
					<label>联系人：<b></b></label>
					<input type="text" id="match_emsusername" class="dfinput fl"  />
				</li>
				<li style="margin-bottom:3px">
					<label>联系号码：<b></b></label>
					<input type="text" id="match_emstelephone" class="dfinput fl"  />
				</li>
				<li style="margin-bottom:3px">
					<label>上传递单：<b></b></label>
					<input type="hidden" id="match_emsimg" data-path="" />
					<plug id="pluguploadid" th:include="sys/common/imgUpload"  th:inline="javascript"  data-bindelem="#match_emsimg" data-filepaths=""  data-type="1" data-maxnum="10"  />
				</li>
			</ul>
		</div>
		<table class="tablelist" style="width:95%;margin-left: 5px">
			<thead>
			    <tr>
			        <th style="width: 100px;">勾选</th>
			        <th>商户账号</th>
			        <th>商户名称</th>
			    </tr>
			</thead>
			<tbody id="lmlist">
				<tr  th:each="item:${poslist}" >
					<td><input type="radio" th:value="${item.posCode}" calss="imeiradio" name="lm" ></td>
					<td th:text="${item.posCode}" ></td>
					<td th:text="${item.unitName}" ></td>
				</tr>
			</tbody>
		</table>
		
		
		<div style="text-align: right;margin-top: 10px;margin-right: 50px;margin-bottom: 100px">
			<input type="button" class="scbtn savematchdevice" value="确定分配" />
		</div>
	</div>


	<!-- 分页 -->
	<div class="pagin">
    	<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录，当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
    	<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
   	</div>
</div>







<div class="global_toolbar">
		<div class="toolbar_btn center" style="top: 50%; margin-top: -150px;">

			<a id="needtohelp_0_shoppingCart" class="bar_cart " data-id="global_toolbar">
				<samp>
					<i class="iconi icon-LiveChat1">
						<img th:src="@{/static/sys/images/icon/car-1.png}" alt="">
					</i>
				</samp>
				<em>
					<i>购物车</i>
				</em>
				<span style="display: block;" class="lmliCount">0</span>
			</a>
		
		
		</div>
		
		
		<div class="toolbar_content" >
			<div class="css_column cart_column js_column" id="shop_cart"  style="overflow-y: scroll;" >
				<h4>
					购物车<a href="javascript:void(0)" class="icon-close " >X</a>
				</h4>
				<div id="resultData">
					<ul style="height: auto;" id="lsImeis">
							
		
					</ul>
				</div>
				<div class="count_info clearfix">
					<label style="width: 50%">
						<span class="text">购物车数量：</span>
						<span class="lmliCount text"></span>
					</label>
				</div>
				
				<div class="shop_function_btn clearfix" style="margin-bottom: 100px">
					<span style="cursor: pointer;" class="more redbtn-moddle1 " id="btn_popup">
						<span>确定分配</span>
					</span>
					<span style="background-color: #ccc;cursor: pointer;" class="go_btn more redbtn-moddle1 redbtn-moddle1-clear">
						<span>一键清空</span>
					</span>
				</div>
			</div>
		</div>
	</div>

</body>


<script src="sys/js/common.js" th:src="@{/static/js/common_math.js}"></script>
<script type="text/javascript">
	var username="[[${#httpSession.getAttribute('admin')!=null ? #httpSession.getAttribute('admin').nickName : ''}]]";
	var lsName="imeiCart_"+username;

	function checkStorageSupport(){    
	    if(window.sessionStorage){          
	        console.log("浏览器支持sessionStorage特性！");    
	   	}else{          
	        console.log("浏览器不支持sessionStorage特性！");    
	        alert("浏览器不支持sessionStorage特性！,建议使用谷歌浏览器。");
	   	}    
	   	if(window.localStorage){        
	        console.log("浏览器支持localStorage特性！");         
	  	}else{  
	        console.log("浏览器不支持localStorage特性！"); 
	        alert("浏览器不支持localStorage特性！,建议使用谷歌浏览器。");
	  	}
	}
	window.addEventListener("load",checkStorageSupport,false);
	

	function saveLocalStorage(imeis){
		var num=0;
		var lsImeis=[];
		if(localStorage.getItem(lsName)!=null && localStorage.getItem(lsName)!='' && localStorage.getItem(lsName)!=undefined){
			lsImeis=localStorage.getItem(lsName).split(",");
		}
		for (var i = 0; i < imeis.length; i++) {
			if(getLocalStorage(imeis[i])==null){
				lsImeis.push(imeis[i]);
				num=num+1;
			}
		}
		parent.layer.msg("添加购物车成功",{icon:6});
		localStorage.setItem(lsName,lsImeis); 
		return true;
	}
	
	function removeLocalStorage(imei){
		var lsImeis=[];
		if(localStorage.getItem(lsName)!=null && localStorage.getItem(lsName)!='' && localStorage.getItem(lsName)!=undefined){
			lsImeis=localStorage.getItem(lsName).split(",");
		}
		for (var i = 0; i < lsImeis.length; i++) {
			if(lsImeis[i]==imei){
				lsImeis.splice(i,1);
			}
		}
		localStorage.setItem(lsName,lsImeis); 
		return true;
	}
	
	
	function getLocalStorage(imei){
		var lsImeis=[];
		if(localStorage.getItem(lsName)!=null && localStorage.getItem(lsName)!='' && localStorage.getItem(lsName)!=undefined){
			lsImeis=localStorage.getItem(lsName).split(",");
		}
		for (var i = 0; i < lsImeis.length; i++) {
			if(lsImeis[i]==imei){
				return lsImeis[i];
			}
		}
		return null;
	}
	
	
	function findLocalStorage(){
		var lsImeis=[];
		if(localStorage.getItem(lsName)!=null && localStorage.getItem(lsName)!='' && localStorage.getItem(lsName)!=undefined){
			lsImeis=localStorage.getItem(lsName).split(",");
		}
		return lsImeis;
	}
	
	
	function sizeLocalStorage(){
		var lsImeis=[];
		if(localStorage.getItem(lsName)!=null && localStorage.getItem(lsName)!='' && localStorage.getItem(lsName)!=undefined){
			lsImeis=localStorage.getItem(lsName).split(",");
		}
		return lsImeis.length;
	}
	
	function clearLocalStorage(){
		localStorage.setItem(lsName,[]); 
	}
	
	

</script>
<script type="text/javascript">
	$(function (){
		refreshImeiCartHtml();
	})
	
	function refreshImeiCartHtml(){
		$(".lmliCount").html(sizeLocalStorage());
		var html=[];
		var lsImeis=findLocalStorage();
		for (var i = 0; i < lsImeis.length; i++) {
			html.push(' <li class="clearfix" > ');
				html.push(' <span style="float: left;" title="'+lsImeis[i]+'">'+lsImeis[i]+'</span> ');
				html.push(' <span style="float: right;cursor: pointer;color:red" onclick="deletedevice(this)" data-imei="'+lsImeis[i]+'" >删除</span> ');
			html.push(' </li> ');
		}
		$("#lsImeis").html(html.join(''));
	}

	$(".adddevice").click(function () {
		var imeis=[];
		$(".imeicheckbox[type=checkbox]").each(function(){
			if($(this).is(':checked')){
				imeis.push($(this).val()); 
			}
		}); 
		saveLocalStorage(imeis);
		refreshImeiCartHtml();
	});

	$(".redbtn-moddle1-clear").click(function () {
		parent.layer.confirm("您确定需要一键清空购物车？", {
			icon: 4, btn: ['确定','取消']
		}, function(){
			clearLocalStorage();
			refreshImeiCartHtml();
			parent.layer.closeAll();
		});
	});
	
	function deletedevice(obj) {
		var imei=$(obj).data("imei");
		removeLocalStorage(imei);
		refreshImeiCartHtml();
	};
	
	$("#btn_popup").click(function () {
		var imeis=findLocalStorage();
		if(imeis.length<=0){
			parent.layer.msg("请选择分配设备",{icon:2});
			return;
		}
		$("#imeis").html("已选设备数量："+imeis.length);
		$("#match_type").val(1);
        layer.open({
            type: 1,
            title: '分配设备',
            shadeClose: false,
            shade: 0.8,
            area: ['50%', '60%'],
            offset: '100px',
            content: $("#lowermerchants")
        });
	});
	

</script>



<script type="text/javascript">
	$(function (){
		
		 $('#match_emsimg').change(function(){
		   	if($(this).val() != ""){
		   		uploadFile('match_emsimg');
		     }
		 })
		
		
		//上传文件方法封装
		function uploadFile(ele){
			var formData = new FormData();
			var files = $('#'+ele)[0].files;
		    for(var i = 0;i < files.length;i++){
		    	var name = files[i].name;              
		        var file = files[i];
		        formData.append("file" + i, file);
		        formData.append("name" + i, name);
		    }
		                                                
		    $.ajax({
		        url: "[[${sysUrl}]]/file/uploads",
		        type: 'POST',
		        data: formData,
		        processData: false,    // ⑧告诉jQuery不要去处理发送的数据
		        contentType: false,    // ⑨告诉jQuery不要去设置Content-Type请求头
		        success: function (data) { 
		        	$('#'+ele).data("path",data.data.pics[0].filePath);
		        	$('#'+ele+"_src").attr("src",data.data.pics[0].fileThumPath);
		            layer.msg("上传成功啦！",{icon:6});
		        },
		        error : function (data) {
		        	layer.msg("上传失败啦，请检查！",{icon:5});
		        }
		    });
		}
		
		$("#basecheckbox").bind("click",function(){
	        if($("#basecheckbox").is(':checked')){
	           $("[name='imeicheckbox']").prop("checked",true);
	        }
	        if(!$("#basecheckbox").is(':checked')){
	           $("[name='imeicheckbox']").removeAttr("checked");
	        }
	    });
		
		$(".matchdevice").click(function () {
			var imeis=[];
			$(".imeicheckbox[type=checkbox]").each(function(){
				if($(this).is(':checked')){
					imeis.push($(this).val()); 
				}
			}); 
			if(imeis.length<=0){
				parent.layer.msg("请选择分配设备",{icon:2});
				return;
			}
			$("#imeis").html("已选设备数量："+imeis.length);
			$("#match_type").val(0);
	        layer.open({
	            type: 1,
	            title: '分配设备',
	            shadeClose: false,
	            shade: 0.8,
	            area: ['50%', '60%'],
	            offset: '100px',
	            content: $("#lowermerchants")
	        });
		});
		
		
		$(".updatedevices").click(function () {
			var ids=[];
			$(".imeicheckbox[type=checkbox]").each(function(){
				if($(this).is(':checked')){
					ids.push($(this).val()); 
				}
			}); 
			if(ids.length<=0){
				alert("请选择收货设备")
				return;
			}
			updatedevice(ids.join(';'),2);
		});
		
		
		$(".returndevices").click(function () {
			var ids=[];
			$(".imeicheckbox[type=checkbox]").each(function(){
				if($(this).is(':checked')){
					ids.push($(this).val()); 
				}
			}); 
			if(ids.length<=0){
				alert("请选择退回设备")
				return;
			}
			returndevice(ids.join(';'),1);
			
		});

		$(".savematchdevice").click(function () {
			var imeis=[];
			if($("#match_type").val()!=1){
				$(".imeicheckbox[type=checkbox]").each(function(){
					if($(this).is(':checked')){
						imeis.push($(this).val()); 
					}
				}); 
			}else{
				imeis=findLocalStorage();
			}
			var poscode=$(".imeiradio,input[type='radio']:checked").val();
			if(poscode==undefined){
				parent.layer.msg("请选择分配商户",{icon:2});
				return;
			}
			if($("#match_emsimg").val()==''){
				parent.layer.msg("请上传快递单",{icon:2});
				return;
			}	
			parent.layer.msg("数据分配中....，请勿刷新。",{icon:3});
			$.ajax({
				url : "[[${sysUrl}]]/sys/fx/matchDevice",
				type : "post",
				data : {ids:imeis.join(";"),
					poscode:poscode,
					emsNumber:$("#match_emsnumber").val(),
					emsAddress:$("#match_emsaddress").val(),
					emsUsername:$("#match_emsusername").val(),
					emsTelephone:$("#match_emstelephone").val(),
					emsImg:$("#match_emsimg").val()
					},
				dataType : "json",
				success : function(data) {
					if(data.meta.success){
						if($("#match_type").val()==1){
							clearLocalStorage();
							refreshImeiCartHtml();
						}
						parent.layer.msg("分配成功",{icon:1});
				    	setTimeout(function(){
				    		location.reload();
						},500);
					}else{
						alert("分配异常，请刷新后重试...")
					}
					$("#match_type").val(0);
				}
			});
		});
		
	})
	

	function editdevice(id){
		layer.open({
		    type: 2,
		    title: '编辑设备',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['50%', '80%'],
		    content: '[[${sysUrl}]]/sys/fx/deviceEdit.html?id='+id
		});
	}
	
	function savedevice(id){
		layer.open({
		    type: 2,
		    title: '编辑设备',
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    area: ['50%', '80%'],
		    offset: '100px',
		    content: '[[${sysUrl}]]/sys/fx/deviceAdd.html'
		});
	}


	function returndevice(id,status){  
		$.ajax({
			url : "[[${sysUrl}]]/sys/fx/returnDevice",
			type : "post",
			data : {id:id,status:status},
			dataType : "json",
			success : function(data) {
				if(data.meta.success){
					parent.layer.msg("操作成功",{icon:1});
			    	setTimeout(function(){
			    		location.reload();
					},500);
				}else{
					alert("操作异常，请刷新后重试...")
				}
			}
		});
	}
	
	function updatedevice(id,status){  
		if(status==5){
			parent.layer.confirm("确定操作删除？", {
				icon: 4, btn: ['确定','关闭'] //按钮
			}, function(){
				$.ajax({
					url : "[[${sysUrl}]]/sys/fx/updateDevice",
					type : "post",
					data : {id:id,status:status},
					dataType : "json",
					success : function(data) {
						if(data.meta.success){
							parent.layer.msg("操作成功",{icon:1});
					    	setTimeout(function(){
					    		location.reload();
							},500);
						}else{
							alert("操作异常，请刷新后重试...")
						}
					}
				});
			});
		}else{
			
			$.ajax({
				url : "[[${sysUrl}]]/sys/fx/updateDevice",
				type : "post",
				data : {id:id,status:status},
				dataType : "json",
				success : function(data) {
					if(data.meta.success){
						parent.layer.msg("操作成功",{icon:1});
				    	setTimeout(function(){
				    		location.reload();
						},500);
					}else{
						alert("操作异常，请刷新后重试...")
					}
				}
			});
			
		}
	}
	
	
    $("#importdevicefile").click(function () {
        var formData = new FormData();
        formData
        .append("importdevice", document.getElementById("importdevice").files[0]);  
        
        $.ajax({
        	url: "[[${sysUrl}]]/sys/fx/importDeviceData",
            type: "POST",
            data: formData,
            /**
            *必须false才会自动加上正确的Content-Type
            */
            contentType: false,
            /**
            * 必须false才会避开jQuery对 formdata 的默认处理
            * XMLHttpRequest会对 formdata 进行正确的处理
            */
            processData: false,
            success: function (data) {
                if (data.status == "success") {
                	parent.layer.msg("上传成功",{icon:1});
			    	setTimeout(function(){
			    		location.reload();
					},500);
                }else {
                    alert(data.msg);
                }
            },
            error: function () {
                alert("上传失败,请刷新后重试。");
            }
        });
    });

</script>

<script type="text/javascript">
$("#button").on('click',function(){
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/fx/exportDevice";
	$("#seachform").submit();
	document.getElementById("seachform").action = "[[${sysUrl}]]/sys/fx/deviceAllList.html";
});
</script>

</html>