detail.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. import useShowToast from '@hooks/useToast'
  21. const { toastSuccess, toastLoading, toastFail, toastText, clearToast } = useShowToast()
  22. const props = defineProps({
  23. info: {
  24. type: Object,
  25. required: true,
  26. default: () => ({})
  27. }
  28. })
  29. const tabActive = ref('线索信息');
  30. const componentKey = ref(1);
  31. const relatedTasksList = ref([]);
  32. const infoData = ref(props.info);
  33. const timeout = ref(null);
  34. watch(() => props.info, (newValue) => {
  35. tabActive.value = '线索信息';
  36. processingData(newValue.id)
  37. })
  38. function getDetails(id) {
  39. requests.post(GET_CLUE_DETAILS, { id }).then(({ data }) => {
  40. infoData.value = data || {}
  41. relatedTasksList.value = data.taskList || []
  42. }).finally(() => {
  43. setTimeout(() => {
  44. componentKey.value++
  45. }, 10)
  46. setTimeout(() => {
  47. clearToast()
  48. }, 200)
  49. })
  50. }
  51. function processingData(id) {
  52. clearTimeout(timeout.value);
  53. toastLoading('加载中...', 0)
  54. timeout.value = setTimeout(() => {
  55. getDetails(id)
  56. }, 100);
  57. }
  58. useLifecycle({
  59. init: () => {
  60. tabActive.value = '线索信息';
  61. processingData(props.info.id)
  62. },
  63. load: () => {
  64. tabActive.value = '线索信息';
  65. processingData(props.info.id)
  66. },
  67. unload: () => {
  68. clearTimeout(timeout.value)
  69. }
  70. });
  71. </script>
  72. <style lang='scss' scoped>
  73. /* 样式代码 */
  74. </style>