审计记录

WebContent/WEB-INF/jsp/pc/activity/activityList.jsp 4.9 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">
沈姿.前端(已离职) committed
9
		<title>文章列表</title>
zxt@theyeasy.com committed
10 11 12
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
	</head>
13

zxt@theyeasy.com committed
14 15 16
	<body class="wrap">
		<div class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
沈姿.前端(已离职) committed
17
				<div class="layui-input-inline">
zxt@theyeasy.com committed
18 19 20 21
					<input type="text" class="layui-input" name="keyword" placeholder="关键字" />
				</div>
				<button class="layui-btn" lay-submit lay-filter="querybtn">查询</button>
				<button class="layui-btn layui-btn-primary resetBtn">重置</button>
沈姿.前端(已离职) committed
22
				<a class="layui-btn layui-btn-warm createBtn" href="#"><i class="layui-icon">&#xe61f;</i> 添加文章</a>
zxt@theyeasy.com committed
23 24
			</div>
		</div>
25
		<table class="layui-table">
zxt@theyeasy.com committed
26 27
			<thead>
				<tr>
沈姿.前端(已离职) committed
28
					<th>No</th>
29 30 31
					<th style="width: 130px;">主图</th>
					<th>标题</th>
					<th>更新时间</th>
沈姿.前端(已离职) committed
32
					<th>操作</th>
zxt@theyeasy.com committed
33 34
				</tr>
			</thead>
沈姿.前端(已离职) committed
35

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

zxt@theyeasy.com committed
42
	</body>
沈姿.前端(已离职) committed
43

zxt@theyeasy.com committed
44 45 46 47 48
	<script src='/zzhnc/res/js/jquery.min.js'></script>
	<script src="/zzhnc/res/plugins/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="/zzhnc/res/js/me.js"></script>
	<script>
		layui.use(['form', 'element', 'laydate', 'layer', 'laypage'], function() {
沈姿.前端(已离职) committed
49 50
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
51 52 53
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
54

沈姿.前端(已离职) committed
55 56
			var queryObj = {
				page: 1,
57
				pagesize: 5,
58
				keyword: null
沈姿.前端(已离职) committed
59
			};
60

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
			initData(queryObj);

			//查询
			form.on('submit(querybtn)', function(data) {
				queryObj.keyword = $("[name=keyword]").val();
				queryObj.page = 1;
				initData(queryObj)
			});
			$(".resetBtn").on("click", function() {
				$("[name=keyword]").val("")
				queryObj.page = 1;
				queryObj.keyword = null;
				initData(queryObj)
				return false
			})
			//初始化数据
			initData(queryObj);

沈姿.前端(已离职) committed
79
			function initData(queryObj) {
80
				$.get("/zzhnc/article/getArticlesList", queryObj, function(data) {
81
					var data = data.data;
82
					console.log(data)
83
					$("#tablelist").html("");
84
					if(data.rows.length < 1) {
85
						$(".nodata").show();
86
					} else {
87
						$(".nodata").hide();
88
						var str = "";
89 90 91
						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>' +
92 93 94 95 96
								'<td><img src="' + data.rows[i].imgurl + '" style="width: 100px; height: 100px;" /></td>' +
								'<td>' + data.rows[i].title + '</td>' +
								'<td>' + toTime_G(data.rows[i].createdtime) + '</td>' +
								'<td>' +
								'<a href="#" class="layui-btn layui-btn-sm updataBtn">修改</a>' +
沈姿.前端(已离职) committed
97
								'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
98 99
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
100
						}
101 102 103 104 105 106 107 108 109 110 111 112 113 114
						$("#tablelist").html(str);
						form.render();
						toNull_G();
						laypage.render({
							elem: 'page',
							count: data.total,
							limit: queryObj.pagesize,
							curr: queryObj.page,
							skip: true,
							jump: function(obj, first) {
								if(!first) {
									queryObj.page = obj.curr
									initData(queryObj);
								}
沈姿.前端(已离职) committed
115
							}
116 117
						})
					}
118

zxt@theyeasy.com committed
119 120
				})
			}
121

沈姿.前端(已离职) committed
122
			//添加文章
123
			$(document).on("click", ".createBtn", function() {
沈姿.前端(已离职) committed
124 125
				if(parent.tab.exists("添加文章") > 0) {
					var tabid = parent.tab.getTabId("添加文章");
zxt@theyeasy.com committed
126 127 128
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
129
					href: "/zzhnc/activity/activityEdit",
zxt@theyeasy.com committed
130
					icon: "fa-cubes",
沈姿.前端(已离职) committed
131
					title: "添加文章"
zxt@theyeasy.com committed
132 133
				});
			})
沈姿.前端(已离职) committed
134
			//修改文章
135 136
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
137 138
				if(parent.tab.exists("修改文章") > 0) {
					var tabid = parent.tab.getTabId("修改文章");
zxt@theyeasy.com committed
139 140 141
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
142
					href: "/zzhnc/activity/activityEdit?id=" + id,
zxt@theyeasy.com committed
143
					icon: "fa-cubes",
沈姿.前端(已离职) committed
144
					title: "修改文章"
145
				});
zxt@theyeasy.com committed
146
			})
沈姿.前端(已离职) committed
147
			//删除文章
zxt@theyeasy.com committed
148
			$(document).on("click", ".deleteBtn", function() {
149
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
150
				layer.confirm('您确定要删除该文章吗?', {
151
					btn: ['确定', '取消'] //按钮
zxt@theyeasy.com committed
152
				}, function(index, layero) {
153
					$.get("/zzhnc/article/deleteArticle", {
154 155
						id: id
					}, function(data) {
zxt@theyeasy.com committed
156 157 158
						console.log(data)
						if(data.code == 0) {
							top.layer.msg("删除成功");
沈姿.前端(已离职) committed
159
							initData(queryObj);
zxt@theyeasy.com committed
160
							layer.close(index);
161
						} else {
zxt@theyeasy.com committed
162 163 164
							top.layer.msg(data.msg);
						}
					})
165 166 167 168

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
169 170 171 172 173 174
			});

		})
	</script>

</html>