审计记录

WebContent/WEB-INF/jsp/pc/goods/goodsList.jsp 4.8 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 13 14 15
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
	</head>
	<body class="wrap">
		<div class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
沈姿.前端(已离职) committed
16
				<div class="layui-input-inline">
zxt@theyeasy.com committed
17 18 19 20
					<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
21
				<a class="layui-btn layui-btn-warm createBtn" href="#"><i class="layui-icon">&#xe61f;</i> 添加商品</a>
zxt@theyeasy.com committed
22 23
			</div>
		</div>
24

zxt@theyeasy.com committed
25 26 27
		<table class="layui-table">
			<thead>
				<tr>
沈姿.前端(已离职) committed
28 29 30 31 32 33 34
					<th>No</th>
					<th>商品主图</th>
					<th>商品标题</th>
					<th>商品副标题</th>
					<th>所属商家</th>
					<th>商家店铺号</th>
					<th>操作</th>
zxt@theyeasy.com committed
35 36
				</tr>
			</thead>
37

zxt@theyeasy.com committed
38
			<tbody id="tablelist">
沈姿.前端(已离职) committed
39
				
zxt@theyeasy.com committed
40 41
			</tbody>
		</table>
42
		<div class="nodata">暂无数据</div>
zxt@theyeasy.com committed
43
		<div id="page"></div>
44

zxt@theyeasy.com committed
45 46 47 48 49 50 51
	</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() {
52 53
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
54 55 56
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
57 58 59 60 61 62

			var queryObj = {
				page: 1,
				pagesize: 10,
				keyword: ''
			};
沈姿.前端(已离职) committed
63
			
64 65 66 67
			function initdata(queryObj) {

				$.post("/zzhnc/article/getArticlesList", queryObj, function(data) {
					data = data.data;
zxt@theyeasy.com committed
68
					console.log(data)
69 70
					laypage.render({
						elem: 'page',
zxt@theyeasy.com committed
71 72 73 74 75 76 77 78 79 80 81
						pages: data.totalPages, //总页数
						curr: queryObj.page,
						skip: true,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initdata(queryObj);
							}

						}
					});
82 83
					var str = "";
					if(data.rows.length < 1) {
84
						$(".nodata").show();
85
					} else {
86
						$(".nodata").hide();
87 88 89 90 91 92 93 94 95 96 97
						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>' +
								'<td style="text-align:left;">' + data.rows[i].title + '</td>' +
								'<td>' + data.rows[i].imgurl + '</td>' +
								'<td>' + toTime_G(data.rows[i].createdtime) + '</td>' +
								'<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 103 104
					$("#tablelist").html(str);
					toNull_G();
				})
			}
105

沈姿.前端(已离职) committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
			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,
					pagesize: 10,
					keyword: ""
				};
				initdata(queryObj)
				return false
			})
			//初始化数据
			initdata(queryObj);

			

zxt@theyeasy.com committed
129
			//添加文章
130 131 132
			$(document).on("click", ".createBtn", function() {
				if(parent.tab.exists("添加文章") > 0) {
					var tabid = parent.tab.getTabId("添加文章");
zxt@theyeasy.com committed
133 134 135 136 137
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
					href: "/zzhnc/article/articleEdit",
					icon: "fa-cubes",
138
					title: "添加文章"
zxt@theyeasy.com committed
139 140 141
				});
			})
			//修改文章
142 143 144 145
			$(document).on("click", ".updataBtn", function() {
				var id = $(this).parents("tr").attr("data-id");
				if(parent.tab.exists("修改文章") > 0) {
					var tabid = parent.tab.getTabId("修改文章");
zxt@theyeasy.com committed
146 147 148
					parent.tab.deleteTab(tabid);
				}
				parent.tab.tabAdd({
149
					href: "/zzhnc/article/articleEdit?id=" + id,
zxt@theyeasy.com committed
150
					icon: "fa-cubes",
151 152
					title: "修改文章"
				});
zxt@theyeasy.com committed
153 154 155
			})
			//删除文章
			$(document).on("click", ".deleteBtn", function() {
156
				var id = $(this).parents("tr").attr("data-id");
zxt@theyeasy.com committed
157 158 159
				layer.confirm('您确定要删除该文章吗?', {
					btn: ['确定', '取消'] //按钮
				}, function(index, layero) {
160 161 162
					$.post("/zzhnc/article/deleteArticle", {
						id: id
					}, function(data) {
zxt@theyeasy.com committed
163 164 165 166 167
						console.log(data)
						if(data.code == 0) {
							top.layer.msg("删除成功");
							initdata(queryObj);
							layer.close(index);
168
						} else {
zxt@theyeasy.com committed
169 170 171
							top.layer.msg(data.msg);
						}
					})
172 173 174 175

				}, function(index, layero) {
					layer.close(index);
				});
zxt@theyeasy.com committed
176 177 178 179 180 181
			});

		})
	</script>

</html>