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

		<div class="mui-content vongi-cytx">
			<div class="mui-content-padded padd10">
				<div class="vongi-center">
					<img src="~$project/assets/img/yaook.png" width="40%" />
					<h2>设置完成</h2>
					<!-- <h4 class='color666'>您还没有添加用药提醒</h4> -->
				</div>
			</div>
			<drug-calendar :monthList="monthList"></drug-calendar>
			<div class="fyy-scon-botton">
				<div class="examine-btn mui-btn-pink mui-btn-outlined" @click="goToEdit">返回修改</div>
				<div class="examine-btn mui-btn-pink" @click="sure">完成</div>
			</div>
		</div>

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

<script>
	import * as API_Drug from '@/apis/Master/drug'
	import Common from '$project/components/Common.vue'
	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
	import DrugCalendar from '@/components/DrugCalendar.vue'
	import {
		mapGetters,
		mapMutations
	} from 'vuex'
	export default {
		name: 'MasterDrugAddSuccess',
		components: {
			Common,
			Loading,
			TopHeader,
			DrugCalendar
		},
		data() {
			return {
				isLoading: false,

				pageTitle: '设置完成',

				id: this.$route.query.id,

				list: [],
			}
		},
		created() {},
		methods: {
			//获取日历计划信息
			getMedicationCalendar() {
				this.isLoading = true;
				API_Drug.medicationCalendar(this.id).then(response => {
					this.isLoading = false;

					this.list = response.list;

				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			//编辑
			goToEdit() {
				this.$router.push({
					name: 'MasterDrugAdd',
					query: {
						id: this.id
					}
				})
			},
			//跳转到列表
			sure() {
				this.isLoading = true;
				API_Drug.medicationCalendarDefine(this.id).then(response => {
					this.isLoading = false;

					mui.toast('处理成功');
					this.$router.push({
						name: 'MasterDrug'
					})

				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			asynCallBack() {

			},
		},
		mounted() {
			//获取日历计划信息
			this.getMedicationCalendar();
		},
		destroyed() {

		},
		computed: {
			monthList: {
				// getter
				get: function() {
					return this.list;
				},
				// setter
				set: function(newValue) {
					console.log(newValue)
				}
			},
			...mapGetters({
				openId: 'wx_openid',
				token: 'token',
				person_data: 'person_data',
				person_popedom: 'person_popedom',
			})
		}
	}
</script>
<style scoped src="$project/assets/css/pension.css"></style>
<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/iconfont.css"></style>
<style>
</style>
