attachmentList.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <view class="message_attachment">
  3. <uni-section class="mb-10" title="附件" type="line">
  4. </uni-section>
  5. <uni-row :gutter="0">
  6. <uni-col v-for="(attachment, index) in attachments" :key="index" :xs="{span: 24}" :sm="6">
  7. <view class="attachment">
  8. <text @click="seeAttachment(attachment.path)">{{ attachment.fileName || '空' }}</text>
  9. </view>
  10. </uni-col>
  11. </uni-row>
  12. </view>
  13. </template>
  14. <script setup lang="ts">
  15. import $tab from '@/plugins/tab';
  16. import { onMounted, ref } from 'vue';
  17. onMounted(() => {
  18. startAttachmentCheck();
  19. })
  20. const intervalId = ref(null); // 定时器ID
  21. // TODO: 根据接口返回的数据动态生成process表单
  22. // const props = defineProps(['attachments'])
  23. const props = defineProps({
  24. attachments: {
  25. type: Array,
  26. required: true,
  27. default: []
  28. }
  29. })
  30. //检查附件列表是否有数据
  31. function startAttachmentCheck() {
  32. intervalId.value = setInterval(() => {
  33. console.log(111);
  34. if (props.attachments) {
  35. console.log('props', props.attachments);
  36. clearInterval(intervalId.value); // 清除定时器
  37. }
  38. }, 100); // 每0.1秒检查一次
  39. }
  40. //预览文件
  41. function seeAttachment(path) {
  42. // console.log('path',path);
  43. $tab.navigateTo('/pages/message/detail/URLView?type=doc&url=' + encodeURIComponent(path));
  44. }
  45. </script>
  46. <style lang="scss">
  47. .attachment {
  48. color: blue;
  49. margin-left: 5px;
  50. }
  51. </style>