dataCenter.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.option = {
  50. tip: '暂无数据'
  51. }
  52. this.initProjectDir();
  53. }
  54. },
  55. methods: {
  56. initProjectDir() {
  57. generateFileNodeProject(this.$store.getters.project.id).then(res => {
  58. if (res.code === 200) {
  59. this.tableData = res.data.sort((a, b) => b.directory - a.directory);
  60. if (this.tableData.length > 0) this.isEmpty = false;
  61. }
  62. });
  63. },
  64. clickFolder(item) {
  65. if (!item.directory) return;
  66. projectPermission({
  67. id: item.id,
  68. oldPermission: item.permissions,
  69. type: 'access',
  70. name: item.name,
  71. folderList: [item.name]
  72. }, () => {
  73. this.$navigateTo('/pages/file/file?parentId=' + item.id + '&title=' + item.name)
  74. });
  75. }
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. .file-list {
  81. padding: 30rpx;
  82. .file-item {
  83. display: flex;
  84. padding: 20rpx;
  85. background: #fff;
  86. display: flex;
  87. align-items: center;
  88. border-radius: 16rpx;
  89. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  90. margin-bottom: 30rpx;
  91. .file-image {
  92. width: 100rpx;
  93. height: 80rpx;
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. margin-right: 30rpx;
  98. }
  99. .title {
  100. font-size: 32rpx;
  101. font-weight: 600;
  102. margin-bottom: 10rpx;
  103. }
  104. .sub {
  105. font-weight: 300;
  106. font-size: 24rpx;
  107. margin-top: 10rpx;
  108. color: $uni-secondary-color;
  109. }
  110. }
  111. }
  112. </style>