{extend name="main"}
{block name="body"}
<div class="bg-white mb-3">
	<el-form :model="search" @submit.native.prevent="submitForm" ref="search" label-position="right" class="flex py-3">

	  <el-form-item label="状态" prop="status" class="flex mb-0 pl-3">
	  	<el-select v-model="search.status" placeholder="请选择" class="w-100px">
		    <el-option label="全部"value="all"></el-option>
		    <el-option label="未开始":value="0"></el-option>
		    <el-option label="报名中":value="1"></el-option>
		    <el-option label="已开启":value="2"></el-option>
		    <el-option label="已结束":value="3"></el-option>
		</el-select>
	  </el-form-item>

	  <el-form-item label="标题" prop="title" class="flex mb-0 pl-3">
	    <el-input v-model="search.title" placeholder="请输入你想搜索的关键词"></el-input>
	  </el-form-item>

	  <el-form-item class="flex mb-0 pl-3">
	    <el-button type="primary" @click="initHtml">查询</el-button>
	    <el-button @click="resetForm('search')">重置</el-button>
	  </el-form-item>
	</el-form>
</div>
<div class="bg-white p-3">
	<div class="table-responsive">
		<el-table
			ref="tableList"
	      	:data="tableData"
    		v-loading="search.ajax"
    		style="width: 100%;"
    		header-cell-class-name="table-header-DDE6FB">
	      <el-table-column
	        prop="id"
	        label="ID"
	        width="60">
	      </el-table-column>
	      <el-table-column
	        label="标题">
		      <template slot-scope="scope">
		      	<el-link type="primary" :href="'{:config('web.url')}/job-fair/detail/'+scope.row.id+'.html'" target="_blank"
		      	:underline="false"
		      	title="在前台打开">{{scope.row.title}}</el-link>
		      </template>
	      </el-table-column>
	      <el-table-column
	        prop="view_people_sum"
	        label="浏览数据"
	        width="160">
		      <template slot-scope="scope">
		      	<div class="small">
		          <div>浏览量：{{ scope.row.view_sum }}</div>
		          <div>浏览人数：{{ scope.row.view_people_sum }}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        prop="resume_sum"
	        label="参会数据"
	        width="160">
		      <template slot-scope="scope">
		      	<div class="small">
		          <div>人才报名：{{ scope.row.resume_sum }}</div>
		          <div>企业参会：{{ scope.row.company_sum }}</div>
		          <div>职位数：{{ scope.row.jobs_sum }}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="封面/横幅"
	        width="120">
		      <template slot-scope="scope">
				  <el-image
				  	v-if="scope.row.thumb" 
				    style="max-width: 80px; height: 23px"
				    :src="scope.row.thumb" 
				    :preview-src-list="[scope.row.thumb]">
				  </el-image>
				  <el-image
				  	v-if="scope.row.banner" 
				    style="max-width: 80px; height: 23px"
				    :src="scope.row.banner" 
				    :preview-src-list="[scope.row.banner]">
				  </el-image>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="状态"
	        width="120">
		      <template slot-scope="scope">
		  		<el-popover
					placement="bottom-end"
					trigger="click">
					<div>
			      		<el-button type="info" size="minism" 
			      		@click="setJobFairStatus(scope.row,0);">未开始</el-button>
			      		<el-button type="primary" size="minism"
			      		@click="setJobFairStatus(scope.row,1);">报名中</el-button>
			      		<el-button type="success" size="minism"
			      		@click="setJobFairStatus(scope.row,2);">已开启</el-button>
			      		<el-button type="danger" size="minism"
			      		@click="setJobFairStatus(scope.row,3);">已结束</el-button>
					</div>
					<div slot="reference">
				      	<transition>
				      		<el-button type="info" size="minism" 
				      		v-if="scope.row.status==0">未开始</el-button>
				      		<el-button type="primary" size="minism"
				      		v-else-if="scope.row.status==1">报名中</el-button>
				      		<el-button type="success" size="minism"
				      		v-else-if="scope.row.status==2">已开启</el-button>
				      		<el-button type="danger" size="minism"
				      		v-else-if="scope.row.status==3">已结束</el-button>
						</transition>
					</div>
				</el-popover>
		      </template>
	      </el-table-column>
	      <el-table-column
	        prop="start_time"
	        label="开始/结束时间"
	        width="200">
		      <template slot-scope="scope">
		      	<div class="small">
		          <div>{{ scope.row.start_time }}</div>
		          <div>{{ scope.row.end_time }}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        prop="start_time"
	        label="报名开始/报名结束"
	        width="200">
		      <template slot-scope="scope">
		      	<div class="small">
		          <div>{{ scope.row.sign_up_start_time }}</div>
		          <div>{{ scope.row.sign_up_end_time }}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="创建/更新时间"
	        width="200">
		      <template slot-scope="scope">
		      	<div class="small">
		          <div>{{ scope.row.create_time }}</div>
		          <div>{{ scope.row.update_time }}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="/"
	        width="180">
		      <template slot-scope="scope">
		        <el-button
		            type="primary"
		            plain
		            round
		            size="minism"
		            @click="window.open('/job-fair/edit/'+scope.row.id)">
		            编辑
		        </el-button>
		        <el-button
		            type="success"
		            plain
		            round
		            size="minism"
		            @click="window.open('/job-fair/boothManage?jid='+scope.row.id)">
		            展位
		        </el-button>
		        <el-button
		            type="success"
		            plain
		            round
		            size="minism"
		            @click="window.open('/job-fair/resumeManage?jid='+scope.row.id)">
		            人才
		        </el-button>
		      </template>
	      </el-table-column>
	    </el-table>
	</div>
	<div class="table-responsive py-3 text-center">
		<el-pagination
		  background
	      @size-change="handleSizeChange"
	      @current-change="handleCurrentChange"
	      :current-page="search.page"
	      :page-sizes="[10,50,100,200]"
	      :page-size="search.pageSize"
	      layout="total, sizes, prev, pager, next, jumper"
	      :total="search.total">
	    </el-pagination>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			labelPosition:'right',
			search:{
				title:'',
				status:'all',
				ajax:false,
				page:1,
				total:0,
				pageSize:10
			},
			tableData:[],
		},
		watch:{
		    view:XYBase.viewWatch,
		},
		created(){
			XYBase.created(this);
		},
	    methods: {
	    	setJobFairStatus(data,status){
	    		$.getJSON('/job-fair/setStatus/'+data.id+'/'+status,function(ret){
	    			if (ret) {
	    				if (ret.code === 0) {
	    					data.status=status;
	    				}else{
	    					XYBase.msg(ret.msg);
	    				}
	    			}else{
						XYBase.error(XYBase.config.system_network_error);
	    			}
	    		});
	    	},
			resetForm:function(formName) {
				this.$refs[formName].resetFields();
			},
			handleSizeChange(val) {
				this.search.page=1;
				this.search.pageSize=val;
	          	this.initHtml();
			},
			handleCurrentChange(val) {
				this.search.page=val;
	          	this.initHtml();
			},
	      	initHtml() {
	      		var _this=this;
	      		_this.search.ajax=true;
				$.ajax({
					url:'',
					type:'get',
					data:_this.search,
					dataType:'json',
					error:function(err){
	      				_this.search.ajax=false;
						XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
	      				_this.search.ajax=false;
						if (ret) {
							if (ret.code === 0) {
								_this.search.total=ret.data.total;
								_this.tableData=ret.data.data;
							}else{
								XYBase.msg(ret.msg);
							}
						}else{
							XYBase.error(XYBase.config.system_network_error);
						}
					}
				});
			}
	    }
	});
	$(function(){
		vm.initHtml();
		reloadWindowSize();
		$(window).resize(function(){
			reloadWindowSize();
		});
	});
	function reloadWindowSize (argument) {
		var winW=$(window).width();
		if(winW <= 576){
			vm.labelPosition='top';
		}else{
			vm.labelPosition='right';
		}
	}
</script>
{/block}