<%@ page import="com.jeeplus.modules.sys.utils.UserUtils" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>案例详情管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
        $(document).ready(function() {
        });
        function openDialogre(title,url,width,height,target){

            if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端，就使用自适应大小弹窗
                width='auto';
                height='auto';
            }else{//如果是PC端，根据用户设置的width和height显示。

            }
            top.layer.open({
                type: 2,
                area: [width, height],
                title: title,
                maxmin: true, //开启最大化最小化按钮
                content: url ,
				skin:"three-btns",
                btn: ['送审','暂存','关闭'],
                btn1: function(index, layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(1) ){
                        top.layer.close(index);//关闭对话框。
                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                },
                btn2:function(index,layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(2) ){
                        top.layer.close(index);//关闭对话框。
//                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                    return false;
                },
                btn3: function(index){
                }
            });
        }
        function openDialogres(title,url,width,height,target){

            if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端，就使用自适应大小弹窗
                width='auto';
                height='auto';
            }else{//如果是PC端，根据用户设置的width和height显示。

            }
            top.layer.open({
                type: 2,
                area: [width, height],
                title: title,
                maxmin: true, //开启最大化最小化按钮
                content: url ,
                skin:"three-btns",
                btn: ['送审','暂存','关闭'],
                btn1: function(index, layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(5) ){
                        top.layer.close(index);//关闭对话框。
                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                },
                btn2:function(index,layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(2) ){
                        top.layer.close(index);//关闭对话框。
//                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                    return false;
                },
                btn3: function(index){
                }
            });
        }
        function openDialogreToo(title,url,width,height,target){
            if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端，就使用自适应大小弹窗
                width='auto';
                height='auto';
            }else{//如果是PC端，根据用户设置的width和height显示。

            }
            top.layer.open({
                type: 2,
                area: [width, height],
                title: title,
                maxmin: true, //开启最大化最小化按钮
                content: url ,
                skin:"two-btns",
                btn: ['重新申请','关闭'],
                btn1: function(index, layero){
                    var body = top.layer.getChildFrame('body', index);
                    var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var inputForm = body.find('#inputForm');
                    var top_iframe;
                    if(target){
                        top_iframe = target;//如果指定了iframe，则在改frame中跳转
                    }else{
                        top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                    }
                    inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                    if(iframeWin.contentWindow.doSubmit(3) ){
                        //top.layer.close(index);//关闭对话框。
                        setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                    }
                },
                /* btn2:function(index,layero){
                     var body = top.layer.getChildFrame('body', index);
                     var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                     var inputForm = body.find('#inputForm');
                     var top_iframe;
                     if(target){
                         top_iframe = target;//如果指定了iframe，则在改frame中跳转
                     }else{
                         top_iframe = top.getActiveTab().attr("name");//获取当前active的tab的iframe
                     }
                     inputForm.attr("target",top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示
                     if(iframeWin.contentWindow.doSubmit(4) ){
                         //top.layer.close(index);//关闭对话框。
                         setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                     }
                     return false;
                 },*/
                btn3: function(index){
                }
            });

        }
	</script>
	<style>
		body{
			height:100%;
		}
	</style>
