<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = path + "/common/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="<%=basePath %>admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>admin/css/style.css" rel="stylesheet" type="text/css" />
<link href="<%=basePath %>admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 微信管理 <span class="c-gray en">&gt;</span> 关键字列表 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<div class="text-c">
	<form action="${pageContext.request.contextPath }/admin/wx/showKeyWordList" method="post" id="searchForm">
		<input type="text" class="input-text" style="width:250px" placeholder="输入关键词" id="word" name="word" value="${word }">
		<button type="button" class="btn btn-success" id="searchWordButton" name=""><i class="Hui-iconfont">&#xe665;</i> 搜关键字</button>
	</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" id="batchDelKeyWordButton" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;" onclick="location.href='${pageContext.request.contextPath}/admin/wx/showEditKeyWordAnswer'" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加关键字</a></span></div>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="9">关键字列表</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" id="allCheck" value=""></th>
				<th width="40">编号</th>
				<th width="80">关键字</th>
				<th width="150">回复内容</th>
				<th width="40">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:if test="${!empty klist }">
				<form action="" method="post" id="checkBoxForm">
					<c:forEach items="${klist }" var="keyword" varStatus="count">
						<tr class="text-c">
							<td><input type="checkbox" value="${keyword.keyServiceNoMd5 }" name="" class="oneCheckBox"></td>
							<td>${(pageNO-1)*pageCount+(count.index+1) }</td>
							<td>${keyword.keyWord }</td>
							<td>
								<c:choose>
									<c:when test="${keyword.reType == 1 }">
										${keyword.refText }
									</c:when>
									<c:when test="${keyword.reType == 2 }">
										图文
									</c:when>
								</c:choose>
							</td>
							<td class="td-manage"> <a title="编辑" href="${pageContext.request.contextPath }/admin/wx/showUpdateImageText/${keyword.keyServiceNoMd5 }" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a> <a title="删除" href="javascript:;" onclick="keyWord_del(this,'${keyword.keyServiceNoMd5 }')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
						</tr>
					</c:forEach>
				</form>
			</c:if>
			<c:if test="${empty klist }">
				<tr class="text-c"><td colspan="5">暂没有相关数据!</td></tr>
			</c:if>
		</tbody>
	</table>
	<div align="right" class="mt-10 mb-10 mr-10">
		<%@include file="/common/other/paper/pager.jsp"%>
  	</div>
</div>
<script type="text/javascript" src="<%=basePath %>admin/lib/jquery/1.9.1/jquery.min.js"></script>  
<script type="text/javascript" src="<%=basePath %>admin/lib/layer/1.9.3/layer.js"></script> 
<script type="text/javascript" src="<%=basePath %>admin/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript" src="<%=basePath %>admin/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="<%=basePath %>admin/js/H-ui.js"></script> 
<script type="text/javascript" src="<%=basePath %>admin/js/H-ui.admin.js"></script> 
<script type="text/javascript">
$(function() {
	//关键字搜索
	$("#searchWordButton").click(function() {
		var word = $("#word").val();
		if(word != "" && word != null) {
			var url = $("#searchForm").attr("action");
			$("#searchForm").attr("action", url).submit();
		} else {
			layer.msg('搜索内容不能为空!',{icon:5,time:1000});
		}
	});
	
	//批量删除
	$("#batchDelKeyWordButton").click(function() {
		var json = [];
		$(".oneCheckBox").each(function() {
			if($(this).is(":checked") == true) {
				  json.push($(this).val());
			}
		})
		if(json.length < 1) {
			layer.msg('请选择删除的内容!',{icon:5,time:1000});
		} else {
			var url = "${pageContext.request.contextPath}/admin/wx/batchDelKeyWord";
			var reqJSON = {"delJSON":JSON.stringify(json)};
			$.post(url, reqJSON, function(result) {
				if(result.msg == "success") {
					layer.msg('删除成功!',{icon:6,time:2000});
					window.location.reload();
				} else {
					layer.msg(result.msg,{icon:5,time:2000});
				}
			});
		}
	});
	
	//单个复选框的控制
	$(".oneCheckBox").change(function() {
		$(".oneCheckBox").each(function() {
			//alert($(this).is(":checked"));
			if($(this).is(":checked") == false) {
				  $("#allCheck").attr("checked", false);
			}
		})
	});
});

</script>
<script type="text/javascript">
/*
	参数解释：
	title	标题
	url		请求的url
	id		需要操作的数据id
	w		弹出层宽度（缺省调默认值）
	h		弹出层高度（缺省调默认值）
*/

/*关键字-删除*/
function keyWord_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		if(id != "" && id != null) {
			var url = "${pageContext.request.contextPath}/admin/wx/delKeyWord/"+id;
			$.post(url, {"time":new Date()}, function(result) {
				if(result.msg == "success") {
					//$(obj).parents("tr").remove();
					layer.msg('删除成功!',{icon:6,time:2000});
					window.location.reload();
				} else {
					layer.msg(result.msg,{icon:5,time:2000});
				}
			})
		} else {
			layer.msg('删除失败!',{icon:5,time:1000});
		}
		//$(obj).parents("tr").remove();
	});
}


</script>
</body>
</html>