<template>
	<div>
		<common @asynCallBack="asynCallBack"></common>
		<top-header :pageTitle="pageTitle"></top-header>

		<div class="mui-content">
			<div class="mui-content-padded vongi-qingjiadt">
				<h5>申请人信息</h5>
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>姓名</label>
						<span v-text="detail.name"></span>
					</div>
					<div class="mui-input-row">
						<label>手机号码</label>
						<span v-text="detail.telephone"></span>
					</div>
					<div class="mui-input-row">
						<label>身份证号</label>
						<span v-text="detail.idCard"></span>
					</div>
					<div class="mui-input-row">
						<label style="width:50%">人脸识别照片</label>
						<span class="vongi-qingjiadt-photo"><img :src="detail.faceImageUrl" /> </span>
					</div>
				</form>
			</div>
			<div class="mui-content-padded vongi-qingjiadt vongi-editme">
				<h5>身份信息</h5>
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>场景类型</label>
						<span v-text="detail.sceneName"></span>
					</div>
					<div class="mui-input-row">
						<label>您的身份</label>
						<span v-text="detail.personRoleName"></span>
					</div>
					<div v-if="detail.companyName" class="mui-input-row">
						<label v-text="companyNameLabel"></label>
						<span v-text="detail.companyName"></span>
					</div>
					<div v-if="detail.structureId" class="mui-input-row">
						<label v-text="structureLabel"></label>
						<span v-text="detail.sceneId=='4'?detail.address:detail.structureName"></span>
					</div>
					<div v-if="detail.address" class="mui-input-row">
						<label>家庭住址</label>
						<span v-text="detail.address"></span>
					</div>
				</form>
			</div>
			<div v-if="detail.status=='0'" class="fyy-scon-botton">
				<div class="examine-btn examine-btn1" @click="openFrom('2')">拒绝</div>
				<div class="examine-btn examine-btn2" @click="openFrom('1')">通过</div>
			</div>
			<!--状态-->
			<div v-if="detail.status>0" class="mui-content-padded vongi-qingjiadt">
				<h5>审核信息</h5>
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>申请状态</label>
						<span :class="detail.status=='1'?'color55f868':'colorfe616c'" v-text="detail.statusN"></span>
					</div>
					<div class="mui-input-row">
						<label>审核时间</label>
						<span v-text="detail.examineTime"></span>
					</div>
				</form>
			</div>
		</div>

	</div>
</template>

<script>
	import * as API_Company from '@/apis/Master/company'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	import * as types from '$project/store/mutation-types'
	export default {
		name: 'MasterCompanyRegisterInfo',
		components: {
			Common,
			Loading,
			TopHeader
		},
		data() {
			return {
				pageTitle: '申请详情',

				isLoading: false,

				id: this.$route.query.id,
				subForm: {
					ids: '',
					content: '',
					status: '',
					deviceIds: ''
				},
				detail: {},

				selectIdList: []
			}
		},
		created() {

		},
		methods: {
			//获取详情
			getDetail() {
				this.isLoading = true;
				API_Company.getApplyInfo(this.id).then(response => {

					this.detail = response;

					this.isLoading = false;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//显示内容表单
			openFrom(status) {
				this.selectIdList = [this.id];
				if (!this.selectIdList.length) {
					mui.toast('请选择要处理的信息');
				} else {
					this.subForm.status = status;
					this.subForm.content = status == 1 ? '同意' : '拒绝';
					//this.openFromVisible = true;
					this.doAction();
				}
			},
			//检测表单
			checkForm() {
				if (!this.subForm.ids) {
					mui.toast('请选择要处理的信息');
					return false;
				} else {
					return true;
				}
			},
			//同意拒绝
			doAction() {
				this.subForm.ids = this.selectIdList.join(',');
				if (this.checkForm()) {
					var _this = this;
					var btnArray = ['否', '是'];
					mui.confirm('是否' + _this.subForm.content + '所勾选的注册申请？', '提示', btnArray, function(e) {
						if (e.index == 1) {
							//同意
							if (_this.subForm.status == 1) {
								_this.set_register_examine_form(_this.subForm);
								_this.$router.push({
									name: 'MasterCompanyRegisterSelectDevice',
									query: {
										hasSceneId4: _this.hasSceneId4 ? '1' : '0'
									}
								})
							} else {
								//拒绝
								_this.isLoading = true;
								API_Company.doApply(_this.subForm).then(response => {
									_this.isLoading = false;
									mui.toast('处理成功');
									_this.getDetail();
								}).catch(error => {
									_this.isLoading = false;
									mui.toast(error);
								})
							}
						}
					})
				}
			},
			asynCallBack() {

			},
			...mapMutations({
				set_register_examine_form: types.SET_REGISTER_EXAMINE_FORM,
			})
		},
		mounted() {
			//获取详情
			this.getDetail();
		},
		destroyed() {},
		computed: {
			structureLabel: {
				// getter
				get: function() {
					if (this.detail.sceneId == '1') {
						return '组职部门';
					} else if (this.detail.sceneId == '2') {
						return '家庭住址';
					} else if (this.detail.sceneId == '3') {
						return '机构房间';
					} else if (this.detail.sceneId == '4') {
						return '家庭住址';
					} else {
						return '';
					}
				},
				// setter
				set: function(newValue) {
					console.log(newValue)
				}
			},
			companyNameLabel: {
				// getter
				get: function() {
					if (this.detail.sceneId == '1') {
						return '公司名称';
					} else if (this.detail.sceneId == '2') {
						return '所在小区';
					} else if (this.detail.sceneId == '3') {
						return '所在小区';
					} else if (this.detail.sceneId == '4') {
						return '所在小区';
					} else {
						return '';
					}
				},
				// setter
				set: function(newValue) {
					console.log(newValue)
				}
			},
			hasSceneId4: {
				// getter
				get: function() {
					if (this.selectIdList.indexOf(this.detail['id']) > -1 && this.detail['sceneId'] == '4') {
						return true;
					} else {
						return false;
					}
				},
				// setter
				set: function(newValue) {
					console.log(newValue)
				}
			},
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
			})
		}
	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style scoped src="$project/assets/css/iconfont.css"></style>
<style scoped>
	.status_r {
		color: #fe616c !important;
		border: 1px solid #fe616c !important;
	}

	.status_a {
		color: #05c8af !important;
		border: 1px solid #05c8af !important;
	}
</style>
