审计记录

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

zxt@theyeasy.com committed
32 33 34
		<table class="layui-table">
			<thead>
				<tr>
沈姿.前端(已离职) committed
35 36 37 38
					<th>No</th>
					<th>商品主图</th>
					<th>商品标题</th>
					<th>商品副标题</th>
39 40 41 42
					<th>原价</th>
					<th>现价</th>
					<th>商家名称</th>
					<th>商家地址</th>
沈姿.前端(已离职) committed
43
					<th>操作</th>
zxt@theyeasy.com committed
44 45
				</tr>
			</thead>
46

zxt@theyeasy.com committed
47
			<tbody id="tablelist">
沈姿.前端(已离职) committed
48
				
zxt@theyeasy.com committed
49 50
			</tbody>
		</table>
51
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
52
		<div id="page"></div>
53

zxt@theyeasy.com committed
54 55 56 57 58 59 60
	</body>

	<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() {
61 62
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
63 64 65
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
66 67 68

			var queryObj = {
				page: 1,
沈姿.前端(已离职) committed
69 70
				size: 10,
				sellerId: 0
71
			};
沈姿.前端(已离职) committed
72
			
沈姿.前端(已离职) committed
73 74
			function initData(queryObj) {
				$.get("/zzhnc/goods/search", queryObj, function(data) {
75
					data = data.data;
zxt@theyeasy.com committed
76
					console.log(data)
沈姿.前端(已离职) committed
77
					
78 79
					var str = "";
					if(data.rows.length < 1) {
80
						$(".nodata").show();
81
					} else {
82
						$(".nodata").hide();
83 84 85
						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
86 87 88
								'<td><img class="imgUrl" src="' + data.rows[i].bannerUrl + '"  /></td>' +
								'<td>' + data.rows[i].name + '</td>' +
								'<td>' + data.rows[i].description + '</td>' +
89 90 91 92
								'<td>' + data.rows[i].primePrice + '</td>' +
								'<td>' + data.rows[i].price + '</td>' +
								'<td>' + data.rows[i].sellerName + '</td>' +
								'<td>' + data.rows[i].sellerAddress + '</td>' +
93 94 95 96 97
								'<td>' +
								'<a href="#" class="layui-btn layui-btn-mini updataBtn">修改</a>' +
								'<a href="#" class="layui-btn layui-btn-mini deleteBtn">删除</a>' +
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
98 99
						}
					}
100

zxt@theyeasy.com committed
101 102
					$("#tablelist").html(str);
					toNull_G();
沈姿.前端(已离职) committed
103 104 105 106 107 108 109 110 111 112 113 114
					
					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
115 116
				})
			}
117

沈姿.前端(已离职) committed
118 119
			//初始化数据
			initData(queryObj);
沈姿.前端(已离职) committed
120 121 122 123 124

			//查询
			form.on('submit(querybtn)', function(data) {
				queryObj.keyword = $("[name=keyword]").val();
				queryObj.page = 1;
沈姿.前端(已离职) committed
125
				initData(queryObj)
沈姿.前端(已离职) committed
126
			});
沈姿.前端(已离职) committed
127 128
			
			//重置
沈姿.前端(已离职) committed
129
			$(".resetBtn").on("click", function() {
沈姿.前端(已离职) committed
130 131 132 133
				$("[name=keyword]").val("");
				queryObj.page = 1;
				queryObj.sellerId = 0;
				initData(queryObj)
沈姿.前端(已离职) committed
134 135 136
				return false
			})

沈姿.前端(已离职) committed
137
			//添加商品
138
			$(document).on("click", ".createBtn", function() {
沈姿.前端(已离职) 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/goods/goodsEdit",
zxt@theyeasy.com committed
145
					icon: "fa-cubes",
沈姿.前端(已离职) committed
146
					title: "添加商品"
zxt@theyeasy.com committed
147 148
				});
			})
沈姿.前端(已离职) committed
149 150
			
			//修改商品
151 152
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
153 154
				if(parent.tab.exists("修改商品") > 0) {
					var tabid = parent.tab.getTabId("修改商品");
zxt@theyeasy.com committed
155 156 157
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
158
					href: "/zzhnc/goods/goodsEdit?id=" + id,
zxt@theyeasy.com committed
159
					icon: "fa-cubes",
沈姿.前端(已离职) committed
160
					title: "修改商品"
161
				});
zxt@theyeasy.com committed
162
			})
沈姿.前端(已离职) committed
163 164
			
			//删除商品
zxt@theyeasy.com committed
165
			$(document).on("click", ".deleteBtn", function() {
166
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
167 168
				layer.confirm('您确定要删除该爆款商品吗?', {
					btn: ['确定', '取消'] 
zxt@theyeasy.com committed
169
				}, function(index, layero) {
170
					$.post("/zzhnc/goods/delete", {
171 172
						id: id
					}, function(data) {
zxt@theyeasy.com committed
173 174 175
						console.log(data)
						if(data.code == 0) {
							top.layer.msg("删除成功");
沈姿.前端(已离职) committed
176
							initData(queryObj);
zxt@theyeasy.com committed
177
							layer.close(index);
178
						} else {
zxt@theyeasy.com committed
179 180 181
							top.layer.msg(data.msg);
						}
					})
182 183 184 185

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

		})
	</script>

</html>