detail.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div class="w-full h-full">
  3. <van-tabs v-model:active="tabActive">
  4. <van-tab title="线索信息">
  5. <ThreadInfo :info="info" />
  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. watch(() => props.info, (newValue) => {
  31. tabActive.value = '线索信息';
  32. processingData(newValue.id)
  33. })
  34. function getDetails(id) {
  35. requests.post(GET_CLUE_DETAILS, { id }).then(({ data }) => {
  36. relatedTasksList.value = data.taskList || []
  37. }).finally(() => {
  38. setTimeout(() => {
  39. componentKey.value++
  40. }, 10)
  41. })
  42. }
  43. function processingData(id) {
  44. getDetails(id)
  45. }
  46. useLifecycle({
  47. init: () => {
  48. tabActive.value = '线索信息';
  49. processingData(props.info.id)
  50. }
  51. });
  52. </script>
  53. <style lang='scss' scoped>
  54. /* 样式代码 */
  55. </style>