<%@ 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() {
            laydate.render({
                elem: '#startDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
                ,type: 'datetime'
            });

            $('#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");
                }
            });
		});

	</script>
	<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%;
		}
		.layui-form-checked[lay-skin=primary] i{
			background-color: #0f92fb;
			border-color: #0f92fb;
		}
		.layui-form-checkbox[lay-skin=primary] i{
			border-radius: 0px;
		}
		.layui-form-checkbox[lay-skin=primary]:hover i{

			border-color: #0f92fb;
		}
	</style>
</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="activityAssignment" action="${ctx}/activityassignment/activityAssignment/" 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 with-icon">
							<sys:treeselect id="user" name="user.id" value="${activityAssignment.user.id}" labelName="user.name" labelValue="${activityAssignment.user.name}"
											title="用户" url="/sys/office/treeDataAll?type=3" cssClass="form-control layui-input" allowClear="true" notAllowSelectParent="true"/>
						</div>
					</div>
					<div class="layui-item query athird">
						<label class="layui-form-label">委托类型：</label>
						<div class="layui-input-block with-icon">
							<form:select path="type"  class="form-control simple-select">
								<form:option value="" label=""/>
								<form:options items="${fns:getDictList('assignmentType')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
							</form:select>
						</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;" class="">
					<div class="layui-item query athird">
						<label class="layui-form-label">委托时间：</label>
						<div class="layui-input-block">
							<input id="startDate" name="startDate" type="text" readonly="readonly" maxlength="20"  class="laydate-icondate form-control layer-date layui-input laydate-icon"
								   value="<fmt:formatDate value="${activityAssignment.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
						</div>
					</div>
					<div style="    clear:both;"></div>
				</div>
			</form:form>
			</div>
		</div>
		<div class="full-width fl">
			<div class="contentShadow layui-form contentDetails">
				<div class="nav-btns">
					<shiro:hasPermission name="activityassignment:activityAssignment:add">
						<table:addRow url="${ctx}/activityassignment/activityAssignment/form" title="工作流任务委托"></table:addRow><!-- 增加按钮 -->
					</shiro:hasPermission>
					<shiro:hasPermission name="activityassignment:activityAssignment:del">
						<button id="deleteRows" class="nav-btn nav-btn-delete"><i class="fa fa-trash-o"> 删除</i>
						</button>
						<%--<table:delRow url="${ctx}/activityassignment/activityAssignment/deleteAll" id="contentTable"></table:delRow><!-- 删除按钮 -->--%>
					</shiro:hasPermission>
					<shiro:hasPermission name="activityassignment:activityAssignment:import">
						<table:importExcel url="${ctx}/activityassignment/activityAssignment/import"></table:importExcel><!-- 导入按钮 -->
					</shiro:hasPermission>
					<shiro:hasPermission name="activityassignment:activityAssignment:export">
						<table:exportExcel url="${ctx}/activityassignment/activityAssignment/export"></table:exportExcel><!-- 导出按钮 -->
					</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" lay-filter="contentTableFilter"></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: [[
                {field:"id",type:'checkbox',align:'center' }
                ,{field:'createBy',align:'center', title: '创建人',templet:function(d){
                        var xml = "<a class=\"attention-info\" href=\"#\" onclick=\"openDialogView('查看工作流任务委托', '${ctx}/activityassignment/activityAssignment/form?id="+ d.id +"&view=view','95%', '95%')\">" +
                            d.createBy +
                            "</a>";
                        return xml;
                    }}
                ,{field:'name',align:'center', title: '被委托人',templet:function(d){
                        var xml = "<a class=\"attention-info\" href=\"#\" onclick=\"openDialogView('查看工作流任务委托', '${ctx}/activityassignment/activityAssignment/form?id="+ d.id +"&view=view','95%', '95%')\">" +
                            d.name +
                            "</a>";
                        return xml;
                    }}
                ,{field:'type',align:'center', title: '委托类型'}
                ,{field:'startDate',align:'center', title: '委托开始时间'}
                ,{field:'endDate', align:'center',title: '委托结束时间'}
                ,{field:'remarks', align:'center',title: '备注信息',templet:function(d){
                        return "<span title='"+ d.remarks +"'>" + d.remarks + "</span>";
                    }}
                ,{field:'op',align:'center',title:"操作",templet:function(d){
                        ////对操作进行初始化
                        var xml = "";

                        if(d.canedit != undefined && d.canedit == "1")
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialog('修改工作流任务委托', '${ctx}/activityassignment/activityAssignment/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}/activityassignment/activityAssignment/delete?id="+ d.id +"\" onclick=\"return confirmx('确认要删除该工作流任务委托吗？', 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="activityAssignment" varStatus="index">
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "id":"${activityAssignment.id}"
                    ,"createBy":"${activityAssignment.createBy.name}"
                    ,"name":"${activityAssignment.user.name}"
                    ,"type":"${fns:getDictLabel(activityAssignment.type, 'assignmentType', '')}"
                    ,"startDate":"<fmt:formatDate value="${activityAssignment.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                    ,"endDate":"<fmt:formatDate value="${activityAssignment.endDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
                    ,"remarks":"<c:out value="${activityAssignment.remarks}" escapeXml="true"/>"
					<shiro:hasPermission name="activityassignment:activityAssignment:edit">,"canedit":
						<c:if test="${fns:getUser().id == activityAssignment.createBy.id }">"1"</c:if>
                    	<c:if test="${fns:getUser().id != activityAssignment.createBy.id }">"0"</c:if>
					</shiro:hasPermission>
					<shiro:hasPermission name="activityassignment:activityAssignment:del">,"candel":
						<c:if test="${fns:getUser().id == activityAssignment.createBy.id }">"1"</c:if>
                   		 <c:if test="${fns:getUser().id != activityAssignment.createBy.id }">"0"</c:if>
					</shiro:hasPermission>
                }
                </c:forEach>
                </c:if>
            ]
        });
        function deleteAll(){
            var checkStatus = layui.table.checkStatus('contentTable');
            var data = checkStatus.data;
            var ids="";
            for(var i = 0; i < data.length;i++)
			{
			    if(i != 0)
				    ids += "," + data[i].id;
				else
				    ids += data[i].id;
			}

            if(ids == ""){
                top.layer.alert('请至少选择一条数据!', {icon: 0, title:'警告'});
                return;
            }
            top.layer.confirm('确认要彻底删除数据吗?', {icon: 3, title:'系统提示'}, function(index){
                window.location = "/a/activityassignment/activityAssignment/deleteAll?ids="+ids;
                top.layer.close(index);
            });
        }
        $('#deleteRows').on('click',deleteAll);
    })

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