审计记录

WebContent/WEB-INF/jsp/pc/activity/activityList.jsp 5.2 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
					<th style="width: 130px;">主图</th>
					<th>标题</th>
31
					<th>类型</th>
32
					<th>更新时间</th>
33
					<th style="min-width: 98px;">操作</th>
zxt@theyeasy.com committed
34 35
				</tr>
			</thead>
沈姿.前端(已离职) committed
36

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

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

zxt@theyeasy.com committed
45 46 47 48 49
	<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
50 51
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
52 53 54
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
55

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

62
			//初始化方法
沈姿.前端(已离职) committed
63
			function initData(queryObj) {
64
				$.get("/zzhnc/article/getArticlesList", queryObj, function(data) {
65
					var data = data.data;
66
					console.log(data)
67
					$("#tablelist").html("");
沈姿.前端(已离职) committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
					if(data.code == 0) {
						if(data.rows.length < 1) {
							$(".nodata").show();
						} else {
							$(".nodata").hide();
							var str = "";
							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><img src="' + data.rows[i].imgurl + '" style="width: 100px; height: 100px;" /></td>' +
									'<td>' + data.rows[i].title + '</td>' +
									'<td>' + toType(data.rows[i].type) + '</td>' +
									'<td>' + toTime_G(data.rows[i].createdtime) + '</td>' +
									'<td>' +
									'<a href="#" class="layui-btn layui-btn-sm updataBtn">修改</a>' +
									'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
									'</td>' +
									'</tr>';
86
							}
沈姿.前端(已离职) committed
87 88 89
							$("#tablelist").html(str);
							form.render();
							toNull_G();
90
						}
沈姿.前端(已离职) committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104
						laypage.render({
							elem: 'page',
							count: data.total,
							limit: queryObj.pagesize,
							curr: queryObj.page,
							layout: ['count', 'prev', 'page', 'next', 'skip'],
							jump: function(obj, first) {
								if(!first) {
									queryObj.page = obj.curr
									initData(queryObj);
								}
							}
						})
					}
zxt@theyeasy.com committed
105 106
				})
			}
107

108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
			//初始化数据
			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
			})

沈姿.前端(已离职) committed
127
			//添加文章
128
			$(document).on("click", ".createBtn", function() {
沈姿.前端(已离职) committed
129 130
				if(parent.tab.exists("添加文章") > 0) {
					var tabid = parent.tab.getTabId("添加文章");
zxt@theyeasy.com committed
131 132 133
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
134
					href: "/zzhnc/activity/activityEdit",
zxt@theyeasy.com committed
135
					icon: "fa-cubes",
沈姿.前端(已离职) committed
136
					title: "添加文章"
zxt@theyeasy.com committed
137 138
				});
			})
139

沈姿.前端(已离职) committed
140
			//修改文章
141 142
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
143 144
				if(parent.tab.exists("修改文章") > 0) {
					var tabid = parent.tab.getTabId("修改文章");
zxt@theyeasy.com committed
145 146 147
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
148
					href: "/zzhnc/activity/activityEdit?id=" + id,
zxt@theyeasy.com committed
149
					icon: "fa-cubes",
沈姿.前端(已离职) committed
150
					title: "修改文章"
151
				});
zxt@theyeasy.com committed
152
			})
153

沈姿.前端(已离职) committed
154
			//删除文章
zxt@theyeasy.com committed
155
			$(document).on("click", ".deleteBtn", function() {
156
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
157
				layer.confirm('您确定要删除该文章吗?', {
158
					btn: ['确定', '取消'] //按钮
zxt@theyeasy.com committed
159
				}, function(index, layero) {
160
					$.get("/zzhnc/article/deleteArticle", {
161 162
						id: id
					}, function(data) {
zxt@theyeasy.com committed
163 164 165
						console.log(data)
						if(data.code == 0) {
							top.layer.msg("删除成功");
沈姿.前端(已离职) committed
166
							initData(queryObj);
zxt@theyeasy.com committed
167
							layer.close(index);
168
						} else {
zxt@theyeasy.com committed
169 170 171
							top.layer.msg(data.msg);
						}
					})
172 173 174 175

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
176
			});
沈姿.前端(已离职) committed
177

178
			//专区类型转换
沈姿.前端(已离职) committed
179 180
			function toType(t) {
				if(t == 1) {
181
					return t = "活动介绍"
沈姿.前端(已离职) committed
182
				} else {
183 184 185
					return t = "福利专区"
				}
			}
zxt@theyeasy.com committed
186 187 188 189 190

		})
	</script>

</html>