<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>工作内容详情管理</title>
	<meta name="decorator" content="default"/>
	<%--<script src="${ctxStatic}/layer-v2.3/laydate/laydate.js"></script>--%>
	<script type="text/javascript">
        $(function() {
            $("#cus_name").show();
            $("#cus_name").siblings().hide();
            //搜索框收放
            $('#moresee').click(function(){
                if($('#moresees').is(':visible'))
                {
                    $('#moresees').slideUp('slow');
                    $(this).text("").removeClass("fa fa-chevron-up").addClass("fa fa-chevron-down");
                    //document.getElementById("moresees").style.visibility = "hidden";
                }else{
                    $('#moresees').slideDown('slow');
                    $(this).text("").removeClass("fa fa-chevron-down").addClass("fa fa-chevron-up");
                    //document.getElementById("moresees").style.visibility = "visible";
                }
            });

            laydate.render({
                elem: '#startDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
            laydate.render({
                elem: '#endDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
        });
        function switchInput(obj){
            $("#"+obj).show();
            $("#"+obj).siblings().hide();
        }

        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,
                skin: 'three-btns',
                maxmin: true, //开启最大化最小化按钮
                content: url ,
                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){
                }
            });
        }

        // 确认对话框
        function confirmxRefresh(mess, href){
            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){
                                parent.layer.msg('删除成功',{icon:1});
                            }else {
                                parent.layer.msg('删除失败',{icon:2});
                            }
                            parent.refreshTrees();
                            location = '${ctx}/projectcontentinfo/projectcontentinfo/list?project.id=${projectRecords.id}';
                        }
                    });
                }
                top.layer.close(index);
            });
            return false;
        }
	</script>
</head>
<body>
<div class="wrapper wrapper-content">
    <sys:message content="${message}"/>
    <div class="layui-row">
        <div class="contentShadow bottomShadow full-width fl">
            <div class=" layui-row" id="queryDiv">
			<!--查询条件-->
                <form:form id="searchForm" modelAttribute="projectcontentinfo" action="${ctx}/projectcontentinfo/projectcontentinfo/list" method="post" class="form-inline">
                    <input id="id" name="id" type="hidden" value="${id}"/>
                    <input id="parentIds" name="parentIds" type="hidden" value="${parentIds}"/>
                    <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">
                                <form:input path="projectContentData.name" htmlEscape="false" maxlength="64"  class=" form-control layui-input"/>
                            </div>
                        </div>
                        <div class="layui-item query athird">
                            <label class="layui-form-label">内容编号：</label>
                            <div class="layui-input-block">
                                <form:input path="projectContentData.number" htmlEscape="false" maxlength="64"   class=" form-control layui-input"/>
                            </div>
                        </div>
                        <div class="layui-item athird">
                            <div class="input-group">
                                <c:if test="${empty change}">
                                <a href="#" id="moresee"><i class="glyphicon glyphicon-menu-down"></i></a>
                                <button id="searchReset" class="fixed-btn searchReset fr" onclick="resetSearch()">重置</button>
                                <button id="searchQuery" class="fixed-btn searchQuery fr" onclick="search()">查询</button>
                                </c:if>
                            </div>
                        </div>
                        <div style="clear:both;"></div>
                    </div>
                    <div id="moresees" style="clear:both;display:none;" class="lw6">
                        <div class="layui-item query athird">
                            <label class="layui-form-label">负责人：</label>
                            <div class="layui-input-block">
                                <form:input path="projectContentData.master.name" htmlEscape="false" maxlength="64"   class=" form-control layui-input"/>
                            </div>
                        </div>
                        <div class="layui-item query athird">
                            <label class="layui-form-label">创建日期：</label>
                            <div class="layui-input-block">
                                <input class="form-control layer-date laydate-icon layui-input laydate-icondate query-group" placeholder="开始时间" id="startDate" name="projectContentData.startDate" value="<fmt:formatDate value="${projectcontentinfo.projectContentData.startDate}" pattern="yyyy-MM-dd"/>" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})">
                                <span class="group-sep">-</span>
                                <input class="form-control layer-date laydate-icon layui-input laydate-icondate query-group" placeholder="结束时间" id="endDate" name="projectContentData.endDate" value="<fmt:formatDate value="${projectcontentinfo.projectContentData.endDate}" pattern="yyyy-MM-dd"/>" onclick="laydate({istime: false, format: 'YYYY-MM-DD'})">
                            </div>
                        </div>
                    </div>
                </form:form>
            </div>
        </div>
        <div class="contentShadow upShadow full-width fl">
            <div class="layui-form contentDetails">
                <div class="nav-btns">
                    <c:if test="${empty change}">
                        <a href="javascript:void(0)" onclick="openDialogre('新增工作内容', '${ctx}/projectcontentinfo/projectcontentinfo/form?view=content&dictType=${dictType}&id=${id}&parentIds=${parentIds}','95%','95%',false,'inputForm')" class="nav-btn nav-btn-add" ><i class="fa fa-plus"></i>&nbsp; 新增</a>
                        <button class="nav-btn nav-btn-refresh" data-toggle="tooltip" data-placement="left" onclick="sortOrRefresh()" title="刷新"><i class="glyphicon glyphicon-repeat"></i>&nbsp;刷新</button>
                    </c:if>
                    <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>
