index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="content">
  3. <van-sticky :offset-top="0">
  4. <van-nav-bar title="项目文件" left-text="返回" left-arrow @click-left="onClickLeft" @click-right="filterclick"> </van-nav-bar>
  5. </van-sticky>
  6. <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
  7. <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
  8. <van-cell-group v-for="item in list" :key="item" inset style="margin-top: 10px">
  9. <van-cell @click="previewfile(item)">
  10. <div style="display: flex;justify-content: space-between;">
  11. <div style="display: flex;">
  12. <img style="width: 25px;height:25px" :src="gettypeicon(item.fileSuffix)" />
  13. <div style="max-width: 50vw;white-space: nowrap;overflow: hidden;text-overflow: ellipsis; ">{{ item.originalName }}</div>
  14. </div>
  15. <div style="font-size: 10px;">
  16. {{ item.createTime }}
  17. </div>
  18. </div>
  19. </van-cell>
  20. </van-cell-group>
  21. </van-list>
  22. </van-pull-refresh>
  23. <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="90vw">
  24. <div style="position: relative;min-height:78vh">
  25. <pdfview :src="currentfile.url"></pdfview>
  26. </div>
  27. <!-- <div><el-affix :offset="120" position="bottom"><el-button type="text" icon="DArrowRight"></el-button></el-affix></div>
  28. </div> -->
  29. <template #footer>
  30. <div class="dialog-footer">
  31. <el-button @click="pdfviewshow = false">关闭</el-button>
  32. <el-button v-hasPermi="['filemanager.project.file.download']" type="primary" @click="downloadfile(currentfile)"> 下载 </el-button>
  33. </div>
  34. </template>
  35. </el-dialog>
  36. </div>
  37. </template>
  38. <script setup lang="ts">
  39. import {
  40. listArchives,
  41. addArchives,
  42. updateArchives,
  43. delArchives,
  44. getArchive_files,
  45. saveArchive_files
  46. } from "@/api/archives/index";
  47. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  48. const { sys_area, sys_project_status } = toRefs<any>(
  49. proxy?.useDict("sys_area", "sys_project_status")
  50. );
  51. import { listByIds,delOss } from "@/api/system/oss";
  52. import _ from "lodash";
  53. const list = ref([]);
  54. const refreshing = ref(false);
  55. const loading = ref(false);
  56. const finished = ref(false);
  57. const router = useRouter();
  58. const route = useRoute();
  59. const currentfile = ref({ url: "" })
  60. const pdfviewshow = ref(false);
  61. const onClickLeft = () => {
  62. router.replace({ path: '/h5/project' });
  63. }
  64. onMounted(() => {
  65. if (route.query.id == undefined) {
  66. router.replace({ path: '/h5/project' });
  67. }
  68. })
  69. const onLoad = () => {
  70. getArchive_files(route.query.id).then((res) => {
  71. loading.value = false;
  72. list.value = res.data
  73. finished.value = true;
  74. });
  75. };
  76. const onRefresh = () => {
  77. // 清空列表数据
  78. finished.value = false;
  79. refreshing.value = false;
  80. // 重新加载数据
  81. // 将 loading 设置为 true,表示处于加载状态
  82. loading.value = true;
  83. onLoad();
  84. };
  85. const previewfile = (file) => {
  86. currentfile.value = file;
  87. listByIds(file.ossId).then((res) => {
  88. currentfile.value.url = res.data[0].url;
  89. pdfviewshow.value = true;
  90. });
  91. }
  92. const downloadfile = (file) => {
  93. proxy?.$download.oss(file.ossId)
  94. }
  95. import txticon from '@/assets/icons/svg/txt.svg'
  96. import picicon from '@/assets/icons/svg/pic.svg'
  97. import pdficon from '@/assets/icons/svg/pdf1.svg'
  98. import docicon from '@/assets/icons/svg/doc.svg'
  99. import xlsicon from '@/assets/icons/svg/xls.svg'
  100. import ppticon from '@/assets/icons/svg/ppt.svg'
  101. import mp4icon from '@/assets/icons/svg/mp4.svg'
  102. import cadicon from '@/assets/icons/svg/cad.svg'
  103. import unknownicon from '@/assets/icons/svg/unknown.svg'
  104. const gettypeicon = (type) => {
  105. if (type.indexOf('png') != -1 || type.indexOf('jp') != -1) {
  106. return picicon;
  107. }
  108. if (type.indexOf('ppt') != -1 ) {
  109. return ppticon;
  110. }
  111. if (type.indexOf('xl') != -1 ) {
  112. return xlsicon;
  113. }
  114. if (type.indexOf('doc') != -1 ) {
  115. return docicon;
  116. }
  117. if (type.indexOf('txt') != -1 ) {
  118. return txticon;
  119. }
  120. if (type.indexOf('ca') != -1 ) {
  121. return cadicon;
  122. }
  123. if (type.indexOf('mp4') != -1 ) {
  124. return mp4icon;
  125. }
  126. if (type.indexOf('pdf') != -1 ) {
  127. return pdficon;
  128. }
  129. return unknownicon
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .content {
  134. text-align: center;
  135. position: relative;
  136. min-height: 100vh;
  137. background: #eff2f5;
  138. .filtercss{
  139. }
  140. }
  141. </style>
  142. <style lang="scss">
  143. .filtercss{
  144. .el-drawer{
  145. background: rgb(236, 235, 235);
  146. .el-drawer__body{
  147. padding:0
  148. }
  149. }
  150. }
  151. </style>