<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>机构管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/webpage/include/treeview.jsp" %>
	<style type="text/css">
		.ztree {overflow:auto;margin:0;_margin-top:10px;padding:10px 0 0 10px;}
		.table.details > tbody > tr >td >a, .table.details > tbody > tr >td >div, .table.details > tbody > tr >td{
			text-overflow: unset;
		}
	</style>
	<script type="text/javascript">
        var validateForm;
        var count = 0;
        function doSubmit(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if(validateForm.form()){
                if(obj == 1){
                    $("#flag").val("yes");
                    var info = false;
                    var dataList = ${fns:toJson(list)};
                    for (var i=0; i<dataList.length; i++){
                        if($("#audit"+dataList[i].id).val() == 0){
                            info = true;
                        }
                    }
                    if (info){
                        parent.layer.msg("请先确认质量符合内容!", {icon: 2});
                        return false;
                    }
                    if('${not empty projectcontentinfo.projectReportData.act.taskDefKey && projectcontentinfo.projectReportData.act.taskDefKey eq 'glyda'}' == 'true' && ($("#number").val()==null || $("#number").val()=='' || $("#number").val() == undefined)){
                        parent.layer.msg("请先输入报告编号!", {icon: 2});
                        return false;
                    }
                    if('${not empty projectcontentinfo.projectReportData.act.taskDefKey && projectcontentinfo.projectReportData.act.taskDefKey eq 'gzr'}' == 'true'){
                        var falt=false;
                        var type="${projectcontentinfo.projectReportData.reportType}";
                        if(type=="电子章"){
                            var id="${projectcontentinfo.projectReportData.id}";
                            $.ajax({
                                type:'post',
                                url:'${ctx}/workcontractsignature/workContractSignature/signatureStatus',
                                async: false,
                                data:{ "id":id},
                                success:function(data) {
                                    if(data){
                                        falt=data;
                                    }
                                }
                            });
                        }
                        if(falt){
                            parent.layer.msg("附件中存在未签章的文件!", {icon: 5});
                            return false;
                        }
                    }
                }else{
                    $("#flag").val("no");
                }
               $("#inputForm").submit();
                return true;
            }

            return false;
        }
        $(document).ready(function() {

            var dataList = ${fns:toJson(list)};
            validateForm = $("#inputForm").validate({
                submitHandler: function(form){
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
        });

        // 确认对话框
        function reviewAudit(mess, href,obj){
            // top.layer.confirm(mess, {icon: 3, title:'系统提示'}, function(index){
                //do something
                if (typeof href == 'function') {
                    href();
                }else{
                    resetTip(); //loading();
                    $.ajax({
                        url:href,
                        data:$('#loginForm').serialize(),
                        type:"post",
                        success:function(data){
                            if(data.status){
                                $("#audit"+obj).val("1");
                                $("#check1"+obj).attr("style","display:none");
                                $("#check2"+obj).attr("style","display");
                                parent.layer.msg('确认质量复核内容成功',{icon:1});
                            }else {
                                parent.layer.msg('确认质量复核内容失败',{icon:2});
                            }
                        }
                    });
                }
            //     top.layer.close(index);
            // });
            return false;
        }
        // 确认对话框
        function reportNumber(number){
            var infoId = '${projectcontentinfo.projectReportData.id}';
            $.ajax({
                url:"${ctx}/projectcontentinfo/projectcontentinfo/reportNumber",
                data:{
                    "infoId":infoId,
                    "number":number,
                    "type":"1"
                },
                type:"post",
                success:function(data){
                    if(data.status){
                        parent.layer.msg('分配文号成功',{icon:1});
                    }else {
                        parent.layer.msg('分配文号失败',{icon:2});
                    }
                }
            });
            return false;
        }
        // 确认对话框
        function reportMaxDeduct(maxDeduct,id,parentId){
            var dataList = ${fns:toJson(list)};
            var maxDeductTotal = 0;
            var maxDeducts = 0;
            for (var i=0; i<dataList.length; i++){
                if(dataList[i].id == id){
                    maxDeducts = dataList[i].maxDeduct;
                }
                // if(dataList[i].id == parentId){
                //     maxDeductTotal = dataList[i].maxDeduct;
                // }
            }
            if (maxDeducts-maxDeduct>=0){
                $.ajax({
                    url:"${ctx}/workreview/workReviewStandard/reportMaxDeduct",
                    data:{
                        "maxDeduct":maxDeduct,
                        "id":id,
                    },
                    type:"post",
                    success:function(data){
                        if(data.status){
                            parent.layer.msg('输入扣分项成功',{icon:1});
                        }else {
                            parent.layer.msg('输入扣分项失败',{icon:2});
                        }
                    }
                });
                return false;
            }else {
                parent.layer.msg('输入扣分项失败,扣分项不能超过总分',{icon:2});
            }

        }
        function addRow(obj) {
            var tr = "<tr>" +
						"<td>" +
							"<input id=\"id"+count+"\" htmlEscape=\"false\" type=\"hidden\" class=\"form-control \">" +
							"<input id=\"parent"+count+"\" htmlEscape=\"false\" type=\"hidden\" value=\""+obj+"\" class=\"form-control \">" +
						"</td>"+
						"<td class=\"input-td\">" +
							"<input id=\"content"+count+"\" htmlEscape=\"false\" onChange=\"if(this.value)saveDate(this.value,'"+count+"');\" class=\"form-control layui-input \">" +
						"</td>"+
                		"<td></td>" +
						"<td>" +
           					"<a onclick=\"return delRow('确认要删除吗？',this,'','"+count+"')\"><i class=\"fa fa-backward\"></i> </a>" +
						"</td>" +
					"</tr>";
            $("#"+obj).after(tr);
            count++
        }
        function delRow(mess,obj,value,id) {
            var v = value;
            if (v==null || v == ''){
                v = $("#id"+id).val();
			}

            top.layer.confirm(mess, {icon: 3, title:'系统提示'}, function(index){
                //do something
                if (typeof href == 'function') {
                    href();
                }else{
                    resetTip(); //loading();
                    $.ajax({
                        url:'${ctx}/workreview/workReviewStandard/deleteData',
                        data:{
                            "id":v
                        },
                        type:"post",
                        success:function(data){
                            if(data.status){
                                $(obj).parent().parent().remove();
                                parent.layer.msg('删除成功',{icon:1});
                            }else {
                                parent.layer.msg('删除失败',{icon:2});
                            }
                        }
                    });
                }
                top.layer.close(index);
            });
            return false;
        }
        function saveDate(obj,count) {
			var auditId = $("#parent"+count).val();
            $.ajax({
                url:"${ctx}/workreview/workReviewStandard/reviewData",
                data:{
                    "content":obj,
                    "auditId":auditId
                },
                type:"post",
                success:function(data){
                    if(data.status){
                        $("#id"+count).val(data.id);
                        layer.msg('保存成功',{icon:1});
                    }else {
                        layer.msg('保存失败',{icon:2});
                    }
                }
            });
        }


		function refresh(){//刷新

			window.location="${ctx}/projectcontentinfo/projectcontentinfo/report?project.id=${projectId}&id=${projectcontentinfo.id}";
		}
	</script>
</head>
<body style="height:100%;">
	<div class="check-container">
		<div class="left-panel">
			<div class="layui-tab tabDiv">
				<ul class="layui-tab-title">
					<li class="active"><a href="javascript:void(0)">项目报告</a></li>
					<li><a href="${ctx}/projectcontentinfo/projectcontentinfo/reportView?project.id=${projectId}&id=${projectcontentinfo.id}">项目资料</a></li>
				</ul>
			</div>
			<div class="ztreeBox">
				<div class="ztreeContainer">
					<div id="ztree" class="ztree leftBox-content">

					</div>
				</div>
			</div>
		</div>
		<div class="middle-panel">
			<div class="middle-panel-inner">
				<div class="middle-panel-content">
					<div class="check-tabs">
						<span class="content-title">相关内容：</span>
						<form:form id="inputForm" modelAttribute="projectcontentinfo" action="${ctx}/projectcontentinfo/projectcontentinfo/reportAudit" method="post" class="form-horizontal">
						<form:hidden path="id"/>
						<form:hidden path="home"/>
						<form:hidden path="parentIds"/>
						<form:hidden path="edit"/>
						<form:hidden path="projectReportData.id"/>
						<form:hidden path="projectReportData.createBy.id"/>
						<form:hidden path="projectReportData.act.taskId"/>
						<form:hidden path="projectReportData.act.taskName"/>
						<form:hidden path="projectReportData.act.taskDefKey"/>
						<form:hidden path="projectReportData.act.procInsId"/>
						<form:hidden path="projectReportData.act.procDefId"/>
						<form:hidden id="flag" path="projectReportData.act.flag"/>
						<sys:message content="${message}"/>
						</form:form>
						<div class="tab-container">
							<button class="roll-nav roll-left content_tabLeft"><i class="fa fa-backward"></i>
							</button>
							<nav class="page-tabs check_menuTabs">
								<div class="check-page-tabs-content">
									<%--<a href="javascript:;" class="active check_menuTab" data-id="${ctx}/home">首页</a>--%>
								</div>
							</nav>
							<div class="roll-right-container">
								<button class="roll-nav roll-right content_tabRight"><i class="fa fa-forward"></i>
								</button>
							</div>
						</div>
					</div>
					<div id="check-contents" class="check-contents">
					</div>
				</div>
				<c:choose>
					<c:when test="${not empty projectcontentinfo.projectReportData.act.taskDefKey && (projectcontentinfo.projectReportData.act.taskDefKey eq 'bzshb' ||  projectcontentinfo.projectReportData.act.taskDefKey eq 'bzshbyg')}">
						<div class="right-panel">
							<div class="title">质量复核内容</div>
							<div style="margin-top: 16px;">
								<div class="layui-item layui-col-xs12 form-table-container" >
									<table id="treeTable2" class="table table-bordered table-condensed details no-bottom-margin">
										<thead>
										<tr>
											<%--<th width="25%">序号</th>--%>
											<th width="40%">符合内容及评分标准</th>
											<th width="20%">扣分</th>
											<%--<th width="15%">操作</th>--%>
										</tr>
										</thead>
										<tbody>
										<c:forEach items="${list}" var="workReviewAudit" varStatus="index">
											<tr id="${workReviewAudit.id}" pid="${workReviewAudit.parent.id}">
												<%--<td title="${workReviewAudit.orderNum}">--%>
														<%--${workReviewAudit.orderNum}--%>
												<%--</td>--%>
												<td title="${workReviewAudit.standardDetail}">
														${workReviewAudit.standardDetail}
												</td>
												<td class="input-td">
													<c:choose>
													<c:when test="${workReviewAudit.orderNum > 4000 && workReviewAudit.orderNum < 5000}">
														<input id="maxDeduct" htmlEscape="false"  class="form-control layui-input" onChange="if(this.value)reportMaxDeduct(this.value,'${workReviewAudit.id}','${workReviewAudit.parent.id}')" value="${workReviewAudit.maxDeduct}">
													</c:when>
													<c:otherwise>
														${workReviewAudit.maxDeduct}
													</c:otherwise>
													</c:choose>
												</td>
												<%--<td>--%>
													<%--<c:choose>--%>
														<%--<c:when test="${not empty workReviewAudit.type && workReviewAudit.type eq '5'}">--%>
															<%--<a  onclick="addRow('${workReviewAudit.id}')" title="新增"><i class="fa fa-plus"></i>&nbsp;</a>--%>
														<%--</c:when>--%>
														<%--<c:when test="${not empty workReviewAudit.type && workReviewAudit.type eq '6'}">--%>
															<%--<a href="" onclick="return delRow('确认要删除吗？',this,'${workReviewAudit.id}','')"  ><i class="fa fa-backward"></i> </a>--%>
														<%--</c:when>--%>
													<%--</c:choose>--%>
												<%--</td>--%>
											</tr>
										</c:forEach>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</c:when>
					<c:when test="${not empty projectcontentinfo.projectReportData.act.taskDefKey && projectcontentinfo.projectReportData.act.taskDefKey eq 'glyda'}">
						<div class="right-panel">
							<div class="title">质量复核内容</div>
							<div style="margin-top: 16px;">
								<div class="layui-item layui-col-xs12 form-table-container" >
									<table id="treeTable3" class="table table-bordered table-condensed details no-bottom-margin">
										<tbody>
										<tr >
											<td class="width-15 active"><label class="pull-right"><font color="red">*</font>报告名称：</label></td>
											<td class="width-35 input-td" colspan="3">
												<input  htmlEscape="false" value="${projectcontentinfo.projectReportData.name}" readonly="readonly" class="form-control layui-input ">
											</td>
										</tr>
										<tr>
											<td class="width-15 active"><label class="pull-right">报告编号：</label></td>
											<td class="width-35 input-td" colspan="3">
												<div style="">
													<input id="number" htmlEscape="false"  class="form-control layui-input" onChange="if(this.value)reportNumber(this.value)" value="${projectcontentinfo.projectReportData.number}">
												</div>
											</td>
										</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</c:when>
					<c:when test="${not empty projectcontentinfo.projectReportData.act.taskDefKey && projectcontentinfo.projectReportData.act.taskDefKey ne 'gzr' && projectcontentinfo.projectReportData.act.taskDefKey ne 'fgzlfz'  && projectcontentinfo.projectReportData.act.taskDefKey ne 'fgld'}">
						<div class="right-panel">
							<div class="title">质量复核内容</div>
							<div style="margin-top: 16px;">
								<div class="layui-item layui-col-xs12 form-table-container" >
									<table id="contentTable" class="table table-bordered table-condensed details no-bottom-margin">
										<thead>
										<tr>
											<%--<th width="25%">序号</th>--%>
											<th width="60%">符合内容及评分标准</th>
											<th width="15%">操作</th>
										</tr>
										</thead>
										<tbody>
										<c:forEach items="${list}" var="workReviewAudit" varStatus="index">
											<tr id="${workReviewAudit.id}">
												<%--<td>${workReviewAudit.orderNum}</td>--%>
												<td title="${workReviewAudit.standardDetail}">
													${workReviewAudit.standardDetail}
												</td>
												<td class="op-td">
													<c:choose>
														<c:when test="${not empty workReviewAudit.remarks}">
															<div class="check-ok">
																<i class="fa fa-check"></i>
															</div>
														</c:when>
														<c:otherwise>
															<div id = "check1${workReviewAudit.id}">
																<input type="hidden" id="audit${workReviewAudit.id}" value="0"/>
																<a href="${ctx}/workreview/workReviewStandard/reviewAudit?auditId=${workReviewAudit.id}" onclick="return reviewAudit('确认要审核该质量复核内容吗？', this.href,'${workReviewAudit.id}')"   class="op-btn op-btn-edit">确认</a>
															</div>
															<div id = "check2${workReviewAudit.id}" class="check-ok" style="display: none">
																<i class="fa fa-check"></i>
															</div>
														</c:otherwise>
													</c:choose>
												</td>
											</tr>
										</c:forEach>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</c:when>
					<c:otherwise>
						<style>
							.middle-panel-content {
								margin-right: 0px;
							}
						</style>
					</c:otherwise>
				</c:choose>
			</div>
		</div>
		<a class="left-close"><i class="glyphicon glyphicon-chevron-left"></i></a>
		<c:choose>
			<c:when test="${ not empty projectcontentinfo.projectReportData.act.taskDefKey && ( projectcontentinfo.projectReportData.act.taskDefKey ne 'gzr' && projectcontentinfo.projectReportData.act.taskDefKey ne 'zlfgld' && projectcontentinfo.projectReportData.act.taskDefKey ne 'fgzlfz')}">
				<a class="right-close"><i class="glyphicon glyphicon-chevron-right"></i></a>
			</c:when>
		</c:choose>
	</div>
	<script>
    $(function () {
   	 	$('.check_menuTabs').on('click', '.check_menuTab', activeCheckTab);
        $('.check_menuTabs').on('click', '.check_menuTab i', closeCheckTab);
        // 左移按扭
        $('.content_tabLeft').on('click', scrollCheckTabLeft);

        // 右移按扭
        $('.content_tabRight').on('click', scrollCheckTabRight);
    });
    function calCheckSumWidth(elements) {
        var width = 0;
        $(elements).each(function () {
            width += $(this).outerWidth(true);
        });
        return width;
    }
    function activeCheckTab() {
        if (!$(this).hasClass('active')) {
            var currentId = $(this).data('id');
            // 显示tab对应的内容区
            $('.check-contents .check_iframe').each(function () {
                if ($(this).data('id') == currentId) {
                    $(this).show().siblings('.check_iframe').hide();
                    return false;
                }
            });

            $(this).addClass('active').siblings('.check_menuTab').removeClass('active');
            scrollToCheckTab(this);
        }
    }
    //滚动到指定选项卡
    function scrollToCheckTab(element) {
        var marginLeftVal = calCheckSumWidth($(element).prevAll()), marginRightVal = calCheckSumWidth($(element).nextAll());
        // 可视区域非tab宽度
        var tabOuterWidth = calCheckSumWidth($(".tab-container").children().not(".check_menuTabs"));
        //可视区域tab宽度
        var visibleWidth = $(".tab-container").outerWidth(true) - tabOuterWidth;
        //实际滚动宽度
        var scrollVal = 0;
        if ($(".check-page-tabs-content").outerWidth() < visibleWidth) {
            scrollVal = 0;
        } else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
            if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
                scrollVal = marginLeftVal;
                var tabElement = element;
                while ((scrollVal - $(tabElement).outerWidth()) > ($(".check-page-tabs-content").outerWidth() - visibleWidth)) {
                    scrollVal -= $(tabElement).prev().outerWidth();
                    tabElement = $(tabElement).prev();
                }
            }
        } else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
            scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
        }
        $('.check-page-tabs-content').animate({
            marginLeft: 0 - scrollVal + 'px'
        }, "fast");
    }
    //查看左侧隐藏的选项卡
    function scrollCheckTabLeft() {
        var marginLeftVal = Math.abs(parseInt($('.check-page-tabs-content').css('margin-left')));
        // 可视区域非tab宽度
        var tabOuterWidth = calCheckSumWidth($(".tab-container").children().not(".check_menuTabs"));
        //可视区域tab宽度
        var visibleWidth = $(".tab-container").outerWidth(true) - tabOuterWidth;
        //实际滚动宽度
        var scrollVal = 0;
        if ($(".check-page-tabs-content").width() < visibleWidth) {
            return false;
        } else {
            var tabElement = $(".check_menuTab:first");
            var offsetVal = 0;
            while ((offsetVal + $(tabElement).outerWidth(true)) <= marginLeftVal) {//找到离当前tab最近的元素
                offsetVal += $(tabElement).outerWidth(true);
                tabElement = $(tabElement).next();
            }
            offsetVal = 0;
            if (calCheckSumWidth($(tabElement).prevAll()) > visibleWidth) {
                while ((offsetVal + $(tabElement).outerWidth(true)) < (visibleWidth) && tabElement.length > 0) {
                    offsetVal += $(tabElement).outerWidth(true);
                    tabElement = $(tabElement).prev();
                }
                scrollVal = calCheckSumWidth($(tabElement).prevAll());
            }
        }
        $('.check-page-tabs-content').animate({
            marginLeft: 0 - scrollVal + 'px'
        }, "fast");
    }

    //查看右侧隐藏的选项卡
    function scrollCheckTabRight() {
        var marginLeftVal = Math.abs(parseInt($('.check-page-tabs-content').css('margin-left')));
        // 可视区域非tab宽度
        var tabOuterWidth = calCheckSumWidth($(".tab-container").children().not(".check_menuTabs"));
        //可视区域tab宽度
        var visibleWidth = $(".tab-container").outerWidth(true) - tabOuterWidth;
        //实际滚动宽度
        var scrollVal = 0;
        if ($(".check-page-tabs-content").width() < visibleWidth) {
            return false;
        } else {
            var tabElement = $(".check_menuTab:first");
            var offsetVal = 0;
            while ((offsetVal + $(tabElement).outerWidth(true)) <= marginLeftVal) {//找到离当前tab最近的元素
                offsetVal += $(tabElement).outerWidth(true);
                tabElement = $(tabElement).next();
            }
            offsetVal = 0;
            while ((offsetVal + $(tabElement).outerWidth(true)) < (visibleWidth) && tabElement.length > 0) {
                offsetVal += $(tabElement).outerWidth(true);
                tabElement = $(tabElement).next();
            }
            scrollVal = calCheckSumWidth($(tabElement).prevAll());
            if (scrollVal > 0) {
                $('.check-page-tabs-content').animate({
                    marginLeft: 0 - scrollVal + 'px'
                }, "fast");
            }
        }
    }
    function closeCheckTab() {
        var closeTabId = $(this).parents('.check_menuTab').data('id');
        var currentWidth = $(this).parents('.check_menuTab').width();

        // 当前元素处于活动状态
        if ($(this).parents('.check_menuTab').hasClass('active')) {

            // 当前元素后面有同辈元素，使后面的一个元素处于活动状态
            if ($(this).parents('.check_menuTab').next('.check_menuTab').size()) {

                var activeId = $(this).parents('.check_menuTab').next('.check_menuTab:eq(0)').data('id');
                $(this).parents('.check_menuTab').next('.check_menuTab:eq(0)').addClass('active');

                $('.check-contents .check_iframe').each(function () {
                    if ($(this).data('id') == activeId) {
                        $(this).show().siblings('.check_iframe').hide();
                        return false;
                    }
                });

                var marginLeftVal = parseInt($('.check-page-tabs-content').css('margin-left'));
                if (marginLeftVal < 0) {
                    $('.check-page-tabs-content').animate({
                        marginLeft: (marginLeftVal + currentWidth) + 'px'
                    }, "fast");
                }

                //  移除当前选项卡
                $(this).parents('.check_menuTab').remove();

                // 移除tab对应的内容区
                $('.check-contents .check_iframe').each(function () {
                    if ($(this).data('id') == closeTabId) {
                        $(this).remove();
                        return false;
                    }
                });
            }
			else if($(this).parents('.check_menuTab').prev('.check_menuTab').size()) {// 当前元素后面没有同辈元素，使当前元素的上一个元素处于活动状态
                var activeId = $(this).parents('.check_menuTab').prev('.check_menuTab:last').data('id');
                $(this).parents('.check_menuTab').prev('.check_menuTab:last').addClass('active');
                $('.check-contents .check_iframe').each(function () {
                    if ($(this).data('id') == activeId) {
                        $(this).show().siblings('.check_iframe').hide();
                        return false;
                    }
                });

                //  移除当前选项卡
                $(this).parents('.check_menuTab').remove();

                // 移除tab对应的内容区
                $('.check-contents .check_iframe').each(function () {
                    if ($(this).data('id') == closeTabId) {
                        $(this).remove();
                        return false;
                    }
                });
            }
            else{
                //  移除当前选项卡
                $(this).parents('.check_menuTab').remove();

                // 移除tab对应的内容区
                $('.check-contents .check_iframe').each(function () {
                    if ($(this).data('id') == closeTabId) {
                        $(this).remove();
                        return false;
                    }
                });
            }
        }
        // 当前元素不处于活动状态
        else {
            //  移除当前选项卡
            $(this).parents('.check_menuTab').remove();

            // 移除相应tab对应的内容区
            $('.check-contents .check_iframe').each(function () {
                if ($(this).data('id') == closeTabId) {
                    $(this).remove();
                    return false;
                }
            });
            scrollToCheckTab($('.check_menuTab.active'));
        }
        return false;
    }
	function openContent(url,name)
	{
		var flag = true;
        // 选项卡菜单已存在
        $('.check_menuTab').each(function () {
            if ($(this).data('id') == url) {
                if (!$(this).hasClass('active')) {
                    $(this).addClass('active').siblings('.check_menuTab').removeClass('active');
                    scrollToCheckTab(this);
                    // 显示tab对应的内容区
                    $('#check-contents .check_iframe').each(function () {
                        if ($(this).data('id') == url) {
                            $(this).show().siblings('.check_iframe').hide();
                            return false;
                        }
                    });
                }
                flag = false;
                return false;
            }
        });

		if(flag)
		{
            var str = '<a href="javascript:;" class="active check_menuTab" data-id="' + url + '">' + name + ' <i class="fa fa-times-circle"></i></a>';
            $('.check_menuTab').removeClass('active');

            // 添加选项卡对应的iframe
            var str1 = '<iframe class="check_iframe"  width="100%" height="100%" src="' + url + '" frameborder="0" data-id="' + url + '" seamless></iframe>';
            $('#check-contents').find('iframe.check_iframe').hide();
            $('#check-contents').append(str1);

            // //显示loading提示
            var loading = layer.load();

            $('.check-contents iframe:visible').load(function () {
                //iframe加载完成后隐藏loading提示
                layer.close(loading);
            });
            // 添加选项卡
            $('.check_menuTabs .check-page-tabs-content').append(str);
            scrollToCheckTab($('.check_menuTab.active'));
		}
		return false;
	}
	function openContentUrl(url,name)
	{
	    if ((url.indexOf("jpg") != -1) || (url.indexOf("png") != -1) || (url.indexOf("gif") != -1) || (url.indexOf("jpeg") != -1) || (url.indexOf("bmp") != -1)){
            openContent(url, name);
        }else {
            preview(name,url,'70%','70%');
        }

	}
    openContent("${ctx}/projectcontentinfo/projectcontentinfo/form?view=reportViewGzr&dictType=${projectcontentinfo.dictType}&id=${projectcontentinfo.id}&parentIds=${projectcontentinfo.parentId}&projectReportData.id=${projectcontentinfo.projectReportData.id}","报告明细");
