<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>
<link href="sys/css/jquery.searchableSelect.css" th:href="@{/static/sys/css/jquery.searchableSelect.css}" rel="stylesheet"/>
<script src="js/layer/layer.js" th:src="@{/static/sys/js/jquery.searchableSelect.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/activity/list.html}" method="post">
	<ul class="seachform">
		
		<li>
			<label>我的商户</label>
			<select class="scinput select_width"  id="merchantId" name="merchantId"   style="width: 150px;" >
				<option value="">全部</option>
				<option th:each="item:${subMerchants}"  th:selected="${search.get('merchantId') eq item.id ? true : false}" th:value="${item.id}">[[${item.unitName}]]</option>
			</select>
		</li>
	
		<li>
			<label>活动主题：</label>
			<input type="text" id="title" name="title" autocomplete="off"  th:value="${search.get('title')}"  class="scinput date_width" placeholder="活动主题">
		</li>
		
		<li>
			<label>开始时间</label>
			<input type="text" id="startTime" name="startTime" autocomplete="off" onclick="WdatePicker()" th:value="${search.get('startTime')}"   class="scinput date_width " placeholder="开始时间">
		</li>
		<li>
			<label>结束时间</label>
			<input type="text" id="endTime" name="endTime" autocomplete="off"  onclick="WdatePicker()"  th:value="${search.get('endTime')}" class="scinput date_width " placeholder="结束时间">
		</li>
		
		
		<li>
			<input type="button" class="scbtn" value="查询" />
		</li>
		
		<li>
			<ul class="toolbar">
				<a href="javascript:;" onclick="editCardActivity('')">
					<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>活动底图</th>
		    	<th>创建时间</th>
		    	<th>状态</th>
		    	<th>抽奖明细</th>
		        <th>活动记录</th>
		    	<th>操作</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
					<td th:text="${itemStat.count}"></td>
					<td th:text="${item.get('unit_name')}"></td>
					<td th:text="${item.get('port_num')}"></td>
					<td th:text="${item.get('title')}"></td>
					<td th:text="${item.get('partake_num')}"></td>
					<td th:text="${ item.get('level1_material_name')!=null ? (item.get('level1_material_name')+' / '+item.get('level1_num')+'个' ) : '无'  }"></td>
					<td th:text="${ item.get('level2_material_name')!=null ? (item.get('level2_material_name')+' / '+item.get('level2_num')+'个'  ) : '无'  }"></td>
					<td th:text="${ item.get('level3_material_name')!=null ? (item.get('level3_material_name')+' / '+item.get('level3_num')+'个'  ) : '无'  }"></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 th:switch="${item.status}">
					   <span th:case="0" style="color:red">已取消</span>
					   <span th:case="1" style="color:red">已发布</span>
					   <span th:case="2" style="color:red">审核中</span>
					   <span th:case="3" style="color:red">不通过</span>
					</td>
					<td> 
						<a th:href="${sysUrl+'/sys/award/sncode/list.html?awardActivityId='+item.id }" class="tablelink">奖品明细</a> 
					</td>
					<td> 
						<a th:href="${sysUrl+'/sys/award/activity/log.html?id='+item.id }" class="tablelink">抽奖记录</a> 
					</td>
					<td >
						<a th:if="${item.status==1 || item.status==2}" href="javascript:;" th:onclick="'statusCardActivity(\''+${item.id}+'\',\'0\')'" 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(){
		$('#merchantId').searchableSelect();
	});


	function editCardActivity(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%', '70%'],
		    content: '[[${sysUrl}]]/sys/award/activity/edit.html?id='+id
		});
	}
	
	
	function statusCardActivity(id){
		parent.layer.confirm("确定取消活动?", {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/award/activity/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});
				}
			});
		});
	}
	
	$("#button").on('click',function(){
		document.getElementById("seachform").action = "[[${sysUrl}]]/sys/award/material/list";
		$("#seachform").submit();
		window.setTimeout(function(){
			document.getElementById("seachform").action = "[[${sysUrl}]]/sys/award/material/list.html";
		},3000);
	});
</script>


</html>