<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>岗位管理</title>
	<meta name="decorator" content="default"/>
	<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">
        // 确认对话框
        function confirmx(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.success){
                                parent.layer.msg(data.msg,{icon:1});
                            }else {
                                parent.layer.msg(data.msg,{icon:2});
                            }
                            parent.refreshTree();
                            location = "${ctx}/sys/role/list";
                        }
                    });
                }
                top.layer.close(index);
            });
            return false;
        }
	</script>
</head>
<body>
<div class="wrapper wrapper-content">
	<sys:message content="${message}"/>
	<div class="layui-row">
		<div class="full-width fl">
			<div class="contentShadow shadowB layui-row" id="queryDiv">
				<form:form id="searchForm" modelAttribute="role" action="${ctx}/sys/role/list" 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">
								<form:input path="name" value="${role.name}"  htmlEscape="false" maxlength="64"  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>
				</form:form>
			</div>
		</div>

		<div class="contentShadow shadowT full-width fl">
			<div class="layui-form contentDetails">
				<div class="nav-btns">
					<shiro:hasPermission name="sys:role:add">
						<table:addRow url="${ctx}/sys/role/form?office=" title="岗位"></table:addRow><!-- 增加按钮 -->
					</shiro:hasPermission>
					<%--<shiro:hasPermission name="sys:role:edit">
						<table:editRow url="${ctx}/sys/role/form" id="contentTable"  title="岗位"></table:editRow><!-- 编辑按钮 -->
					</shiro:hasPermission>--%>
					<%--<shiro:hasPermission name="sys:role:del">
						<table:delRow url="${ctx}/sys/role/deleteAll" id="contentTable"></table:delRow><!-- 删除按钮 -->
					</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>
<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',  width:40,title: '序号'}
                ,{field:'number',align:'center', title: '岗位编码', width:80,templet:function(d){
                        var xml = "<a class=\"attention-info\" href=\"javascript:void(0)\" onclick=\"openDialogView('查看岗位', '${ctx}/sys/role/form?id=" + d.id + "&office.id=" + d.officeId + "&office.name=" + encodeURI(d.office) + "&view=view','95%','95%')\">" +
                            "<span title=" + d.number + ">" + d.number + "</span></a>";
                        return xml;
                    }}
                ,{field:'name',align:'center', title: '岗位名称', minWidth:100,templet:function(d){
                        return "<span title='"+ d.name +"'>" + d.name + "</span>";
                    }}
                ,{field:'company', align:'center',title: '归属公司', minWidth :80,templet:function(d){
                        return "<span title='"+ d.company +"'>" + d.company + "</span>";
                    }}
                ,{field:'office', align:'center',title: '归属部门', minWidth:80,templet:function(d){
                        return "<span title='"+ d.office +"'>" + d.office + "</span>";
                    }}
                ,{field:'dataScope', align:'center',title: '数据范围',width:160}
                ,{field:'op',align:'center',title:"操作",width:200,templet:function(d){
                        ////对操作进行初始化
                        var xml = "";
                        if(d.candelete1 != undefined && d.candelete1 == "1")
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialog('修改岗位', '${ctx}/sys/role/form?id="+ d.id + "&office="+ d.officeId+"','95%','95%')\" class=\"op-btn op-btn-edit\" ><i class=\"fa fa-edit\"></i> 修改</a>";
                        if(d.candelete2 != undefined && d.candelete2 == "1")
                            xml +="<a href=\"${ctx}/sys/role/deleteAlls?ids=" + d.id + "\" onclick=\"return confirmx('确认要删除该岗位吗？', this.href)\"   class=\"op-btn op-btn-delete\"><i class=\"fa fa-trash\"></i> 删除</a>";
                        if(d.candelete3 != undefined && d.candelete3 == "1")
                            /*xml +="<a href=\"javascript:void(0)\" onclick=\"openDialog('权限设置', '${ctx}/sys/role/auth?id="+ d.id + "&office="+ d.officeId+"','350px','500px')\" class=\"op-btn op-btn-submit\" ><i class=\"fa fa-edit\"></i> 权限设置</a>";
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialogView('分配用户', '${ctx}/sys/role/assign?id="+ d.id + "&office="+ d.officeId+"&office.name="+encodeURI(d.office)+"','95%','95%')\" class=\"op-btn  op-btn-add\" ><i class=\"glyphicon glyphicon-plus\"></i> 分配用户</a>";
                       		 if(d.candelete4 != undefined && d.candelete4 == "1")
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialog('关联工作流角色', '${ctx}/sys/role/form?id="+ d.id + "&view=copy&office="+ d.officeId+"&office.name="+encodeURI(d.office)+"','80%','500px')\" class=\"op-btn op-btn-revert\" ><i class=\"fa fa-refresh\"></i> 关联角色</a>";
                        */
                            xml +="<a href=\"javascript:void(0)\" onclick=\"openDialogView('分配用户', '${ctx}/sys/role/assign?id="+ d.id + "&office="+ d.officeId+"&office.name="+encodeURI(d.office)+"','95%','95%')\" class=\"op-btn  op-btn-add\" ><i class=\"glyphicon glyphicon-plus\"></i> 分配用户</a>";

                        return xml;
                    }}
            ]]
            ,data: [
                <c:if test="${ not empty page.list}">
                <c:forEach items="${page.list}" var="role" varStatus="index">
                <c:if test="${index.index != 0}">,</c:if>
                {
                    "index":"${index.index+1}"
                    ,"id":"${role.id}"
                    ,"number":"${role.number}"
                    ,"name":"${role.name}"
                    ,"company":"${role.company.name}"
                    ,"office":"${role.office.topCompany}"
                    ,"officeId":"${role.office.id}"
                    ,"dataScope":"${fns:getDictLabel(role.dataScope, 'sys_data_scope', '无')}"
                    <shiro:hasPermission name="sys:role:edit">
                    ,"candelete1":"1"
                    </shiro:hasPermission>
                    <shiro:hasPermission name="sys:role:del">
                    ,"candelete2":"1"
                    </shiro:hasPermission>
                    <shiro:hasPermission name="sys:role:assign">
                    ,"candelete3":"1"
                    </shiro:hasPermission>
                    <c:if test="${fns:getUser().comId ne '1'}">
                    ,"candelete4":"1"
                    </c:if>

                }
                </c:forEach>
                </c:if>
            ]
            // ,even: true
            // ,height: 315
        });
    })
    resizeListTable();
</script>
<script>
    $("a").on("click",addLinkVisied);
    resizeListWindow3();
    $(window).resize(function(){
        resizeListWindow3();
    });
</script>
</body>
</html>