<template>
	<u-popup :show="value" @close="close()" round="15" mode="center" :closeable="true" :mask-close-able="true" :customStyle="{ width: '90%' }">
		<view class="ppopup">
			<u-divider text="发送面试邀请" style="margin-top: 25px"></u-divider>
			<view class="form_group">
				<picker :disabled="true" @click="show = true">
					<input placeholder="请选择面试时间" v-model="item.inviteTime" :disabled="true" />
					<view class="icon more">&#xe62b;</view>
				</picker>
			</view>
			<button class="btn" @click="confirm()">确认</button>
			<u-datetime-picker :show="show" :closeOnClickOverlay="true" :minDate="Number(new Date())" @close="show = false" @cancel="show = false" @confirm="ok"></u-datetime-picker>
		</view>
	</u-popup>
</template>

<script>
export default {
	props: {
		value: {
			type: Boolean,
			default: true
		},
		resumeDeliverId: {
			type: Number
		}
	},
	data() {
		return {
			show: false,
			item: {}
		};
	},
	methods: {
		ok(e) {
			this.show = false;
			this.item.inviteTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM');
		},
		confirm() {
			let rule = [{ name: 'inviteTime', checkType: 'notnull', errorMsg: '请选择面试时间' }];
			if (!this.verify.check(this.item, rule)) {
				uni.showModal({ content: this.verify.error, showCancel: false });
				return false;
			}
			uni.showModal({
				title: '提示',
				content: '确定发送面试邀请',
				success: (res) => {
					if (res.confirm) {
						this.item.id = this.resumeDeliverId;
						this.http.request({
							url: '/app/deliver/invite',
							data: this.item,
							method: 'POST',
							success: (res) => {
								uni.showToast({ title: '发送成功' });
								this.$emit('input', false);
							}
						});
					}
				}
			});
		},
		close() {
			this.$emit('input', false);
		}
	}
};
</script>

<style lang="scss">
.ppopup {
	padding: 20px;
}
</style>
