/**
 * create by robot 
 * date Wed Sep 25 17:39:35 CST 2019 
 */ 

var pageIndex=1;
$(document).ready(function(){
	//调用查询
	pageIndex=StringUtil.getQueryString('pageIndex');
	if(pageIndex==undefined||pageIndex==null){
		pageIndex=1;
	}
	queryMerchantOrder(pageIndex);
	//绑定hover操作
	$(document).on('mouseenter','.listOperaters',function(){
		$(this).children(".ops_itemDiv").show();
		var width=15;
		$(this).children('div').find('li').each(function(){
			//获取li宽度
			width+=$(this).width();
		});
		$(this).children('div').width(width);
	})
	$(document).on('mouseleave','.listOperaters',function(){
		$(this).children(".ops_itemDiv").hide();
	});

	//日历控件
	layui.use(['layer', 'laydate'], function() {
		var layer = layui.layer;
		laydate = layui.laydate;
		laydate.render({
		elem: '#date1' //指定元素
		});
		laydate.render({
			elem: '#date2' //指定元素
		});
	});


	//行选中事件
	$("#allCheck").find("span").click(function() {
		$(this).toggleClass('checked');
		if($(this).hasClass('checked')){
			//所有列选中
		  $(".checker").find("span").each(function () {
		         $(this).addClass("checked");
		    })
		}else{
			//所有列取消选中
			$(".checker").find("span").each(function () {
				 $(this).removeClass("checked");
		    })
		}
	});

	//单个选中
	$(document).on('click','.checkeBox span',function() {
		$(this).toggleClass('checked');
		//设置头部事件
		var length=$('.checkeBox span').length;
		var count=0;
		$(".checkeBox").find("span").each(function () {
	        if($(this).hasClass("checked")){
	        	count++;
	        }
	   })
		//全选
	   if(count==length){
		   $("#allCheck").find("span").addClass('checked');
	   }else{
		   $("#allCheck").find("span").removeClass('checked');
	   }
	})
	//左右div高度相等
	var left_content_height = $(".right-content").height();
	$(".left-content").height(left_content_height+35);
	var sub_left_height=$(".res-menu").height(left_content_height-60);
});

//查询
function queryMerchantOrder(index){
	if(typeof(index)=='undefined'){
		index=1;
	}
	var url=ctx+'/merchantOrder/querySummaryOfWater';
	$.ajax({  
        url:url,  
        type:"post",
        dataType:"json",  
        data:{ 
        	"merchantCode":$("#merchantCode").val(),
        	"payTypeCodeList":$("#payTypeCodeList").ySelectedValues(","),
        	"staffCodeList":$("#staffCodeList").ySelectedValues(","),
        	"storeIdList":$("#storeIdList").ySelectedValues(","),
        	"timeStatus":$("#timeStatus").val(),
        },  
        success:function(result){  
        	//渲染数据
        	$('#data_content').empty();
        	var header='';
        	var summaryOfWater=result.summaryOfWaterVO;
        	var data='';
        	data+='<tr class="odd">';
    		data+='<td class="textc">'+summaryOfWater.dealCount+'</td>';
    		data+='<td class="textc">'+summaryOfWater.dealSum+'</td>';
    		data+='<td class="textc">'+summaryOfWater.refundCount+'</td>';
    		data+='<td class="textc">'+summaryOfWater.netRefund+'</td>';
    		/*data+='<td class="textc">';
    		data+='<div class="positionr listOperaters">';
    		data+='		<a href="javascript:void(0);"  class="icon-large dlblock w16 h16"><img src="'+resourcePath+'/images/angle-down.png"/></a>';
    		data+='		<div class="ops_box ops_itemDiv positiona clearfix whitebg">';
    		data+='			<ul>';
    		data+='				<li class="fl ml2 mr2"><a href="javascript:void(0);" onclick="showMemberOrderDetails('+memberOrder.id+')" class="btn btn-primary fa fa-edit ops_more f12">编辑</a></li>';
    		data+='				<li class="fl ml2 mr2"><a href="javascript:void(0);" onclick="initDeleteMemberOrder('+memberOrder.id+')" class="btn btn-primary fa fa-remove ops_more f12">删除</a></li>';
    		data+='				<li class="fl ml2 mr2"><a href="javascript:void(0);" onclick="showMemberOrderDetails('+memberOrder.id+')" class="btn btn-primary fa fa-detail ops_more f12">明细</a></li>';
    	    data+='			</ul>';
          data+='		</div>';
    	    data+='</div>';
    	    data+='</td>';*/
    	    data+='</tr>';
    	    $('#data_content').append(data);
        	
        	/*$.each(result.summaryOfWater,function(i){
        		var memberOrder=result.memberOrderList[i];
        		var data='';
        		data+='<tr class="odd">';
        		data+='<td class="textc">';
				data+='		 <div class="checker checkeBox">';        		data+='		 <span class=""  data-id="'+memberOrder.id+'"><input type="checkbox"  value=""></span>';
        		data+='		</div>';
        		data+='</td>';
        		data+='<td class="textc">'+memberOrder.id+'</td>';
        		data+='<td class="textc">'+memberOrder.merchantCode+'</td>';
        		data+='<td class="textc">'+memberOrder.merchantName+'</td>';
        		data+='<td class="textc">'+memberOrder.storeId+'</td>';
        		data+='<td class="textc">'+memberOrder.storeName+'</td>';
        		data+='<td class="textc">'+memberOrder.memberCode+'</td>';
        		data+='<td class="textc">'+memberOrder.nickName+'</td>';
        		data+='<td class="textc">'+memberOrder.createDt+'</td>';
        		data+='<td class="textc">'+memberOrder.orderType+'</td>';
        		data+='<td class="textc">'+memberOrder.orderFee+'</td>';
        		data+='<td class="textc">'+memberOrder.orderStatus+'</td>';
        		data+='<td class="textc">'+memberOrder.rechargeType+'</td>';
        		data+='<td class="textc">';
        		data+='<div class="positionr listOperaters">';
        		data+='		<a href="javascript:void(0);"  class="icon-large dlblock w16 h16"><img src="'+resourcePath+'/images/angle-down.png"/></a>';
        		data+='		<div class="ops_box ops_itemDiv positiona clearfix whitebg">';
        		data+='			<ul>';
        		data+='				<li class="fl ml2 mr2"><a href="javascript:void(0);" onclick="showMemberOrderDetails('+memberOrder.id+')" class="btn btn-primary fa fa-edit ops_more f12">编辑</a></li>';
        		data+='				<li class="fl ml2 mr2"><a href="javascript:void(0);" onclick="initDeleteMemberOrder('+memberOrder.id+')" class="btn btn-primary fa fa-remove ops_more f12">删除</a></li>';
        		data+='				<li class="fl ml2 mr2"><a href="javascript:void(0);" onclick="showMemberOrderDetails('+memberOrder.id+')" class="btn btn-primary fa fa-detail ops_more f12">明细</a></li>';
        	    data+='			</ul>';
              data+='		</div>';
        	    data+='</div>';
        	    data+='</td>';
        	    data+='</tr>';
        	    $('#data_content').append(data);
        	});*/
        }  
    });  
	//表头列不选中
	$("#allCheck").find("span").removeClass('checked');
}



