审计记录

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
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
沈姿.前端(已离职) committed
12 13 14 15 16 17 18
		<style>
			.imgUrl {
				width: 50px;
				height: 50px;
				display: block;
			}
		</style>
zxt@theyeasy.com committed
19
	</head>
20

zxt@theyeasy.com committed
21 22 23
	<body class="wrap">
		<div class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
沈姿.前端(已离职) committed
24
				<div class="layui-input-inline">
zxt@theyeasy.com committed
25 26 27 28
					<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
29
				<a class="layui-btn layui-btn-warm createBtn" href="#"><i class="layui-icon">&#xe61f;</i> 添加文章</a>
zxt@theyeasy.com committed
30 31
			</div>
		</div>
32

沈姿.前端(已离职) committed
33
		<table class="layui-table layui-form">
zxt@theyeasy.com committed
34 35
			<thead>
				<tr>
沈姿.前端(已离职) committed
36 37 38 39 40 41 42 43 44
					<th>No</th>
					<th>文章主图</th>
					<th>文章标题</th>
					<th>文章副标题</th>
					<th>商家名称</th>
					<th>商家地址</th>
					<th>商家电话</th>
					<th>是否首页显示</th>
					<th>操作</th>
zxt@theyeasy.com committed
45 46
				</tr>
			</thead>
沈姿.前端(已离职) committed
47

zxt@theyeasy.com committed
48
			<tbody id="tablelist">
沈姿.前端(已离职) committed
49

zxt@theyeasy.com committed
50 51
			</tbody>
		</table>
52
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
53
		<div id="page"></div>
54

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

zxt@theyeasy.com committed
57 58 59 60 61
	<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
62 63
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
64 65 66
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
67

沈姿.前端(已离职) committed
68 69 70 71 72
			var queryObj = {
				page: 1,
				size: 10,
				sellerId: 0
			};
73

沈姿.前端(已离职) committed
74 75
			function initData(queryObj) {
				$.get("/zzhnc/goods/search", queryObj, function(data) {
76
					data = data.data;
zxt@theyeasy.com committed
77 78
					console.log(data)

79 80
					var str = "";
					if(data.rows.length < 1) {
81
						$(".nodata").show();
82
					} else {
83
						$(".nodata").hide();
84 85 86
						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>' +
沈姿.前端(已离职) committed
87 88 89 90 91 92 93 94 95
								'<td><img class="imgUrl" src="' + data.rows[i].bannerUrl + '"  /></td>' +
								'<td>' + data.rows[i].name + '</td>' +
								'<td>' + data.rows[i].description + '</td>' +
								'<td>' + data.rows[i].primePrice + '</td>' +
								'<td>' + data.rows[i].sellerAddress + '</td>' +
								'<td>' + data.rows[i].sellerPhone + '</td>' +
								'<td>' + ' <input type="checkbox" disabled  ' + (data.rows[i].isHome ? "checked" : "") + ' lay-skin="switch" lay-text="是|否"></td>' +
								'<td><a href="#" class="layui-btn layui-btn-sm updataBtn">修改</a>' +
								'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
96 97
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
98 99
						}
					}
100

zxt@theyeasy.com committed
101
					$("#tablelist").html(str);
沈姿.前端(已离职) committed
102

zxt@theyeasy.com committed
103
					toNull_G();
沈姿.前端(已离职) committed
104 105 106 107 108 109 110 111 112 113 114 115 116
					form.render();

					laypage.render({
						elem: 'page',
						count: data.totalPages,
						curr: queryObj.page,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initData(queryObj);
							}
						}
					});
zxt@theyeasy.com committed
117 118
				})
			}
119

沈姿.前端(已离职) committed
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
			//初始化数据
			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.sellerId = 0;
				initData(queryObj)
				return false
			})

			//添加文章
140
			$(document).on("click", ".createBtn", function() {
沈姿.前端(已离职) 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=0",
zxt@theyeasy.com committed
147
					icon: "fa-cubes",
沈姿.前端(已离职) committed
148
					title: "添加文章"
zxt@theyeasy.com committed
149 150
				});
			})
沈姿.前端(已离职) committed
151 152

			//修改文章
153 154
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
155 156
				if(parent.tab.exists("修改文章") > 0) {
					var tabid = parent.tab.getTabId("修改文章");
zxt@theyeasy.com committed
157 158 159
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
160
					href: "/zzhnc/activity/activityEdit?id=" + id,
zxt@theyeasy.com committed
161
					icon: "fa-cubes",
沈姿.前端(已离职) committed
162
					title: "修改文章"
163
				});
zxt@theyeasy.com committed
164
			})
沈姿.前端(已离职) committed
165 166

			//删除文章
zxt@theyeasy.com committed
167
			$(document).on("click", ".deleteBtn", function() {
168
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
169 170
				layer.confirm('您确定要删除该文章吗?', {
					btn: ['确定', '取消']
zxt@theyeasy.com committed
171
				}, function(index, layero) {
沈姿.前端(已离职) committed
172
					$.post("/zzhnc/goods/delete", {
173 174
						id: id
					}, function(data) {
zxt@theyeasy.com committed
175 176 177
						console.log(data)
						if(data.code == 0) {
							top.layer.msg("删除成功");
沈姿.前端(已离职) committed
178
							initData(queryObj);
zxt@theyeasy.com committed
179
							layer.close(index);
180
						} else {
zxt@theyeasy.com committed
181 182 183
							top.layer.msg(data.msg);
						}
					})
184 185 186 187

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
188 189 190 191 192 193
			});

		})
	</script>

</html>