<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:'num',align:'center',minWidth:200,title: '内容编号', sort: true}
                ,{field:'name',align:'center',minWidth:200, title: '内容名称',templet:function(d){
                        var xml = "<a class=\"attention-info\" href=\"javascript:void(0)\" onclick=\"openDialogView('查看工作内容详情', '${ctx}/projectcontentinfo/projectcontentinfo/form?view=contentView&dictType=" + d.dictType +"&id="+ d.id + "&parentIds=" + d.pid + "&infoId=" + d.bid + "','95%','95%')\">" +
                            "<span title=" + d.name + ">" + d.name + "</span></a>";
                        return xml;
                    }}
                ,{field:'type',align:'center', title: '内容类型', width:150}
                ,{field:'master',align:'center', title: '负责人', width:150}
                ,{field:'createDate', align:'center',title: '创建日期', width:150, sort: true}
                ,{align:'center',title:"操作",width:180,templet:function(d){
                        ////对操作进行初始化
                        var xml = "";
                        if(d.canedit != undefined && d.canedit == "1")
                        {
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialogre('修改工作内容详情', '${ctx}/projectcontentinfo/projectcontentinfo/form?view=content&dictType="+ d.dictType + "&id=" + d.id + "&parentIds="+ d.pid + "&projectContentData.id=" + d.bid + "','95%','95%')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i> 修改</a>";
                            xml +="<a href=\"${ctx}/projectcontentinfo/projectcontentinfo/delete?infoId=" + d.bid + "&id=" + d.id + "&type=2\" onclick=\"return confirmxRefresh('确认要删除该工作内容详情吗？', this.href)\"   class=\"op-btn op-btn-delete\"><i class=\"fa fa-trash\"></i> 删除</a>";
                        }
                        return xml;
                    }}
            ]]
            ,data: [
                <c:if test="${ not empty page.list}">
                <c:forEach items="${page.list}" var="projectContentData" varStatus="index">
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "bid":"${projectContentData.id}"
                    ,"dictType":"${dictType}"
                    ,"id":"${id}"
                    ,"pid":"${parentIds}"
                    ,"num":"${projectContentData.number}"
                    ,"name":"<c:out value="${projectContentData.name}" escapeXml="true"/>"
                    ,"type":"${fns:getContentTypeName(projectContentData.type,"")}"
                    ,"master":"${projectContentData.master.name}"
                    ,"createDate":"<fmt:formatDate value="${projectContentData.createDate}" pattern="yyyy-MM-dd"/>"
                    <c:if test="${projectContentData.createBy.id eq fns:getUser().id && empty change}">,"canedit":"1"</c:if>
                }
                </c:forEach>
                </c:if>
            ]
            // ,even: true
            // ,height: 315
        });

    })

    resizeListTable();/*消除由于有竖向滚动条造成table出现横向滚动条*/
    $("a").on("click",addLinkVisied);
</script>
<script>
    resizeListWindow3();
    $(window).resize(function(){
        resizeListWindow3();
    });
    $("a").on("click",addLinkVisied);
</script>
</body>
</html>