{extend name="main"}
{block name="style"}
{css href="__TEMPLATE_STATIC__/user.css"}
<style type="text/css">
	.inviteAnInterviewForm .el-dialog{min-width: 768px;}
	.inviteAnInterviewForm>.el-input, .inviteAnInterviewForm>.el-select{width: 40%;}
	.el-date-editor.el-input, .el-date-editor.el-input__inner{width: 100%;}
</style>
{/block}
{block name="header"}
{include file="module/user_top_nav"/}
{/block}
{block name="body"}
<div class="flex1 flex h-100">
	<div class="w-180px bg-dark p-4 overflow-y-auto">
	{include file="module/user/company_left" left="module/user/company_left_resume"/}
	</div>
	<div class="frame-body flex-1 overflow-y-auto py-3">
		<div class="container-xl bg-white shadow">
			<div class="flex">
				<div class="flex-1 block-title-before py-2">我发起的面试邀请</div>
			</div>
			<div class="py-3">
				<el-form :model="search" ref="form" label-width="100px" label-position="right"  size="mini">
					<div class="flex">
					  <el-form-item label="简历姓名：" prop="resume_name" class="flex-1 mb-0">
						  <el-input
						    v-model="search.resume_name"
						    placeholder="输入简历姓名查找"
						    class="rounded-0">
						  </el-input>
					  </el-form-item>
					  <el-form-item label="应聘职位：" prop="jobs_id" class="flex-1 mb-0">
						  <el-select
						    v-model="search.jobs_id"
						    filterable
						    remote
						    reserve-keyword
						    placeholder="全部职位"
						    :remote-method="getJobsList"
						    class="rounded-0"
						    @focus="getJobsList">
						    <el-option :key="" value="">全部职位</el-option>
						    <el-option
						      v-for="item in jobsList"
						      :key="item.id"
						      :label="item.title"
						      :value="item.id">
						    </el-option>
						  </el-select>
					  </el-form-item>
					  <el-form-item label="简历来源：" prop="app_id" class="flex-1 mb-0">
						  <el-select
						    v-model="search.app_id"
						    filterable
						    remote
						    reserve-keyword
						    placeholder="不限"
						    :remote-method="getClientApp"
						    class="rounded-0"
						    @focus="getClientApp">
						    <el-option :key="" value="">不限</el-option>
						    <el-option
						      v-for="item in ClientApp"
						      :key="item.app_id"
						      :label="item.app_name"
						      :value="item.app_id">
						    </el-option>
						  </el-select>
					  </el-form-item>
					  <div class="flex-1"></div>
					  <div>
					  	<el-button type="primary" class="rounded-0" size="mini"
					  	@click="setPageChange(1)">查找</el-button>
					  </div>
					</div>
				</el-form>
			</div>
			<div class="table-responsive">
				<el-table
					ref="multipleTable"
			      	:data="tableData"
		    		stripe
		    		v-loading="search.ajax"
		    		style="width: 100%;"
		    		header-cell-class-name="bg-1E54E5 text-666666"
    				@selection-change="handleSelectionChange">
			      <el-table-column
			        type="selection"
			        width="50">
			      </el-table-column>
				  <el-table-column
			        prop="name"
			        label="ID"
			        width="100">
				      <template slot-scope="scope">
				      	<el-link :href="'/resume/'+scope.row.resume_id+'.html'"
				      	:underline="false"
				      	target="_blank">{{scope.row.id}}</el-link>
				      </template>
			      </el-table-column>
			      <el-table-column
			        prop="name"
			        label="名称"
			        width="100">
				      <template slot-scope="scope">
				      	<el-link :href="'/resume/'+scope.row.resume_id+'.html'"
				      	:underline="false"
				      	target="_blank">{{scope.row.name}}</el-link>
				      </template>
			      </el-table-column>
			      <el-table-column
			        label="基本信息"
			        min-width="180">
			        <template slot-scope="scope">
			        	{{XYBase.Date.getMStoYear(scope.row.age*1000)}}/
						<span v-if="scope.row.sex==1">男</span>
						<span v-else-if="scope.row.sex==2">女</span>
						<span v-else="scope.row.sex">未设置</span>
			        	/{{scope.row.educational_background}}/{{XYBase.Date.getMStoYear(scope.row.work_experience_time*1000)}}年经验
			        </template>
			      </el-table-column>
			      <el-table-column
			        prop="title"
			        label="意向职位"
			        width="160">
				      <template slot-scope="scope">
				      	<el-link :href="'/jobs/'+scope.row.jobs_id+'.html'"
				      	:underline="false"
				      	target="_blank">{{scope.row.title}}</el-link>
				      </template>
			      </el-table-column>
			      <el-table-column
			        prop="create_time"
			        label="时间"
			        width="180">
			      </el-table-column>
			      <el-table-column
			        label="筛选"
			        width="80">
			        <template slot-scope="scope">
			        	<el-tag
						    v-if="scope.row.status===0"
		        			type="info"
						    effect="plain"
						    :disable-transitions="true"
						    size="mini">
						    等待接受
						</el-tag>
			        	<el-tag
						    v-else-if="scope.row.status===1"
		        			type="warning"
						    effect="plain"
						    :disable-transitions="true"
						    size="mini">
						    等待面试
						</el-tag>
			        	<el-tag
						    v-else-if="scope.row.status===2"
		        			type="danger"
						    effect="plain"
						    :disable-transitions="true"
						    size="mini">
						    已拒绝
						</el-tag>
			        	<el-tag
						    v-else-if="scope.row.status===3"
		        			type="info"
						    effect="plain"
						    :disable-transitions="true"
						    size="mini">
						    待处理
						</el-tag>
			        	<el-tag
						    v-else-if="scope.row.status===4"
		        			type="info"
						    effect="plain"
						    :disable-transitions="true"
						    size="mini">
						    已结束
						</el-tag>
			        </template>
			      </el-table-column>
			      <el-table-column
			        label="操作"
			        width="200">
			        <template slot-scope="scope">
			        	<el-button-group class="text-nowrap">
						  <el-button type="success" size="minism" 
						  v-if="scope.row.status===3"
						  @click="offerInviteAnInterview(scope.row);">发Offer</el-button>
						  <el-button type="danger" size="minism" 
						  v-if="scope.row.status===3"
						  @click="refuseInterviewInvitation(scope.row);">不合适</el-button>
						  <el-button type="warning" size="minism" @click="handleInterviewInvitation(scope.row);">面试信息</el-button>
						</el-button-group>
			        </template>
			      </el-table-column>
			    </el-table>
			</div>
			<div class="pt-3">
				<el-button-group class="text-nowrap">
				  <el-button type="primary" size="mini">设为已读</el-button>
				  <el-button type="danger" size="mini">删除</el-button>
				</el-button-group>
			</div>
			<div class="table-responsive py-3 text-center">
				<el-pagination
				  background
				  :hide-on-single-page="true"
				  @current-change="setPageChange"
			      :current-page="search.page"
			      :page-size="15"
			      layout="total,  prev, pager, next, jumper"
			      :total="search.total">
			    </el-pagination>
			</div>
		</div>
	</div>