</script>
	<script>
        function addDiyDom(treeId, treeNode) {
            var spaceWidth = 15;
            var switchObj = $("#" + treeNode.tId + "_switch"),
                icoObj = $("#" + treeNode.tId + "_ico");
            switchObj.remove();
            icoObj.before(switchObj);

            if (treeNode.level > 0) {
                var spaceStr = "<span style='display: inline-block;width:" + (spaceWidth * treeNode.level)+ "px'></span>";
                switchObj.before(spaceStr);
            }
        }

        var setting = {data:{simpleData:{enable:true,idKey:"id",pIdKey:"pId",rootPId:'0'}},
            callback:{onClick:function(event, treeId, treeNode){
                if(treeNode.read == 'read'){
					if (treeNode.dictType == 0){
						openContentUrl(treeNode.urlInfo,treeNode.name);
					}else if (treeNode.dictType){
						var id = treeNode.id == '0' ? '' :treeNode.id;
						var url = "${ctx}/projectcontentinfo/projectcontentinfo/reportlist?id="+id+"&parentIds="+treeNode.pIds;

						openContent(url, treeNode.name);
					}
				}
                    <%--var id = treeNode.id == '0' ? '' :treeNode.id;--%>
                    <%--$('#userContent').attr("src","${ctx}/sys/user/list?office.id="+id+"&office.name="+treeNode.name);--%>
                }
            }
            ,view:{
                showLine: false,
                showIcon: false,
                addDiyDom: addDiyDom
            }
        };

        function refreshTree(){
            $.getJSON("${ctx}/projectcontentinfo/projectcontentinfo/treeDataReport?projectId=${projectId}&infoId=${projectcontentinfo.infoId}",function(data){
                $.fn.zTree.init($("#ztree"), setting, data).expandAll(true);
            });
        }
        refreshTree();
	</script>

	<script>
        $(".left-close").click(function(){
            if($('.left-panel').is(':visible'))
            {
                $(this).children(":first").attr("class","glyphicon glyphicon-chevron-right");
                $('.middle-panel').addClass("close-left");
            }
            else
            {
                $(this).children(":first").attr("class","glyphicon glyphicon-chevron-left");
                $('.middle-panel').removeClass("close-left");
            }
            $(this).toggleClass("closed");
            $(".left-panel").toggleClass("closed");
        })
        $(".right-close").click(function(){
            if($('.right-panel').is(':visible'))
            {
                $(this).children(":first").attr("class","glyphicon glyphicon-chevron-left");
                $('.middle-panel-content').addClass("close-right");
            }
            else
            {
                $(this).children(":first").attr("class","glyphicon glyphicon-chevron-right");
                $('.middle-panel-content').removeClass("close-right");
            }
            $(this).toggleClass("closed");
            $(".right-panel").toggleClass("closed");
        })

	</script>
</body>
</html>