审计记录

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 12 13
		<link rel="stylesheet" href="/zzhnc/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/zzhnc/res/css/basic.css">
	</head>
	<style>
14 15 16 17 18 19 20 21 22 23
		.layui-form-select dl {
			max-height: 190px;
		}
		
		#allmap {
			top: 10px;
			width: 100%;
			height: 200px;
			overflow: hidden;
			margin: 0;
zxt@theyeasy.com committed
24 25
		}
	</style>
26

zxt@theyeasy.com committed
27 28 29 30 31 32 33 34 35 36 37
	<body class="wrap">
		<div class="layui-form">
			<div class="layui-form-item searchbox" style="margin-bottom: 0px;">
				<div class="layui-input-inline" style="width: 140px;">
					<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>
				<a class="layui-btn layui-btn-warm createBtn" href="#"><i class="layui-icon">&#xe61f;</i> 添加文章</a>
			</div>
		</div>
38

zxt@theyeasy.com committed
39 40 41 42 43 44 45 46 47 48
		<table class="layui-table">
			<thead>
				<tr>
					<th style="width: 30px;">No</th>
					<th style="min-width:120px;">标题</th>
					<th style="min-width: 120px;">图片链接</th>
					<th style="min-width: 80px;">更新时间</th>
					<th style="min-width: 80px;">操作</th>
				</tr>
			</thead>
49

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

zxt@theyeasy.com committed
56 57 58 59 60 61 62
	</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() {
63 64
			var form = layui.form,
				element = layui.element,
zxt@theyeasy.com committed
65 66 67
				laydate = layui.laydate,
				layer = layui.layer,
				laypage = layui.laypage;
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

			var queryObj = {
				page: 1,
				pagesize: 10,
				keyword: ''
			};

			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: ""
zxt@theyeasy.com committed
89
				};
90 91 92
				initdata(queryObj)
				return false
			})
zxt@theyeasy.com committed
93 94
			//初始化数据
			initdata(queryObj);
95 96 97 98 99

			function initdata(queryObj) {

				$.post("/zzhnc/article/getArticlesList", queryObj, function(data) {
					data = data.data;
zxt@theyeasy.com committed
100
					console.log(data)
101 102
					laypage.render({
						elem: 'page',
zxt@theyeasy.com committed
103 104 105 106 107 108 109 110 111 112 113
						pages: data.totalPages, //总页数
						curr: queryObj.page,
						skip: true,
						jump: function(obj, first) {
							if(!first) {
								queryObj.page = obj.curr
								initdata(queryObj);
							}

						}
					});
114 115
					var str = "";
					if(data.rows.length < 1) {
116
						$(".nodata").show();
117
					} else {
118
						$(".nodata").hide();
119 120 121 122 123 124 125 126 127 128 129
						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
130 131
						}
					}
132

zxt@theyeasy.com committed
133 134 135 136
					$("#tablelist").html(str);
					toNull_G();
				})
			}
137

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

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

		})
	</script>

</html>