</head>
<body>
<div class="wrapper wrapper-content">
	<div class="layui-row">
		<div class="full-width fl">
			<div class="list-form-tab" id="tabDiv">
				<ul class="list-tabs" >
					<%--<li><a href="${ctx}/caseinfo/caseInfo/caseInfoTodoList">待办任务</a></li>--%>
					<%--<li><a href="${ctx}/caseinfo/caseInfo/caseInfoHistoricList">已办任务</a></li>--%>
					<li class="active"><a href="${ctx}/caseinfo/caseInfo/list?sign=me">我的案例</a></li>
					<li ><a href="${ctx}/caseinfo/caseInfo/list?sign='office'">公司案例</a></li>
				</ul>
			</div>


		<sys:message content="${message}"/>

		<!--查询条件-->

			<div class=" layui-row" id="queryDiv">
				<form:form id="searchForm" modelAttribute="caseInfo" action="${ctx}/caseinfo/caseInfo/?sign=me" method="post" class="form-inline">
					<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
					<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
					<table:sortColumn id="orderBy" name="orderBy" value="${page.orderBy}" callback="sortOrRefresh();"/><!-- 支持排序 -->

					<div class="commonQuery lw6">
						<div class="layui-item query athird">
							<label class="layui-form-label">案例名称：</label>
							<div class="layui-input-block with-icon">
								<form:input path="name" htmlEscape="false" maxlength="255"  class=" form-control layui-input"/>
							</div>
						</div>
						<div class="layui-item athird fr">
							<div class="input-group">
								<button id="searchReset" class="fixed-btn searchReset fr" onclick="resetSearch()">重置</button>
								<button id="searchQuery" class="fixed-btn searchQuery fr" onclick="search()">查询</button>
							</div>
						</div>
						<div style="    clear:both;"></div>
					</div>

				</form:form>
			</div>
		</div>

		<div class="full-width fl">
			<div class=" layui-form contentDetails">
				<div class="nav-btns">
					<shiro:hasPermission name="caseinfo:caseInfo:add">
						<button class="nav-btn nav-btn-add" title="案例详情" onclick="openDialogre('案例详情','${ctx}/caseinfo/caseInfo/form?cid=${caseInfo.caseCategory.id}','95%','95%')"><i class="fa fa-plus"></i>&nbsp;添加</button>
					</shiro:hasPermission>

					<button class="nav-btn nav-btn-refresh" data-toggle="tooltip" data-placement="left" onclick="sortOrRefresh()" title="刷新"><i class="glyphicon glyphicon-repeat"></i>&nbsp;刷新</button>
					<div style="clear: both;"></div>
				</div>
				<table class="oa-table layui-table" id="contentTable"></table>

				<!-- 分页代码 -->
				<table:page page="${page}"></table:page>
				<div style="clear: both;"></div>
			</div>
		</div>
	</div>
	<div id="changewidth"></div>
