<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/staffingList.html}" method="post">
	  <input type="hidden" name="EQ_libId" th:value="${search.get('EQ_libId')}">
	  <input type="hidden" name="orgCode" th:value="${search.get('orgCode')}">
	<ul class="seachform">
		<li>
			<label>销售人员</label>
			<input name="LIKE_user.name" type="text" class="scinput" th:value="${search.get('LIKE_user.name')}"/>
		</li>
		<li>
		<label>销售类型</label>
					<select class="scinput" style="width: 100px;" 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>
						<option value="s_sd"  th:selected="${ search.get('EQ_type') eq 's_sd' }"  >总部SD</option>
					</select>
		</li>
		<li>
			<label>&nbsp;</label>
			<input type="button" class="scbtn" value="查询" />
		</li>
		<li th:if="${libtype != 1 && sort.code ne 's_cc'}" style="margin-right: 1px;"  th:each="sort:${sortlist}" th:onclick="'getUserList(\''+${search.get('EQ_libId')}+'\',\''+${sort.code}+'\',\''+${search.get('orgCode')}+'\')'" >
				<ul class="toolbar">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span><font th:text="'新增'+${sort.aliases}"></font></li>
				</ul>
		</li>
		<li th:if="${libtype == 1}" style="margin-right: 1px;"  th:each="sort:${sortlist}" th:onclick="'getUserList(\''+${search.get('EQ_libId')}+'\',\''+${sort.code}+'\',\''+${search.get('orgCode')}+'\')'" >
				<ul class="toolbar">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span><font th:text="'新增'+${sort.name}"></font></li>
				</ul>
		</li>
		<li th:if="${libtype == 1}" style="margin-right: 1px;"  th:onclick="'getUserList(\''+${search.get('EQ_libId')}+'\',\''+s_sd+'\',\''+${search.get('orgCode')}+'\')'" >
				<ul class="toolbar">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增总部SD</li>
				</ul>
		</li>
		<li style="margin-right: 1px;" th:if="${search.get('EQ_libId') eq '41147a6f-4b3f-11e7-963a-00163e02357e' || search.get('EQ_libId') eq 'ad93af7e-a9cc-4b0d-af3b-656985a6a9f2' || search.get('EQ_libId') eq 'd805ab33-e426-4479-8bbf-b340ead0a469' || search.get('EQ_libId') eq 'de3e0475-a32e-4727-ade6-b82ade59538e' || search.get('EQ_libId') eq '060b99b0-a427-11e7-963a-00163e02357e'}"  th:onclick="'getUserList(\''+${search.get('EQ_libId')}+'\',\''+s_qd+'\',\''+${search.get('orgCode')}+'\')'" >
				<ul class="toolbar">
					<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增销售人员</li>
				</ul>
		</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>人员头像</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.name}" th:data-name="${item.name}" class="item_name"></td>
					<td  class="imgtd">
							<img  th:if="${item.user.photo}!=null" th:src="${imgUrl}+''+${item.user.photo}+'?x-oss-process=image/resize,m_lfit,h_100,w_100'" style="width: 50px;height: 50px;" />
					</td>
					<td th:text="${item.user.name}" th:data-name="${item.user.name}" class="item_user_name" ></td>
					<td th:text="${item.telephone}" ></td>
					<td  th:switch="${item.sex}">
					   <span th:case="1">男</span>
					   <span th:case="2">女</span>
					   <span th:case="*"></span>
					</td>
					<td>
				        <span  th:each="sort:${sortlist}" th:if="${sort.code eq item.type && libtype ==1}" th:text="${sort.name}"></span>
				        <span  th:each="sort:${sortlist}" th:if="${sort.code eq item.type && libtype !=1}" th:text="${sort.aliases}"></span>
				        <span th:if="${orgLevel eq 2}">区域管理人员</span>
				        <span th:if="${item.type eq 's_sd'}">来自总部SD</span>
				        <span th:if="${item.type eq 'SSJ-SSJ-XX'}">总部销售人员</span>
				        <span th:if="${item.type eq 'SSJ-SSJ-CW'}">总部财务人员</span>
				        <span th:if="${item.type eq 'SSJ-SSJ-SD'}">总部SD人员</span>
				        <span th:if="${item.type eq 's_qd'}">销售人员</span>
				    </td>
					<td  th:text="${#calendars.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}" ></td>
					<td >
						<a href="javascript:;" th:onclick="'deleteById(\''+${item.id}+'\',\''+${item.type}+'\',\''+${item.libId}+'\',this)'"  class="tablelink" >删除</a>
						<a href="javascript:;" th:onclick="'staffingEdit(\''+${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 getUserList(libId,type,orgCode){
	var url ='[[${sysUrl}]]/sys/sales/getUserList.html?libId='+libId+'&type='+type+'&orgCode='+orgCode;
	var title="添加销售人员";
	if(type == 's_zb'){
		url = '[[${sysUrl}]]/sys/sales/getUserListZB.html?libId='+libId+'&type='+type+'&orgCode='+orgCode;
		title="添加总部销售人员";
	}else if(type == 's_sd'){
		url = '[[${sysUrl}]]/sys/sales/getUserListSD.html?libId='+libId+'&type='+type+'&orgCode='+orgCode;
		title="添加总部SD人员";
	}
	layer.open({
	    type: 2,
	    title: title,
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    //offset: '100px',
	    area: ['80%', '90%'],
	    content: url
	});
}
function staffingEdit(id){
	var url ='[[${sysUrl}]]/sys/sales/staffingEdit.html?id='+id;
	var title="修改人员信息";
	layer.open({
	    type: 2,
	    title: title,
	    closeBtn: 1, //不显示关闭按钮
	    shift: 0.8,
	    //offset: '100px',
	     area: ['50%', '55%'],
	    content: url
	});
}
function deleteById(id,type,libId,_this){
	layer.confirm("确定删除吗？",
			{icon: 4, btn: ['确定','取消']
	}, function(){
		 debugger;
		var name=$(_this).parents('tr').find('.item_name').attr('data-name'); 
		 if(name==''||name==undefined){
			 name=$(_this).parents('tr').find('.item_user_name').attr('data-name'); 
		 }
		$.ajax({
			url: '[[${sysUrl}]]/sys/sales/libStaffingDelete',
			type: "post",
			data:{
				'id': id,
				'name': name,
				'type': type,
				'libId': libId
			},
			dataType: "json",
			success:function(data){
					
					if(data.meta.success){
						layer.msg("删除成功",{icon:1});
				    	setTimeout(function(){
				    		location.reload();
						},1000);
					}else{
						layer.msg(data.meta.message,{icon:11});
					}
			}
		});
	});
}
</script>
</html>