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

		<div class="mui-content margin60">
			<div class="mui-content-padded vongi-qingjiadt vongi-editme">
				<form class="mui-input-group">
					<div class="mui-input-row">
						<label>头像</label>
						<button class="mui-btn mui-btn-block  " type='button' style="width:65%;padding-right:15px">
							<img :src="detail.faceImageUrl" />
						</button>
					</div>
					<div class="mui-input-row">
						<label>姓名</label>
						<span>{{detail.name}}</span>
					</div>
					<div class="mui-input-row">
						<label>性别</label>
						<button class="mui-btn mui-btn-block mui-navigate-right mui-ellipsis"
						 type='button' style="width:65%" @click="selectGender">
							{{detail.gender}}
						</button>
					</div>
					<div class="mui-input-row">
						<label>出生年月</label>
						<button class="mui-btn mui-btn-block mui-navigate-right mui-ellipsis"

						 @click="selectDate" type='button' style="width:65%" >
							{{detail.birthDate?detail.birthDate:'请选择'}}
						</button>
					</div>
				</form>
			</div>
			<div class="vongi-meform-pho mui-content-padded">
				<h4>过敏药品</h4>
				<div class="mui-input-row">
					<textarea id="textarea" rows="5"  v-model="detail.allergicDrugs" placeholder="请输入过敏药品"></textarea>
				</div>
			</div>
			<div class="vongi-meform-pho mui-content-padded">
				<h4>已有病史</h4>
				<div class="mui-input-row">
					<textarea id="textarea" rows="5" v-model="detail.medicalHistory"
					 placeholder="请输入已有病史"></textarea>
				</div>
			</div>

		</div>
		<div class="fyy-footer">
			<div class="bindfyy-btn"><button type="submit"  @click="submit()"
			class="mui-btn mui-btn-pink ">保  存</button></div>
		</div>
				 <loading :visible="isLoading"></loading>

</div>
</template>


<script>
	require('$project/assets/js/mui.picker.min.js');

	import * as API from '@/apis/Master/hospital'
	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 {


	} from '$project/utils'
	export default {
		name: 'MasterHospitalArchives',
		components: {
			Common,
			Loading,
			TopHeader
		},
		data() {
			return {
				pageTitle: '就医档案',
				isLoading: false,
 				detail:{},
			}
		},
		created() {

		 },
		methods:  {
		submit(){
								this.isLoading = true;

		        	API.medicalPersonSave(this.detail).then(res=>{
                             this.$router.push({
                             					name: 'MasterHospital',
                             					query: {
                              					}
                             				})
                                    this.detail=res;
                					mui.toast("已提交");

                  }).catch(error => {
                  			this.isLoading = false;

                					mui.toast(error);

                    })
		},
		selectGender(){
		  	var picker = new mui.PopPicker();

		    		picker.setData([
		    		{
            						text: "男",
            						value: '男'
            					},
            					{
            						text: "女",
            						value: '女'
            					},{
                                     text: "未知",
                                     value: '未知'
                                }
            				]);
            	picker.show((selectItems) => {
                      this.detail.gender = selectItems[0].text;

             });
		},
			selectDate(){
			            var dtPicker = new mui.DtPicker({
            					type: 'date',
            					"beginYear": 1900,
            					"endDate": new Date(),
            				});

            				dtPicker.show((selectItems) => {
            					var year = selectItems.y.value;
            					var month = selectItems.m.value;
            					var day = selectItems.d.value;

            					var curDate = year + "-" + month + "-" + day;
                                this.detail.birthDate=curDate;

            				});
			},
		getDetail(){
						this.isLoading = true;

	        	API.medicalPersonDetail(this.person_data.id).then(res=>{
                    this.detail=res;
				this.isLoading = false;

         		}).catch(error => {
                    this.isLoading = false;
        		})
		}

		 ,asynCallBack(){},
		},
		mounted() {
            this.getDetail();
		},
		destroyed() {

		},
		computed: {
			...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 src="$project/assets/css/mui.picker.min.css"></style>

<style>
</style>