</div>
<script src="${ctxStatic}/layer-v2.3/layui/layui.all.js" charset="utf-8"></script>
<script>

    layui.use('table', function(){
        layui.table.render({
            limit:${ page.pageSize }
            ,elem: '#contentTable'
            ,page: false
            ,cols: [[
                // {checkbox: true, fixed: true},
                {field:'index',align:'center', title: '序号',width:40}
                ,{field:'project',align:'center', title: '所属项目',minWidth:120,templet:function(d){
                        return "<span title='"+ d.project +"'>" + d.project + "</span>";
                    }}
                ,{field:'caseName',align:'center', title: '案例名称(分部分项)',minWidth:125,templet:function(d){
                        return "<a class=\"attention-info\" title=\"" + d.caseName + "\" href=\"javascript:void(0);\" onclick=\"openDialogView('查看案例详情', '${ctx}/caseinfo/caseInfo/form?id=" + d.id +"&tabId=0','95%', '95%')\">" + d.caseName + "</a>";
                    }}
                ,{field:'caseCate', align:'center',title: '案例分类',width:80,templet:function(d){
                        return "<span title='"+ d.caseCate +"'>" + d.caseCate + "</span>";
                    }}
                ,{field:'startDate', align:'center',title: '施工时间', sort:true, width:80}
                ,{field:'area',align:'center', title: '工程所在地',  width:80,templet:function(d){
                        return "<span title=\"" + d.area + "\">" + d.area + "</span>";
                    }}
                ,{field:'company',align:'center', title: '案例分享公司',  width:90,templet:function(d){
                        return "<span title=\"" + d.company + "\">" + d.company + "</span>";
                    }}
                ,{field:'createBy',align:'center', title: '创建人',  width:60}
                // ,{field:'auditBy',align:'center', title: '审核人',  width:80}
                ,{field:'caseType',align:'center', title: '案例类型',  width:70}
                ,{align:'center', title: '状态',  width:70,templet:function(d){
                        var st = getAuditState(d.status)
                        /*if(d.status == 1){
							var xmls = "<a href=\"${ctx}/caseinfo/caseInfo/startposs?id=" + d.id +"\" onclick=\"return confirmx('确认要发起案例审核吗？', this.href)\"   class=\"op-btn op-btn-revert\"> 启动</a>"
							return xmls;
						}else {
                            var xml = "<span onclick=\"openDialogView('流程追踪', '${ctx}/caseinfo/caseInfo/getProcess?id=" + d.id + "','95%','95%')\" class=\"status-label status-label-" + st.label + "\" >" + st.status + "</span>";
                            return xml;
						}*/
                    var xml = "<span onclick=\"openDialogView('流程追踪', '${ctx}/caseinfo/caseInfo/getProcess?id=" + d.id + "','95%','95%')\" class=\"status-label status-label-" + st.label + "\" >" + st.status + "</span>";
                    return xml;
                    }}
                ,{field:'op',align:'center',title:"操作",width:130,templet:function(d){
                        ////对操作进行初始化
                        var xml="";
                        if(d.canedit1 != undefined && d.canedit1 =="1")
                        {
                            xml+="<a href=\"javascript:void(0);\" onclick=\"openDialogreToo('重新申请案例', '${ctx}/caseinfo/caseInfo/form?id=" + d.id +"','95%', '95%')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i> 修改</a>";
                        }
                        if(d.canedit2 != undefined && d.canedit2 =="1")
                        {
                            xml+="<a href=\"javascript:void(0);\" onclick=\"openDialogres('修改案例', '${ctx}/caseinfo/caseInfo/form?id=" + d.id + "','95%', '95%')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i> 修改</a>";
                        }
                        if(d.candel != undefined && d.candel =="1")
                        {
                            xml+="<a href=\"${ctx}/caseinfo/caseInfo/delete?id=" + d.id + "&sign=me\" onclick=\"return confirmx('确认要删除该案例详情吗？', this.href)\" class=\"op-btn op-btn-delete\"><i class=\"fa fa-trash\"></i> 删除</a>";
                        }
                        if(d.cancancel != undefined && d.cancancel =="1")
                        {
                            xml+="<a href=\"${ctx}/caseinfo/caseInfo/revoke?id=" + d.id + "&processInstanceId=" + d.procId + "\" onclick=\"return confirmx('确认要撤回吗？', this.href)\" class=\"op-btn op-btn-cancel\" ><i class=\"glyphicon glyphicon-share-alt\"></i> 撤回</a>";
                        }

                        return xml;
                    }}
            ]]
            ,data: [
                <c:if test="${ not empty page.list}">
                <c:forEach items="${page.list}" var="caseInfo" varStatus="index">
                <c:set var="Sid" scope="session" value="<%= UserUtils.getUser().getId()%>"/>
                <c:set var="rname" scope="session" value="<%= UserUtils.getSelectRole().get(0).getName()%>"/>
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "index":"${index.index+1}"
                    ,"id":"${caseInfo.id}"
                    ,"project":<c:choose><c:when test="${caseInfo.ext == 1}">"${caseInfo.contractName}"</c:when><c:otherwise>"${caseInfo.project.projectName}"</c:otherwise></c:choose>
                    ,"caseName":"${caseInfo.name}"
                    ,"caseCate":"${caseInfo.caseCategory.name}"
                    ,"startDate":"<fmt:formatDate value="${caseInfo.startDate}" pattern="yyyy-MM-dd"/>"
                    ,"area":"${caseInfo.area.name}"
                    ,"company":"${caseInfo.companyName}"
                    ,"createBy":"${caseInfo.createBy.name}"
                    ,"auditBy":<c:choose><c:when test="${caseInfo.status == 1 or caseInfo.status == 2}">"未审核"</c:when><c:otherwise>"${caseInfo.updateBy.name}"</c:otherwise></c:choose>
                    ,"caseType":"${fns:getDictLabel(caseInfo.shareStatus, 'share_status', '')}"
                    ,"status":"${caseInfo.status}"
                    ,"procId":"${caseInfo.processInstanceId}"
                    <c:choose><c:when test="${caseInfo.status  == 4 and caseInfo.createBy.id == fns:getUser() and caseInfo.processEnded}">,"canedit1":"1"</c:when>
                    <c:when test="${(caseInfo.status == 1 or caseInfo.status == 3)and caseInfo.createBy.id == fns:getUser()}">,"canedit2":"1"</c:when></c:choose>
                    <shiro:hasPermission name="caseinfo:caseInfo:del">
                    <c:choose>
                    <c:when test="${(caseInfo.status == '1' or caseInfo.status == '3' or caseInfo.status == '4')}">,"candel":"1"</c:when>
                    </c:choose>
					</shiro:hasPermission>
                    <c:if test="${(caseInfo.createBy.id eq fns:getUser().id) && (caseInfo.status ==2)}">,"cancancel":"1"</c:if>
                }
                </c:forEach>
                </c:if>
            ]
            // ,even: true
            // ,height: 315
        });
    })

    resizeListTable();
</script>
<script>
    resizeListWindow4();
    $(window).resize(function(){
        resizeListWindow4();
    });
</script>
</body>
</html>