<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>
<body>
	<div class="rightinfo">
	
	
		
		<form id="seachform" th:action="@{/sys/org/staffinglist.html}" method="post">
		       <input type="hidden" name="EQ_orgCode" th:value="${search.get('EQ_orgCode')}" />
		       <input type="hidden" name="orgLevel" th:value="${search.get('orgLevel')}" />
				<ul class="seachform">
					<li>
						<label>人员姓名</label>
						<input name="LIKE_name" type="text" class="scinput" th:value="${search.get('LIKE_name')}"/>
					</li>
					<li>
						<label>&nbsp;</label>
						<input type="button" class="scbtn" value="查询" />
					</li>
					<div class="tools" th:if="${ search.get('orgLevel') gt 1 && ( not #strings.contains(search.get('EQ_orgCode'),'SSJ-SSJ') ) }" th:remove="tag">
					   <li>
						 <ul class="toolbar" th:if="${search.get('orgLevel') eq 3}" th:each="sort:${sortlist}" th:onclick="'getUserList(\''+${search.get('libId')}+'\',\''+${sort.code}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+${sort.name}+'\')'" >
								<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span><font th:text="'新增'+${sort.name}"></font></li>
						 </ul>
						 <ul class="toolbar" th:if="${search.get('orgLevel') eq 3}"  th:onclick="'getUserList(\''+${search.get('libId')}+'\',\''+s_sd+'\',\''+${search.get('EQ_orgCode')}+'\',\''+总部SD人员+'\')'" >
								<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增总部SD人员</li>
						 </ul>
						 <ul class="toolbar" th:if="${search.get('orgLevel') eq 2}"  th:onclick="'getUserList(\''+${search.get('libId')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+区域管理人员+'\')'" >
								<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增区域管理人员</li>
						 </ul>
						 </li>
					</div>
					<div class="tools" th:if="${ search.get('orgLevel') gt 2 &&  #strings.contains(search.get('EQ_orgCode'),'SSJ-SSJ') }" th:remove="tag" >
					    <li>
						 <ul class="toolbar" th:if="${ search.get('EQ_orgCode') eq 'SSJ-SSJ-CW' }" th:onclick="'getUserList(\''+${search.get('libId')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+总部财务人员+'\')'" >
								<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增总部财务人员</li>
						 </ul>
						 <ul class="toolbar" th:if="${ search.get('EQ_orgCode') eq 'SSJ-SSJ-SD' }" th:onclick="'getUserList(\''+${search.get('libId')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+总部SD人员+'\')'" >
								<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增总部SD人员</li>
						 </ul>
						 <ul class="toolbar" th:if="${ search.get('EQ_orgCode') eq 'SSJ-SSJ-SR' }" th:onclick="'getUserList(\''+${search.get('libId')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+${search.get('EQ_orgCode')}+'\',\''+总部SR人员+'\')'" >
								<li class="click"><span><img th:src="@{/static/sys/images/t01.png}" /></span>新增总部SR人员</li>
						 </ul>
						 </li>
					</div>
				</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}" ></td>
					<td  class="imgtd">
							<img  th:if="${item.user}!=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}" ></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}" th:text="${sort.name}"></span>
				        <span th:if="${search.get('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 'SSJ-SSJ-SR'}">总部SR人员</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.name}+'\',\''+${item.type}+'\',\''+${item.libId}+'\')'"  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>
	
<script type="text/javascript">
function getUserList(libId,type,orgCode,title){
	var url ='[[${sysUrl}]]/sys/sales/getUserList.html?libId='+libId+'&type='+type+'&orgCode='+orgCode;
	title = '添加'+title;
	if(type == 's_zb'){
		url = '[[${sysUrl}]]/sys/sales/getUserListZB.html?libId='+libId+'&type='+type+'&orgCode='+orgCode;
	}else if(type == 's_sd'){
		url = '[[${sysUrl}]]/sys/sales/getUserListSD.html?libId='+libId+'&type='+type+'&orgCode='+orgCode;
	}
	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: ['80%', '90%'],
	    content: url
	});
}
function deleteById(id,name,type,libId){
	layer.confirm("确定删除该用户？",
			{icon: 4, btn: ['确定','取消']
	}, function(){
		$.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>
</body>
</html>