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

<div id="classSetting">
	<div class="list_title">募捐活动列表<el-button type="primary" style="margin-right: 10px;" @click="addEvent()">募捐活动发布</el-button></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.max_money}}元 <span>已募捐金额: </span>{{tmp.money}}元 <span>
      		</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 ($donations_event_count > 0) {
  ?>
<!--page begin-->
<?
  require_once ("page_common.inc");
  ?>
<!--page end-->
<?
}
?>
<script type="text/javascript">
	var list=[];
	<?
	foreach ( $donations_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?>',
			max_money:'<?=floatval($tmp->max_money)?>',
			money:'<?=floatval($tmp->money)?>',
			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:{
		  addEvent(){
		    window.location.href='donations_edit_input.php?action_type=new';
		  },
		  editChange(row) {
		  	window.location.href='donations_edit_input.php?action_type=edit&id='+row.id;
		  },
		  handleDetail(row){
		  	window.location.href='donations_detail_list.php?id='+row.id;
		  },
		  toDetail(row){
		    window.location.href='donations_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='donations_delete_result.php?id='+rows.id;
		   	}).catch(() => {
		    	this.$message({
		      	type: 'info',
		      	message: '已取消删除'
		    	});          
		    });
	    },
		}
	})
</script>