<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> 
</head>
<style>
	.tablelink{margin-right:10px;}
	.stylecss{
	      color: red;
	}
	.select_width{
	     width: 70px;
	}
	.date_width{
	     width: 100px;
	}
</style>
<body>
<div class="place">
	<span>位置：</span>
	<ul class="placeul">
		<li><a href="#">图书馆管理</a></li>
		<li><a th:href="@{/sys/lib/libJoinList.html}">图书馆</a></li>
		<li><a href="#">销售卡管理</a></li>
	</ul>
</div>
<div class="rightinfo">
	<form id="seachform" th:action="@{/sys/sales/commissionList.html}" method="post">
	<input type="hidden" name="EQ_libId" th:value="${search.get('EQ_libId')}">
	<ul class="seachform">
		<li>
		<label>销售卡类型</label>
					<select class="scinput" style="width: 200px;" name="EQ_type"   >
					    <option value=""  th:selected="${ search.get('EQ_type') eq '' }"  >全部</option>
						<option th:value="${sort.code}" th:each="sort:${sortlist}" th:selected="${ search.get('EQ_type') eq sort.code }" >[[${sort.name}]]</option>
					</select>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li>
				<ul class="toolbar">
					<a th:href="@{/sys/lib/libJoinList.html}"><li class="click"><span><img style="width: 24px;height: 24px" th:src="@{/static/sys/images/goto.png}" /></span>返回</li></a>
				</ul>
		</li>
	</ul>
	</form>
	<table class="tablelist">
		<thead>
		     <tr>
		        <th style="width: 80px;">序号</th>
		        <th>销售人员类型</th>
		        <th style="text-align: center;" >新签提成</th>
		        <th style="text-align: center;">续签提成</th>
		        <th>添加时间</th>
		    </tr>
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td th:text="${itemStat.count}" ></td>
					<td>
				       <span th:each="sort:${sortlist}" th:if="${sort.code eq item.type}" th:text="${sort.name}"></span>
				    </td>
				    <td style="text-align: center;" >
					 <input type="number" th:value="${item.newSign}" th:onBlur="'updateNewSign(\''+${item.id}+'\',\''+${item.newSign}+'\',this)'"  class="dfinput" style="width: 60px; height: 30px;color: red;"  >
					</td>
				    <td style="text-align: center;" >
					 <input type="number" th:value="${item.xSign}" th:onBlur="'updateXSign(\''+${item.id}+'\',\''+${item.xSign}+'\',this)'"  class="dfinput" style="width: 60px; height: 30px;color: red;"  >
					</td>
					<td  th:text="${#calendars.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}" ></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>
<script type="text/javascript">
function updateNewSign(id,oldNewSign,_this){
	var newSign = $(_this).val();
	if(newSign == oldNewSign){
		return false;
	}
	if(newSign ==''|| newSign ==null){
		return false;
	}
	$(_this).removeAttr("onBlur");
	$.ajax({
		url : "[[${sysUrl}]]/sys/sales/updateNewSign",
		type : "post",
		data : {
			id : id,
			newSign : newSign
		},
		dataType : "json",
		success : function(data) {
			if(data.meta.success){
				 parent.layer.msg('操作成功',{icon:1});
				 $(_this).attr("onBlur","updateNewSign("+id+","+newSign+",this)");
			}else{
				parent.layer.msg('操作失败',{icon: 9})
				$(_this).attr("onBlur","updateNewSign("+id+","+oldNewSign+",this)");
			}
		}
	});
}
function updateXSign(id,oldXSign,_this){
	var xSign = $(_this).val();
	if(xSign == oldXSign){
		return false;
	}
	if(xSign ==''|| xSign ==null){
		return false;
	}
	$(_this).removeAttr("onBlur");
	$.ajax({
		url : "[[${sysUrl}]]/sys/sales/updateXSign",
		type : "post",
		data : {
			id : id,
			xSign : xSign
		},
		dataType : "json",
		success : function(data) {
			if(data.meta.success){
				 parent.layer.msg('操作成功',{icon:1});
				 $(_this).attr("onBlur","updateXSign("+id+","+xSign+",this)");
			}else{
				parent.layer.msg('操作失败',{icon: 9})
				$(_this).attr("onBlur","updateXSign("+id+","+oldXSign+",this)");
			}
		}
	});
}

</script>
</body>
</html>