You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

290 lines
7.9 KiB

3 years ago
<template>
<div class="header">
<a-button type="primary" large class="btn-primary" @click='createFile'>创建文件夹</a-button>
<div v-show="state.selectedRowIds.length" class="other-btn">
<a-button large class="btn-primary">压缩并下载</a-button>
<a-button large class="btn-primary">移动</a-button>
</div>
<div class="search-content">
<a-form>
<a-row :gutter="16">
<a-col :span="10">
<a-form-item name="timestamp">
<a-range-picker v-model:value="searchParam.timestamp" show-time/>
</a-form-item>
</a-col>
<a-col :span="7">
<a-form-item name="type">
<a-select placeholder="所有类型">
<a-select-option value="searchParam.type">所有类型</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="7">
<a-form-item name="type">
<a-select placeholder="所有负载">
<a-select-option value="searchParam.type">所有负载</a-select-option>
</a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="16">
<a-col :span="7">
<a-form-item name="type">
<a-select placeholder="标签筛选">
<a-select-option value="searchParam.type">所有类型</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="7">
<a-form-item name="name">
<a-input v-model:value="searchParam.name" placeholder="按文件名称搜索">
<template #addonAfter>
<ZoomInOutlined />
</template>
</a-input>
</a-form-item>
</a-col>
</a-row>
</a-form>
</div>
</div>
<a-spin :spinning="loading" tip="加载中..." size="large">
3 years ago
<div class="media-panel-wrapper">
<div class="bread-content">
<span v-for="(item,index) in breadList" :key="item">{{ item }}<span v-if="index!=breadList.length-1" >/</span></span>
</div>
<a-table :columns="columns" :data-source="mediaData.data" :scroll="{ x: '100%', y: 400 }" :row-selection="rowSelection" :pagination="paginationProp">
<template v-for="col in ['file_name']" #[col]="{ text,index }" :key="col">
<div @click="goDetail(mediaData.data[index])">
<img src="../assets/icons/folder.svg" v-if='mediaData.data[index].file_type==0'>
<img src="../assets/icons/zip.svg" v-if='mediaData.data[index].file_type==2'>
<a-image :width="30" :hight="30" v-if='mediaData.data[index].file_type==1' :src="mediaData.data[index].picture_url" :preview="{
src: mediaData.data[index].picture_url}"
/>
<a-tooltip :title="text">
<a>&nbsp;{{ text }}</a>
</a-tooltip>
</div>
3 years ago
</template>
<template #action="{ record }">
<a-tooltip title="download">
<a class="fz18" @click="downloadMedia(record)"><DownloadOutlined /></a>
</a-tooltip>
</template>
</a-table>
3 years ago
</div>
</a-spin>
<a-modal v-model:visible="state.folderOpen" :closable="false" :maskClosable="false">
<template #title>
<div ref="modalTitleRef" style="width: 100%; cursor: move" class="model-title">创建文件夹</div>
</template>
<a-input class="ml10"
v-model:value="state.fileName"
placeholder="请输入文件名"></a-input>
<template #footer>
<div>
<a-button large class="btn-primary" @click='state.folderOpen=false'>取消</a-button>
<a-button type="primary" large class="btn-primary" @click='state.folderOpen=true'>确定</a-button>
</div>
</template>
</a-modal>
3 years ago
</template>
<script setup lang="ts">
import { ref } from '@vue/reactivity'
3 years ago
import { TableState } from 'ant-design-vue/lib/table/interface'
import { onMounted, reactive } from 'vue'
import { IPage } from '../api/http/type'
import { ELocalStorageKey } from '../types/enums'
import { downloadFile } from '../utils/common'
import { downloadMediaFile, getMediaFiles } from '/@/api/media'
import {
ZoomInOutlined,
DownloadOutlined
} from '@ant-design/icons-vue'
3 years ago
import { message, Pagination } from 'ant-design-vue'
3 years ago
const workspaceId = localStorage.getItem(ELocalStorageKey.WorkspaceId)!
const loading = ref(false)
2 years ago
const pathId = ref('')
const searchParam = reactive({ timestamp: [], type: [], name: '' })
const state = reactive({ selectedRowIds: [], folderOpen: false, fileName: '' })
const breadList = ref(['全部文件'])
const breadNum = ref(0)
3 years ago
const columns = [
{
title: '文件名称',
3 years ago
dataIndex: 'file_name',
ellipsis: true,
slots: { customRender: 'file_name' }
3 years ago
},
{
title: '拍摄负载',
dataIndex: 'payload',
3 years ago
ellipsis: true,
},
{
title: '大小',
3 years ago
dataIndex: 'drone'
3 years ago
},
{
title: '创建时间',
3 years ago
dataIndex: 'create_time'
3 years ago
},
{
title: '操作',
key: 'operation',
fixed: 'right',
width: 100,
3 years ago
slots: { customRender: 'action' }
3 years ago
}
]
3 years ago
const body: IPage = {
page: 1,
total: 0,
page_size: 50
}
const paginationProp = reactive({
pageSizeOptions: ['20', '50', '100'],
showQuickJumper: true,
showSizeChanger: true,
page_size: 50,
page: 1,
3 years ago
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,
3 years ago
file_id: string,
3 years ago
}
const mediaData = reactive({
data: [] as MediaFile[]
})
onMounted(() => {
// pathId.value = val
getFiles()
3 years ago
})
function getFiles () {
loading.value = true
getMediaFiles(workspaceId, paginationProp).then(res => {
3 years ago
mediaData.data = res.data.list
paginationProp.total = res.data.pagination.total
paginationProp.page = res.data.pagination.page
}).finally(() => {
loading.value = false
3 years ago
})
}
3 years ago
function refreshData (page: Pagination) {
body.page = page?.current!
body.page_size = page?.pageSize!
getFiles()
}
function downloadMedia (media: MediaFile) {
loading.value = true
3 years ago
downloadMediaFile(workspaceId, media.file_id).then(res => {
if (!res) {
3 years ago
return
}
3 years ago
const data = new Blob([res])
3 years ago
downloadFile(data, media.file_name)
}).finally(() => {
loading.value = false
})
}
const rowSelection = {
onChange: (selectedRowKeys:any, selectedRows:any) => {
state.selectedRowIds = selectedRows.map((item:any) => item.father_id)
},
}
const createFile = () => {
state.folderOpen = true
}
const goDetail = (param:any) => {
if (param.file_type !== 0) { return }
loading.value = true
breadNum.value++
breadList.value[breadNum.value] = param.file_name
getMediaFiles(workspaceId, paginationProp, param.father_id).then(res => {
mediaData.data = res.data.list
paginationProp.total = res.data.pagination.total
paginationProp.page = res.data.pagination.page
}).finally(() => {
loading.value = false
})
}
3 years ago
</script>
<style lang="scss" scoped>
.media-panel-wrapper {
width: 100%;
3 years ago
padding: 16px;
.bread-content{
background: #fff;
padding: 16px;
}
3 years ago
.media-table {
background: #fff;
}
.action-area {
color: $primary;
cursor: pointer;
}
}
.video-img{
width:25px;
height: 25px;
margin-right: 8px;
}
3 years ago
.header {
width: 100%;
padding: 16px 16px 0 16px;
3 years ago
color: #000;
.other-btn{
display: inline-block;
}
&::v-deep{
.ant-btn{
margin-right: 8px !important;
}
.ant-calendar-picker{
width:100% !important;
}
.ant-form-item{
margin-bottom: 8px !important;
}
}
.btn-primary{
margin-bottom: 16px;
}
}
.model-title{
text-align: center;
border: none;
3 years ago
}
::v-deep{
.ant-modal-header{
padding: 0 0 !important;
}
}
3 years ago
</style>