<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>私塾家</title>
<script th:include="sys/common/metaCSS" th:remove="tag"></script> 
<script th:include="sys/common/metaJS" th:remove="tag"></script> 
<script src="sys/js/My97DatePicker/WdatePicker.js" th:src="@{/static/sys/js/My97DatePicker/WdatePicker.js}"></script>
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
	.select_width{
	     width: 220px;
	}
	.date_width{
	     width: 150px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">新版抽奖管理</a></li>
		<li><a href="#">奖品物资管理</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/award/material/list.html}" method="post">
	<ul class="seachform">
		<li>
			<label>奖品：</label>
			<input type="text" id="name" name="name" autocomplete="off"  th:value="${search.get('name')}"  class="scinput date_width" placeholder="奖品名称">
		</li>
		
		<li>
			<label>奖品等奖</label>
			<select class="scinput select_width"  id="level" name="level"   style="width: 150px;" >
				<option value="">全部</option>
				<option value="1" th:selected="${search.get('level')+'' eq '1' ? true : false}">一等奖</option>
				<option value="2" th:selected="${search.get('level')+'' eq '2' ? true : false}">二等奖</option>
				<option value="3" th:selected="${search.get('level')+'' eq '3' ? true : false}">三等奖</option>
			</select>
		</li>
		
		<li>
			<input type="button" class="scbtn" value="查询" />
		</li>
		
		
		<li>
			<ul class="toolbar">
				<a href="javascript:;" onclick="list_export()">
					<li class="click"><span><img th:src="@{/static/sys/images/t04.png}"></span>导出明细</li>
				</a>
			</ul>
		</li>
		
		<li>
			<ul class="toolbar">
				<a href="javascript:;" onclick="editCardMaterial('')">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}"></span>添加奖品</li>
				</a>
			</ul>
		</li>
		
		
		
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		    <tr>
				<th style="width: 50px;">序号</th>
				<th>奖品名称</th>
				<th>等级</th>
				<th>录入总库存</th>
				<th>已用库存</th>
				<th>未用库存</th>
				<th>兑换积分</th>
				<th>市场价</th>
		    	<th>奖品备注</th>
		    	<th>奖品LOGO</th>
		    	<th>创建时间</th>
		    	<th>操作</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
					<td th:text="${itemStat.count}"></td>
					<td th:text="${item.get('name')}"></td>
					<td  th:switch="${item.level}">
					   <span th:case="1" >一等奖</span>
					   <span th:case="2" >二等奖</span>
					   <span th:case="3" >三等奖</span>
					   <span th:case="4" >四等奖</span>
					</td>
					<td >
						<a style="color: red" href="javascript:;" th:href="@{/sys/award/sncode/list.html(awardMaterialId=${item.id} )}">
							[[${item.get('stock_number')}]]
						</a>
					</td>
					<td >
						<a style="color: red" href="javascript:;" th:href="@{/sys/award/sncode/list.html(awardMaterialId=${item.id},status='1;2;3;4' )}">
							[[${item.get('new_use_number')}]]
						</a>
					</td>
					<td >
						<a style="color: red" href="javascript:;" th:href="@{/sys/award/sncode/list.html(awardMaterialId=${item.id},status='0' )}">
							[[${item.get('not_use_number')}]]
						</a>
					</td>
					<td th:text="${item.get('exchange_integral')}"></td>
					<td th:text="${item.get('price')}"></td>
					<td th:text="${item.get('remarks')}"></td>
					<td >
						<img style="height: 40px;"  th:if="${item.get('img')!=null && item.get('img')!=''}" th:src="${imgUrl+item.get('img')}">
					</td>
					<td th:text="${item.get('create_time')}"></td>
<!-- 					<td>  -->
<!-- 						<a th:href="${sysUrl+'/sys/award/material/consume.html?id='+item.id }" class="tablelink">奖品配送明细</a>  -->
<!-- 					</td> -->
<!-- 					<td>  -->
<!-- 						<a th:href="${sysUrl+'/sys/award/sncode/list.html?awardMaterialId='+item.id }" class="tablelink">奖品信息</a> -->
<!-- 					</td> -->
					<td>
						<div th:if="${curMerchant.posCode ne 'sishujia'}">
						<a href="javascript:;" th:onclick="'numberCardMaterial(\''+${item.id}+'\')'" class="tablelink">新增库存</a>
						<a href="javascript:;" th:onclick="'editCardMaterial(\''+${item.id}+'\')'" class="tablelink">修改</a>
						<a href="javascript:;" th:onclick="'statusCardMaterial(\''+${item.id}+'\')'" class="tablelink">删除</a>
					</td>
			</tr>
		</tbody>
	</table>
	<!-- 分页 -->
	<div class="pagin">
		<div class="message">共<i class="blue">[[${page.rowCnt}]]</i>条记录，当前显示第&nbsp;<i class="blue">[[${page.pageNo }]]&nbsp;</i>页</div>
		<div th:utext='${listNavigatHtml}' th:remove="tag" ></div>
	</div>
	
</div>
</body>
<script type="text/javascript">


	function numberCardMaterial(id){
		var title="新增库存";
		parent.layer.open({
		    type: 2,
		    title: title,
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['40%', '30%'],
		    content: '[[${sysUrl}]]/sys/award/material/number.html?id='+id
		});
	}


	function editCardMaterial(id){
		var title="添加奖品";
		if(id!=null && id!='' && id!=undefined){
			title="编辑奖品";
		}
		parent.layer.open({
		    type: 2,
		    title: title,
		    closeBtn: 1, //不显示关闭按钮
		    shift: 0.8,
		    offset: '100px',
		    area: ['40%', '50%'],
		    content: '[[${sysUrl}]]/sys/award/material/edit.html?id='+id
		});
	}
	
	
	function statusCardMaterial(id){
		parent.layer.confirm("确定删除奖品信息?", {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/award/material/status";
			var params ={
			 	'id' : id,
	            'status' :"0"
	        };
			$.post(url,params,function(data){
				if(data.meta.success){
					parent.layer.msg("删除成功",{icon:1});
					parent.location.reload();
					parent.layer.close(parent.layer.getFrameIndex(window.name));
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
			});
		});
	}
	
	function list_export(){
		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/award/material/list_export";
		$("#seachform").submit();
		window.setTimeout(function(){
			document.getElementById("seachform").action = "[[${sysUrl}]]/sys/award/material/list.html";
		},3000);
	};
	
</script>


</html>