</div>
<el-drawer
  title="我是标题"
  :visible.sync="drawerHandleInterviewInvitation"
  :with-header="false">
  	<div class="wrap h-100">
		<div class="flex px-3 py-2">
			<div class="flex-1 block-title-before py-2">面试邀请信息</div>
			<div class="py-2">
	        	<el-tag
	        		v-if="handleInterviewInvitationData.status === 0"
	        		type="info"
				    effect="plain"
				    :disable-transitions="true"
				    size="mini">
				    等待接受
				</el-tag>
	        	<el-tag
	        		v-else-if="handleInterviewInvitationData.status === 1"
	        		type="warning"
				    effect="plain"
				    :disable-transitions="true"
				    size="mini">
				    等待面试
				</el-tag>
	        	<el-tag
	        		v-else-if="handleInterviewInvitationData.status === 2"
	        		type="danger"
				    effect="plain"
				    :disable-transitions="true"
				    size="mini">
				    已拒绝
				</el-tag>
	        	<el-tag
	        		v-else-if="handleInterviewInvitationData.status === 3"
	        		type="info"
				    effect="plain"
				    :disable-transitions="true"
				    size="mini">
				    待处理
				</el-tag>
	        	<el-tag
	        		v-else-if="handleInterviewInvitationData.status === 4"
	        		type="info"
				    effect="plain"
				    :disable-transitions="true"
				    size="mini">
				    已结束
				</el-tag>
			</div>
		</div>
  		<div class="flex1 p-3 overflow-auto">
		  	<table v-if="handleInterviewInvitationData.id" class="table table-bordered">
			  	<tr>
			  		<td width="120" class="text-secondary text-right">职位名称：</td>
			  		<td>{{handleInterviewInvitationData.title}}</td>
			  	</tr>
			  	<tr>
			  		<td width="120" class="text-secondary text-right">公司名称：</td>
			  		<td>{{handleInterviewInvitationData.company_name}}</td>
			  	</tr>
			  	<tr>
			  		<td class="text-secondary text-right">面试联系人：</td>
			  		<td>{{handleInterviewInvitationData.contacts}}</td>
			  	</tr>
			  	<tr>
			  		<td class="text-secondary text-right">联系人手机：</td>
			  		<td>{{handleInterviewInvitationData.contacts_mobile}}</td>
			  	</tr>
			  	<tr v-if="handleInterviewInvitationData.contacts_tel">
			  		<td class="text-secondary text-right">联系人座机：</td>
			  		<td>{{handleInterviewInvitationData.contacts_tel}}</td>
			  	</tr>
			  	<tr v-if="handleInterviewInvitationData.contacts_email">
			  		<td class="text-secondary text-right">联系人邮箱：</td>
			  		<td>{{handleInterviewInvitationData.contacts_email}}</td>
			  	</tr>
			  	<tr>
			  		<td class="text-secondary text-right">面试地址：</td>
			  		<td>{{handleInterviewInvitationData.address}}</td>
			  	</tr>
			  	<tr>
			  		<td class="text-secondary text-right">面试时间：</td>
			  		<td>
			  			<span class="pr-3">
			  				{{handleInterviewInvitationData.interview_date}}
			  			</span>
			  			<span>
			  				{{handleInterviewInvitationData.interview_start_time}}
			  				~
			  				{{handleInterviewInvitationData.interview_end_time}}
			  			</span>
			  		</td>
			  	</tr>
			  	<tr>
			  		<td class="text-secondary text-right">备注：</td>
			  		<td>{{handleInterviewInvitationData.remarks}}</td>
			  	</tr>
		  	</table>
	  	</div>
  	</div>
