<template>
  <evaluation-message 
    v-if="payload.description === 'PATIENT_RATE_MESSAGE'" 
    :doctorInfo="doctorInfo" 
    :extension="extension" 
    @popupStatusChange="handlePopupStatusChange"
  />
</template>
<script setup>
import { computed } from 'vue';
import evaluationMessage from './evaluation.vue';

const props = defineProps({
  message: {
    type: Object
  },
  doctorInfo:{
    type: Object,
    default: () => ({})
  }
});

const emit = defineEmits(['popupStatusChange']);

const payload = computed(() => {
  return props.message && props.message.payload ? props.message.payload : {};
})
const extension = computed(() => {
  try {
    return JSON.parse(payload.value.extension)
  } catch (e) {
    return {}
  }
})

// 处理弹窗状态变化，传递给父组件
const handlePopupStatusChange = (isOpen) => {
  emit('popupStatusChange', isOpen);
}
</script>