<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;
	}
	
	.tablelist th,td{
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}
	
	
</style>
<body>

<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/problem/merchantList.html}" method="post">
	<input type="hidden" name="pageSize" id="pageSize" value="10" />
	<ul class="seachform">
			<input type="hidden" th:value="${search.get('schoolAreaId')}" id="schoolAreaId" name="schoolAreaId"/>
			<li>
			 <label>商户名称</label>
			  <input name=orgCode type="hidden" class="scinput" th:value="${search.get('LIKE_orgCode')}"/>
			  <input name="unitName" type="text" class="scinput" th:value="${search.get('LIKE_unitName')}"/>
		    </li>
		    
		    <li>
			 <label>商户帐号</label>
			  <input name="posCode" type="text" class="scinput" th:value="${search.get('LIKE_posCode')}"/>
		    </li>
			
		<li>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
			<ul class="toolbar">
				<li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/select.png}" /></span>选择</li>
			</ul>
		</li>
	</ul>
	</form>
	 
	

	<table class="tablelist">
		<thead>
		    <tr>
				<th><input type="checkbox" onchange="selectAll()"></th>
		    	<th >商户帐号</th>
		    	<th >单位名称 </th>
		    	<th style="width: 60px;">商户级别</th>
		    	<th  >关联机构 </th>
		    	<th style="width: 60px;">端口数量</th>
		    	<th style="width: 60px;">机构塾币</th>
		    	<th style="width: 60px;">平台塾币</th>
		    	<th style="max-width: 160px;" >签约时间</th>
		        <th  >状态</th>
		        <th  >创建时间</th>
		    </tr> 
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				    <td><input name="selectlist" type="checkbox" th:data-id="${item.id}" /></td>
					<td th:title="${item.posCode}" th:text="${item.posCode}"></td>
					<td th:title="${item.unitName}" th:text="${item.unitName}"></td>
					<td  th:switch="${item.level}">
					   <span th:case="1" style="color:red">市代</span>
					   <span th:case="2" style="color:red">区代</span>
					   <span th:case="3" style="color:red">学校独家</span>
					   <span th:case="4" style="color:red">普通</span>
					   <span th:case="*" >--</span>
					</td>
					
					<td  th:title="${item.libJoin!=null ? item.libJoin.leagueName : '' }"   th:text="${item.libJoin!=null ? item.libJoin.leagueName : '' }"></td>
					<td  th:text="${item.portNum}"></td>
					<td  th:text="${item.libService}"></td>
					<td  th:text="${item.platformService}"></td>
					
					<td th:title="${item.signTime!=null ?  #dates.format(item.signTime, 'yyyy-MM-dd')+'~'+#dates.format(item.endSignTime, 'yyyy-MM-dd') : '' }"  th:text="${item.signTime!=null ?  #dates.format(item.signTime, 'yyyy-MM-dd')+'~'+#dates.format(item.endSignTime, 'yyyy-MM-dd') : '' }"></td>
					
					<td  th:switch="${item.status}">
					   <span th:case="1">待签</span>
					   <span th:case="2">已签待交付</span>
					   <span th:case="3">已签已交付</span>
					   <span th:case="4">无效</span>
					</td>

					<td  th:text="${#calendars.format(item.createTime,'yyyy-MM-dd')}" ></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 () {
	$('ul.toolbar li.click').click(function () {
		var selectIds=[];
		$('[name=selectlist]:checkbox:checked').each(function() {
			var id = $(this).attr('data-id');
			selectIds.push(id);
		});
		if(selectIds.length>0){
			showIndex(selectIds);
		}else{
			closeWin();
		}

	});
	$('[name=selectlist]:checkbox').change(function () {
		$(this).checked = !$(this).checked;
	});
})


function selectAll() {
	$('[name=selectlist]:checkbox').each(function() {
		this.checked = !this.checked;
	});
}
function showIndex(selectIds){
	var content ="您确定要添加商户吗?";
	parent.layer.confirm(content, {
		icon: 4, btn: ['确定','关闭'] //按钮
	}, function(){
		var url="[[${sysUrl}]]/sys/problem/addMerchant";
		var areaId=$("#schoolAreaId").val();
		var params ={
			'ids' : selectIds,
			'areaId':areaId
		};
		$.post(url,params,function(data){
			if(data.meta.success){
				parent.layer.msg("添加成功",{icon:1});
				closeWin();
			}else{
				parent.layer.msg(data.meta.message,{icon:11});
				closeWin();
			}
		});
	});
}
function closeWin(){
	parent.location.reload();
	parent.layer.close(parent.layer.getFrameIndex(window.name));
}


</script>
</html>