| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <template>
- <div class="header">照片视频</div>
- <a-spin :spinning="loading" :delay="1000" tip="downloading" size="large">
- <div class="media-panel-wrapper">
- <a-table class="media-table" :columns="columns" :data-source="mediaData.data" row-key="fingerprint"
- :pagination="paginationProp" :scroll="{ x: '100%', y: 600 }" @change="refreshData">
- <template v-for="col in ['name', 'path']" #[col]="{ text }" :key="col">
- <a-tooltip :title="text">
- <a v-if="col === 'name'">{{ text }}</a>
- <span v-else>{{ text }}</span>
- </a-tooltip>
- </template>
- <template #original="{ text }">
- {{ text }}
- </template>
- <template #action="{ record }">
- <a-tooltip title="download">
- <a class="fz18" @click="downloadMedia(record)">
- <DownloadOutlined />
- </a>
- </a-tooltip>
- </template>
- </a-table>
- </div>
- </a-spin>
- </template>
- <script setup lang="ts">
- import { onMounted, reactive, ref } from 'vue'
- import { Pagination } from 'ant-design-vue'
- import { TableState } from 'ant-design-vue/lib/table/interface'
- import { IPage } from '../api/http/type'
- import { downloadFile } from '../utils/common'
- import { downloadMediaFile, getMediaFiles } from '/@/api/media'
- import { DownloadOutlined } from '@ant-design/icons-vue'
- import { getWorkspaceId } from '/@/utils/index';
- const loading = ref(false)
- const columns = [
- {
- title: '文件名称',
- dataIndex: 'file_name',
- ellipsis: true,
- slots: { customRender: 'name' }
- },
- {
- title: '目录',
- dataIndex: 'file_path',
- ellipsis: true,
- slots: { customRender: 'path' }
- },
- {
- title: '设备',
- dataIndex: 'drone'
- },
- {
- title: '拍摄负载',
- dataIndex: 'payload'
- },
- {
- title: '原图',
- dataIndex: 'is_original',
- slots: { customRender: 'original' }
- },
- {
- title: '上传时间',
- dataIndex: 'create_time'
- },
- {
- title: '下载',
- slots: { customRender: 'action' }
- }
- ]
- const body: IPage = {
- page: 1,
- total: 0,
- page_size: 50
- }
- const paginationProp = reactive({
- pageSizeOptions: ['20', '50', '100'],
- showQuickJumper: true,
- showSizeChanger: true,
- pageSize: 50,
- current: 1,
- total: 0
- })
- type Pagination = TableState['pagination']
- interface MediaFile {
- fingerprint: string,
- drone: string,
- payload: string,
- is_original: string,
- file_name: string,
- file_path: string,
- create_time: string,
- file_id: string,
- }
- const mediaData = reactive({
- data: [] as MediaFile[]
- })
- onMounted(() => {
- getFiles()
- })
- function getFiles() {
- getMediaFiles(getWorkspaceId(), body).then(res => {
- mediaData.data = res.data.list
- paginationProp.total = res.data.pagination.total
- paginationProp.current = res.data.pagination.page
- console.info(mediaData.data[0])
- })
- }
- function refreshData(page: Pagination) {
- body.page = page?.current!
- body.page_size = page?.pageSize!
- getFiles()
- }
- function downloadMedia(media: MediaFile) {
- loading.value = true
- downloadMediaFile(getWorkspaceId(), media.file_id).then(res => {
- if (!res) {
- return
- }
- const data = new Blob([res])
- downloadFile(data, media.file_name)
- }).finally(() => {
- loading.value = false
- })
- }
- </script>
- <style lang="scss" scoped>
- .media-panel-wrapper {
- width: 100%;
- padding: 16px;
- .media-table {
- background: #fff;
- margin-top: 10px;
- }
- .action-area {
- color: $primary;
- cursor: pointer;
- }
- }
- .header {
- width: 100%;
- height: 60px;
- background: #fff;
- padding: 16px;
- font-size: 20px;
- font-weight: bold;
- text-align: start;
- color: #000;
- }
- </style>
|