审计记录

WebContent/WEB-INF/jsp/pc/activity/activityList.jsp 4.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">
沈姿.前端(已离职) 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
					data = data.data;
82 83
					console.log(data)

84 85
					var str = "";
					if(data.rows.length < 1) {
86
						$(".nodata").show();
87
						$("#page").hide();
88
					} else {
89
						$(".nodata").hide();
90
						$("#page").show();
91 92 93
						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>' +
94 95 96 97 98
								'<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
99
								'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
100 101
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
102 103
						}
					}
104

zxt@theyeasy.com committed
105 106
					$("#tablelist").html(str);
					toNull_G();
沈姿.前端(已离职) committed
107 108 109 110 111

					laypage.render({
						elem: 'page',
						count: data.totalPages,
						curr: queryObj.page,
112
						skip: true,
沈姿.前端(已离职) committed
113 114 115 116 117
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initData(queryObj);
							}
118

沈姿.前端(已离职) committed
119 120
						}
					});
zxt@theyeasy.com committed
121 122
				})
			}
123

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

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

		})
	</script>

</html>