审计记录

WebContent/WEB-INF/jsp/pc/autoresponse/autoresponse.jsp 8.5 KB
zxt@theyeasy.com committed
1 2 3 4 5 6 7 8
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!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="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
9
		<title>自动回复</title>
zxt@theyeasy.com committed
10 11 12 13
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/Layuiglobal.css">
		<link rel="stylesheet" href="/zzhnc/res/plugins/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="http://at.alicdn.com/t/font_191348_aee57zbh6jyk3xr.css">
14
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
zxt@theyeasy.com committed
15
	</head>
16

zxt@theyeasy.com committed
17 18 19
	<body class="wrap">
		<div class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
20
				<div class="layui-input-inline" style="width: 200px;">
zxt@theyeasy.com committed
21 22
					<input type="text" class="layui-input" name="keyword" placeholder="关键字" />
				</div>
23 24
				<button class="layui-btn" lay-submit lay-filter="querybtn">查询</button>
				<button class="layui-btn layui-btn-primary resetBtn">重置</button>
zxt@theyeasy.com committed
25 26 27 28 29 30 31 32 33 34 35 36 37
				<a class="layui-btn layui-btn-warm createBtn" href="#"><i class="layui-icon">&#xe61f;</i> 添加关键字</a>
				<a class="layui-btn publicBtn" href="#"><i class="layui-icon">&#xe609;</i> 发布</a>
			</div>
		</div>
		<table class="layui-table">
			<thead>
				<tr>
					<th style="width: 30px;">No</th>
					<th style="min-width:120px;">关键字</th>
					<th style="min-width:140px;">回复内容</th>
					<th style="min-width:80px;">操作</th>
				</tr>
			</thead>
38

zxt@theyeasy.com committed
39 40 41
			<tbody id="tablelist">
			</tbody>
		</table>
42
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
43
		<div id="page"></div>
44

zxt@theyeasy.com committed
45 46
	</body>
	<div class="popupbox" style="display:none;">
47 48 49 50 51 52
		<div class="popupbos">
			<div class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label"><i style="color:red;margin-right:5px;">*</i>关键词:</label>
					<div class="layui-input-inline" style="width:250px;">
						<input type="text" name="keywords" lay-verify="required" placeholder="关键词" autocomplete="off" id="text1" class="layui-input" value="">
zxt@theyeasy.com committed
53
					</div>
54 55 56 57 58 59
					<div class="layui-form-mid layui-word-aux">多个关键词请用英文“ | ”分隔</div>
				</div>
				<div class="layui-form-item layui-form-text Redirectbox">
					<label for="" class="layui-form-label"><i style="color:red;margin-right:5px;">*</i>回复内容:</label>
					<div class="layui-input-inline" style="width:65%;">
						<textarea class="layui-textarea" name="content" lay-verify="required" id="saytext" placeholder="请输入内容" style="height:100px;"></textarea>
zxt@theyeasy.com committed
60
					</div>
61
					<div class="layui-form-mid layui-word-aux " style="margin-left:150px;">注: 活动结束或过期后会自动停止推送</div>
zxt@theyeasy.com committed
62 63 64
				</div>
			</div>
		</div>
65
	</div>
zxt@theyeasy.com committed
66 67 68 69
	<script src='/zzhnc/res/js/jquery.min.js'></script>
	<script src="/zzhnc/res/plugins/layui/layui.js" charset="utf-8"></script>
	<script src="/zzhnc/res/js/me.js"></script>
	<script>
70
		layui.use(['form', 'element', 'laydate', 'layer', 'laypage'], function() {
沈姿.前端(已离职) committed
71 72
			var form = layui.form,
				element = layui.element,
73 74 75 76 77
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;

			//查询条件
zxt@theyeasy.com committed
78
			var queryObj = {
79
				page: 1,
沈姿.前端(已离职) committed
80 81
				size: 10,
				keyword: null
82 83 84 85 86 87
			}
			
			//页面初始化
			function initdata(queryObj) {
				$.post("/zzhnc/autoreply/getAutoreplyList", queryObj, function(data) {
					data = data.data;
zxt@theyeasy.com committed
88
					console.log(data)
89 90 91
					
					var str = "";
					if(data.rows.length < 1) {
92
						$(".nodata").show();
93
					} else {
94
						$(".nodata").hide();
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
						for(var i = 0; i < data.rows.length; i++) {
							str += '<tr data-id=' + data.rows[i].id + '>' +
								'<td>' + ((data.page - 1) * data.pageSize + i + 1) + '</td>' +
								'<td style="text-align:left;">' + data.rows[i].keywords + '</td>' +
								'<td style="text-align:left;">' + data.rows[i].contents + '</td>' +
								'<td>' +
								'<a href="#" class="layui-btn layui-btn-mini updataBtn">修改</a>' +
								'<a href="#" class="layui-btn layui-btn-mini deleteBtn">删除</a>' +
								'</td>' +
								'</tr>';
						}
					}

					$("#tablelist").html(str);
					
沈姿.前端(已离职) committed
110 111 112 113
					laypage.render({
						elem: 'page',
						count: data.totalPages, 
						limit: queryObj.size,
zxt@theyeasy.com committed
114 115 116 117 118 119 120
						curr: queryObj.page,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initdata(queryObj);
							}
						}
121 122
					});

zxt@theyeasy.com committed
123 124
				})
			}
