detail.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. import useShowToast from '@hooks/useToast'
  29. const { toastSuccess, toastLoading, toastFail, toastText, clearToast } = useShowToast()
  30. const props = defineProps({
  31. info: {
  32. type: Object,
  33. required: true,
  34. default: () => ({})
  35. }
  36. })
  37. const tabActive = ref('商机信息');
  38. const relatedProductsList = ref([]);
  39. const relatedTasksList = ref([]);
  40. const infoData = ref(props.info);
  41. const timeout = ref(null);
  42. watch(() => props.info, (newValue) => {
  43. tabActive.value = '商机信息';
  44. processingData(newValue.id)
  45. })
  46. function refreshData() {
  47. processingData(infoData.value.id)
  48. }
  49. function getBusinessOpportunityDetails(id) {
  50. requests.post(GET_BUSINESS_OPPORTUNITY_DETAILS, { id }).then(({ data }) => {
  51. infoData.value = data
  52. relatedProductsList.value = data.businessItemProducts || []
  53. relatedTasksList.value = data.taskList || []
  54. }).finally(() => {
  55. setTimeout(() => {
  56. clearToast()
  57. }, 200)
  58. })
  59. }
  60. function processingData(id) {
  61. clearTimeout(timeout.value);
  62. toastLoading('加载中...', 0)
  63. timeout.value = setTimeout(() => {
  64. getBusinessOpportunityDetails(id)
  65. }, 100);
  66. }
  67. useLifecycle({
  68. init: () => {
  69. tabActive.value = '商机信息';
  70. processingData(props.info.id)
  71. },
  72. load: () => {
  73. tabActive.value = '商机信息';
  74. processingData(props.info.id)
  75. },
  76. unLoad: () => {
  77. clearTimeout(timeout.value);
  78. }
  79. });
  80. </script>
  81. <style lang='scss' scoped>
  82. /* 样式代码 */
  83. </style>