<template>
	<el-dialog :title="titleMap[mode]" v-model="visible" :width="500" destroy-on-close draggable @closed="$emit('closed')">
		<el-form :model="form" ref="dialogForm" label-width="140px">
			<el-form-item label="公司名称" prop="full_name">
				<span>{{form.full_name}}</span>
			</el-form-item>
			<el-form-item label="公司系统入口地址" prop="domain">
				<span>{{form.domain}}</span>
			</el-form-item>
			<el-form-item label="系统开通日期" prop="activation_date">
				<span>{{form.activation_date}}</span>
			</el-form-item>
			<el-form-item label="公司类型" prop="company_type_name">
				<span>{{form.company_type_name}}</span>
			</el-form-item>
			<el-form-item label="公司地址" prop="address">
				<span>{{form.address}}</span>
			</el-form-item>
			<el-form-item label="负责人/联系方式" prop="owner">
				<span>{{form.owner}} {{form.mobile}}</span>
			</el-form-item>
			<el-form-item label="公司LOGO" prop="logo">
				<el-image style="height: 80px;width: 80px;border-radius: 2px;" fit="cover" :src="form.logo">
					<template #error>
						<div class="image-slot" style="text-align: center;font-size: 60px;">
							<el-icon><el-icon-Picture /></el-icon>
						</div>
					</template>
				</el-image>
			</el-form-item>
			<el-form-item label="证件照" prop="doc_attach">
				<el-image v-for="item in form.doc_attach" :key="item" style="height: 80px;width: 80px;border-radius: 2px;margin: 0 5px 5px 0" fit="cover" :src="item.doc_url">
					<template #error>
						<div class="image-slot" style="text-align: center;font-size: 60px;">
							<el-icon><el-icon-Picture /></el-icon>
						</div>
					</template>
				</el-image>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	emits: ['success', 'closed'],
	data() {
		return {
			mode: "show",
			titleMap: {
				show: '查看公司详情'
			},
			setMap:{
				companyType:[]
			},
			visible: false,
			//表单数据
			form: {},
		}
	},
	mounted() {

	},
	methods: {
		//显示
		open(mode='show'){
			this.mode = mode;
			this.visible = true;
			return this
		},
		// 加载公司类型
		async getCompanyTypeSelect(e){
			if(!e) return
			const res = await this.$API.system.company.typeSelect.post();
			if(res.code == 200){
				this.setMap['companyType'] = res.data;
			}
		},
		//表单注入数据
		async setData(data) {
			let params = {
				id:data.id
			}
			await this.getCompanyTypeSelect(true);

			const res = await this.$API.system.company.info.post(params);
			if(res.code == 200){
				this.form = res.data;
				this.form.company_type_name = "";
				this.setMap.companyType.forEach(em=>{
					if(em.company_type === res.data.company_type){
						this.form.company_type_name = em.label
					}
				})
			}
		}
	}
}
</script>

<style>
</style>
