<?php
/**
 * 活动列表
 * $Id: event_list.inc,v 1.1 2015/10/08 11:18:50 wanggb Exp $
 * @author netvillage
 * @access public
 * @package manager.templates
 */
?>

<div id="classSetting">
	<div class="list_title">活动列表</div>
	<br />
	<div class="result_list">
		<div class="block" v-for="tmp in tableData" >
      <table style="border-spacing:10px">
      	<tr>
        	<td rowspan="5">
        		<a href="javascript:void(0);"@click="toDetail(tmp)"><el-image class="list_img" :src="tmp.front_image" style="object-fit: contain;"></el-image></a>
        	</td>
        </tr>
        <tr>
      		<td>
      			<span><a href="javascript:void(0);"@click="toDetail(tmp)" style="color:#000;">{{tmp.title}}</a></span>
      			<el-tag :type="tmp.status_type" v-if="tmp.status !=''" style="line-height:18px;height:18px;padding:0px;margin-left:5px;" effect="dark">{{tmp.status}}</el-tag>
      			<el-tag :type="tmp.time_status" v-if="tmp.status ==''" style="line-height:18px;height:18px;padding:0px;margin-left:5px;" effect="dark">{{tmp.event_status}}</el-tag>
      		</td>
      	</tr>
      	<tr>
      		<td>
      			<span>活动时间: </span>{{tmp.start_time}} — {{tmp.finish_time}}
      		</td>
      	</tr>
      	<tr>
      		<td>
      			<span>报名人数: </span>{{tmp.involved_count}} <span>完成人数: </span>{{tmp.finish_count}} <span>完成率: </span>{{tmp.finish_rate}}
      		</td>
      	</tr>
      	<tr>
      		<td>
      			<el-button type="info"size="mini" @click="editChange(tmp)">修改</el-button>&nbsp;&nbsp;&nbsp;
      			<el-button type="info"size="mini" @click="deleteRow(tmp)">删除</el-button>&nbsp;&nbsp;&nbsp;
      			<el-button type="info"size="mini" @click="handleDetail(tmp)">查看数据</el-button>
      		</td>
      	</tr>
  		</table>
  		<div style="background-color:#E6E3E3;height:1px;">
		</div>
	</div>
	<div v-if="tableData.length == 0"class="list_title"> <br/><br/>暂无数据</div>
</div>
</div>
<?
if ($event_count > 0) {
  ?>
<!--page begin-->
<?
  require_once ("page_common.inc");
  ?>
<!--page end-->
<?
}
?>
<script type="text/javascript">
	var list=[];
	<?
foreach ( $event_list as $tmp ) {
  ?>
		var data={
			id:<?=$tmp["id"] ?>,
			title:'<?=$tmp["title"]?>',
			start_time:'<?=date("Y-m-d ",strtotime($tmp["start_time"]))?>',
			finish_time:'<?=date("Y-m-d ",strtotime($tmp["finish_time"]))?>',
			front_image:'<?=$tmp["front_image"]?>',
			involved_count:'<?=empty($tmp["involved_count"])?"0":$tmp["involved_count"]?>',
			finish_count:'<?=empty($tmp["finish_count"])?"0":$tmp["finish_count"]?>',
			finish_rate:'<?=empty($tmp["finish_count"])?"0":round($tmp["finish_count"]/$tmp["involved_count"]*100)."%"?>',
			time_status:'<?=date("Y-m-d H:i:s") > $tmp["finish_time"]?"info":(date("Y-m-d H:i:s") < $tmp["start_time"]?"success":"")?>',
			event_status:'<?=date("Y-m-d H:i:s") > $tmp["finish_time"]?"已结束":(date("Y-m-d H:i:s") < $tmp["start_time"]?"未开始":"进行中")?>',
			status:'<?=$tmp["status"]=="NEW"?"未审核":($tmp["status"]=="NG"?"审核未通过":($tmp["status"]=="FINISH"?"活动结束":""))?>',
			status_type:'<?=$tmp["status"]=="NEW"?"warning":($tmp["status"]=="NG"?"danger":($tmp["status"]=="FINISH"?"info":""))?>'
		};
		list.push(data);
	<?
}
?>

	new Vue({
		el:'#classSetting',
		data:{
			tableData: list
		},
		methods:{
		  editChange(row) {
		  	window.location.href='event_edit_input.php?id='+row.id;
		  },
		  handleDetail(row){
		  	window.location.href='event_detail_list.php?id='+row.id;
		  },
		  toDetail(row){
		    window.location.href='event_dat_detail.php?id='+row.id;
		  },
		  deleteRow(rows) {
	    	this.$confirm('是否删除?', '提示', {
		    	confirmButtonText: '确定',
		    	cancelButtonText: '取消',
		    	type: 'warning'
		 		}).then(() => {
		    	this.$message({
		      	type: 'success',
		      	message: '删除成功!'
		     	});
//	        		rows.splice(index, 1);
					window.location.href='event_delete_result.php?id='+rows.id;
		   	}).catch(() => {
		    	this.$message({
		      	type: 'info',
		      	message: '已取消删除'
		    	});          
		    });
	    },
		}
	})
</script>