{extend name="main"}
{block name="style"}
<style type="text/css">
	.flex-lable{width: 100px;color: #6c757d;text-align: right;padding-right: 10px;}
</style>
{/block}
{block name="body"}
<div class="bg-white p-3">
	<el-form :model="search" @submit.native.prevent="submitForm" ref="search" label-width="120px" :label-position="labelPosition" size="mini">

	  <el-form-item label="搜索类型" prop="search_type">
	    <el-radio-group v-model="search.search_type">
	      <el-radio :label="'id'">职位ID</el-radio>
	      <el-radio :label="'company_id'">公司ID</el-radio>
	      <el-radio :label="'uid'">UID</el-radio>
	      <el-radio :label="'company_name'">公司名</el-radio>
	    </el-radio-group>
	  </el-form-item>

	  <el-form-item :label="getSearchType()" prop="key">
	    <el-input v-model="search.key" class="col-12 col-sm-2 pl-0 pr-0"></el-input>
	  </el-form-item>

	  <el-form-item label="企业认证" prop="attestation">
	    <el-radio-group v-model="search.attestation">
	      <el-radio :label="'all'">全部</el-radio>
	      <el-radio v-for="v in attestation" :label="v.value">{{v.title}}</el-radio>
	    </el-radio-group>
	  </el-form-item>

	  <el-form-item label="审核" prop="examine">
	    <el-radio-group v-model="search.examine">
	      <el-radio :label="'all'">全部</el-radio>
	      <el-radio :label="0">未审核</el-radio>
	      <el-radio :label="1">已通过</el-radio>
	      <el-radio :label="2">未通过</el-radio>
	    </el-radio-group>
	  </el-form-item>

	  <el-form-item>
	    <el-button type="primary" @click="initHtml">查询</el-button>
	    <el-button @click="resetForm('search')">重置</el-button>
	  </el-form-item>
	</el-form>
	<div class="table-responsive py-3">
		<el-button-group class="text-nowrap flex" style="min-width: 500px">
		  	<el-button type="primary" size="mini" @click="exportJobs">导出({{tableData.length}})</el-button>
	  		<el-button type="success" size="mini" icon="el-icon-refresh" @click="refreshJobsALL">刷新</el-button>
		  	<el-button type="success" size="mini" @click="openRefuseWin()">批量审核</el-button>
			<el-popover
			placement="right"
			width="300"
			trigger="click"
			title="置顶职位">
				<div class="flex flex-center">
					<div class="flex-lable">置顶天数</div>
		      		<el-input-number v-model="top" :step="1" step-strictly
		      		:min="0"
		      		size="small"
		      		controls-position="right"
		      		placeholder="置顶天数"></el-input-number>
				</div>
				<div class="flex flex-center pt-3">
					<div class="flex-lable">是否累加</div>
		      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
					<div>0、为取消置顶，n>0、置顶n天</div>
					<div>开启累加之后如若当前置顶时间未到期，则追加天数</div>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
				</div>
	      		<div class="flex">
	      			<div class="flex-1"></div>
			  		<el-button type="info" size="mini"
			  		:disabled="top>0"
			  		@click="setJobsTopAll">取消置顶</el-button>
			  		<div class="px-1"></div>
			  		<el-button type="primary" size="mini"
			  		:disabled="top<=0"
			  		@click="setJobsTopAll">置顶{{top}}天</el-button>
			  	</div>
			  	<div slot="reference">
		      		<el-button type="success" size="mini">批量置顶</el-button>
			  	</div>
			</el-popover>
			<el-popover
			placement="right"
			width="300"
			trigger="click"
			title="推荐职位">
				<div class="flex flex-center">
					<div class="flex-lable">推荐天数</div>
		      		<el-input-number v-model="recommend" :step="1" step-strictly
		      		:min="0"
		      		size="small"
		      		controls-position="right"
		      		placeholder="推荐天数"></el-input-number>
				</div>
				<div class="flex flex-center pt-3">
					<div class="flex-lable">是否累加</div>
		      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
					<div>0、为取消推荐，n>0、推荐n天</div>
					<div>开启累加之后如若当前推荐时间未到期，则追加天数</div>
				</div>
	      		<div class="flex">
	      			<div class="flex-1"></div>
			  		<el-button type="info" size="mini"
			  		:disabled="recommend>0"
			  		@click="setJobsRecommendAll">取消推荐</el-button>
			  		<div class="px-1"></div>
			  		<el-button type="primary" size="mini"
			  		:disabled="recommend<=0"
			  		@click="setJobsRecommendAll">推荐{{recommend}}天</el-button>
			  	</div>
			  	<div slot="reference">
		      		<el-button type="success" size="mini">批量推荐</el-button>
			  	</div>
			</el-popover>
			<el-popover
			placement="right"
			width="300"
			trigger="click"
			title="紧急招聘">
				<div class="flex flex-center">
					<div class="flex-lable">紧急招聘天数</div>
		      		<el-input-number v-model="urgent" :step="1" step-strictly
		      		:min="0"
		      		size="small"
		      		controls-position="right"
		      		placeholder="紧急招聘天数"></el-input-number>
				</div>
				<div class="flex flex-center pt-3">
					<div class="flex-lable">是否累加</div>
		      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
					<div>0、为取消紧急招聘，n>0、紧急招聘n天</div>
					<div>开启累加之后如若当前紧急招聘时间未到期，则追加天数</div>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
				</div>
	      		<div class="flex">
	      			<div class="flex-1"></div>
			  		<el-button type="info" size="mini"
			  		:disabled="urgent>0"
			  		@click="setJobsUrgentAll">取消紧急招聘</el-button>
			  		<div class="px-1"></div>
			  		<el-button type="primary" size="mini"
			  		:disabled="urgent<=0"
			  		@click="setJobsUrgentAll">紧急招聘{{urgent}}天</el-button>
			  	</div>
			  	<div slot="reference">
		      		<el-button type="success" size="mini">紧急招聘</el-button>
			  	</div>
			</el-popover>
		</el-button-group>
	</div>
	<div class="table-responsive py-3">
		<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 class="table-responsive">
		<el-table
			ref="tableList"
	      	:data="tableData"
    		stripe
    		v-loading="search.ajax"
    		style="width: 100%;"
    		row-class-name="row-flex"
    		@selection-change="handleSelectionChange">
		  <el-table-column
			  type="selection"
			  width="55">
		  </el-table-column>
	      <el-table-column
	        prop="id"
	        label="ID"
	        width="100">
	      </el-table-column>
	      <el-table-column
	        label="职位名称"
	        min-width="200">
		      <template slot-scope="scope">
		      	<el-link :href="'{:config('web.url')}/jobs/'+scope.row.id+'.html'" target="_blank" :underline="false">{{scope.row.title}}</el-link>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="公司名称"
	        width="300">
		      <template slot-scope="scope">
		      	<el-link :href="'{:config('web.url')}/company/'+scope.row.company_id+'.html'" target="_blank" :underline="false">{{scope.row.company_name}}</el-link>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="企业认证"
	        width="80">
		      <template slot-scope="scope">
		      	<transition>
		      		<el-button v-for="v in attestation" :type="v.type" size="minism"
		      		v-if="scope.row.attestation==v.value"
		      		@click="window.open('/company/attestation?uid='+scope.row.uid)">{{v.title}}</el-button>
				</transition>
		      </template>
	      </el-table-column>
	      <el-table-column
	        prop="delivery_resume"
	        label="投递/浏览"
	        width="140">
		      <template slot-scope="scope">
		      <div class="small">
		      	<div>投递：{{scope.row.delivery_resume}}</div>
		      	<div>浏览：{{scope.row.view}}</div>
		      	<div>来源：{{scope.row.app_name}}</div>
		      </div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="审核/状态"
	        width="100">
		      <template slot-scope="scope">
		      	<div>
				<div>
		      	<transition>
		      		<el-button type="success" size="minism"
		      		v-if="scope.row.examine==1 || scope.row.examine=='loading'"
		      		@click="openRefuseWin(scope.row);" 
		      		:loading="scope.row.examine=='loading'">已审核</el-button>
		      		<el-button type="info" size="minism" 
		      		v-else-if="scope.row.examine==0 || scope.row.examine=='loading'" 
		      		@click="openRefuseWin(scope.row);" 
		      		:loading="scope.row.examine=='loading'">待审核</el-button>
		      		<el-button type="danger" size="minism" 
		      		v-else-if="scope.row.examine==2 || scope.row.examine=='loading'" 
		      		@click="setJobsExamine(scope.row,1);" 
		      		:loading="scope.row.examine=='loading'">未通过</el-button>
				</transition>
				</div>
				<div>
		      	<transition>
		      		<el-button type="success" size="minism"
		      		v-if="scope.row.status==1 || scope.row.status=='loading'"
		      		@click="setJobsStatus(scope.row);" 
		      		:loading="scope.row.status=='loading'">展示中</el-button>
		      		<el-button type="info" size="minism" 
		      		v-else-if="scope.row.status==0 || scope.row.status=='loading'" 
		      		@click="setJobsStatus(scope.row);" 
		      		:loading="scope.row.status=='loading'">未展示</el-button>
		      		<el-button type="danger" size="minism" 
		      		v-else>已删除</el-button>
				</transition>
				</div>
				</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="置顶/推荐"
	        width="100">
		      <template slot-scope="scope">
		      	<div>
				<el-popover
				placement="left"
				width="300"
				trigger="click"
				title="置顶职位">
					<div class="flex flex-center">
						<div class="flex-lable">置顶天数</div>
			      		<el-input-number v-model="top" :step="1" step-strictly
			      		:min="0"
			      		size="small"
			      		controls-position="right"
			      		placeholder="置顶天数"></el-input-number>
					</div>
					<div class="flex flex-center pt-3">
						<div class="flex-lable">是否累加</div>
			      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
					</div>
					<div class="bg-light p-2 rounded my-3 text-secondary small">
						<p class="text-dark font-weight-bold" v-if="scope.row.top_time">当前置顶结束时间：{{scope.row.top_time}}</p>
						<div>0、为取消置顶，n>0、置顶n天</div>
						<div>开启累加之后如若当前置顶时间未到期，则追加天数</div>
					</div>
		      		<div class="flex">
		      			<div class="flex-1"></div>
				  		<el-button type="info" size="mini"
				  		:disabled="top>0"
				  		@click="setJobsTop(scope.row)">取消置顶</el-button>
				  		<div class="px-1"></div>
				  		<el-button type="primary" size="mini"
				  		:disabled="top<=0"
				  		@click="setJobsTop(scope.row)">置顶{{top}}天</el-button>
				  	</div>
				  	<div slot="reference">
			      		<el-button type="success" size="minism"
			      		v-if="scope.row.top==1 || scope.row.top==2" 
			      		:loading="scope.row.top==2">置顶中</el-button>
			      		<el-button type="info" size="minism" 
			      		:loading="scope.row.top==2"
			      		v-else="scope.row.top==0 || scope.row.top==2">未置顶</el-button>
				  	</div>
				</el-popover>
				<el-popover
				placement="left"
				width="300"
				trigger="click"
				title="推荐职位">
					<div class="flex flex-center">
						<div class="flex-lable">推荐天数</div>
			      		<el-input-number v-model="recommend" :step="1" step-strictly
			      		:min="0"
			      		size="small"
			      		controls-position="right"
			      		placeholder="推荐天数"></el-input-number>
					</div>
					<div class="flex flex-center pt-3">
						<div class="flex-lable">是否累加</div>
			      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
					</div>
					<div class="bg-light p-2 rounded my-3 text-secondary small">
						<p class="text-dark font-weight-bold" v-if="scope.row.top_time">当前推荐结束时间：{{scope.row.recommend_time}}</p>
						<div>0、为取消推荐，n>0、推荐n天</div>
						<div>开启累加之后如若当前推荐时间未到期，则追加天数</div>
					</div>
		      		<div class="flex">
		      			<div class="flex-1"></div>
				  		<el-button type="info" size="mini"
				  		:disabled="recommend>0"
				  		@click="setJobsRecommend(scope.row)">取消推荐</el-button>
				  		<div class="px-1"></div>
				  		<el-button type="primary" size="mini"
				  		:disabled="recommend<=0"
				  		@click="setJobsRecommend(scope.row)">推荐{{recommend}}天</el-button>
				  	</div>
				  	<div slot="reference">
			      		<el-button type="success" size="minism"
			      		v-if="scope.row.recommend==1 || scope.row.recommend==2" 
			      		:loading="scope.row.recommend==2">推荐中</el-button>
			      		<el-button type="info" size="minism" 
			      		:loading="scope.row.recommend==2"
			      		v-else="scope.row.recommend==0 || scope.row.recommend==2">未推荐</el-button>
				  	</div>
				</el-popover>
				<el-popover
				placement="left"
				width="300"
				trigger="click"
				title="紧急招聘">
					<div class="flex flex-center">
						<div class="flex-lable">紧急招聘天数</div>
			      		<el-input-number v-model="urgent" :step="1" step-strictly
			      		:min="0"
			      		size="small"
			      		controls-position="right"
			      		placeholder="紧急招聘天数"></el-input-number>
					</div>
					<div class="flex flex-center pt-3">
						<div class="flex-lable">是否累加</div>
			      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
					</div>
					<div class="bg-light p-2 rounded my-3 text-secondary small">
						<p class="text-dark font-weight-bold" v-if="scope.row.top_time">当前紧急招聘结束时间：{{scope.row.recommend_time}}</p>
						<div>0、为取消紧急招聘，n>0、紧急招聘n天</div>
						<div>开启累加之后如若当前紧急招聘时间未到期，则追加天数</div>
					</div>
		      		<div class="flex">
		      			<div class="flex-1"></div>
				  		<el-button type="info" size="mini"
				  		:disabled="urgent>0"
				  		@click="setJobsUrgent(scope.row)">取消紧急招聘</el-button>
				  		<div class="px-1"></div>
				  		<el-button type="primary" size="mini"
				  		:disabled="urgent<=0"
				  		@click="setJobsUrgent(scope.row)">紧急招聘{{urgent}}天</el-button>
				  	</div>
				  	<div slot="reference">
			      		<el-button type="success" size="minism"
			      		v-if="scope.row.urgent==1 || scope.row.urgent==2" 
			      		:loading="scope.row.urgent==2">紧急招聘中</el-button>
			      		<el-button type="info" size="minism" 
			      		:loading="scope.row.urgent==2"
			      		v-else="scope.row.urgent==0 || scope.row.urgent==2">未紧急招聘</el-button>
				  	</div>
				</el-popover>
				</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="时间线"
	        width="180">
		      <template slot-scope="scope">
		        <el-popover trigger="hover" placement="top">
		          <p>创建时间: {{ scope.row.create_time }}</p>
		          <p>更新时间: {{ scope.row.update_time }}</p>
		          <p>刷新时间: {{ scope.row.refresh_time }}</p>
		          <p v-if="scope.row.delete_time">删除时间: {{ scope.row.delete_time }}</p>
		          <p v-if="scope.row.top_time">置顶结束: {{ scope.row.top_time }}</p>
		          <p v-if="scope.row.recommend_time">推荐结束: {{ scope.row.recommend_time }}</p>
		          <p v-if="scope.row.urgent_time">紧急招聘结束: {{ scope.row.urgent_time }}</p>
		          <div slot="reference" class="name-wrapper">
		            <el-tag size="small" type="info">{{ scope.row.create_time }}</el-tag>
		          </div>
		        </el-popover>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="/"
	        width="120">
		      <template slot-scope="scope">
		        <el-button
		            type="success"
		            size="minism"
		            @click="Business.openBusiness(scope.row.company_id,true)">
		            业务
		        </el-button>
		        <el-button
		            type="primary"
		            size="minism"
		            @click="window.open('/jobs/editJobs/'+scope.row.company_id+'/'+scope.row.id)">
		            编辑
		        </el-button>
		      </template>
	      </el-table-column>
	    </el-table>
	</div>
	<div class="table-responsive py-3">
		<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 class="table-responsive py-3">
		<el-button-group class="text-nowrap flex" style="min-width: 500px">
		  	<el-button type="success" size="mini" @click="openRefuseWin()">批量审核</el-button>
			<el-popover
			placement="right"
			width="300"
			trigger="click"
			title="置顶职位">
				<div class="flex flex-center">
					<div class="flex-lable">置顶天数</div>
		      		<el-input-number v-model="top" :step="1" step-strictly
		      		:min="0"
		      		size="small"
		      		controls-position="right"
		      		placeholder="置顶天数"></el-input-number>
				</div>
				<div class="flex flex-center pt-3">
					<div class="flex-lable">是否累加</div>
		      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
					<div>0、为取消置顶，n>0、置顶n天</div>
					<div>开启累加之后如若当前置顶时间未到期，则追加天数</div>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
				</div>
	      		<div class="flex">
	      			<div class="flex-1"></div>
			  		<el-button type="info" size="mini"
			  		:disabled="top>0"
			  		@click="setJobsTopAll">取消置顶</el-button>
			  		<div class="px-1"></div>
			  		<el-button type="primary" size="mini"
			  		:disabled="top<=0"
			  		@click="setJobsTopAll">置顶{{top}}天</el-button>
			  	</div>
			  	<div slot="reference">
		      		<el-button type="success" size="mini">批量置顶</el-button>
			  	</div>
			</el-popover>
			<el-popover
			placement="right"
			width="300"
			trigger="click"
			title="推荐职位">
				<div class="flex flex-center">
					<div class="flex-lable">推荐天数</div>
		      		<el-input-number v-model="recommend" :step="1" step-strictly
		      		:min="0"
		      		size="small"
		      		controls-position="right"
		      		placeholder="推荐天数"></el-input-number>
				</div>
				<div class="flex flex-center pt-3">
					<div class="flex-lable">是否累加</div>
		      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
					<div>0、为取消推荐，n>0、推荐n天</div>
					<div>开启累加之后如若当前推荐时间未到期，则追加天数</div>
				</div>
	      		<div class="flex">
	      			<div class="flex-1"></div>
			  		<el-button type="info" size="mini"
			  		:disabled="recommend>0"
			  		@click="setJobsRecommendAll">取消推荐</el-button>
			  		<div class="px-1"></div>
			  		<el-button type="primary" size="mini"
			  		:disabled="recommend<=0"
			  		@click="setJobsRecommendAll">推荐{{recommend}}天</el-button>
			  	</div>
			  	<div slot="reference">
		      		<el-button type="success" size="mini">批量推荐</el-button>
			  	</div>
			</el-popover>
			<el-popover
			placement="right"
			width="300"
			trigger="click"
			title="紧急招聘">
				<div class="flex flex-center">
					<div class="flex-lable">紧急招聘天数</div>
		      		<el-input-number v-model="urgent" :step="1" step-strictly
		      		:min="0"
		      		size="small"
		      		controls-position="right"
		      		placeholder="紧急招聘天数"></el-input-number>
				</div>
				<div class="flex flex-center pt-3">
					<div class="flex-lable">是否累加</div>
		      		<el-checkbox v-model="accumulation" :true-lable="1" :false-lable="0">{{accumulation?'关闭':'开启'}}</el-checkbox>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
					<div>0、为取消紧急招聘，n>0、紧急招聘n天</div>
					<div>开启累加之后如若当前紧急招聘时间未到期，则追加天数</div>
				</div>
				<div class="bg-light p-2 rounded my-3 text-secondary small">
				</div>
	      		<div class="flex">
	      			<div class="flex-1"></div>
			  		<el-button type="info" size="mini"
			  		:disabled="urgent>0"
			  		@click="setJobsUrgentAll">取消紧急招聘</el-button>
			  		<div class="px-1"></div>
			  		<el-button type="primary" size="mini"
			  		:disabled="urgent<=0"
			  		@click="setJobsUrgentAll">紧急招聘{{urgent}}天</el-button>
			  	</div>
			  	<div slot="reference">
		      		<el-button type="success" size="mini">紧急招聘</el-button>
			  	</div>
			</el-popover>
		</el-button-group>
	</div>
</div>
<el-dialog
  title="审核"
  :visible.sync="dialogVisible"
  width="600px"
  :before-close="cancelRefuseWinSubmit">
	<el-form :model="form" label-width="80px" :rules="rules" ref="form" size="small">
		  <el-form-item label="审核" prop="status">
		    <el-radio-group v-model="form.status">
		      <el-radio :label="1">通过</el-radio>
		      <el-radio :label="2">驳回</el-radio>
		    </el-radio-group>
		  </el-form-item>
		  <el-form-item label="驳回原因" prop="msg" v-if="form.status==2">
		    <el-input type="textarea" v-model="form.msg" class="col-12 pl-0 pr-0" :autosize="{ minRows: 4, maxRows: 20}" maxlength="200" show-word-limit></el-input>
		  </el-form-item>
		  <el-form-item label="通知" prop="notice">
		  	<el-checkbox v-model="form.notice"
		  	:true-label="1"
		  	:false-label="0">发送通知</el-checkbox>
		  	<p v-if="form.notice" class="small text-danger">当前发送通知</p>
		  </el-form-item>
	</el-form>
	<div class="pointer text-primary small py-1" @click="showLog= !showLog;">{{showLog?'收起日志':'查看日志'}}</div>
  	<div v-show="showLog" style="max-height:500px;overflow-y: auto;">
		<div class="py-2 border-bottom mb-2" v-for="(v,index) in rowData.log">
			<div class="flex">
				<div class="text-secondary" v-if="v.status===0">提交申请</div>
				<div class="text-success" v-if="v.status===1">审核通过</div>
				<div class="text-danger" v-if="v.status===2">被驳回</div>
				<div class="flex-1 pl-2">{{v.nickname}}</div>
				<div class="small text-secondary">{{v.create_time}}</div>
			</div>
			<div class="pt-2">{{v.msg}}</div>
		</div>
  	</div>
	<div slot="footer">
	    <el-button @click="cancelRefuseWinSubmit">取 消</el-button>
	    <el-button type="primary" @click="submitForm('form');" :loading="form.ajax">{{form.ajax?'提交中...':'提交'}}</el-button>
	</div>
</el-dialog>
{/block}
{block name="script"}
<script type="text/javascript">
	{empty name="attestation"}
	var attestation=[];
	{else/}
	var attestation={:json_encode($attestation,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="role"}
	var role=[];
	{else/}
	var role={:json_encode($role,JSON_UNESCAPED_UNICODE)};
	{/empty}
</script>
<script type="text/javascript">
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			showLog:false,
			role:role,
			labelPosition:'right',
			attestation:attestation,
			search:{
				{notempty name=":request()->get('jobs_id')"}
				search_type:'id',
				key:'{:request()->get('jobs_id')}',
				{elseif request()->get('uid')/}
				search_type:'uid',
				key:'{:request()->get('uid')}',
				{elseif request()->get('name')/}
				search_type:'name',
				key:'{:request()->get('name')}',
				{elseif request()->get('mobile')/}
				search_type:'mobile',
				key:'{:request()->get('mobile')}',
				{elseif request()->get('email')/}
				search_type:'email',
				key:'{:request()->get('email')}',
				{else/}
				search_type:'id',
				key:'',
				{/notempty}
				attestation:'all',
				examine:{:request()->get('examine',"\'all\'")},
				ajax:false,
				page:1,
				total:0,
				pageSize:10
			},
			tableData:[],
			multipleSelection:[],
			multipleSelectionIndex:0,
			dialogVisible:false,
			rowData:{},
			top:0,
			recommend:0,
			urgent:0,
			accumulation:0,
			form:{
				ajax:false,
				status:1,
				notice:1,
				msg:''
			},
	        rules: {
	          status: [
	            { required: true, message: '请选择审核结果', trigger: 'change' },
	          ],
	          msg: [
	            { required: true, message: '请输入审核结果', trigger: 'blur' },
	          ],
	        }
		},
		watch:{
		    view:XYBase.viewWatch,
		},
		created(){
			XYBase.created(this);
		},
	    methods: {
		    toggleSelection(rows) {
		        if (rows) {
		          rows.forEach(row => {
		            this.$refs.tableList.toggleRowSelection(row);
		          });
		        } else {
		          this.$refs.tableList.clearSelection();
		        }
		    },
		    handleSelectionChange(val) {
		        this.multipleSelection = val;
		    },
	      	cancelRefuseWinSubmit(done){
	      		this.rowData={};
	      		this.$refs.form&&this.$refs.form.resetFields();
	      		typeof done==='function'&&done();
				this.dialogVisible=false;
	      	},
			openRefuseWin(row){
				if (row){
					this.rowData=row;
				}else{
					if (this.multipleSelection.length<1)return XYBase.msg('请选择职位');
				}
				this.dialogVisible=true;
			},
			submitForm(formName) {
				var _this=this;
				_this.$refs[formName].validate((valid) => {
				  if (valid) {
				  	if (this.rowData.id) {
					  	_this.setJobsExamine(_this.rowData,_this.form.status);
				  	}else{
						_this.dialogVisible=false;
				  		_this.setJobsExamineALL();
				  	}
				  } else {
					return XYBase.warning('请先把表单填写完整。');
				  }
				});
			},
			refreshJobsALL(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.refreshJobsALLAjax();
			},
			refreshJobsALLAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
						url:'/jobs/refreshJobs/'+D.id,
						type:'get',
						dataType:'json',
						error:function(err){
				          	loading.close();
							_this.multipleSelectionIndex=0;
					        _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].refresh_time=ret.data.refresh_time;
									_this.multipleSelectionIndex++;
									_this.refreshJobsALLAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.refreshJobsALLAjax();
								}
							}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
								_this.multipleSelectionIndex=0;
						        _this.$refs.tableList.clearSelection();
							}
						}
					})
				}else{
		          	loading.close();
					_this.multipleSelectionIndex=0;
			        _this.$refs.tableList.clearSelection();
				}
			},
			setJobsExamine(row,examine){
	    		if (row.examine=='loading') return;
				var _this=this;
	    		var oldExamine=row.examine;
	    		row.examine='loading';
				_this.form.ajax=true;
				var msg='';
				if (examine===2)msg='/'+_this.form.msg;
				$.ajax({
					url:'/jobs/setJobsExamine/'+row.id+'/'+examine+msg,
					type:'get',
					data:{
						notice:_this.form.notice
					},
					dataType:'json',
					error:function(err){
						_this.form.ajax=false;
	    				row.examine=oldExamine;
			          	XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
						_this.form.ajax=false;
	    				row.examine=oldExamine;
						if (ret) {
							if (ret.code === 0) {
								row.examine=examine;
								row.update_time=ret.time;
								_this.cancelRefuseWinSubmit();
								XYBase.success(ret.msg);
							}else XYBase.msg(ret.msg);
						}else XYBase.error(XYBase.config.system_network_error);
					}
				})
			},
			setJobsExamineALL(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.setJobsExamineALLAjax();
			},
			setJobsExamineALLAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					var msg='';
					if (_this.form.status===2)msg='/'+_this.form.msg;
					$.ajax({
						url:'/jobs/setJobsExamine/'+D.id+'/'+_this.form.status+msg,
						type:'get',
						data:{
							notice:_this.form.notice
						},
						dataType:'json',
						error:function(err){
				          	loading.close();
							_this.multipleSelectionIndex=0;
					        _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].examine=_this.form.status;
									_this.multipleSelection[_this.multipleSelectionIndex].update_time=ret.time;
									_this.multipleSelectionIndex++;
									_this.setJobsExamineALLAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.setJobsExamineALLAjax();
								}
							}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
								_this.multipleSelectionIndex=0;
						        _this.$refs.tableList.clearSelection();
							}
						}
					})
				}else{
		          	loading.close();
					_this.multipleSelectionIndex=0;
			        _this.$refs.tableList.clearSelection();
				}
			},
			setJobsStatus(data){
	    		if (data.status=='loading') return;
	    		var status=1,oldStatus=data.status;
	    		if (data.status) status=0;
	    		data.status='loading';
	    		$.getJSON('/jobs/setJobsStatus/'+data.id+'/'+status,function(ret){
	    			data.status=oldStatus;
	    			if (ret) {
	    				if (ret.code === 0) {
	    					data.status=status;
	    				}else{
	    					XYBase.msg(ret.msg);
	    				}
	    			}else{
						XYBase.error(XYBase.config.system_network_error);
	    			}
	    		});
			},
			setJobsTop(data){
	    		if (data.top=='loading') return;
	    		var _this=this,oldStatus=data.top;
	    		data.top='loading';
	    		$.ajax({
	    			url:'/jobs/setJobsTop',
	    			data:{
	    				id:data.id,
	    				top:_this.top,
	    				accumulation:_this.accumulation
	    			},
	    			type:'POST',
	    			dataType:'json',
	    			error:function(err){
	    				data.top=oldStatus;
	    				XYBase.error(XYBase.config.system_network_error);
	    			},
	    			success:function(ret) {
	    				data.top=oldStatus;
	    				if(ret){
	    					if(ret.code===0){
	    						data.top=ret.data.top;
	    						data.top_time=ret.data.top_time;
	    					}else{
	    						XYBase.msg(ret.msg);
	    					}
	    				}else{
	    					XYBase.error(XYBase.config.system_network_error);
	    				}
	    			}
	    		});
			},
			setJobsTopAll(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.setJobsTopAllAjax();
			},
			setJobsTopAllAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
		    			url:'/jobs/setJobsTop',
		    			data:{
		    				id:D.id,
		    				top:_this.top,
		    				accumulation:_this.accumulation
		    			},
		    			type:'POST',
		    			dataType:'json',
						error:function(err){
				          	loading.close();
							_this.multipleSelectionIndex=0;
					        _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].top=ret.data.top;
									_this.multipleSelection[_this.multipleSelectionIndex].top_time=ret.data.top_time;
									_this.multipleSelectionIndex++;
									_this.setJobsTopAllAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.setJobsTopAllAjax();
								}
							}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
								_this.multipleSelectionIndex=0;
						        _this.$refs.tableList.clearSelection();
							}
						}
					})
				}else{
		          	loading.close();
					_this.multipleSelectionIndex=0;
			        _this.$refs.tableList.clearSelection();
				}
			},
			setJobsRecommend(data){
	    		if (data.recommend=='loading') return;
	    		var _this=this,oldStatus=data.recommend;
	    		data.recommend='loading';
	    		$.ajax({
	    			url:'/jobs/setJobsRecommend',
	    			data:{
	    				id:data.id,
	    				recommend:_this.recommend,
	    				accumulation:_this.accumulation
	    			},
	    			type:'POST',
	    			dataType:'json',
	    			error:function(err){
	    				data.recommend=oldStatus;
	    				XYBase.error(XYBase.config.system_network_error);
	    			},
	    			success:function(ret) {
	    				data.recommend=oldStatus;
	    				if(ret){
	    					if(ret.code===0){
	    						data.recommend=ret.data.recommend;
	    						data.recommend_time=ret.data.recommend_time;
	    					}else{
	    						XYBase.msg(ret.msg);
	    					}
	    				}else{
	    					XYBase.error(XYBase.config.system_network_error);
	    				}
	    			}
	    		});
			},
			setJobsRecommendAll(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.setJobsRecommendAllAjax();
			},
			setJobsRecommendAllAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
		    			url:'/jobs/setJobsRecommend',
		    			data:{
		    				id:D.id,
		    				recommend:_this.recommend,
		    				accumulation:_this.accumulation
		    			},
		    			type:'POST',
		    			dataType:'json',
						error:function(err){
				          	loading.close();
							_this.multipleSelectionIndex=0;
					        _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].recommend=ret.data.recommend;
									_this.multipleSelection[_this.multipleSelectionIndex].recommend_time=ret.data.recommend_time;
									_this.multipleSelectionIndex++;
									_this.setJobsRecommendAllAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.setJobsRecommendAllAjax();
								}
							}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
								_this.multipleSelectionIndex=0;
						        _this.$refs.tableList.clearSelection();
							}
						}
					})
				}else{
		          	loading.close();
					_this.multipleSelectionIndex=0;
			        _this.$refs.tableList.clearSelection();
				}
			},
			setJobsUrgent(data){
	    		if (data.urgent=='loading') return;
	    		var _this=this,oldStatus=data.urgent;
	    		data.urgent='loading';
	    		$.ajax({
	    			url:'/jobs/setJobsUrgent',
	    			data:{
	    				id:data.id,
	    				urgent:_this.urgent,
	    				accumulation:_this.accumulation
	    			},
	    			type:'POST',
	    			dataType:'json',
	    			error:function(err){
	    				data.urgent=oldStatus;
	    				XYBase.error(XYBase.config.system_network_error);
	    			},
	    			success:function(ret) {
	    				data.urgent=oldStatus;
	    				if(ret){
	    					if(ret.code===0){
	    						data.urgent=ret.data.urgent;
	    						data.urgent_time=ret.data.urgent_time;
	    					}else{
	    						XYBase.msg(ret.msg);
	    					}
	    				}else{
	    					XYBase.error(XYBase.config.system_network_error);
	    				}
	    			}
	    		});
			},
			setJobsUrgentAll(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.setJobsUrgentAllAjax();
			},
			setJobsUrgentAllAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
		    			url:'/jobs/setJobsUrgent',
		    			data:{
		    				id:D.id,
		    				urgent:_this.urgent,
		    				accumulation:_this.accumulation
		    			},
		    			type:'POST',
		    			dataType:'json',
						error:function(err){
				          	loading.close();
							_this.multipleSelectionIndex=0;
					        _this.$refs.tableList.clearSelection();
						},
						success:function(ret){
							if (ret) {
								if(ret.code === 0){
									_this.multipleSelection[_this.multipleSelectionIndex].urgent=ret.data.urgent;
									_this.multipleSelection[_this.multipleSelectionIndex].urgent_time=ret.data.urgent_time;
									_this.multipleSelectionIndex++;
									_this.setJobsUrgentAllAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.setJobsUrgentAllAjax();
								}
							}else{
								XYBase.error(XYBase.config.system_network_error);
					          	loading.close();
								_this.multipleSelectionIndex=0;
						        _this.$refs.tableList.clearSelection();
							}
						}
					})
				}else{
		          	loading.close();
					_this.multipleSelectionIndex=0;
			        _this.$refs.tableList.clearSelection();
				}
			},
	    	getSearchType(){
	    		var text='职位ID';
	    		switch(this.search.search_type){
	    			case 'id':
	    				text='职位ID';
	    				break;
	    			case 'company_id':
	    				text='公司ID';
	    				break;
	    			case 'uid':
	    				text='UID';
	    				break;
	    			case 'company_name':
	    				text='公司名';
	    				break;
	    		}
	    		return text;
	    	},
			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);
						}
					}
				});
			},
		    exportJobs() {
		    	var _this=this;
		    	_this.search.ajax=true;
				$.ajax({
					url:'/jobs/exportJobs',
					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) {
								window.open(ret.data.url);
							}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>
{include file="business"/}
{/block}