</el-drawer>

<!-- 邀请面试 -->
<el-dialog
  :title="'向【'+inviteAnInterviewData.name+'】发送【'+inviteAnInterviewData.title+'】职位Offer'"
  :visible.sync="dialogVisible"
  width="40%"
  class="inviteAnInterviewForm"
  :before-close="handleClose">
  <el-form :model="inviteAnInterviewForm" label-width="140px" :rules="rules" ref="inviteAnInterviewForm" size="small">
	  <el-form-item label="面试联系人" prop="contacts">
	    <el-input v-model="inviteAnInterviewForm.contacts" class="col-12 col-sm-3 pl-0 pr-0"></el-input>
	  </el-form-item>
	  <el-form-item label="联系人电话" prop="contacts_mobile">
	    <el-input v-model="inviteAnInterviewForm.contacts_mobile" class="col-12 col-sm-5 pl-0 pr-0" maxlength="11"></el-input>
	  </el-form-item>
	  <el-form-item label="联系人邮箱" prop="contacts_email">
	    <el-input v-model="inviteAnInterviewForm.contacts_email" class="col-12 col-sm-5 pl-0 pr-0"></el-input>
	  </el-form-item>
	  <el-form-item label="面试地址" prop="address">
	    <el-input v-model="inviteAnInterviewForm.address" class="col-12 col-sm-7 pl-0 pr-0"></el-input>
	  </el-form-item>
	  <el-form-item label="面试日期">
	  	<div class="flex">
	  		<el-form-item prop="interview_date" class="mb-0 flex-1">
			    <el-date-picker
			      v-model="inviteAnInterviewForm.interview_date"
			      type="date"
			      placeholder="面试日期"
			      format="yyyy 年 MM 月 dd 日"
			      value-format="timestamp"
			      :picker-options="{disabledDate:(time)=>{return time.getTime() < Date.now()}}">
			    </el-date-picker>
	  		</el-form-item>
	  		<div class="px-2"></div>
	  		<el-form-item prop="interview_start_time" class="mb-0 flex-1">
			  	<el-time-select
				    placeholder="起始时间"
				    v-model="inviteAnInterviewForm.interview_start_time"
				    :picker-options="{
				      start: '07:00',
				      step: '00:30',
				      end: '18:30'
				    }">
				</el-time-select>
	  		</el-form-item>
	  		<div class="px-1">-</div>
	  		<el-form-item prop="interview_end_time" class="mb-0 flex-1">
			   	<el-time-select
				    placeholder="结束时间"
				    v-model="inviteAnInterviewForm.interview_end_time"
				    :picker-options="{
				      start: '07:00',
				      step: '00:30',
				      end: '18:30',
				      minTime: inviteAnInterviewForm.interview_start_time
				    }">
				</el-time-select>
	  		</el-form-item>
	  	</div>
	  </el-form-item>
	  <el-form-item label="面试备注" prop="remarks">
	    <el-input v-model="inviteAnInterviewForm.remarks" class="col-12 col-sm-7 pl-0 pr-0"></el-input>
	  </el-form-item>
  </el-form>
  <span slot="footer" class="dialog-footer">
	    <el-button @click="cancelInviteAnInterviewFormSubmit();">取 消</el-button>
	    <el-button type="primary" @click="submitForm('inviteAnInterviewForm');" :loading="inviteAnInterviewForm.ajax">{{inviteAnInterviewForm.ajax?'提交中...':'发送'}}</el-button>
  </span>
