ZhangXianQiang
2024-07-03 eebf6591511daa7c92a7b009a0fef5fb2bea501b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<template>
  <div class="train-container w-screen h-screen bg-slate-50 flex flex-col items-center">
    <NormalHeader class="shrink-0"></NormalHeader>
 
    <div class="list-container container grow relative">
      <div class="list-content absolute top-0 bottom-0 left-0 right-0 py-4">
        <div class="list-wrapper w-full h-full">
          <el-card class="h-full" :body-style="{ height: '100%' }">
            <div class="card-wrapper w-full h-full flex flex-col px-8 box-border">
              <div class="card-header flex justify-between items-center shrink-0">
                <div class="header-search flex items-center">
                  <el-input v-model="searchText" placeholder="请输入搜索内容" :prefix-icon="Search" />
                  <el-button type="primary" class="ml-4">搜索</el-button>
                </div>
              </div>
 
              <div class="card-main flex-1 my-5 relative">
                <div class="main-content absolute top-0 bottom-0 left-0 right-0">
                  <el-table :data="fileList" height="100%">
                    <el-table-column label="文件名称">
                      <template #default="scope">
                        <div class="row-info">
                          <div class="icon">
                            <img :src="fileType[scope.row.type].iconPath" class="width-img" />
                          </div>
                          <div class="label">{{ scope.row.name }}</div>
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column prop="class" label="班级" align="center" />
                    <el-table-column prop="subject" label="科目" align="center" />
                    <el-table-column prop="date" label="上传时间" align="center" />
                    <el-table-column>
                      <template #default="scope">
                        <el-button link type="primary" @click.prevent="checkRow(scope.row)">
                          查看
                        </el-button>
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
              </div>
 
              <div class="card-footer flex justify-center mb-7 shrink-0">
                <el-pagination background layout="prev, pager, next" :total="1000" />
              </div>
            </div>
          </el-card>
        </div>
      </div>
    </div>
 
    <div class="pdf-container">
      <PDFViewer :pdfUrl="'/helloworld.pdf'"></PDFViewer>
    </div>
  </div>
</template>
 
<script setup>
import { ref } from 'vue';
import NormalHeader from '@/components/NormalHeader/index.vue';
import { Search } from '@element-plus/icons-vue';
import { getFileList } from '@/api/modules/file.js';
 
import PDFViewer from '@/components/PDFViewer/index.vue';
 
const fileType = {
  'img': {
    iconPath: '/static/icons/file_type_image.png',
    handle: (item) => {
      console.log(item);
    }
  },
  'video': {
    iconPath: '/static/icons/file_type_video.png',
    handle: (item) => {
      console.log(item);
    }
  },
  'pdf': {
    iconPath: '/static/icons/file_type_image.png',
    handle: (item) => {
      console.log(item);
    }
  },
};
 
const searchText = ref('');
 
 
const fileList = ref([
  {
    id: 1,
    name: '测试测试测试',
    url: '',
    date: '2024-12-12',
    class: 'test',
    subject: '测试',
    type: 'img'
  },
  {
    id: 2,
    name: '测试测试测试',
    url: '',
    date: '2024-12-12',
    class: 'test',
    subject: '测试',
    type: 'video'
  },
  {
    id: 3,
    name: '测试测试测试',
    url: '',
    date: '2024-12-12',
    class: 'test',
    subject: '测试',
    type: 'pdf'
  }
]);
 
const loading = ref(false);
 
const checkRow = (item) => {
  fileType[item.type] && fileType[item.type].handle(item);
};
 
const getData = () => {
  getFileList().then(res => {
 
  });
};
getData();
 
</script>
 
<style lang="scss" scoped>
:deep(.el-tabs__nav-wrap:after) {
  display: none;
}
 
.row-info {
  display: flex;
  align-items: center;
 
  .icon {
    width: 35px;
    margin-right: 20px;
  }
}
 
.pdf-container {
  width: 800px;
  height: 800px;
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
</style>