<?php
/**
 * 活动列表-数据详情
 * $Id: event_detail_list.inc,v 1.1 2020/01/03 11:18:46  Exp $
 * @author lixq
 * @access public
 * @package manager.templates
 */

?>
<style type="text/css">
	.m-l{
		margin-left: 10px;
	}
</style>
<div id="classSetting">
	<div class="list_title">
		活动列表-数据详情
	</div>
	<br/>
	<p>活动名称:<?=$event_dat->title?></p>
	<p>完成/参与:<?=$finish_count?>/<?=$total_count?></p>
	<h4>参与详情:</h4>
	<form id="search_form" action="event_detail_list.php" method="post">
		<input type="hidden"  name="circle_id" value="<?=$circle_id?>"/>
		<input type="hidden"  name="id" value="<?=$id?>"/>
		用户姓名:<input type="text" value="<?=$name?>" name="name" class="el-input__inner input_100 m-l"/>&nbsp;&nbsp;
		联系方式:<input type="text" value="<?=$mobile?>" name="mobile" class="el-input__inner input_100 m-l"/>&nbsp;
		是否完成:
		<template>
  		<el-radio v-model="is_finish" name="is_finish" label="1">是</el-radio>
  		<el-radio v-model="is_finish" name="is_finish" label="2">否</el-radio>
		</template>
		<br/>
		是否团队参与:
		<template>
  		<el-radio v-model="is_circle" name="is_circle" label="1">是</el-radio>
  		<el-radio v-model="is_circle" name="is_circle" label="2">否</el-radio>
		</template>&nbsp;&nbsp;
		团队名称:<el-select v-model="circle_id" size="small" style="margin-left: 10px;">
      <el-option
          v-for="item in circle_list"
          :key="item.id"
          :label="item.title"
          :value="item.id">
      </el-option>
  	</el-select>
	<el-button type="primary" @click="search()" class="edit_btn search_btn">检索</el-button>
	<el-button type="primary" @click="clear()" class="edit_btn search_btn">清空条件</el-button>
	</form>
  <br />
  <div style="background-color:#E6E3E3;height:1px;"></div>
  <br />
  <form id="input_time_form" action="event_input_time.php" method="post">
  	<input type="hidden" name="ids" value=""/>
  	<input type="hidden" name="names" value=""/>
  	<input type="hidden" name="event_id" value="<?=$id?>"/>
  </form>
  <el-button type="primary" style="margin-right: 10px;" @click="batchInputTime()">批量时长录入</el-button>
  <div class="result_list">
  	<el-table :data="tableData" @selection-change="handleSelectionChange" border>
  	 <el-table-column  type="selection" label="全部" width="55"></el-table-column>
  	<el-table-column  prop="index_no" label="编号" width=""></el-table-column>
  		<el-table-column  prop="user_name" label="用户姓名" width=""></el-table-column>
  		<el-table-column  prop="mobile" label="联系方式" width=""></el-table-column>
  		<el-table-column  prop="is_circle" label="是否团队参与" width=""></el-table-column>
  		<el-table-column  prop="circle_name" label="团队名称" width=""></el-table-column>
  		<el-table-column  prop="user_type" label="用户身份" width=""></el-table-column>
  		<el-table-column  prop="user_identity" label="用户类型" width=""></el-table-column>
  		<el-table-column  prop="finish_time" label="完成时间" width=""></el-table-column>
  		<el-table-column  prop="is_finish" label="状态" width=""></el-table-column>
  		<el-table-column  label="操作"  width="150">
			<template slot-scope="scope"  >
				<el-button @click="handleChange(scope.row)" type="text" size="small">详情</el-button>
				<el-button type="text" size="small" @click="inputTime(scope.row)">时长录入</el-button>
			</template>
			
  			</el-table-column>
  	</el-table>
  </div>
</div>
<?
if ($event_member_count > 0) {
?>
<!--page begin-->
<?
require_once("page_common.inc");
?>
<!--page end-->
<?
}
?>
<script type="text/javascript">
	var list=[];
	<?
	foreach ($event_member_list as $tmp) {
	?>
		var data={
			id:<?=$tmp["id"] ?>,
			index_no:'<?=$tmp["index_no"]?>',
			user_name:'<?=$tmp["user_name"]?>',
			mobile:'<?=$tmp["mobile"]?>',
			is_circle:'<?=$tmp["circle_id"]=="0"?"否":"是"?>',
			circle_name:'<?=!empty($tmp["circle_title"])?$tmp["circle_title"]:"无"?>',
			user_type:'<?=UserRole::getTitleById($tmp["role"])?>',
			user_identity:'<?=$tmp["circle_id"]== 0?"个人":"圈子"?>',
			finish_time:'<?=!empty($tmp["finish_time"])?date("Y/m/d H:i",strtotime($tmp["finish_time"])):""?>',
			is_finish:'<?=$tmp["status"]=="NEW"?"参与中":($tmp["status"]=="FINISH"?"已完成":"时间已录入")?>'
		};
		list.push(data);
	<?
	}
	?>

	new Vue({
		el:'#classSetting',
		data:{
			tableData: list,
			is_circle:'<?=$is_circle?>',
			is_finish:'<?=$is_finish?>',
			circle_list:<?=json_encode($circle_list)?>,
			circle_id:'<?=$circle_id?>',
			multipleSelection: []
		},
		methods:{
			handleChange(row) {
		  	window.location.href='event_member_detail.php?id='+row.id;
		  },
		  inputTime(row){
		    $("input[name='ids']").val(row.id);
		    $("input[name='names']").val(row.user_name);
		    $("#input_time_form").submit();
		    
		  },
		  batchInputTime(){
			  if(this.multipleSelection.length == 0){
			    this.$message({
            type: 'error',
            message: '请选择至少一个用户!'
          });
          return;
				}
				var ids = "";
				var names = "";
			  for (i = 0; i < this.multipleSelection.length; i++) { 
			    ids += this.multipleSelection[i].id + ",";
			    names += this.multipleSelection[i].user_name + ",";
			  }
			  if (ids.length > 0) {
			    ids = ids.substr(0,ids.length - 1);
			  }
			  if (names.length > 0) {
			    names = names.substr(0,names.length - 1);
			  }
		    $("input[name='ids']").val(ids);
		    $("input[name='names']").val(names);
		    $("#input_time_form").submit();
		  },
		  clear(){
		    $("input[name='name']").val("");
    	  $("input[name='mobile']").val("");
    	  this.is_circle = "";
    	  this.is_finish = "";
    	  this.circle_id = "";
    	  
			},
		  search(){
			  $("input[name='circle_id']").val(this.circle_id);
				$("#search_form").submit();
			},
			handleSelectionChange(val) {
        this.multipleSelection = val;
      }
		}
		 
	})
</script>