dataCenter.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <mescroll-empty :option="option" @emptyclick="$navigateTo('/pages/login/login')" v-if="isEmpty">
  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="aspectFill"></image>
  9. </view>
  10. <view class="file-content">
  11. <view class="title">{{item.name}}</view>
  12. <view class="sub">{{item.createDate || '-'}}</view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import {
  20. generateFileNodeProject,
  21. getProjectDirList
  22. } from '@/request/api/datacenter.js'
  23. import {
  24. projectPermission
  25. } from '@/uitls/datacenter'
  26. export default {
  27. data() {
  28. return {
  29. option: {
  30. tip: '暂未加入项目'
  31. },
  32. tableData: [],
  33. parentId: '',
  34. isEmpty: true
  35. }
  36. },
  37. onShow() {
  38. this.isEmpty = true;
  39. if (!uni.getStorageSync('token')) {
  40. this.option = {
  41. tip: '暂未登录',
  42. btnText: '点击登录'
  43. }
  44. } else if (!this.$store.getters.project.id) {
  45. this.option = {
  46. tip: '暂未加入项目'
  47. }
  48. } else {
  49. this.initProjectDir();
  50. this.isEmpty = false;
  51. }
  52. },
  53. methods: {
  54. initProjectDir() {
  55. generateFileNodeProject(this.$store.getters.project.id).then(res => {
  56. if (res.code === 200) {
  57. this.tableData = res.data.sort((a, b) => b.directory - a.directory);
  58. }
  59. });
  60. },
  61. clickFolder(item) {
  62. if (!item.directory) return;
  63. projectPermission({
  64. id: item.id,
  65. oldPermission: item.permissions,
  66. type: 'access',
  67. name: item.name,
  68. folderList: [item.name]
  69. }, () => {
  70. this.$navigateTo('/pages/file/file?parentId=' + item.id + '&title=' + item.name)
  71. });
  72. }
  73. }
  74. }
  75. </script>
  76. <style lang="scss">
  77. .file-list {
  78. padding: 30rpx;
  79. .file-item {
  80. display: flex;
  81. padding: 20rpx;
  82. background: #fff;
  83. display: flex;
  84. align-items: center;
  85. border-radius: 16rpx;
  86. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  87. margin-bottom: 30rpx;
  88. .file-image {
  89. width: 100rpx;
  90. height: 80rpx;
  91. display: flex;
  92. align-items: center;
  93. justify-content: center;
  94. margin-right: 30rpx;
  95. }
  96. .title {
  97. font-size: 32rpx;
  98. font-weight: 600;
  99. margin-bottom: 10rpx;
  100. }
  101. .sub {
  102. font-weight: 300;
  103. font-size: 24rpx;
  104. margin-top: 10rpx;
  105. color: $uni-secondary-color;
  106. }
  107. }
  108. }
  109. </style>