detail.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. props.info = data
  41. relatedBusinessOpportunitiesList.value = data.businessOpportunityList || []
  42. relatedTasksList.value = data.taskList || []
  43. })
  44. }
  45. function processingData(id) {
  46. getDetailedData(id)
  47. }
  48. useLifecycle({
  49. init: () => {
  50. tabActive.value = '联系人信息';
  51. processingData(props.info.id || props.info.customId)
  52. }
  53. });
  54. </script>
  55. <style lang='scss' scoped>
  56. /* 样式代码 */
  57. </style>