审计记录

WebContent/WEB-INF/jsp/pc/autoresponse/autoresponse.jsp 7.8 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
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
11
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
zxt@theyeasy.com committed
12
	</head>
13

zxt@theyeasy.com committed
14 15
	<body class="wrap">
		<div class="layui-form">
16 17 18
			<div class="layui-form-mid">说明:添加或修改完关键字后,需要进行发布,以使新添加或修改的关键字生效。</div>
			<div class="layui-form-item">
				<div class="layui-input-inline">
zxt@theyeasy.com committed
19 20
					<input type="text" class="layui-input" name="keyword" placeholder="关键字" />
				</div>
21 22
				<button class="layui-btn" lay-submit lay-filter="querybtn">查询</button>
				<button class="layui-btn layui-btn-primary resetBtn">重置</button>
23 24
				<a class="layui-btn layui-btn-warm createBtn"><i class="layui-icon">&#xe61f;</i> 添加关键字</a>
				<a class="layui-btn publicBtn"><i class="layui-icon">&#xe609;</i> 发布</a>
zxt@theyeasy.com committed
25 26 27 28 29
			</div>
		</div>
		<table class="layui-table">
			<thead>
				<tr>
30 31 32 33
					<th>No</th>
					<th>关键字</th>
					<th>回复内容</th>
					<th>操作</th>
zxt@theyeasy.com committed
34 35 36 37 38
				</tr>
			</thead>
			<tbody id="tablelist">
			</tbody>
		</table>
39
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
40 41 42
		<div id="page"></div>
	</body>
	<div class="popupbox" style="display:none;">
43 44 45
		<div class="popupbos">
			<div class="layui-form">
				<div class="layui-form-item">
46 47 48
					<label class="layui-form-label"><i class="redrequired">*</i>关键词:</label>
					<div class="layui-input-block">
						<input type="text" name="keywords" lay-verify="required" placeholder="关键词" class="layui-input">
zxt@theyeasy.com committed
49
					</div>
50 51 52 53 54
					
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-word-aux">注:多个关键词请用英文“ | ”分隔</div>
55
				</div>
56 57 58 59
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="redrequired">*</i>回复内容:</label>
					<div class="layui-input-block">
						<textarea class="layui-textarea" name="content" lay-verify="required" placeholder="请输入内容" style="height:150px; "></textarea>
zxt@theyeasy.com committed
60 61 62 63
					</div>
				</div>
			</div>
		</div>
64
	</div>
zxt@theyeasy.com committed
65 66 67 68
	<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>
69
		layui.use(['form', 'element', 'layer', 'laypage'], function() {
沈姿.前端(已离职) committed
70 71
			var form = layui.form,
				element = layui.element,
72 73 74 75
				layer = layui.layer,
				laypage = layui.laypage;

			//查询条件
zxt@theyeasy.com committed
76
			var queryObj = {
77
				page: 1,
沈姿.前端(已离职) committed
78 79
				size: 10,
				keyword: null
80 81 82 83
			}
			
			//页面初始化
			function initdata(queryObj) {
沈姿.前端(已离职) committed
84
				$.get("/zzhnc/autoreply/getAutoreplyList", queryObj, function(data) {
85
					var data = data.data;
zxt@theyeasy.com committed
86
					console.log(data)
87
					if(data.rows.length < 1) {
88
						$(".nodata").show();
89
					} else {
90
						$(".nodata").hide();
91
						var str = "";
92 93 94 95 96 97
						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>' +
沈姿.前端(已离职) committed
98 99
								'<a href="#" class="layui-btn layui-btn-sm updataBtn">修改</a>' +
								'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
100 101 102
								'</td>' +
								'</tr>';
						}
103 104 105 106 107 108 109 110 111 112 113 114 115 116
						$("#tablelist").html(str);
						form.render();
						toNull_G();
						laypage.render({
							elem: 'page',
							count: data.total, 
							limit: queryObj.size,
							curr: queryObj.page,
							skip: true,
							jump: function(obj, first) {
								if(!first) {
									queryObj.page = obj.curr
									initdata(queryObj);
								}
zxt@theyeasy.com committed
117
							}
118 119
						})
					}
zxt@theyeasy.com committed
120 121
				})
			}
沈姿.前端(已离职) committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
			
			//初始化数据
			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
139
				initdata(queryObj);
沈姿.前端(已离职) committed
140
			})
