index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="content">
  3. <van-sticky :offset-top="0">
  4. <van-nav-bar title="项目文件" left-text="返回" left-arrow @click-left="onClickLeft"> </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;align-items: center;">
  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:50vh">
  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 txticon from '@/assets/icons/svg/txt.svg'
  40. import picicon from '@/assets/icons/svg/pic.svg'
  41. import pdficon from '@/assets/icons/svg/pdf1.svg'
  42. import docicon from '@/assets/icons/svg/doc.svg'
  43. import xlsicon from '@/assets/icons/svg/xls.svg'
  44. import ppticon from '@/assets/icons/svg/ppt.svg'
  45. import mp4icon from '@/assets/icons/svg/mp4.svg'
  46. import cadicon from '@/assets/icons/svg/cad.svg'
  47. import unknownicon from '@/assets/icons/svg/unknown.svg'
  48. import {
  49. listArchives,
  50. addArchives,
  51. updateArchives,
  52. delArchives,
  53. getArchive_files,
  54. saveArchive_files
  55. } from "@/api/archives/index";
  56. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  57. const { sys_area, sys_project_status } = toRefs<any>(
  58. proxy?.useDict("sys_area", "sys_project_status")
  59. );
  60. import { listByIds,delOss } from "@/api/system/oss";
  61. import _ from "lodash";
  62. const list = ref([]);
  63. const refreshing = ref(false);
  64. const loading = ref(false);
  65. const finished = ref(false);
  66. const router = useRouter();
  67. const route = useRoute();
  68. const currentfile = ref({ url: "" })
  69. const pdfviewshow = ref(false);
  70. const onClickLeft = () => {
  71. router.replace({ path: '/h5/project' });
  72. }
  73. onMounted(() => {
  74. if (route.query.id == undefined) {
  75. router.replace({ path: '/h5/project' });
  76. }
  77. })
  78. const onLoad = () => {
  79. if (route.query.id == undefined) {
  80. router.replace({ path: '/h5/project' });
  81. return
  82. }
  83. getArchive_files(route.query.id).then((res) => {
  84. loading.value = false;
  85. list.value = res.data
  86. finished.value = true;
  87. });
  88. };
  89. const onRefresh = () => {
  90. // 清空列表数据
  91. finished.value = false;
  92. refreshing.value = false;
  93. // 重新加载数据
  94. // 将 loading 设置为 true,表示处于加载状态
  95. loading.value = true;
  96. onLoad();
  97. };
  98. const previewfile = (file) => {
  99. currentfile.value = file;
  100. listByIds(file.ossId).then((res) => {
  101. currentfile.value.url = res.data[0].url;
  102. pdfviewshow.value = true;
  103. });
  104. }
  105. const downloadfile = (file) => {
  106. proxy?.$download.oss(file.ossId)
  107. }
  108. const gettypeicon = (type) => {
  109. if (type.indexOf('png') != -1 || type.indexOf('jp') != -1) {
  110. return picicon;
  111. }
  112. if (type.indexOf('ppt') != -1 ) {
  113. return ppticon;
  114. }
  115. if (type.indexOf('xl') != -1 ) {
  116. return xlsicon;
  117. }
  118. if (type.indexOf('doc') != -1 ) {
  119. return docicon;
  120. }
  121. if (type.indexOf('txt') != -1 ) {
  122. return txticon;
  123. }
  124. if (type.indexOf('ca') != -1 ) {
  125. return cadicon;
  126. }
  127. if (type.indexOf('mp4') != -1 ) {
  128. return mp4icon;
  129. }
  130. if (type.indexOf('pdf') != -1 ) {
  131. return pdficon;
  132. }
  133. return unknownicon
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .content {
  138. text-align: center;
  139. position: relative;
  140. min-height: 100vh;
  141. background: #eff2f5;
  142. .filtercss{
  143. }
  144. }
  145. </style>
  146. <style lang="scss">
  147. .filtercss{
  148. .el-drawer{
  149. background: rgb(236, 235, 235);
  150. .el-drawer__body{
  151. padding:0
  152. }
  153. }
  154. }
  155. </style>