沈姿.前端(已离职) committed
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
			
			//初始化数据
			initdata(queryObj);

			//查询操作
			form.on('submit(querybtn)', function(data) {
				queryObj = data.field;
				queryObj.page = 1;
				initdata(queryObj);
				form.render();
			});

			//重置操作
			$(".resetBtn").on("click", function() {
				$("input[name=keyword]").val("");
				form.render();
				queryObj.keyword = null;
沈姿.前端(已离职) committed
142
				initdata(queryObj);
沈姿.前端(已离职) committed
143
			})
144

沈姿.前端(已离职) committed
145 146 147
			//发布操作
			$(".publicBtn").on("click", function() {
				$.get("/zzhnc/autoreply/publish", function(data) {
沈姿.前端(已离职) committed
148
					console.log(data)
沈姿.前端(已离职) committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
					if(data.code == 0) {
						top.layer.msg("发布成功!");
					} else {
						top.layer.msg(data.msg);
					}
				})
			})
			
			//发布按钮提示信息
			$(".publicBtn").on("mouseenter", function() {
				layer.tips('添加或修改完关键字后,需要进行发布,以使新添加或修改的关键字生效。', ".publicBtn", {
					tips: [1, '#3595CC'],
					time: 4000
				});
			})
			
zxt@theyeasy.com committed
165
			//添加关键字
166
			$(document).on("click", ".createBtn", function() {
zxt@theyeasy.com committed
167
				layer.open({
168 169 170 171 172 173
					type: 1,
					title: '添加关键字',
					area: ["650px", "450px"],
					content: $(".popupbox"),
					btnAlign: "c",
					btn: ["提交", "取消"],
zxt@theyeasy.com committed
174
					scrollbar: false,
175 176 177
					yes: function(index, layero) {
						var keywords = $("input[name=keywords]").val();
						if(keywords == "") {
zxt@theyeasy.com committed
178 179 180
							top.layer.msg("请填写关键词");
							return false;
						}
181 182
						var content = $("textarea[name=content]").val();
						if(content == "") {
zxt@theyeasy.com committed
183 184 185
							top.layer.msg("请填写回复内容");
							return false;
						}
186 187 188 189 190
						$.post("/zzhnc/autoreply/addAutoreply", {
							keywords: keywords,
							content: content
						}, function(data) {
							if(data.code == 0) {
zxt@theyeasy.com committed
191 192
								top.layer.msg("添加成功");
								layer.close(index);
193 194
								queryObj.page = 1;
								initdata(queryObj);
沈姿.前端(已离职) committed
195 196
								$("[name=keywords]").val("");
								$("[name=content]").val("");
zxt@theyeasy.com committed
197
							}
198 199
						});
						form.render();
zxt@theyeasy.com committed
200
					},
201
					btn2: function(index, layero) {
zxt@theyeasy.com committed
202 203
						layer.close(index);
					},
204 205
					cancel: function(index, layero) {
						layer.close(index);
zxt@theyeasy.com committed
206 207 208
					}
				})
			})
209

zxt@theyeasy.com committed
210
			//修改关键字
211 212
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
zxt@theyeasy.com committed
213
				layer.open({
214 215 216 217 218 219
					type: 1,
					title: '修改关键字',
					area: ["650px", "450px"],
					content: $(".popupbox"),
					btnAlign: "c",
					btn: ["提交", "取消"],
zxt@theyeasy.com committed
220
					scrollbar: false,
221 222 223
					yes: function(index, layero) {
						var keywords = $("input[name=keywords]").val();
						if(keywords == "") {
zxt@theyeasy.com committed
224 225 226
							top.layer.msg("请填写关键词");
							return false;
						}
227 228
						var content = $("textarea[name=content]").val();
						if(content == "") {
zxt@theyeasy.com committed
229 230 231
							top.layer.msg("请填写回复内容");
							return false;
						}
232 233 234 235 236 237
						$.post("/zzhnc/autoreply/updateAutoreply", {
							id: id,
							keywords: keywords,
							content: content
						}, function(data) {
							if(data.code == 0) {
zxt@theyeasy.com committed
238 239
								top.layer.msg("修改成功");
								layer.close(index);
240 241
								queryObj.page = 1;
								initdata(queryObj);
zxt@theyeasy.com committed
242 243
							}
						});
244
						form.render();
zxt@theyeasy.com committed
245
					},
246 247 248 249 250 251 252 253 254
					success: function(){
						$.post("/zzhnc/autoreply/getAutoReply", {
							id: id
						}, function(data) {
							console.log(data)
							$("input[name=keywords]").val(data.data.keywords);
							$("textarea[name=content]").val(data.data.contents);
							form.render();
						})
zxt@theyeasy.com committed
255 256 257 258
					}
				})
			})

沈姿.前端(已离职) committed
259
			//删除关键字
260 261 262 263 264 265 266 267 268 269 270 271
			$(document).on("click", ".deleteBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
				layer.confirm('您确定要删除该关键字吗?', {
					btn: ['确定', '取消']
				}, function(index, layero) {
					$.post("/zzhnc/autoreply/deleteAutoreply", {
						id: id
					}, function(data) {
						console.log(data)
						if(data.code == 0) {
							top.layer.msg("删除成功");
							queryObj.page = 1;
沈姿.前端(已离职) committed
272
							initdata(queryObj);
273 274 275 276 277 278 279 280 281
							layer.close(index);
						} else {
							top.layer.msg(data.msg);
						}
					})
				}, function(index, layero) {
					layer.close(index);
				});
			});
zxt@theyeasy.com committed
282

283
		})
zxt@theyeasy.com committed
284 285 286
	</script>

</html>