</el-dialog>
{/block}
{block name="footer"}
{include file="module/login"/}
{/block}
{block name="script"}
<script type="text/javascript">
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			userInfo:UserInfo,
			loginTabs:XYBase.loginTabs,
			feedback:XYBase.feedback,
			drawerHandleInterviewInvitation:false,
			handleInterviewInvitationData:{},
			dialogVisible:false,
			inviteAnInterviewData:{},
			inviteAnInterviewForm:{
				ajax:false,
				id:'',
				contacts:'',
				contacts_tel:'',
				contacts_mobile:'',
				contacts_email:'',
				address:'',
				interview_date:'',
				interview_start_time:'',
				interview_end_time:'',
				remarks:'',
			},
	        rules: {
	          contacts: [
	            { required: true, message: '请输入联系人', trigger: 'blur' },
	          ],
	          contacts_mobile: [
	            { required: true, message: '请输入联系人手机号', trigger: 'blur' },
	          ],
	          address: [
	            { required: true, message: '请输入面试地址', trigger: 'blur' },
	          ],
	          interview_date: [
	            { required: true, message: '请选择面试时间', trigger: 'change' },
	          ],
	          interview_start_time: [
	            { required: true, message: '请选择面试时间', trigger: 'change' },
	          ],
	          interview_end_time: [
	            { required: true, message: '请选择面试时间', trigger: 'change' },
	          ],
	        },
			jobsList:[],
			ClientApp:[],
			search:{
				is_stop_recruiting:0,
				resume_name:'',
				jobs_id:'',
				app_id:'',
		    	ajax:false,
				total:100,
				page: 1
			},
			tableData:[]
		},
		watch:{
		    view:XYBase.viewWatch,
		    loginTabs:XYBase.loginTabsWatch,
			userInfo:{
				handler(val,oldVal){
					if (!val.id) {
						window.location.reload();
					}
				},
				deep:true
			},
		},
		created(){
			XYBase.created(this);
			this.initHtml();
		},
		methods:XYBase.methods({
			toggleSelection(rows) {
				if (rows) {
				  rows.forEach(row => {
				    this.$refs.multipleTable.toggleRowSelection(row);
				  });
				} else {
				  this.$refs.multipleTable.clearSelection();
				}
			},
			handleSelectionChange(val) {
				this.multipleSelection = val;
			},
			filterHandler(value, row, column){
				console.log(value);
		        const property = column['property'];
		        return row[property] === value;
			},
			handleInterviewInvitation(row){
				this.handleInterviewInvitationData=row;
				this.drawerHandleInterviewInvitation=true;
			},
			setPageChange(val){
				this.search.page=val;
				this.initHtml();
			},
			/*offerInviteAnInterview(row){
				this.inviteAnInterviewData=row;
				this.inviteAnInterviewForm.id=row.id;
				this.dialogVisible=true;
			},*/
		    handleClose(done) {
		        this.$confirm('确认关闭面试邀请？')
		          .then(_ => {
				  	if (!this.inviteAnInterviewForm.ajax)
			            done();
		          })
		          .catch(_ => {});
	      	},
			offerInviteAnInterview(row){
				var _this=this;
		        this.$confirm('确定向'+row.name+'发送Offre吗？')
		          .then(_ => {
					_this.sendGet({
						url:'/user/interview/handleInterviewInvitation/offer/'+row.id,
					},function(ret){
						if (ret) {
							if (ret.code === 0) {
								row.status=4
							}else{XYBase.msg(ret.msg);}
						}
					});
		          })
		          .catch(_ => {});
			},
			refuseInterviewInvitation(row){
				var _this=this;
		        this.$confirm('确定设置'+row.name+'的面试为不合适吗？')
		          .then(_ => {
					_this.sendGet({
						url:'/user/interview/handleInterviewInvitation/inappropriate/'+row.id,
					},function(ret){
						if (ret) {
							if (ret.code === 0) {
								row.status=4
							}else{XYBase.msg(ret.msg);}
						}
					});
		          })
		          .catch(_ => {});
			},
			initHtml(){
				var _this=this;
				_this.search.ajax=true;
				_this.sendGet({
					url:'',
					data:_this.search,
				},function(ret){
					_this.search.ajax=false;
					if (ret) {
						_this.tableData=[];
						_this.search.total=ret.data.total;
						if (ret.code === 0) {
							_this.tableData=ret.data.data;
						}else XYBase.msg(ret.msg);
					}
				});
			},
			submitForm:function(formName) {
				var _this=this;
				var D=_this.form;
				_this.$refs[formName].validate((valid) => {
				  if (valid) {
					const loading = XYBase.openloading();
					_this.sendPost({
						url:url,
						data:D,
					},function(ret){
				        loading.close();
				        if (ret) {
							if(ret.code == 0){
								XYBase.success(ret.msg);
							}else{
								XYBase.msg(ret.msg);
							}
				        }
					});
				  } else {
					XYBase.warning('请先把表单填写完整。');
				    return false;
				  }
				});
			},
			getJobsList(){
				var _this=this;
				_this.sendGet({
					url:'/user/jobs/management',
					data:{
						status:'all',
						page: 1
					},
				},function(ret){
					if (ret) {
						_this.jobsList=[];
						if (ret.code === 0) {
							_this.jobsList=ret.data.data;
						}
					}
				});
			},
			getClientApp(){
				var _this=this;
				if(_this.ClientApp.length)return;
				_this.sendGet({
					url:'/ajax/getClientApp',
					data:{key:1}
				},function(ret){
					if (ret) {
						_this.ClientApp=[];
						if (ret.code === 0) {
							_this.ClientApp=ret.data;
						}
					}
				});
			},
		})
	});
</script>
{/block}