file.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view>
  3. <mescroll-empty :option="option" v-if="tableData.length === 0">
  4. </mescroll-empty>
  5. <view class="file-list" v-else>
  6. <view class="file-item" v-for="(item,index) in tableData" :key="index" @click="clickFolder(item)">
  7. <view class="file-image">
  8. <image class="image" src="../../static/image/datacenter/folder.png" mode="heightFix"
  9. v-if="item.directory"></image>
  10. <image class="image" :src="returnImage(item)" mode="heightFix" v-else></image>
  11. </view>
  12. <view class="file-content">
  13. <view class="title">{{item.name}}</view>
  14. <view class="sub">{{item.createDate || '-'}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import {
  22. getProjectDirList
  23. } from '@/request/api/datacenter.js'
  24. const fileBox = {
  25. 'doc': 'doc.png',
  26. 'docx': 'doc.png',
  27. 'jpg': 'jpg.png',
  28. 'jpeg': 'jpg.png',
  29. 'mp3': 'mp3.png',
  30. 'mp4': 'mp4.png',
  31. 'pdf': 'pdf.png',
  32. 'png': 'png.png',
  33. 'ppt': 'ppt.png',
  34. 'pptx': 'pptx.png',
  35. 'txt': 'txt.png',
  36. 'xls': 'xls.png',
  37. 'xlsx': 'xls.png',
  38. 'zip': 'zip.png',
  39. }
  40. import {
  41. projectPermission
  42. } from '@/uitls/datacenter'
  43. export default {
  44. data() {
  45. return {
  46. option: {
  47. tip: '当前文件夹暂无数据'
  48. },
  49. tableData: [],
  50. parentId: '',
  51. }
  52. },
  53. onLoad(body) {
  54. this.parentId = body.parentId;
  55. uni.setNavigationBarTitle({
  56. title: body.title
  57. });
  58. this.projectDirList();
  59. },
  60. methods: {
  61. returnImage(item) {
  62. console.log(item);
  63. let name = item.name.split('.');
  64. let type = name[name.length - 1].toLowerCase();
  65. let fileName = fileBox[type] || 'nofile.png'
  66. return '../../static/image/datacenter/' + fileName;
  67. },
  68. projectDirList() {
  69. getProjectDirList(this.parentId).then(res => {
  70. if (res.code === 200) {
  71. this.tableData = res.data.sort((a, b) => b.directory - a.directory);
  72. }
  73. });
  74. },
  75. clickFolder(item) {
  76. if (!item.directory) return;
  77. projectPermission({
  78. id: item.id,
  79. oldPermission: item.permissions,
  80. type: 'access',
  81. name: item.name,
  82. folderList: [item.name]
  83. }, () => {
  84. this.$navigateTo('/pages/file/file?parentId=' + item.id + '&title=' + item.name)
  85. });
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. .file-list {
  92. padding: 30rpx;
  93. .file-item {
  94. display: flex;
  95. padding: 20rpx;
  96. background: #fff;
  97. display: flex;
  98. align-items: center;
  99. border-radius: 16rpx;
  100. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  101. margin-bottom: 30rpx;
  102. .file-image {
  103. width: 100rpx;
  104. height: 80rpx;
  105. display: flex;
  106. align-items: center;
  107. justify-content: center;
  108. margin-right: 30rpx;
  109. }
  110. .title {
  111. font-size: 32rpx;
  112. font-weight: 600;
  113. margin-bottom: 10rpx;
  114. }
  115. .sub {
  116. font-weight: 300;
  117. font-size: 24rpx;
  118. margin-top: 10rpx;
  119. color: $uni-secondary-color;
  120. }
  121. }
  122. }
  123. </style>