his_files.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <div class="full-width full-height white-bg mb-10">
  3. <div class="flex flex-col">
  4. <div class="flex flex-align-center padding border-bottom bold title-sp">
  5. <span class="flex-1"></span>
  6. <span style="flex: 2">文件/文件夹名称</span>
  7. <span style="flex: 1">更新(上传)时间</span>
  8. <span class="flex-1">文件大小</span>
  9. <!-- <span class="flex-1">是否同步</span>-->
  10. <span class="flex-1">上传人</span>
  11. <span style="flex: 3">操作</span>
  12. </div>
  13. <el-empty v-if="fileData && fileData.length === 0"/>
  14. <div v-for="item in fileData" :key='item.id' class="flex flex-center border-bottom padding content-sp">
  15. <div class="flex-1" v-if='item.type === 1 '>
  16. <img v-if="item.suffix === 'docx'" class="icon" src="../../assets/svg/folder/doc.svg">
  17. <img v-else-if="item.suffix === 'pdf'" class="icon" src="../../assets/svg/folder/pdf.svg">
  18. <img v-else-if="item.suffix === 'xlsx'" class="icon" src="../../assets/svg/folder/xls.svg">
  19. <img v-else class="icon" src="../../assets/svg/folder/other.svg">
  20. </div>
  21. <div class="flex-1" v-if='item.type === 2 '>
  22. <img v-if="item.isAccess === 1" class="icon" src="../../assets/svg/folder/see.svg">
  23. <img v-else-if="item.isAccess === 2" class="icon" src="../../assets/svg/folder/edit.svg">
  24. <img v-else class="icon" src="../../assets/svg/folder/invisible.svg">
  25. </div>
  26. <span style="flex: 2">{{ item.title }}</span>
  27. <span style="flex: 1">{{ item.updateTime }}</span>
  28. <span class="flex-1" >{{ item.type !== 2 ? item.size: '-' }}</span>
  29. <!-- <span class="flex-1">{{ item.status }}</span>-->
  30. <span class="flex-1">{{ item.createUserName }}</span>
  31. <div class="flex flex-center" style="flex: 3">
  32. <main-button icon="View" title="详情" width="85" @click="fileView(item)"/>
  33. <main-button icon="Download" v-if='item.type !== 2' title="下载" width="85" @click="downFile(item)"/>
  34. <!-- <main-button icon="UploadFilled" title="同步" width="85"/>-->
  35. <main-button icon="Delete" title="删除" v-if='item.isAccess === 2' width="85" @click="removeFile(item)"/>
  36. </div>
  37. </div>
  38. </div>
  39. <!-------分页----->
  40. <div v-if="fileData && fileData.length !== 0" class="mt-20 flex flex-center flex-justify-end"
  41. style="margin-right: 50px;padding-bottom: 20px">
  42. <span class="mr-20">共{{ fileData.total }}条</span>
  43. <el-pagination :total="fileData.total" background layout="prev, pager, next"/>
  44. </div>
  45. <el-image-viewer
  46. v-if='showImage'
  47. :url-list="imgList"
  48. @close='showImage = false'
  49. />
  50. </div>
  51. </template>
  52. <route>
  53. {
  54. name: '历史文件',
  55. }
  56. </route>
  57. <script>
  58. import mainButton from '../../components/main-button.vue'
  59. import { bytesToSize } from '../../utils/tools.js'
  60. import api from '@/api/index.js'
  61. export default {
  62. name: 'his_files',
  63. components: { mainButton },
  64. data () {
  65. return {
  66. showImage: false,
  67. imgList: [],
  68. id: '',
  69. fileData: []
  70. }
  71. },
  72. created () {
  73. this.id = this.$route.query.id
  74. this.getFileList()
  75. },
  76. methods: {
  77. getFileList () {
  78. this.$api.project.fileList({ id: this.id, isHistory: 1 }).then(res => {
  79. if (res.code === 200) {
  80. this.fileData = res.data.records.map(e => {
  81. e.size = bytesToSize(e.volume)
  82. return e
  83. })
  84. } else {
  85. this.$message.error(res.msg)
  86. }
  87. })
  88. },
  89. fileView (item) {
  90. if (item.type === 2) {
  91. // 文件夹
  92. this.$api.project.fileList({ id: item.id, isHistory: 1 }).then(res => {
  93. if (res.code === 200) {
  94. this.fileData = res.data.records.map(e => {
  95. e.size = bytesToSize(e.volume)
  96. return e
  97. })
  98. } else {
  99. this.$message.error(res.msg)
  100. }
  101. })
  102. } else {
  103. if (api.offices.includes(item.suffix)) {
  104. const routeData = this.$router.resolve({ path: '/home/file_detail', query: { id: item.fileId } })
  105. window.open(routeData.href, '_blank')
  106. } else {
  107. this.imgList = [item.url]
  108. this.showImage = true
  109. }
  110. }
  111. },
  112. downFile (item) {
  113. window.open('/api/wutong-file/minio/file/downFile/' + item.dowloadFileId, '')
  114. },
  115. removeFile (item) {
  116. if (item.hasChildren || item.fileAmount > 0) {
  117. this.$confirm('该文件夹不为空,请先删除子文件', {
  118. confirmButtonText: '确定',
  119. cancelButtonText: '取消',
  120. type: 'warning'
  121. })
  122. return
  123. }
  124. this.$confirm('确认是否删除该文件?', {
  125. confirmButtonText: '确定',
  126. cancelButtonText: '取消',
  127. type: 'warning'
  128. })
  129. .then(() => {
  130. this.$api.project.fileRemove({ ids: item.id }).then(res => {
  131. if (res.code === 200) {
  132. this.$message.success(res.msg)
  133. this.getFileList()
  134. } else {
  135. this.$message.error(res.msg)
  136. }
  137. })
  138. }
  139. )
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .title-sp {
  146. color: #596A8A;
  147. height: 55px;
  148. }
  149. .content-sp {
  150. color: #707070;
  151. }
  152. .flex-1 {
  153. flex: 0.5;
  154. }
  155. .icon {
  156. width: 43px;
  157. height: 45px;
  158. }
  159. </style>