141

沈姿.前端(已离职) committed
142 143 144
			//发布操作
			$(".publicBtn").on("click", function() {
				$.get("/zzhnc/autoreply/publish", function(data) {
沈姿.前端(已离职) committed
145
					console.log(data)
沈姿.前端(已离职) committed
146 147 148 149 150 151 152 153
					if(data.code == 0) {
						top.layer.msg("发布成功!");
					} else {
						top.layer.msg(data.msg);
					}
				})
			})
			
zxt@theyeasy.com committed
154
			//添加关键字
155
			$(document).on("click", ".createBtn", function() {
zxt@theyeasy.com committed
156
				layer.open({
157 158
					type: 1,
					title: '添加关键字',
159
					area: ["550px", "400px"],
160 161 162
					content: $(".popupbox"),
					btnAlign: "c",
					btn: ["提交", "取消"],
zxt@theyeasy.com committed
163
					scrollbar: false,
164 165 166
					yes: function(index, layero) {
						var keywords = $("input[name=keywords]").val();
						if(keywords == "") {
zxt@theyeasy.com committed
167 168 169
							top.layer.msg("请填写关键词");
							return false;
						}
170 171
						var content = $("textarea[name=content]").val();
						if(content == "") {
zxt@theyeasy.com committed
172 173 174
							top.layer.msg("请填写回复内容");
							return false;
						}
175 176 177 178 179
						$.post("/zzhnc/autoreply/addAutoreply", {
							keywords: keywords,
							content: content
						}, function(data) {
							if(data.code == 0) {
zxt@theyeasy.com committed
180 181
								top.layer.msg("添加成功");
								layer.close(index);
182 183
								queryObj.page = 1;
								initdata(queryObj);
沈姿.前端(已离职) committed
184 185
								$("[name=keywords]").val("");
								$("[name=content]").val("");
zxt@theyeasy.com committed
186
							}
187 188
						});
						form.render();
zxt@theyeasy.com committed
189
					},
190
					btn2: function(index, layero) {
zxt@theyeasy.com committed
191 192
						layer.close(index);
					},
193 194
					cancel: function(index, layero) {
						layer.close(index);
zxt@theyeasy.com committed
195 196 197
					}
				})
			})
198

zxt@theyeasy.com committed
199
			//修改关键字
200 201
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
zxt@theyeasy.com committed
202
				layer.open({
203 204
					type: 1,
					title: '修改关键字',
205
					area: ["550px", "400px"],
206 207 208
					content: $(".popupbox"),
					btnAlign: "c",
					btn: ["提交", "取消"],
zxt@theyeasy.com committed
209
					scrollbar: false,
210 211 212
					yes: function(index, layero) {
						var keywords = $("input[name=keywords]").val();
						if(keywords == "") {
zxt@theyeasy.com committed
213 214 215
							top.layer.msg("请填写关键词");
							return false;
						}
216 217
						var content = $("textarea[name=content]").val();
						if(content == "") {
zxt@theyeasy.com committed
218 219 220
							top.layer.msg("请填写回复内容");
							return false;
						}
221 222 223 224 225 226
						$.post("/zzhnc/autoreply/updateAutoreply", {
							id: id,
							keywords: keywords,
							content: content
						}, function(data) {
							if(data.code == 0) {
zxt@theyeasy.com committed
227 228
								top.layer.msg("修改成功");
								layer.close(index);
229 230
								queryObj.page = 1;
								initdata(queryObj);
zxt@theyeasy.com committed
231 232
							}
						});
233
						form.render();
zxt@theyeasy.com committed
234
					},
235
					success: function(){
沈姿.前端(已离职) committed
236
						$.get("/zzhnc/autoreply/getAutoReply", {
237 238 239 240 241 242 243
							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
244 245 246 247
					}
				})
			})

沈姿.前端(已离职) committed
248
			//删除关键字
249 250 251 252 253 254 255 256 257 258 259 260
			$(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
261
							initdata(queryObj);
262 263 264 265 266 267 268 269 270
							layer.close(index);
						} else {
							top.layer.msg(data.msg);
						}
					})
				}, function(index, layero) {
					layer.close(index);
				});
			});
zxt@theyeasy.com committed
271

272
		})
zxt@theyeasy.com committed
273 274 275
	</script>

</html>