<template>
  <van-form>
    <van-field
      v-model="specialty"
      rows="2"
      autosize
      label="医生擅长"
      type="textarea"
      maxlength="300"
      placeholder="擅长治疗方向"
      show-word-limit
      :rules="[{ required: true, message: '请输入擅长的治疗方向' }]"
    />

    <van-field
      v-model="description"
      rows="2"
      autosize
      label="医生简介"
      type="textarea"
      maxlength="1000"
      placeholder="医生简介"
      show-word-limit
      :rules="[{ required: true, message: '请输入医生简介' }]"
    />

    <van-button
      class="next-step-btn"
      type="info"
      size="large"
      @click="submitForm"
    >提交审核</van-button>
  </van-form>
</template>

<script>
export default {
  data() {
    return {
      specialty: "",   // 擅长
      description: ""     // 简介
    }
  },
  methods: {
    submitForm() {
      if(this.specialty && this.description) {
        // 将数据存起来
        window.sessionStorage.setItem('doctorMessageForm', JSON.stringify({specialty:this.specialty, description:this.description}))
        this.$emit('handleSubmitAudit', {specialty:this.specialty, description:this.description})
      }else {
        this.$toast('请填写医生擅长或医生简介内容!')
      }
    }
  },
  mounted(){
    let obj = JSON.parse(window.sessionStorage.getItem('doctorMessageForm'))
    if(obj) {
      this.specialty = obj.specialty
      this.description = obj.description
    }
  }
}
</script>

<style>
.next-step-btn {
  /*   position: absolute;
  bottom: 5%;
  transform: translate(-50%); */
  margin: 0.5rem 0;
  width: 90%;
}
</style>