detail.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="w-full h-full">
  3. <van-tabs v-model:active="tabActive">
  4. <van-tab title="联系人信息" name="联系人信息">
  5. <ContactsInfo :info="info" />
  6. </van-tab>
  7. <van-tab title="相关任务" name="相关任务">
  8. <RelatedTasks :infoList="relatedTasksList" />
  9. </van-tab>
  10. <van-tab title="相关商机" name="相关商机">
  11. <RelatedBusinessOpportunities :infoList="relatedBusinessOpportunitiesList" />
  12. </van-tab>
  13. </van-tabs>
  14. </div>
  15. </template>
  16. <script setup>
  17. import { ref, onActivated, watch } from 'vue';
  18. import { useLifecycle } from '@hooks/useCommon.js';
  19. import { GET_CONTACT_DETAILS } from "@hooks/useApi"
  20. import requests from "@common/requests";
  21. import ContactsInfo from './contactsInfo.vue';
  22. import RelatedTasks from '../tasks/relatedTasks.vue';
  23. import RelatedBusinessOpportunities from '../business/relatedBusinessOpportunities.vue';
  24. const props = defineProps({
  25. info: {
  26. type: Object,
  27. required: true,
  28. default: () => ({})
  29. }
  30. })
  31. const tabActive = ref('联系人信息');
  32. const relatedBusinessOpportunitiesList = ref([]);
  33. const relatedTasksList = ref([]);
  34. watch(() => props.info, (newValue) => {
  35. tabActive.value = '联系人信息';
  36. processingData(newValue.id)
  37. })
  38. function getDetailedData(id) {
  39. requests.post(GET_CONTACT_DETAILS, { id }).then(({ data }) => {
  40. relatedBusinessOpportunitiesList.value = data.businessOpportunityList || []
  41. relatedTasksList.value = data.taskList || []
  42. })
  43. }
  44. function processingData(id) {
  45. getDetailedData(id)
  46. }
  47. useLifecycle({
  48. init: () => {
  49. tabActive.value = '联系人信息';
  50. processingData(props.info.id)
  51. }
  52. });
  53. </script>
  54. <style lang='scss' scoped>
  55. /* 样式代码 */
  56. </style>