<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<!-- bootstrap 3.0.2 -->
<link href="<c:url value='/styles/lib/bootstrap.min.css'/>" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="<c:url value='/styles/lib/font-awesome.min.css'/>" rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href='<c:url value='/styles/lib/ionicons.min.css' />' rel="stylesheet" type="text/css" />
<!-- DATA TABLES -->
<link href="<c:url value='/styles/lib/datatables/dataTables.bootstrap.css' />" rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="<c:url value='/styles/AdminLTE.css'/>" rel="stylesheet" type="text/css" />
<!-- date -->
<script src="${ctx }/scripts/lib/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
	$(document).ready(function () {
		function fn(selector, container) {
			$(selector).click(function () {
				var stats = $(this).prop('checked') || false;
				$(container).each(function (idx, item) {
					$(item).prop('checked', stats);
				});
			});

			$(container).click(function () {
				var chklen = $(container).filter(function (idx, el) {
					if ($(el).prop('checked')) {
						return el;
					}
				}).length;
				var chkStats = $(container).length === chklen;
				$(selector).prop('checked', chkStats);
			});
		};
		fn("#checkAll", "input[name='chkBtn']");
		$("#backBtn").click(function () {
			location.href = '<c:url value='/system/elementgroup?funcid=19'/>';
		});
		$("#backBtn2").click(function () {
			location.href = '<c:url value='/system/elementgroup?funcid=19 '/>';
		});
		$("#delBtn").click(function () {
			var chk = $("input:checked[name='chkBtn']");
			var flag = false;
			for (var i = 0; i < chk.length; i++) {
				if (chk[i].checked) {
					flag = true;
					break;
				}
			}
			if (flag) {
				if (confirm('<fmt:message key='button.delete'/>?')) {
					var delid = new Array();
					$.each($("input:checked[name='chkBtn']"), function (i, val) {
						delid[i] = val.value;
					});
					$.ajax({
						type: "post",
						url: '<c:url value="/system/elementgroup/deleteElement"></c:url>',
						data: {
							id: delid
						},
						traditional: true,
						success: function (data, textStatus) {
							alert("删除成功！");
							window.location.href = "<c:url value='/system/elementgroup?funcid=19'></c:url>";
						},
						error: function () {
							//请求出错处理
							alert("删除失败！")
						}
					});
				}
			} else {
				alert('请选择记录');
				return flag;
			}
		});
	});


	//翻页
	function goPage(pageNo) {
		$("#pageNo").val(pageNo);
		$("#conditionform").submit();
	}
</script>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<style type="text/css">
		th {
			text-align: center;
		}

		td {
			text-align: center;
			vertical-align: middle;
		}
	</style>
</head>

<body>
	<section class="content">
		<div class="row">
			<div class="col-xs-12">
				<div class="box">
					<!-- /.box-header -->
					<div class="box-body table-responsive">
						<form:form modelAttribute="elementGroup" action="${ctx}/system/elementgroup/saveElementGroup" method="POST">
							<input type="hidden" name="id" value="${elementGroup.id}">
							<div class="form-group">
								<label>所属功能</label>
								<select name="itemId" class="func_belong" style="width: 200px;">
									<c:forEach items="${funcList}" var="func">
										<option value="${func.id }" <c:if test="${func.id eq elementGroup.itemId}">selected="selected"</c:if>>${func.itemname}</option>
									</c:forEach>
								</select>
							</div>
							<div class="form-group">
								<label>项目可自定义</label>
								<label><input style="position: relative;top: 10px;" name="isOrgCustom" type="radio" value="1" <c:if test="${ elementGroup.isOrgCustom == '1' }"> checked="checked" </c:if>/> &nbsp;是 </label>
								<label><input style="position: relative;top: 10px;" name="isOrgCustom" type="radio" value="0" <c:if test="${ elementGroup.isOrgCustom == '0' }"> checked="checked" </c:if>/> &nbsp;否 </label>
							</div>
							<div class="form-group">
								<label>组名</label> <input name="groupcode" value="${elementGroup.groupcode }" /> <label>组名备注</label> <input name="groupname"
								 value="${elementGroup.groupname }" />
								<!--  type="submit" -->
							</div>
							<div align="left" style="margin-bottom: 8px;">
								<button type="submit" class="btn btn-primary">保存</button>
								&nbsp;
								<button type="button" class="btn btn-back" id="backBtn">返回</button>
							</div>
						</form:form>
						<!-- ---------------数据字典form end -->

						<form:form modelAttribute="element" action="${ctx}/system/elementgroup/saveElement" method="POST" id="conditionform">
							<input type="hidden" name="pageNo" id="pageNo" />
							<input type="hidden" name="elementGroup.id" value="${elementGroup.id }" />
							<div class="form-group">
								<label>成员代码</label> <input name="itemcode" value="${element.itemcode }" /> <label>成员名称</label> <input name="itemname"
								 value="${element.itemname }" /> <label>排序号</label>
								<input name="orderno" value="${element.orderno }" />
								<!--  type="submit" -->
							</div>
							<div align="left" style="margin-bottom: 8px;">
								<button type="submit" class="btn btn-primary">保存</button>
								&nbsp;
								<button type="button" class="btn btn-back" id="backBtn2">返回</button>
								<button type="button" class="btn btn-danger" id="delBtn">删除</button>
							</div>
						</form:form>
						<!-- ---------------详细信息form end -->

						<table class="table table-bordered table-hover" id="dataareaid">
							<thead>
								<tr>
									<th><input type="checkbox" id="checkAll">
										</td>
									<th>成员代码
										</td>
									<th>成员名称
										</td>
									<th>排序号
										</td>
									<th>操作
										</td>
								</tr>
							</thead>
							<c:forEach items="${page.items }" var="obj">
								<tr>
									<td><input type="checkbox" name="chkBtn" value="${obj.id }"></td>
									<td>${obj.itemcode}</td>
									<td>${obj.itemname }</td>
									<td>${obj.orderno }</td>
									<td><a href="<c:url value='/system/elementgroup/elementModify?id=${obj.id }'/>">编辑</a></td>
								</tr>
							</c:forEach>
						</table>
						<div align="center">
							<c:forEach items="${page.iterPages }" var="pageNo">
								<c:choose>
									<c:when test="${pageNo == page.currentPage }">
										<span class='current'>${pageNo }</span>
									</c:when>
									<c:when test="${pageNo != null}">
										<a href="javascript:goPage('${pageNo}')">${pageNo}</a>
									</c:when>
									<c:otherwise>
										...
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</body>

</html>