{extend name="main"}
{block name="style"}
<style type="text/css">
	.flex-lable{width: 140px;color: #6c757d;text-align: right;padding-right: 10px;}
	.w-100px{width: 100px;}
</style>
{/block}
{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="search_type" class="flex mb-0 pl-3">
	  	<el-select v-model="search.search_type" placeholder="请选择" class="w-100px">
		    <el-option key="id"label="公司ID"value="id"></el-option>
		    <el-option key="uid"label="UID"value="uid"></el-option>
		    <el-option key="uscc"label="统一社会信用代码"value="uscc"></el-option>
		    <el-option key="company_name"label="公司名"value="company_name"></el-option>
		    <el-option key="contacts_mobile"label="联系人手机号"value="contacts_mobile"></el-option>
		    <el-option key="contacts_email"label="联系人邮箱"value="contacts_email"></el-option>
		</el-select>
	  </el-form-item>

	  <el-form-item label="企业认证" prop="attestation" class="flex mb-0 pl-3">
	  	<el-select v-model="search.attestation" placeholder="请选择" class="w-100px">
		    <el-option key="all"label="全部"value="all"></el-option>
		    <el-option v-for="v in attestation" :key="v.value":label="v.title":value="v.value"></el-option>
		</el-select>
	  </el-form-item>

	  <el-form-item label="套餐" prop="vip_level" class="flex mb-0 pl-3">
	  	<el-select v-model="search.vip_level" placeholder="请选择" class="w-100px">
		    <el-option key="all"label="全部"value="all"></el-option>
		    <el-option v-for="v in vip" :key="v.level":label="v.title":value="v.level" v-if="v.is_company"></el-option>
		</el-select>
	  </el-form-item>

	  <el-form-item :label="getSearchType()" prop="key" class="flex mb-0 pl-3">
	    <el-input v-model="search.key" 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 py-3">
		  <el-button type="primary" size="mini" @click="exportCompany">导出({{tableData.length}})</el-button>
		  <el-button type="success" size="mini" icon="el-icon-refresh" @click="refreshCompanyALL">刷新</el-button>
		  <el-button type="primary" size="mini" @click="drawerHandle=true;">设置顾问</el-button>
		  <el-button type="primary" size="mini" @click="window.open('/company/importCompany')" plain>导入企业</el-button>
		  <el-button type="warning" size="mini" @click="window.open('/message/send')" plain>发消息</el-button>
		  <el-button type="primary" size="mini" @click="window.open('/company/addCompany')" plain>手动添加企业</el-button>
	</div>
	<div class="table-responsive">
		<el-table
				ref="tableList"
	      :data="tableData"
    		v-loading="search.ajax"
    		style="width: 100%;"
    		header-cell-class-name="table-header-DDE6FB"
    		@expand-change="getCompanyInfo"
    		@selection-change="handleSelectionChange">
		  <el-table-column
			  type="selection"
			  width="55">
		  </el-table-column>
		  <el-table-column type="expand" width="20">
			  <template slot-scope="scope">
			  	<div v-if="scope.row.company_info==1">
				  	<div class="flex text-dark">
				  		<div class="flex-1 pr-2">
							<el-divider content-position="left">用户信息</el-divider>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">用户</div>
								<el-image
								  	v-if="scope.row.data.headimg" 
								    style="width: 30px; height: 30px"
								    lazy
								    class="rounded-circle mr-2"
								    :src="scope.row.data.headimg" 
								    :preview-src-list="[scope.row.data.headimg]">
								</el-image>
				  				<div class="flex-1">
							      	<el-link :href="'/user?uid='+scope.row.uid" target="_blank"
							      	:underline="false"
							      	title="用户中心">{{scope.row.data.nickname}}</el-link>
				  				</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">手机号</div>
				  				<div class="flex-1">{{scope.row.data.mobile}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">邮箱</div>
				  				<div class="flex-1">{{scope.row.data.email}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3" v-if="(!scope.row.data.adviser_id&&v.adviser_default)||(scope.row.data.adviser_id&&v.id==scope.row.data.adviser_id)" v-for="v in admin">
				  				<div class="flex-lable">顾问</div>
								<el-image
								  	v-if="v.headimg" 
								    style="width: 30px; height: 30px"
								    lazy
								    class="rounded-circle mr-2"
								    :src="v.headimg" 
								    :preview-src-list="[v.headimg]">
								</el-image>
				  				<div class="flex-1">
							      	<el-link
							      	:underline="false">{{v.nickname}}</el-link>
				  				</div>
				  			</div>
							<el-divider content-position="left">企业基本信息</el-divider>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">ID</div>
				  				<div class="flex-1">{{scope.row.data.id}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">企业简称</div>
				  				<div class="flex-1">{{scope.row.data.stitle}}</div>
				  			</div>
				  			<div class="flex pb-3">
				  				<div class="flex-lable">企业认证</div>
			      				<div class="flex-1">
						      		<el-button v-for="v in attestation" :type="v.type" size="minism"
						      		v-if="scope.row.data.attestation==v.value">{{v.title}}</el-button>
			      				</div>
				  			</div>
				  			<div class="flex pb-3">
				  				<div class="flex-lable">营业执照</div>
			      				<div class="flex-1" >
								  <el-image
								  	v-if="scope.row.data.business_license" 
								  	class="mw-50px mh-50px"
								    :src="scope.row.data.business_license"
								    :preview-src-list="[scope.row.data.business_license]">
								  </el-image>
								  <div v-else class="text-secondary small">未上传</div>
			      				</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">统一社会信用代码</div>
			      				<div class="flex-1">{{scope.row.data.uscc}}</div>
				  			</div>
				  			<div class="flex pb-3">
				  				<div class="flex-lable">企业LOGO</div>
			      				<div class="flex-1" >
								  <el-image
								  	v-if="scope.row.data.logo" 
								  	class="mw-50px mh-50px"
								    :src="scope.row.data.logo"
								    :preview-src-list="[scope.row.data.logo]">
								  </el-image>
								  <div v-else class="text-secondary small">未上传</div>
			      				</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">企业性质</div>
			      				<div class="flex-1" v-for="v in nature" v-if="scope.row.data.nature==v.value">{{v.title}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">融资阶段</div>
			      				<div class="flex-1" v-for="v in finance" v-if="scope.row.data.finance==v.value">{{v.title}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">所属行业</div>
			      				<div class="flex-1">{{scope.row.data.industry}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">公司规模</div>
			      				<div class="flex-1" v-for="v in size_type" v-if="scope.row.data.size_type==v.value">{{v.title}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">注册资金</div>
			      				<div class="flex-1">{{scope.row.data.registered_capital}}万{{scope.row.data.registered_capital?'美元':'人民币'}}</div>
				  			</div>
				  			<div class="flex pb-3">
				  				<div class="flex-lable">企业福利</div>
			      				<div class="flex-1"><el-tag size="small" type="success" v-for="v in corporate_welfare" v-if="scope.row.data.corporate_welfare.indexOf(v.value)>=0" class="mr-2">{{v.title}}</el-tag></div>
				  			</div>
				  		</div>
				  		<div class="flex-1 pl-2">
							<el-divider content-position="left">企业拓展信息</el-divider>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">企业联系人</div>
			      				<div class="flex-1">{{scope.row.data.contacts}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">联系人手机号</div>
			      				<div class="flex-1">{{scope.row.data.contacts_mobile}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">固定电话</div>
			      				<div class="flex-1">{{scope.row.data.contacts_tel}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">联系邮箱</div>
			      				<div class="flex-1">{{scope.row.data.contacts_email}}</div>
				  			</div>
				  			<div class="flex flex-center pb-3">
				  				<div class="flex-lable">公司地址</div>
			      				<div class="flex-1">{{scope.row.data.contacts_address}}</div>
				  			</div>
				  			<div class="flex pb-3">
				  				<div class="flex-lable">公司网址</div>
			      				<div class="flex-1">{{scope.row.data.company_website}}</div>
				  			</div>
				  			<div class="flex pb-3">
				  				<div class="flex-lable">公司简介</div>
			      				<div class="flex-1" v-html="XYBase.strntobr(scope.row.data.company_introduction)"></div>
				  			</div>
				  			<div class="flex pb-3">
				  				<div class="flex-lable">公司介绍</div>
			      				<div class="flex-1" v-html="XYBase.strntobr(scope.row.data.company_descript)"></div>
				  			</div>
				  		</div>
				  	</div>
				  	<div class="py-3">
				        <el-button
				            type="primary"
				            size="minism"
				            @click="window.open('/company/editCompany/'+scope.row.id)">
				            编辑
				        </el-button>
				        <el-button
				            type="success"
				            size="minism"
				            @click="window.open('/jobs/addJobs/'+scope.row.id)">
				            发布职位
				        </el-button>
				        <el-button
				            type="primary"
				            size="minism"
				            @click="drawerHandleFind=scope.row;drawerHandle=true;">
				            设置顾问
				        </el-button>
				        <el-button
				            type="info"
				            size="minism"
				            @click="window.open('/user/loginLog?uid='+scope.row.uid)">
				            登录日志
				        </el-button>
				        <el-button
				            type="info"
				            size="minism"
				            @click="window.open('/user/apiLog?uid='+scope.row.uid)">
				            操作日志
				        </el-button>
				        <el-button
				            type="info"
				            size="minism"
				            @click="window.open('{:config('web.url')}/company/'+scope.row.id+'.html')">
				            浏览
				        </el-button>
				  	</div>
			  	</div>
			  	<div class="text-center py-5 text-secondary small" v-else-if="scope.row.company_info==0">
			  		<i class="el-icon-loading mr-2"></i>加载中...
			  	</div>
			  	<div class="text-center py-5 text-secondary small" v-else="scope.row.company_info">
			  		未获取到用户信息
			  	</div>
			  </template>
		  </el-table-column>
	      <el-table-column
	        prop="uid"
	        label="UID"
	        width="100">
	      </el-table-column>
	      <el-table-column
	      	prop="title"
	        label="公司信息"
	        min-width="200">
		      <template slot-scope="scope">
		      	<div>
		      	<el-link @click="openWinTo(scope.row)"
		      	:underline="false"
		      	title="免登录跳转至用户中心">{{scope.row.title}}</el-link>
		      	<div class="text-primary">{{scope.row.mobile}}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="企业认证"
	        width="120">
		      <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
	        label="职位数"
	        width="120">
		      <template slot-scope="scope">
		      	<div>
			      	<div><span class="text-danger">{{scope.row.jobs_count}}</span>个</div>
			      	<el-link type="primary" :href="'/jobs/addJobs/'+scope.row.id" :underline="false" target="_blank" v-if="scope.row.attestation==3">添加</el-link>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        prop="app_name"
	        label="来源"
	        width="160">
	      </el-table-column>
	      <el-table-column
	        label="会员"
	        width="160">
		      <template slot-scope="scope">
		      	<div>
			      	<div>{{scope.row.vip_title}}</div>
			      	<div v-if="scope.row.company_vip_time">{{scope.row.company_vip_time}}</div>
			      	<div v-else>不限</div>
		      	</div>
		      </template>

	      </el-table-column>
	      <el-table-column
	        label="名企"
	        width="100">
		      <template slot-scope="scope">
					<div>
		      	<transition>
		      		<el-button type="success" size="minism"
		      		v-if="scope.row.is_famous==1 || scope.row.is_famous=='loading'"
		      		@click="setIsFamous(scope.row);" 
		      		:loading="scope.row.is_famous=='loading'">是</el-button>
		      		<el-button type="info" size="minism" 
		      		v-else-if="scope.row.is_famous==0 || scope.row.is_famous=='loading'" 
		      		@click="setIsFamous(scope.row);" 
		      		:loading="scope.row.is_famous=='loading'">否</el-button>
						</transition>
					</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="创建/更新/刷新时间"
	        width="180">
		      <template slot-scope="scope">
		      	<div class="small">
		          <div>{{ scope.row.create_time }}</div>
		          <div>{{ scope.row.update_time }}</div>
		          <div>{{ scope.row.refresh_time }}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="/"
	        width="120">
		      <template slot-scope="scope">
		        <el-button
		            type="success"
		            plain
		            round
		            size="minism"
		            @click="Business.openBusiness(scope.row.id,true)">
		            业务
		        </el-button>
		        <el-button
		            type="primary"
		            plain
		            round
		            size="minism"
		            @click="window.open('/company/editCompany/'+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,500,1000]"
	      :page-size="search.pageSize"
	      layout="total, sizes, prev, pager, next, jumper"
	      :total="search.total">
	    </el-pagination>
	</div>
</div>
<el-drawer
  title="我是标题"
  :visible.sync="drawerHandle"
  :with-header="false"
  :before-close="closeDrawerHandle">
  	<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">
		  		<div class="small" v-if="drawerHandleFind.id">{{drawerHandleFind.title}}</div>
		  		<div class="small" v-else>批量设置</div>
			</div>
		</div>
		<div class="flex1 p-3" style="overflow-y: auto;">
			<div class="flex flex-center border border-lg rounded-lg mb-3 p-3 pointer"
			v-for="v in admin"
			:class="{'border-primary':adviser.id==v.id}"
			@click="adviser=v">
				<el-image
				  	v-if="v.headimg" 
				    style="width: 60px; height: 60px"
				    lazy
				    class="rounded-circle mr-2"
				    :src="v.headimg" 
				    :preview-src-list="[v.headimg]">
				</el-image>
  				<div class="flex-1">
			      	<el-link
			      	:underline="false">{{v.nickname}}</el-link>
  				</div>
  				<div class="text-secondary small" v-if="v.adviser_default">默认</div>
			</div>
		</div>
	  	<div class="flex px-3 py-2">
	  		<div class="flex-1">
			    <el-button @click="drawerHandle=false;drawerHandleFind={};">关闭</el-button>
		    </div>
	  		<div v-if="drawerHandleFind.id">
		    	<el-button type="primary" @click="setAdviser(drawerHandleFind)">设置</el-button>
		    </div>
	  		<div v-else>
		    	<el-button type="primary" @click="setAdviserALL()">设置</el-button>
		    </div>
	  	</div>
  	</div>
</el-drawer>
{/block}
{block name="script"}
<script type="text/javascript">
	{empty name="admin"}
	var admin=[];
	{else/}
	var admin={:json_encode($admin,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="attestation"}
	var attestation=[];
	{else/}
	var attestation={:json_encode($attestation,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="nature"}
	var nature=[];
	{else/}
	var nature={:json_encode($nature,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="finance"}
	var finance=[];
	{else/}
	var finance={:json_encode($finance,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="industry"}
	var industry=[];
	{else/}
	var industry={:json_encode($industry,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="size_type"}
	var size_type=[];
	{else/}
	var size_type={:json_encode($size_type,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="corporate_welfare"}
	var corporate_welfare=[];
	{else/}
	var corporate_welfare={:json_encode($corporate_welfare,JSON_UNESCAPED_UNICODE)};
	{/empty}
	{empty name="vip"}
	var vip=[];
	{else/}
	var vip={:json_encode($vip,JSON_UNESCAPED_UNICODE)};
	{/empty}
</script>
<script type="text/javascript">
	var loading=null;
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			vip:vip,
			labelPosition:'right',
			drawerHandle:false,
			drawerHandleFind:{},
			admin:admin,
			adviser:{id:0},
			attestation:attestation,
			nature:nature,
			finance:finance,
			industry:industry,
			size_type:size_type,
			corporate_welfare:corporate_welfare,
			multipleSelection:[],
			search:{
				{notempty name=":request()->get('uid')"}
				search_type:'uid',
				key:'{:request()->get('uid')}',
				{elseif request()->get('id')/}
				search_type:'id',
				key:'{:request()->get('id')}',
				{elseif request()->get('uscc')/}
				search_type:'uscc',
				key:'{:request()->get('uscc')}',
				{elseif request()->get('company_name')/}
				search_type:'company_name',
				key:'{:request()->get('company_name')}',
				{elseif request()->get('contacts_mobile')/}
				search_type:'contacts_mobile',
				key:'{:request()->get('contacts_mobile')}',
				{elseif request()->get('contacts_email')/}
				search_type:'contacts_email',
				key:'{:request()->get('contacts_email')}',
				{else/}
				search_type:'id',
				key:'',
				{/notempty}
				attestation:'all',
				vip_level:'all',
				ajax:false,
				page:1,
				total:0,
				pageSize:10
			},
			tableData:[],
		},
		watch:{
		    view:XYBase.viewWatch,
		},
		created(){
			XYBase.created(this);
		},
	    methods: {
	    	closeDrawerHandle(done){
	    		this.drawerHandleFind={};
	    		done();
	    	},
	    	openWinTo(row){
		        this.$confirm('即将免登录打开【'+row.title+'】,是否继续？', '提示', {
		        	dangerouslyUseHTMLString:true,
		          confirmButtonText: '继续',
		          cancelButtonText: '取消',
		          type: 'warning'
		        }).then(() => {
	    			window.open('user/exemptLoginRedirect/'+row.uid+'?path=/user/account');
		        }).catch(() => {
					XYBase.msg('已取消');
		        });
	    	},
		    toggleSelection(rows) {
		        if (rows) {
		          rows.forEach(row => {
		            this.$refs.tableList.toggleRowSelection(row);
		          });
		        } else {
		          this.$refs.tableList.clearSelection();
		        }
		    },
		    handleSelectionChange(val) {
		        this.multipleSelection = val;
		    },
	    	getSearchType(){
	    		var text='公司ID';
	    		switch(this.search.search_type){
	    			case 'id':
	    				text='公司ID';
	    				break;
	    			case 'uid':
	    				text='UID';
	    				break;
	    			case 'uscc':
	    				text='统一社会信用代码';
	    				break;
	    			case 'company_name':
	    				text='公司名';
	    				break;
	    			case 'contacts_mobile':
	    				text='联系人手机号';
	    				break;
	    			case 'contacts_email':
	    				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();
			},
			setIsFamous(data){
	    		if (data.is_famous=='loading') return;
	    		var is_famous=1,oldStatus=data.is_famous;
	    		if (data.is_famous) is_famous=0;
	    		data.is_famous='loading';
	    		$.getJSON('/company/setIsFamous/'+data.id+'/'+is_famous,function(ret){
	    			data.is_famous=oldStatus;
	    			if (ret) {
	    				if (ret.code === 0) {
	    					data.is_famous=is_famous;
	    				}else{
	    					XYBase.msg(ret.msg);
	    				}
	    			}else{
						XYBase.error(XYBase.config.system_network_error);
	    			}
	    		});
			},
			setAdviser(row){
				var _this=this;
				if(!_this.adviser.id) return XYBase.msg('请先选择顾问');
				_this.drawerHandle=false;
				var loadinger = XYBase.openloading();
				$.ajax({
					url:'/company/setAdviser/'+row.id+'/'+_this.adviser.id,
					type:'get',
					data:{},
					dataType:'json',
					error:function(err){
				        loadinger.close();
			          	XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
				        loadinger.close();
						if (ret) {
							if (ret.code === 0) {
								row.data.adviser_id=_this.adviser.id;
								XYBase.success(ret.msg);
							}else XYBase.msg(ret.msg);
						}else XYBase.error(XYBase.config.system_network_error);
					}
				})
			},
			setAdviserALL(){
				var _this=this;
				if(!_this.adviser.id) return XYBase.msg('请先选择顾问');
				if (_this.multipleSelection.length<1)return;
				_this.drawerHandle=false;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.setAdviserALLAjax();
			},
			setAdviserALLAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
						url:'/company/setAdviser/'+D.id+'/'+_this.adviser.id,
						type:'get',
						data:{},
						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].data.adviser_id=_this.adviser.id;
									_this.multipleSelectionIndex++;
									_this.setAdviserALLAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.setAdviserALLAjax();
								}
							}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();
				}
			},
			refreshCompanyALL(){
				var _this=this;
				if (_this.multipleSelection.length<1)return;
				loading = XYBase.openloading();
				_this.multipleSelectionIndex=0;
				_this.refreshCompanyALLAjax();
			},
			refreshCompanyALLAjax(){
				var _this=this;
				var D=_this.multipleSelection[_this.multipleSelectionIndex];
				if (D) {
					loading.setText((_this.multipleSelectionIndex+1)+'/'+_this.multipleSelection.length);
					$.ajax({
						url:'/company/refreshCompany/'+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.refreshCompanyALLAjax();
								}else{
									_this.multipleSelectionIndex++;
									_this.refreshCompanyALLAjax();
								}
							}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();
				}
			},
			getCompanyInfo(row,expandedRows) {
				if (row.company_info)return;
	    		$.getJSON('/getCompanyInfo/'+row.id,function(ret){
	    			if (ret) {
	    				if (ret.code === 0) {
	    					row.company_info=1;
	    					row.data=ret.data;
	    				}else{
	    					row.company_info=2;
	    					XYBase.msg(ret.msg);
	    				}
	    			}else{
						XYBase.error(XYBase.config.system_network_error);
	    			}
	    		});
			},
	    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);
						}
					}
				});
			},
	    exportCompany() {
	    	var _this=this;
	    	_this.search.ajax=true;
	    	var loading=XYBase.openloading();
				$.ajax({
					url:'/company/exportCompany',
					type:'get',
					data:_this.search,
					dataType:'json',
					error:function(err){
	      		_this.search.ajax=false;
	      		loading.close();
						XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
	      		loading.close();
	      		_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}