审计记录

WebContent/WEB-INF/jsp/pc/goods/goodsList.jsp 5.3 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 12
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
	</head>
沈姿.前端(已离职) committed
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">
18
					<input type="text" class="layui-input" name="key" placeholder="关键字" />
zxt@theyeasy.com committed
19 20 21
				</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

沈姿.前端(已离职) committed
26
		<table class="layui-table layui-form">
zxt@theyeasy.com committed
27 28
			<thead>
				<tr>
沈姿.前端(已离职) committed
29 30
					<th>No</th>
					<th>商品主图</th>
31 32
					<th>商品名称</th>
					<th>商品类别</th>
33 34 35 36
					<th>原价</th>
					<th>现价</th>
					<th>商家名称</th>
					<th>商家地址</th>
沈姿.前端(已离职) committed
37 38
					<th>商家电话</th>
					<th>是否首页显示</th>
沈姿.前端(已离职) committed
39
					<th>操作</th>
zxt@theyeasy.com committed
40 41
				</tr>
			</thead>
42

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

zxt@theyeasy.com committed
45 46
			</tbody>
		</table>
47
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
48
		<div id="page"></div>
49

zxt@theyeasy.com committed
50 51 52 53 54 55
	</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>
56
		layui.use(['form', 'element', 'layer', 'laypage'], function() {
57 58
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
59 60
				layer = layui.layer,
				laypage = layui.laypage;
61 62 63

			var queryObj = {
				page: 1,
沈姿.前端(已离职) committed
64
				size: 10,
65 66
				sellerId: 0,
				key: null
67
			};
沈姿.前端(已离职) committed
68

沈姿.前端(已离职) committed
69 70
			function initData(queryObj) {
				$.get("/zzhnc/goods/search", queryObj, function(data) {
71
					var data = data.data;
zxt@theyeasy.com committed
72
					console.log(data)
73
					$("#tablelist").html("");
74
					if(data.rows.length < 1) {
75
						$(".nodata").show();
76
					} else {
77
						$(".nodata").hide();
78
						var str = "";
79 80 81
						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
82 83
								'<td><img class="imgUrl" src="' + data.rows[i].bannerUrl + '"  /></td>' +
								'<td>' + data.rows[i].name + '</td>' +
84
								'<td>' + data.rows[i].categoryName + '</td>' +
85 86 87 88
								'<td>' + data.rows[i].primePrice + '</td>' +
								'<td>' + data.rows[i].price + '</td>' +
								'<td>' + data.rows[i].sellerName + '</td>' +
								'<td>' + data.rows[i].sellerAddress + '</td>' +
沈姿.前端(已离职) committed
89
								'<td>' + data.rows[i].sellerPhone + '</td>' +
90
								'<td>' + isHome(data.rows[i].isHome) +'</td>' +
沈姿.前端(已离职) committed
91 92
								'<td><a href="#" class="layui-btn layui-btn-sm updataBtn">修改</a>' +
								'<a href="#" class="layui-btn layui-btn-sm deleteBtn">删除</a>' +
93 94
								'</td>' +
								'</tr>';
zxt@theyeasy.com committed
95
						}
96 97
						$("#tablelist").html(str);
						form.render();
98 99 100 101 102 103 104 105 106 107 108 109
						toNull_G();
						laypage.render({
							elem: 'page',
							count: data.total,
							limit: queryObj.size,
							curr: queryObj.page,
							skip: true,
							jump: function(obj, first) {
								if(!first) {
									queryObj.page = obj.curr
									initData(queryObj);
								}
沈姿.前端(已离职) committed
110
							}
111 112
						})
					}
zxt@theyeasy.com committed
113 114
				})
			}
115

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

			//查询
			form.on('submit(querybtn)', function(data) {
121
				queryObj.key = $("[name=key]").val();
沈姿.前端(已离职) committed
122
				queryObj.page = 1;
沈姿.前端(已离职) committed
123
				initData(queryObj)
沈姿.前端(已离职) committed
124
			});
沈姿.前端(已离职) committed
125

沈姿.前端(已离职) committed
126
			//重置
沈姿.前端(已离职) committed
127
			$(".resetBtn").on("click", function() {
128
				$("[name=key]").val("");
沈姿.前端(已离职) committed
129
				queryObj.page = 1;
130
				queryObj.key = null;
沈姿.前端(已离职) committed
131
				initData(queryObj)
沈姿.前端(已离职) committed
132 133 134
				return false
			})

沈姿.前端(已离职) committed
135
			//添加商品
136
			$(document).on("click", ".createBtn", function() {
沈姿.前端(已离职) committed
137 138
				if(parent.tab.exists("添加商品") > 0) {
					var tabid = parent.tab.getTabId("添加商品");
zxt@theyeasy.com committed
139 140 141
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
142
					href: "/zzhnc/goods/goodsEdit?id=0",
zxt@theyeasy.com committed
143
					icon: "fa-cubes",
沈姿.前端(已离职) committed
144
					title: "添加商品"
zxt@theyeasy.com committed
145 146
				});
			})
沈姿.前端(已离职) committed
147

沈姿.前端(已离职) committed
148
			//修改商品
149 150
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
沈姿.前端(已离职) committed
151 152
				if(parent.tab.exists("修改商品") > 0) {
					var tabid = parent.tab.getTabId("修改商品");
zxt@theyeasy.com committed
153 154 155
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
沈姿.前端(已离职) committed
156
					href: "/zzhnc/goods/goodsEdit?id=" + id,
zxt@theyeasy.com committed
157
					icon: "fa-cubes",
沈姿.前端(已离职) committed
158
					title: "修改商品"
159
				});
zxt@theyeasy.com committed
160
			})
沈姿.前端(已离职) committed
161

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

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
184
			});
185 186 187 188 189 190 191 192 193
			
			function isHome(v){
				if(v){
					v = "是"
				}else{
					v = "否"
				}
				return v;
			}
zxt@theyeasy.com committed
194 195 196 197 198

		})
	</script>

</html>