审计记录

WebContent/WEB-INF/jsp/pc/activity/activityList.jsp 5.1 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("");
68
					if(data.rows.length < 1) {
69
						$(".nodata").show();
70
					} else {
71
						$(".nodata").hide();
72
						var str = "";
73 74 75
						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>' +
76 77
								'<td><img src="' + data.rows[i].imgurl + '" style="width: 100px; height: 100px;" /></td>' +
								'<td>' + data.rows[i].title + '</td>' +
78
								'<td>' + toType(data.rows[i].type) + '</td>' +
79 80 81
								'<td>' + toTime_G(data.rows[i].createdtime) + '</td>' +
								'<td>' +
								'<a href="#" class="layui-btn layui-btn-sm updataBtn">修改</a>' +
沈姿.前端(已离职) committed
82
								'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
83 84
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
85
						}
86 87 88 89
						$("#tablelist").html(str);
						form.render();
						toNull_G();
					}
90 91 92 93 94 95 96 97 98 99 100 101 102
					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
103 104
				})
			}
105

106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
			//初始化数据
			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
125
			//添加文章
126
			$(document).on("click", ".createBtn", function() {
沈姿.前端(已离职) committed
127 128
				if(parent.tab.exists("添加文章") > 0) {
					var tabid = parent.tab.getTabId("添加文章");
zxt@theyeasy.com committed
129 130 131
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
132
					href: "/zzhnc/activity/activityEdit",
zxt@theyeasy.com committed
133
					icon: "fa-cubes",
沈姿.前端(已离职) committed
134
					title: "添加文章"
zxt@theyeasy.com committed
135 136
				});
			})
137

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

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

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
174
			});
175 176 177 178 179 180 181 182 183
			
			//专区类型转换
			function toType(t){
				if(t == 1){
					return t = "活动介绍"
				}else{
					return t = "福利专区"
				}
			}
zxt@theyeasy.com committed
184 185 186 187 188

		})
	</script>

</html>