<template>
  <Dialog v-model="dialogVisible" :title="dialogTitle" width="95%"  @close="handleClose">
    <div style="max-height: 800px;min-height: 800px;padding: 10px;overflow: auto">
      <component :is="component" v-if="component" openType="tobedone"/>
    </div>
  </Dialog>
</template>
<script setup>
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的是否展示
const component = ref(null)
const loadComponent = async (type) => {
  if (type == "待售后") {
    component.value = defineAsyncComponent(() =>
      import('@/views/mall/trade/afterSale/index.vue')
    )
  }else if(type == "待发货"){
    component.value = defineAsyncComponent(() =>
      import('@/views/mall/trade/order/index.vue')
    )
  }
};
/** 打开弹窗 */
const open = (type) => {
  dialogVisible.value = true
  dialogTitle.value = type
  loadComponent(type)
}
const emit = defineEmits(['close']);
// 处理 Dialog 关闭操作
function handleClose() {
  // 触发父组件的 close 事件
  emit('close');
}
defineExpose({ open })
</script>