$(function() {

	/**
	 * change事件-隐藏-显示数据列
	 */
	$('input[type=checkbox][name=columnShow]').on('change', function(e) {
		var column = $(this).attr('column');
		var isAccept = $(this).prop("checked");
		
		isColumnShow(isAccept,column);
		
		localStorage.setItem('curingColumn_'+column, isAccept);
	});

})

/**
 * 初始化数据列--是否展示
 * @param columnLength
 * @returns
 */
function refreshColumn(columnLength){
	var checkBoxList=$('input[type=checkbox][name=columnShow]');
	var cbi=0;
	
	for(var i=1;i<=columnLength;i++){
		var isAccept=localStorage.getItem("curingColumn_"+i);

		if(isAccept=='false'){
			isAccept=false;
		}
		
		if (isAccept==null||isAccept) {
			//console.log(isAccept);
			checkBoxList.eq(cbi).attr("checked",'true');
		}else{
			//console.log(isAccept+'dddd');
			checkBoxList.eq(cbi).removeAttr("checked");
		}
		
		isColumnShow(isAccept,i);
		cbi++;
	}
}

function isColumnShow(isAccept,column){

	if (isAccept==null||isAccept) {
		//console.log(isAccept==null||isAccept);
		$('table[columnShow] tr').find('th:eq('+column+')').show();
		$('table[columnShow] tr').find('td:eq('+column+')').show();
	} else {
		//console.log(column);
		$('table[columnShow] tr').find('th:eq('+column+')').hide();
		$('table[columnShow] tr').find('td:eq('+column+')').hide();
	}
}