<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>
<meta http-equiv="Content-Disposition" content="attachment;">
</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;
	}
	.tablelist td a{
    	text-decoration: underline;
	}
	
</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/poster/join/list.html}" method="post" style="float: left;width: 460px;">
	<input type="hidden" name="pageSize" id="pageSize" value="10" />
	<ul class="seachform">
			<li>
			 <label>机构名称</label>
			  <input name="name" type="text" class="scinput" th:value="${search.name}"  />
		    </li>
			<li>
				<input type="button" class="scbtn selectbtu" value="查询" />
			</li>
			<li>
				<ul class="toolbar">
					<a href="javascript:;" onclick="edit('')">
						<li class="click"><span><img th:src="@{/static/sys/images/t01.png}"></span>新增机构</li>
					</a>
				</ul>
			</li>
	</ul>
	</form> 
	
	<ul class="seachform"  style="float: left;width: 500px;">
		<li>
		  <input type="button" id="teacherimput" style="width: 100px;height: 30px;margin-top: 4px;"  class="scbtn" value=" + 批量导入机构" />
		  <div style="display: none">
		 	 <input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" id="teacherfile" />
		  </div>
	    </li>
	    
	     <li>
		  	<a th:href="@{/static/sys/excel/join_lib.xlsx}"><input type="button" style="width: 100px;height: 30px;margin-top: 4px;"  class="scbtn" value="下载导入表格" /></a>
	     </li>
     </ul>

	<table class="tablelist">
		<thead>
		    <tr>
		    	<th style="width: 50px;">序号</th>
		    	<th >机构名称 </th>
		    	<th >联系方式</th>
		    	<th >地址</th>
		    	<th >创建时间</th>
		    	<th >LOGO</th>
		    	<th >LOGO2</th>
		    	<th >二维码1</th>
		    	<th >二维码2</th>
		    	<th >操作</th>
		    </tr> 
		</thead>
		<tbody>
			<tr th:each="item:${list}" >
				<td th:text="${itemStat.count+((page.pageNo-1)*page.pageSize) }"></td>
				<td th:text="${item.name}"></td>
				<td th:text="${item.phone}"></td>
				<td th:text="${item.address}"></td>
				<td th:text="${item.create_time}"></td>
				<td class="imgtd">
					<img  th:if="${item.logo_img!=null && item.logo_img!=''}" style="width: 50px;height: 50px;" th:src="${imgUrl+item.logo_img}">
				</td><td class="imgtd">
					<img  th:if="${item.logo_img2!=null && item.logo_img2!=''}" style="width: 50px;height: 50px;" th:src="${imgUrl+item.logo_img2}">
				</td>
				<td class="imgtd">
					<img th:if="${item.qrcode_img1!=null && item.qrcode_img1!=''}" style="width: 50px;height: 50px;" th:src="${imgUrl+item.qrcode_img1}">
				</td>
				<td class="imgtd">
					<img th:if="${item.qrcode_img2!=null && item.qrcode_img2!=''}" style="width: 50px;height: 50px;" th:src="${imgUrl+item.qrcode_img2}">
				</td>
				<td >
					<a style="color: red" th:href="${'javascript:joinDel(''' + item.id + ''')'}"  class="tablelink">删除机构</a>
					&nbsp;&nbsp;
					<a href="javascript:;" th:onclick="'edit(\''+${item.id}+'\')'" >编辑机构</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">
	var aid="[[${param.id}]]";
	
	$(function (){
		
		$("#teacherimput").click(function (){
			$("#teacherfile").click();
		})
	
	    var $teacherfile =$("#teacherfile");
	    $teacherfile.change(function () {
	        if($(this).val() != ""){
	        	fileJoinLoad(this);
	        }
	    })
	    
	    function fileJoinLoad(ele){
		  var formData = new FormData();
		  var name = $(ele).val();
		  var files = $(ele)[0].files[0];
		  formData.append("file", files);
		  formData.append("name", name);
		  $.ajax({
		      url: "[[${sysUrl}]]/sys/poster/join/import?id="+aid,
		      type: 'POST',
		      data: formData,
		      processData: false,
		      contentType: false, 
		      beforeSend: function () {
		    	  parent.layer.msg("数据正在导入中....",{icon:2});
		      },
		      success: function (responseStr) {
		    	  if(responseStr.meta.success){
		    	  	 parent.layer.msg("导入成功",{icon:1});
					 $("#teacherfile").val("");
					 $(".selectbtu").click();
		    	  }else{
		    		 parent.layer.msg(responseStr.meta.message,{icon:11});
		    		 $("#teacherfile").val("");
		    	  }
		      }
		      ,
		      error : function (responseStr) {
		    		parent.layer.msg("导入失败,请刷新后重试！",{icon:11});
		    		$("#teacherfile").val("");
		      }
		  });
		 
		}
		
		
	})
	
	
	function edit(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: ['50%', '60%'],
		    content: '[[${sysUrl}]]/sys/poster/join/edit.html?aid='+aid+'&id='+id
		});
	}
	
	function joinDel(id){
		parent.layer.confirm("您确定要删除机构?", {
			icon: 4, btn: ['确定','关闭'],offset: '100px' //按钮
		}, function(){
			var url="[[${sysUrl}]]/sys/poster/join/del?id="+id;
			var params ={};
			$.post(url,params,function(data){
				if(data.meta.success){
					parent.layer.msg("删除成功",{icon:1});
					$(".selectbtu").click();
				}else{
					parent.layer.msg(data.meta.message,{icon:11});
				}
			});
		});
	}
	
	
</script>

</html>