function viewWork(viewname,id){
	mylistpage = $('#weekViewList').getGridParam('page');
	window.location.href = window.location.href+'?fromPlanView=1'
	$(".yk_rightcontent").load("/weekWorkPlan/list?userId="+id,function(){
		backTop('.yk_rightcontent');
		$(".modifyWeekWorkBtn,.deleteWeekWorkBtn").remove();
		$(".add-week-work,.icon-trash,.icon-edit").hide();
		$(".yk_rightcontent .week-header").append('<a class="icon icon-reply-all returnto-weekplanview"></a>');
		$(".breadcrumb li:last").text("查看他人").after('<li>'+viewname+'</li>');
		$("#mylistpage").val(mylistpage);
		$('.week_box .week-plan_taskul').on("mouseenter","li",function(){
			$(".icon-trash,.icon-edit").css({"font-size":'0','opacity':'0'})
		})
	})
}
$(function(){
	function loadData(){
		$('#weekViewList').setGridParam({
			url : '/weekWorkPlan/do_weekPlanList',
			datatype : 'json',
			postData: { 'department.id':sxUtil.tree.getSelectOrgId() },
			page : 1
		});
		$('#weekViewList').trigger('reloadGrid');
	}
	//刷新
	$(".weekplanview_refresh").click(function(){
		loadData();
	})
	//初始化组织架构
	sxUtil.tree.navTreeMap({
		selectedAfter:loadData
	});
	
	function enterpriseCNFmatter(cellvalue, options, rowObject){ 
	       return '<div class="operateIcon noHover"><p><span>查看</span><i class="operateIconfont operateIcon-chakan" onclick="viewWork(\''+rowObject.userName+'\','+rowObject.userId+')"></i></p></div>';
	}; 
	/* 给部门列添加背景色 */
	function departmentFmatter(cellvalue, options, rowObject){
		var cellval=cellvalue.replace(/\s{1,}/g,",");
		var arr=cellval.split(',');
		var returndiv='';
		for(var i=0;i<arr.length-1;i++){
			if(arr[i].length){
				returndiv+='<span class="yk_DMbackground">'+arr[i]+' '+'</span>'
			}
		}
		returndiv = '<div style="white-space:normal;">'+returndiv+'</div>'
		return returndiv;
	}
	//操作栏单元格字体的移入
	$(".weekmeeting-detail").on("mouseenter",'.yk_weekView',function(){
		$(this).find('i').removeClass("icon-search").text("查看")
	})
	//操作栏单元格字体的移出
	$(".weekmeeting-detail").on("mouseleave",'.yk_weekView',function(){
		$(this).find('i').addClass("icon-search").text("")
	})
	sxUtil.jqGrid('#weekViewList',{
		colNames:['序号','用户id','员工姓名','部门','手机号','分机号','操作'],
		colModel:[
			{name: 'orderNumber', label: '序号', width:60,sortable:false,title:false},
			{name: 'userId', label: '用户ID', hidedlg:true, hidden:true,sortable:false,title:false},
			{name: 'userName', label: '姓名',sortable:false,align:'center',width:120,title:false},
            {name: 'department', label: '部门',sortable:false,title:false,width:300,formatter:departmentFmatter},
            {name: 'mobile', label: '手机号',sortable:false,align:'center',title:false,width:120},
            {name: 'tel', label: '分机号',sortable:false,align:'center',title:false,width:90},
            {name: 'desc', label: '操作',sortable:false,align:'center',width:120,title:false, formatter:enterpriseCNFmatter}
		], 
		height:'auto',
		url : '/weekWorkPlan/do_weekPlanList',
		pager : "#weekViewListPage",
		multiselect: false,
		rownumbers:false,
		postData : {
			'department.id':sxUtil.tree.getSelectOrgId()
		},
		page:mylistpage,
		loadError:function(){
			new $.zui.Messager('列表加载失败', {
			    type: 'warning',
			    time:1500
			}).show();
		},
		onPaging:function(pgButton){
			console.log(pgButton)
		}
	},true);
})