<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>日常事务管理</title>
	<meta name="decorator" content="default"/>
    <style>
        .widthClass{
            display: inline-block;
        }
        .shows .input-group{
            width: 48%!important;
        }
    </style>
    <style>
        body{
            background-color:transparent;
            filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#26FFFFFF, endColorstr=#26FFFFFF);
            color:#ffffff;
            background-color:rgba(255,255,255,0);
            height:100%;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#cus_name").show();
            $("#cus_name").siblings().hide();
            //搜索框收放
            $('#moresee').click(function(){
                if($('#moresees').is(':visible'))
                {
                    $('#moresees').slideUp(0,resizeListWindow1);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-up").addClass("glyphicon glyphicon-menu-down");
                }else{
                    $('#moresees').slideDown(0,resizeListWindow1);
                    $('#moresee i').removeClass("glyphicon glyphicon-menu-down").addClass("glyphicon glyphicon-menu-up");
                }
            });
            laydate.render({
                elem: '#beginCreateDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus', //响应事件。如果没有传入event，则按照默认的click
                type : 'date'
            });
            laydate.render({
                elem: '#endCreateDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus', //响应事件。如果没有传入event，则按照默认的click
                type : 'date'
            });
        });
	</script>
</head>
<body>
<div class="wrapper wrapper-content">
    <sys:message content="${message}"/>
    <div class="layui-row">
        <div class="full-width fl">
            <div class="contentShadow layui-row" id="queryDiv">
                <form:form id="searchForm" modelAttribute="workDailyRoutine" action="${ctx}/workdailyroutine/workDailyRoutine/" 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">
                        <div class="layui-item query athird">
                            <label class="layui-form-label">事务名称：</label>
                            <div class="layui-input-block">
                                <form:input path="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="createBy.name" htmlEscape="false" maxlength="64"  class=" form-control layui-input"/>
                            </div>
                        </div>
                        <div class="layui-item athird">
                            <div class="input-group">
                                <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>
                            </div>
                        </div>
                        <div style="    clear:both;"></div>
                    </div>
                    <div id="moresees" style="clear:both;display:none;">
                        <div class="layui-item query athird">
                            <label class="layui-form-label">创建时间：</label>
                            <div class="layui-input-block with-icon">
                                <input id="beginCreateDate" name="beginCreateDate" type="text" readonly="readonly" maxlength="20" placeholder="开始时间" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
                                       value="<fmt:formatDate value="${workDailyRoutine.beginCreateDate}" pattern="yyyy-MM-dd"/>"/>
                                </input>
                                <span class="group-sep">-</span>
                                <input id="endCreateDate" name="endCreateDate" type="text" readonly="readonly" maxlength="20" placeholder="结束时间" class="laydate-icondate form-control layer-date layui-input laydate-icon query-group"
                                       value="<fmt:formatDate value="${workDailyRoutine.endCreateDate}" pattern="yyyy-MM-dd"/>"/>
                                </input>
                            </div>
                        </div>
                        <div class="layui-item query athird">
                            <label class="layui-form-label">事务来源：</label>
                            <div class="layui-input-block">
                                <form:input path="source" htmlEscape="false" maxlength="10"  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:select path="status" class=" form-control simple-select">
                                    <form:option value="" label=""/>
                                    <form:option value="未完成" label="未完成"/>
                                    <form:option value="已完成" label="已完成"/>
                                    <form:option value="已关闭" label="已关闭"/>
                                </form:select>
                            </div>
                        </div>
                        <div class="layui-item query athird">
                            <label class="layui-form-label">收到/发出：</label>
                            <div class="layui-input-block">
                                <form:select path="sOr" class=" form-control simple-select">
                                    <form:option value="" label=""/>
                                    <form:option value="发出" label="发出"/>
                                    <form:option value="收到" label="收到"/>
                                </form:select>
                            </div>
                        </div>
                    </div>
            </form:form>
        </div>
	    </div>
	
	<!-- 工具栏 -->
        <div class="full-width fl">
            <div class="contentShadow layui-form contentDetails">
                <div class="nav-btns">
                    <shiro:hasPermission name="workdailyroutine:workDailyRoutine:add">
                        <table:addRow url="${ctx}/workdailyroutine/workDailyRoutine/form" title="日常事务"></table:addRow><!-- 增加按钮 -->
                    </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>
    <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: [[
                    {field:'index',align:'center', title: '序号',width:40}
                    ,{field:'name',align:'center', title: '事务名称',minWidth:200,templet:function(d){
                            var xml = '';
                            if(d.sOr != undefined && d.sOr == "收到"){
                            xml = "<a class=\"attention-info\" href=\"javascript:void(0);\" onclick=\"openDialogView('查看事务', '${ctx}/workdailyroutine/workDailyRoutine/detailView?id="+d.id+"','95%','95%')\">" +
                                "<span title=" + d.name + ">" + d.name + "</span></a>";
                            }else {
                                xml = "<a class=\"attention-info\" href=\"javascript:void(0);\" onclick=\"openDialogView('查看事务', '${ctx}/workdailyroutine/workDailyRoutine/view?id="+d.id+"','95%','95%')\">" +
                                    "<span title=" + d.name + ">" + d.name + "</span></a>";
                            }
                            return xml;
                        }}
                    ,{field:'source',align:'center', title: '事务来源',minWidth:120}
                    ,{field:'createBy',align:'center', title: '创建人',width:120}
                    ,{field:'createDate', align:'center',sort:true,title: '创建时间',minWidth:150}
                    ,{field:'status',align:'center', title: '事务状态', width:100}
                    ,{field:'sOr',align:'center', title: '收到/发出', width:100}
                    ,{field:'op',align:'center',title:"操作",width:130,templet:function(d){
                            ////对操作进行初始化
                            var xml = "";
                            if(d.canedit != undefined && d.canedit == "1" && d.sOr != '收到'){
                                xml +="<a href=\"${ctx}/workdailyroutine/workDailyRoutine/close?id=" + d.id+"\" onclick=\"return confirmx('确认要关闭该日常事务吗？', this.href)\"   class=\"op-btn op-btn-delete\"><i class=\"fa fa-trash\"></i> 关闭</a>";
                            }
                            if(d.sOr != undefined && d.sOr == "收到" && d.status =='未完成' && d.subStatus =='未完成'){
                                xml+="<a href=\"#\" onclick=\"openDialog('日常事务', '${ctx}/workdailyroutine/workDailyRoutine/detailForm?id=" + d.id + "','95%', '95%','','提交,关闭')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i> 办理</a>";
                            }
                            return xml;
                        }}
                ]]
                ,data: [
                    <c:if test="${ not empty page.list}">
                    <c:forEach items="${page.list}" var="workDailyRoutine" varStatus="index">
                    <c:if test="${index.index != 0}">,</c:if>
                    {
                        "index":"${index.index+1}"
                        ,"id":"${workDailyRoutine.id}"
                        ,"name":"<c:out value="${workDailyRoutine.name}" escapeXml="true"/>"
                        ,'source':"${workDailyRoutine.source}"
                        ,'createBy':"${workDailyRoutine.createBy.name}"
                        ,"createDate":"<fmt:formatDate value="${workDailyRoutine.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                        ,"sOr":"${workDailyRoutine.sOr}"
                        ,"status":"${workDailyRoutine.status}"
                        ,"subStatus":"${workDailyRoutine.subStatus}"
                        <c:if test="${flag == '1' or fns:getUser().id == workDailyRoutine.createBy.id}">
                        <shiro:hasPermission name="workdailyroutine:workDailyRoutine:edit">
                        ,"canedit":<c:choose><c:when test="${workDailyRoutine.status eq '未完成'}">"1"</c:when><c:otherwise>"0"</c:otherwise></c:choose>
                        </shiro:hasPermission>
                        </c:if>
                    }
                    </c:forEach>
                    </c:if>
                ]
            });

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