<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>假期类型字典管理</title>
	<meta name="decorator" content="default"/>
	<%@include file="/webpage/include/treetable.jsp" %>
	<script type="text/javascript">
        $(document).ready(function() {
            $("#treeTable").treeTable({expandLevel : 2},{ expandable: true });
        });
	</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="leaveType" action="${ctx}/leavetype/leaveType/" method="post" class="form-inline">
					<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" htmlEscape="false" class=" form-control layui-input"></form:input>
							</div>
						</div>
						<div class="layui-item query athird">
							<label class="layui-form-label">假期编号：</label>
							<div class="layui-input-block with-icon">
								<form:input path="no" htmlEscape="false" class=" form-control layui-input number"></form:input>
							</div>
						</div>
						<div class="layui-item athird">
							<div class="input-group">
								<button id="searchReset" style="margin-right: 10px;" 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>

				</form:form>
			</div>
		</div>
		<div class="full-width fl">
			<div class="contentShadow layui-form contentDetails">
				<div class="nav-btns">
					<shiro:hasPermission name="leavetype:leaveType:add">
						<a href="javascript:void(0)" onclick="openDialogAdd('新增请假类型', '${ctx}/leavetype/leaveType/form?tabId=1','95%','95%')" class="nav-btn nav-btn-add" ><i class="fa fa-plus"></i>&nbsp;添加</a>
					</shiro:hasPermission>
					<button class="nav-btn nav-btn-import" onclick="openDialogSys('系统默认类型', '${ctx}/leavetype/leaveType/sysList','95%','95%')"  ><i class="glyphicon glyphicon-v"></i>&nbsp;同步系统预制</button>
					<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="treeTable" class="table table-bordered table-hover list-table">
					<thead>
					<tr>
						<th width="15%">假期编号</th>
						<th  width="15%">假期名称</th>
						<th  width="10%">计假模式</th>
						<th  >计假单位</th>
						<th  >累计方式</th>
						<th  >是否计算出勤</th>
						<th  >是否计算补助</th>
						<th  width="6%">状态</th>
						<th width="150px">操作</th>
					</tr>
					</thead>
					<c:choose>
						<c:when test="${not empty list}">
							<c:forEach items="${list}" var="leaveType">
								<tr id="${leaveType.id}" pid="${leaveType.parentId}">
									<td><a  href="#" onclick="openDialogView('查看指标项目', '${ctx}/leavetype/leaveType/form?id=${leaveType.id}&view=view','95%', '95%')">
											${leaveType.no}
									</a></td>
									<td style="text-align: center">
											${leaveType.name}
									</td>
									<td style="text-align: center">
											${fns:getDictLabel(leaveType.model, 'fake_model', '')}
									</td>
									<td style="text-align: center">
											${fns:getDictLabel(leaveType.unit, 'false_unit', '')}
									</td>
									<td style="text-align: center">
											${fns:getDictLabel(leaveType.method, 'cumulative_way', '')}
									</td>
									<td style="text-align: center">
											${fns:getDictLabel(leaveType.isAttendance, 'yes_no', '')}
									</td>
									<td style="text-align: center">
											${fns:getDictLabel(leaveType.isSubsidized, 'yes_no', '')}
									</td>
									<td style="text-align: center">
											${fns:getDictLabel(leaveType.state, 'is_disable', '')}
									</td>
									<td class="op-td text-center">
										<div class="op-btn-box">
											<a href="javascript:void(0);" onclick="openDialog('修改', '${ctx}/leavetype/leaveType/form?id=${leaveType.id}&view=edit','95%','95%')" class="op-btn op-btn-edit"><i class="fa fa-edit"></i> 修改</a>
											<c:choose>
												<c:when test="${leaveType.state eq 1}">
													<a href="${ctx}/leavetype/leaveType/updateDelFlag?id=${leaveType.id}&flat=0" onclick="return confirmx('确认要启用该请假类型吗？', this.href)"   class="op-btn op-btn-delete"><i class="fa fa-trash"></i> 启用</a>
												</c:when>
												<c:otherwise>
													<a href="${ctx}/leavetype/leaveType/updateDelFlag?id=${leaveType.id}&flat=1" onclick="return confirmx('确认要禁用该请假类型吗？', this.href)"   class="op-btn op-btn-delete"><i class="fa fa-trash"></i> 禁用</a>
												</c:otherwise>
											</c:choose>
										</div>
									</td>
								</tr>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<tr>
								<td colspan="9" align="center">暂无数据</td>
							</tr>
						</c:otherwise>
					</c:choose>

					</tbody>
				</table>

				<!-- 分页代码 -->
				<%--<table:page page="${page}"></table:page>--%>

			</div>
		</div>
	</div>
</div>
<script>
    resizeListWindow1();
    $(window).resize(function(){
        resizeListWindow1();
    });
    //打开对话框(添加修改)
    function openDialogAdd(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,
            maxmin: true, //开启最大化最小化按钮
            content: url ,
            skin: 'two-btns',
            btn: ['提交', '关闭'],
            yes: 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() ){
                    // top.layer.close(index);//关闭对话框。
                    setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                }

            },
            cancel: function(index){
            }
        });

    }
    function openDialogSys(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: 'two-btns',
            maxmin: true, //开启最大化最小化按钮
            content: url ,
            btn: ['同步系统预制','关闭'],
            yes: function(index, layero){
             $.ajax({
                type:'post',
                url:'${ctx}/leavetype/leaveType/syncDict',
					success:function(data){
                        if(data.flag){
                            parent.layer.msg("同步成功",{icon:1});
                        }else{
                            parent.layer.msg("同步失败或者已经同步",{icon:1});
                        }
            }
        })
                setTimeout(function(){top.layer.close(index)}, 100);//延时0.1秒，对应360 7.1版本bug
                sortOrRefresh();
              // window.location.href='${ctx}/leavetype/leaveType/syncDict';

            }

        });
    }
</script>
</body>
</html>