detail.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <div class="w-full h-full">
  3. <van-tabs v-model:active="tabActive">
  4. <van-tab title="线索信息">
  5. <ThreadInfo :info="infoData" />
  6. </van-tab>
  7. <van-tab title="相关任务" name="相关任务">
  8. <RelatedTasks :infoList="relatedTasksList" :key="componentKey" />
  9. </van-tab>
  10. </van-tabs>
  11. </div>
  12. </template>
  13. <script setup>
  14. import { ref, watch } from 'vue';
  15. import { useLifecycle } from '@hooks/useCommon.js';
  16. import { GET_CLUE_DETAILS } from "@hooks/useApi"
  17. import requests from "@common/requests";
  18. import ThreadInfo from './threadInfo.vue';
  19. import RelatedTasks from '../tasks/relatedTasks.vue';
  20. const props = defineProps({
  21. info: {
  22. type: Object,
  23. required: true,
  24. default: () => ({})
  25. }
  26. })
  27. const tabActive = ref('线索信息');
  28. const componentKey = ref(1);
  29. const relatedTasksList = ref([]);
  30. const infoData = ref(props.info);
  31. const timeout = ref(null);
  32. watch(() => props.info, (newValue) => {
  33. tabActive.value = '线索信息';
  34. processingData(newValue.id)
  35. })
  36. function getDetails(id) {
  37. requests.post(GET_CLUE_DETAILS, { id }).then(({ data }) => {
  38. infoData.value = data || {}
  39. relatedTasksList.value = data.taskList || []
  40. }).finally(() => {
  41. setTimeout(() => {
  42. componentKey.value++
  43. }, 10)
  44. })
  45. }
  46. function processingData(id) {
  47. clearTimeout(timeout.value);
  48. timeout.value = setTimeout(() => {
  49. getDetails(id)
  50. }, 100);
  51. }
  52. useLifecycle({
  53. init: () => {
  54. tabActive.value = '线索信息';
  55. processingData(props.info.id)
  56. },
  57. load: () => {
  58. tabActive.value = '线索信息';
  59. processingData(props.info.id)
  60. },
  61. unload: () => {
  62. clearTimeout(timeout.value)
  63. }
  64. });
  65. </script>
  66. <style lang='scss' scoped>
  67. /* 样式代码 */
  68. </style>