审计记录

WebContent/WEB-INF/jsp/pc/goods/goodsList.jsp 5.0 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 39 40 41
					<th>No</th>
					<th>商品主图</th>
					<th>商品标题</th>
					<th>商品副标题</th>
					<th>所属商家</th>
					<th>商家店铺号</th>
					<th>操作</th>
zxt@theyeasy.com committed
42 43
				</tr>
			</thead>
44

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

zxt@theyeasy.com committed
52 53 54 55 56 57 58
	</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() {
59 60
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
61 62 63
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
64 65 66

			var queryObj = {
				page: 1,
沈姿.前端(已离职) committed
67 68
				size: 10,
				sellerId: 0
69
			};
沈姿.前端(已离职) committed
70
			
沈姿.前端(已离职) committed
71 72
			function initData(queryObj) {
				$.get("/zzhnc/goods/search", queryObj, function(data) {
73
					data = data.data;
zxt@theyeasy.com committed
74
					console.log(data)
沈姿.前端(已离职) committed
75
					
76 77
					var str = "";
					if(data.rows.length < 1) {
78
						$(".nodata").show();
79
					} else {
80
						$(".nodata").hide();
81 82 83
						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
84 85 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>' +
								'<td>' + data.rows[i].sellerId + '</td>' +
								'<td>' + data.rows[i].sellerId + '</td>' +
89 90 91 92 93
								'<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
94 95
						}
					}
96

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

沈姿.前端(已离职) committed
114 115
			//初始化数据
			initData(queryObj);
沈姿.前端(已离职) committed
116 117 118 119 120

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

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

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
182 183 184 185 186 187
			});

		})
	</script>

</html>