detail.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div class="w-full h-full">
  3. <van-tabs v-model:active="tabActive">
  4. <van-tab title="商机阶段" name="商机阶段">
  5. <BusinessOpportunityStage :info="infoData" @chnage="refreshData()" />
  6. </van-tab>
  7. <van-tab title="商机信息" name="商机信息">
  8. <BusinessInfo :info="infoData" />
  9. </van-tab>
  10. <van-tab title="相关产品" name="相关产品">
  11. <RelatedProducts :infoList="relatedProductsList" />
  12. </van-tab>
  13. <van-tab title="相关任务" name="相关任务">
  14. <RelatedTasks :infoList="relatedTasksList" />
  15. </van-tab>
  16. </van-tabs>
  17. </div>
  18. </template>
  19. <script setup>
  20. import { ref, onActivated, watch } from 'vue';
  21. import { useLifecycle } from '@hooks/useCommon.js';
  22. import { GET_BUSINESS_OPPORTUNITY_DETAILS } from "@hooks/useApi"
  23. import requests from "@common/requests";
  24. import RelatedProducts from '../product/relatedProducts.vue';
  25. import BusinessInfo from './businessInfo.vue';
  26. import RelatedTasks from '../tasks/relatedTasks.vue';
  27. import BusinessOpportunityStage from './businessOpportunityStage.vue';
  28. const props = defineProps({
  29. info: {
  30. type: Object,
  31. required: true,
  32. default: () => ({})
  33. }
  34. })
  35. const tabActive = ref('商机信息');
  36. const relatedProductsList = ref([]);
  37. const relatedTasksList = ref([]);
  38. const infoData = ref(props.info);
  39. const timeout = ref(null);
  40. watch(() => props.info, (newValue) => {
  41. tabActive.value = '商机信息';
  42. processingData(newValue.id)
  43. })
  44. function refreshData() {
  45. processingData(infoData.value.id)
  46. }
  47. function getBusinessOpportunityDetails(id) {
  48. requests.post(GET_BUSINESS_OPPORTUNITY_DETAILS, { id }).then(({ data }) => {
  49. infoData.value = data
  50. relatedProductsList.value = data.businessItemProducts || []
  51. relatedTasksList.value = data.taskList || []
  52. })
  53. }
  54. function processingData(id) {
  55. clearTimeout(timeout.value);
  56. timeout.value = setTimeout(() => {
  57. getBusinessOpportunityDetails(id)
  58. }, 100);
  59. }
  60. useLifecycle({
  61. init: () => {
  62. tabActive.value = '商机信息';
  63. processingData(props.info.id)
  64. },
  65. load: () => {
  66. tabActive.value = '商机信息';
  67. processingData(props.info.id)
  68. },
  69. unLoad: () => {
  70. clearTimeout(timeout.value);
  71. }
  72. });
  73. </script>
  74. <style lang='scss' scoped>
  75. /* 样式代码 */
  76. </style>