123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <template>
- <view>
- <mescroll-empty :option="option" v-if="tableData.length === 0">
- </mescroll-empty>
- <view class="file-list" v-else>
- <view class="file-item" v-for="(item,index) in tableData" :key="index" @click="clickFolder(item)">
- <view class="file-image">
- <image class="image" src="../../static/image/datacenter/folder.png" mode="heightFix"
- v-if="item.directory"></image>
- <image class="image" :src="returnImage(item)" mode="heightFix" v-else></image>
- </view>
- <view class="file-content">
- <view class="title">{{item.name}}</view>
- <view class="sub">{{item.createDate || '-'}}</view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getProjectDirList
- } from '@/request/api/datacenter.js'
- const fileBox = {
- 'doc': 'doc.png',
- 'docx': 'doc.png',
- 'jpg': 'jpg.png',
- 'jpeg': 'jpg.png',
- 'mp3': 'mp3.png',
- 'mp4': 'mp4.png',
- 'pdf': 'pdf.png',
- 'png': 'png.png',
- 'ppt': 'ppt.png',
- 'pptx': 'pptx.png',
- 'txt': 'txt.png',
- 'xls': 'xls.png',
- 'xlsx': 'xls.png',
- 'zip': 'zip.png',
- }
- import {
- projectPermission
- } from '@/uitls/datacenter'
- export default {
- data() {
- return {
- option: {
- tip: '当前文件夹暂无数据'
- },
- tableData: [],
- parentId: '',
- }
- },
- onLoad(body) {
- this.parentId = body.parentId;
- uni.setNavigationBarTitle({
- title: body.title
- });
- this.projectDirList();
- },
- methods: {
- returnImage(item) {
- console.log(item);
- let name = item.name.split('.');
- let type = name[name.length - 1].toLowerCase();
- let fileName = fileBox[type] || 'nofile.png'
- return '../../static/image/datacenter/' + fileName;
- },
- projectDirList() {
- getProjectDirList(this.parentId).then(res => {
- if (res.code === 200) {
- this.tableData = res.data.sort((a, b) => b.directory - a.directory);
- }
- });
- },
- clickFolder(item) {
- if (!item.directory) return;
- projectPermission({
- id: item.id,
- oldPermission: item.permissions,
- type: 'access',
- name: item.name,
- folderList: [item.name]
- }, () => {
- this.$navigateTo('/pages/file/file?parentId=' + item.id + '&title=' + item.name)
- });
- }
- }
- }
- </script>
- <style lang="scss">
- .file-list {
- padding: 30rpx;
- .file-item {
- display: flex;
- padding: 20rpx;
- background: #fff;
- display: flex;
- align-items: center;
- border-radius: 16rpx;
- box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
- margin-bottom: 30rpx;
- .file-image {
- width: 100rpx;
- height: 80rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 30rpx;
- }
- .title {
- font-size: 32rpx;
- font-weight: 600;
- margin-bottom: 10rpx;
- }
- .sub {
- font-weight: 300;
- font-size: 24rpx;
- margin-top: 10rpx;
- color: $uni-secondary-color;
- }
- }
- }
- </style>
|