<%@ page import="com.jeeplus.modules.sys.utils.UserUtils" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<%
	boolean admin = UserUtils.getUser().isAdmin();
%>
<html>
<head>
	<title>字典管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
		    var company="${mainDict.company}";
		    if(company!=null&&''!=company){
                $("#company").val(company);
			}
            //搜索框收放
            $('#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");
                }
            });
		});

        //打开对话框(查看)
        function openDialogView(title,url,width,height){
            var company=$("#company").val();
            if(company==null||''==company){
                top.layer.msg("非管理员用户不能自定义!", {icon: 5});
                return false;
			}
            url=url+"&company="+company;
            if(navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)){//如果是移动端，就使用自适应大小弹窗
                width='auto';
                height='auto';
            }else{//如果是PC端，根据用户设置的width和height显示。

            }
            top.layer.open({
                type: 2,
                skin: 'one-btn',
                area: [width, height],
                title: title,
                maxmin: true, //开启最大化最小化按钮
                content: url ,
                btn: ['关闭'],
                cancel: function(index){
                }
            });

        }
        function getChange(value){
            window.location="${ctx}/sys/mainDict/list?company="+value;

        }
	</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%;
		}
	</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="mainDict" action="${ctx}/sys/mainDict/" 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">
							<select id="company" name="company" onchange="getChange(this.value)" class=" form-control  simple-select">
							<c:if test="${ not empty list}">
								<c:forEach items="${list}" var="role" varStatus="index">
									<option value="${role.office.id}"/>${role.office.name}</option>
								</c:forEach>
							</c:if>
							</select>
						</div>
					</div>
				<%--	<div class="layui-item query athird ">
						<label class="layui-form-label">定义方式：</label>
						<div class="layui-input-block">
							<form:select path="dictType" class=" form-control  simple-select">
								<form:option value="" label=""/>
								<form:options items="${fns:getDictList('main_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
							</form:select>
						</div>
					</div>--%>
					<div class="layui-item query athird">
						<label class="layui-form-label">类型名称：</label>
						<div class="layui-input-block">
							<form:input path="name" htmlEscape="false"    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">
							<form:input path="typeName" htmlEscape="false"    class="form-control layui-input"/>
						</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">
					<c:if test="<%=admin%>">
							<table:addRow url="${ctx}/sys/mainDict/form" title="字典类型"></table:addRow><!-- 增加按钮 -->
					</c:if>
					<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 id="contentTable" class="table table-striped table-bordered table-hover table-condensed dataTables-example dataTable">
					<thead>
						<tr>
							<th width="40"> <input type="checkbox" class="i-checks"></th>
							<th  class="sort-column typeName">类型</th>
							<th  class="sort-column name">类型名称</th>
							<th  class=" mainType">定义方式</th>
							<th  class="sort-column typeSort">类型排序</th>
							<th  class="sort-column remarks">类型描述</th>
							<th width="270">操作</th>
						</tr>
					</thead>
					<tbody>
					<c:forEach items="${page.list}" var="mainDict">
						<tr>
							<td> <input type="checkbox" id="${mainDict.id}" class="i-checks"></td>

							<td>
								<a class="attention-info" href="#" onclick="openDialogView('查看字典', '${ctx}/sys/mainDict/form?id=${mainDict.id}&view=view','95%', '95%')">
								${mainDict.typeName}
							</td>
							<td>

								${mainDict.name}
								</a>
							</td>
							<td>
								${fns:getDictLabel(mainDict.dictType, 'main_type', '')}
							</td>
							<td>
								${mainDict.typeSort}
							</td>
							<td>
								${mainDict.remarks}
							</td>
							<td class="op-td text-center">
								<div class="op-btn-box">
								<a href="#" onclick="openDialogView('字典明细', '${ctx}/sys/mainDict/form?id=${mainDict.id}&view=2','95%', '95%')"   class="op-btn op-btn-submit"><i class="fa fa-edit"></i> 自定义</a>
									<c:if test="<%=admin%>">
										<shiro:hasPermission name="sys:mainDict:edit">
											<a href="#" onclick="openDialog('修改字典', '${ctx}/sys/mainDict/form?id=${mainDict.id}','95%', '95%')" class="op-btn op-btn-edit" ><i class="fa fa-edit"></i> 修改</a>
										</shiro:hasPermission>
										<shiro:hasPermission name="sys:mainDict:del">
											<a href="${ctx}/sys/mainDict/delete?id=${mainDict.id}" onclick="return confirmx('确认要删除该字典吗？', this.href)"   class="op-btn op-btn-delete"><i class="fa fa-trash"></i> 删除</a>
										</shiro:hasPermission>
									</c:if>
								<shiro:hasPermission name="sys:mainDict:view">
									<a href="#" onclick="openDialogView('默认字典', '${ctx}/sys/mainDict/form?id=${mainDict.id}&view=1','95%', '95%')" class="op-btn op-btn-revert" ><i class="fa fa-search-plus"></i> 默认字典</a>
								</shiro:hasPermission>
								</div>
							</td>
						</tr>
					</c:forEach>
					</tbody>
				</table>

					<!-- 分页代码 -->
				<table:page page="${page}"></table:page>
				<div style="clear: both;"></div>
			</div>
		</div>
	</div>
</div>
<script>
    $("a").on("click",addLinkVisied);

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