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

		<div class="mui-content">
			<div class="mui-content-padded vongi-editme vongi-qingjiadt">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>申请人</label>
						<span v-text="detail.applicant"></span>
					</div>
					<div class="mui-input-row">
						<label>房号</label>
						<span v-text="detail.roomNumber"></span>
					</div>
					<div class="mui-input-row">
						<label>申请时间</label>
						<span v-text="detail.applicationTime"></span>
					</div>
				</form>
			</div>

			<div class="vongi-hdsq-dat">
				<h5>活动标题封面</h5>
				<div class="mui-card">
					<router-link :to="{name:'MasterActivityInfo',query:{id:detail.id}}">
						<div class="mui-card-content">
							<div class="mui-card-content-inner">
								<img :src="detail.frontCover" />
							</div>
						</div>
						<div class="mui-card-footer">
							<span class="mui-navigate-right">
								{{detail.title}}
							</span>
						</div>
					</router-link>
				</div>
				<div class="flew-sp">
					活动起止日期
					<span>{{detail.startTime.substr(0,10)}} 至 {{detail.endTime.substr(0,10)}}</span>
				</div>
			</div>
			<div v-if="detail.verify==0" class="fyy-scon-botton">
				<div class="examine-btn examine-btn1" @click="doAction(2)">拒绝</div>
				<div class="examine-btn examine-btn2" @click="doAction(1)">同意</div>
			</div>
			<!--状态-->
			<div class="mui-content-padded vongi-editme vongi-qingjiadt">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>申请状态</label>
						<span v-if="detail.verify<=1" class="color55f868" v-text="getStatusName(detail.verify)"></span>
						<span v-if="detail.verify==2" class="colorfe616c" v-text="getStatusName(detail.verify)"></span>
					</div>
					<div v-if="detail.verifyMsg" class="mui-input-row">
						<label>审核意见</label>
						<span class="vongi-span" v-text="detail.verifyMsg"></span>
					</div>
					<div v-if="detail.verifyTime" class="mui-input-row">
						<label>审核时间</label>
						<span v-text="detail.verifyTime"></span>
					</div>
				</form>
			</div>
			<!--弹窗-->
			<div v-if="openFormVisible" class="mui-popup mui-popup-in vongi-mui-pop">
				<div class="mui-popup-inner vongi-pop-inner">
					<div class="mui-popup-title">审核意见</div>
					<div class="mui-popup-input">
						<textarea v-model="subForm.verifyMsg" rows="3" placeholder="可输入审核意见"></textarea>
					</div>
				</div>
				<div class="mui-popup-buttons">
					<span class="mui-popup-button" @click="openFormVisible=false">取消</span>
					<span class="mui-popup-button mui-popup-button-bold" @click="submit">确定</span>
				</div>
			</div>
			<div v-if="openFormVisible" class="mui-popup-backdrop mui-active" @click="openFormVisible=false"></div>
		</div>

		<loading :visible="isLoading"></loading>
	</div>
</template>

<script>
	import * as API_Activity from '@/apis/Master/activity'
	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'
	export default {
		name: 'MasterActivityExamineInfo',
		components: {
			Common,
			Loading,
			TopHeader,
		},
		data() {
			return {
				isLoading: false,

				pageTitle: '申请详情',

				detail: {
					startTime: '',
					endTime: ''
				},

				openFormVisible: false,

				subForm: {
					id: this.$route.query.id,
					verify: '',
					verifyMsg: '',
				}
			}
		},
		created() {},
		methods: {
			//获取详情
			getInfo() {
				this.isLoading = true;
				API_Activity.getActivityInfo(this.subForm.id).then(response => {
					this.isLoading = false;
					this.detail = response;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//获取审核状态
			getStatusName(status) {
				let statusArr = ['待审核', '已批准', '未批准'];
				return statusArr[status];
			},
			//审批
			doAction(status) {
				this.subForm.verify = status;
				this.openFormVisible = true;
				this.subForm.verifyMsg = status == 1 ? '同意' : '拒绝';
			},
			//检测
			checkForm() {
				if (!this.subForm.id) {
					mui.toast('id不存在');
					return false;
				} else {
					return true;
				}
			},
			//提交
			submit() {
				if (this.checkForm()) {
					this.isLoading = true;
					API_Activity.examineActivity(this.subForm).then(response => {
						this.isLoading = false;
						mui.toast('处理成功');
						this.$router.go(-1);
					}).catch(error => {
						this.isLoading = false;
						mui.toast(error);
					})
				}
			},
			asynCallBack() {

			},
		},
		mounted() {
			this.getInfo();
		},
		destroyed() {},
		computed: {
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
				person_data: 'person_data',
				person_popedom: 'person_popedom',
			})
		}
	}
</script>

<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
