<template>
  <Page :title="`${currentRoutingInformation?.name}详情`">
    <template v-slot:body>
      <!-- 商机 -->
      <template v-if="currentRoutingInformation?.key == 'business'">
        <Business />
      </template>
      <!-- 线索 -->
      <template v-if="currentRoutingInformation?.key == 'thread'">
        <Thread />
      </template>
      <!-- 客户 -->
      <template v-if="currentRoutingInformation?.key == 'customer'">
        <Customer />
      </template>
      <!-- 联系人 -->
      <template v-if="currentRoutingInformation?.key == 'contacts'">
        <Contacts />
      </template>
      <!-- 任务 -->
      <template v-if="currentRoutingInformation?.key == 'tasks'">
        <Tasks />
      </template>
      <!-- 产品管理 -->
      <template v-if="currentRoutingInformation?.key == 'product'">
        <Product />
      </template>
      <!-- 合同管理 -->
      <template v-if="currentRoutingInformation?.key == 'contract'">
        <Contract />
      </template>
      <!-- 销售订单 -->
      <template v-if="currentRoutingInformation?.key == 'order'">
        <Order />
      </template>
    </template>
  </Page>
</template>

<script setup>
import { ref } from 'vue';
import { useLifecycle } from '@hooks/useCommon.js';
import useRouterStore from "@store/useRouterStore.js";

import Business from "@pages/pageComponents/business/detail.vue" 
import Thread from "@pages/pageComponents/thread/detail.vue"
import Customer from "@pages/pageComponents/customer/detail.vue"
import Contacts from "@pages/pageComponents/contacts/detail.vue"
import Tasks from "@pages/pageComponents/tasks/detail.vue"
import Product from "@pages/pageComponents/product/detail.vue"
import Contract from "@pages/pageComponents/contract/detail.vue"
import Order from "@pages/pageComponents/order/detail.vue"

const router = useRouterStore()
const queryParameters = ref({})
const currentRoutingInformation = ref({})
function reloadListData(data) {
  const { routerInfo = '', parameter = '' } = data
  queryParameters.value = JSON.parse(parameter)
  currentRoutingInformation.value = JSON.parse(routerInfo)
}

useLifecycle({
  load: () => {
    router.on('detailParameter', (data) => {
      reloadListData(data)
    })
  }
});
</script>

<style lang='scss' scoped>
  /* 样式代码 */
</style>