husq
2023-09-25 60bb69f4cfc33cd0224e856afc2b00f6bc80e4d4
src/components/MediaPanel.vue
@@ -1,5 +1,29 @@
<template>
  <div class="header">Media Files</div>
<!--  <div class="header">媒体文件</div>-->
  <!--搜索栏-->
  <div class="search-panel-wrapper">
    <div class="search-part">
      <a-range-picker :size="searchPanelOptions.size" :format="searchPanelOptions.dateFormat" :valueFormat="searchPanelOptions.valueFormat" v-model:value="timeRangeArr.data" @change="dateChange" style="width: 300px" />
    </div>
    <div class="search-part">
      <a-select v-model:value="subFileTypeArr" allowClear @change="subFileTypeChange"  :options="subFileTypeOptions" :maxTagCount="searchPanelOptions.maxTagCount" mode="multiple"
                :size="searchPanelOptions.size" placeholder="所有类型" style="width: 300px">
      </a-select>
    </div>
    <div class="search-part">
      <a-select v-model:value="payloadArr" allowClear @change="payloadChange"  :options="payloadOptions" :maxTagCount="searchPanelOptions.maxTagCount" mode="multiple"
                :size="searchPanelOptions.size" placeholder="所有负载" style="width: 300px">
      </a-select>
    </div>
    <div class="search-part">
      <a-input-search  :size="searchPanelOptions.size" v-model:value="searchQuery.name"  @change="inputChange" placeholder="按文件名称搜索" style="width: 300px"/>
    </div>
  </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"
@@ -30,50 +54,74 @@
import { IPage } from '../api/http/type'
import { ELocalStorageKey } from '../types/enums'
import { downloadFile } from '../utils/common'
import { downloadMediaFile, getMediaFiles } from '/@/api/media'
import { downloadMediaFile, getMediaFiles, MediaQueryParam } from '/@/api/media'
import { DownloadOutlined } from '@ant-design/icons-vue'
import { Pagination } from 'ant-design-vue'
import { load } from '@amap/amap-jsapi-loader'
import { message, Pagination } from 'ant-design-vue'
import { TaskStatus, TaskStatusMap } from '/@/types/task'
const workspaceId = localStorage.getItem(ELocalStorageKey.WorkspaceId)!
const loading = ref(false)
// 搜索栏配置项
const searchPanelOptions = reactive({
  size: 'large',
  maxTagCount: 2,
  dateFormat: 'YYYY-MM-DD',
  valueFormat: 'YYYY-MM-DD'
})
const subFileTypeOptions = [
  { value: 0, label: '普通图片' },
  { value: 1, label: '全景图' },
]
const payloadOptions = [
]
const timeRangeArr = reactive({
  data: [] as string[]
})
const searchQuery = reactive<MediaQueryParam>({
})
const subFileTypeArr = reactive([])
const payloadArr = reactive([])
const columns = [
  {
    title: 'File Name',
    title: '文件名称',
    dataIndex: 'file_name',
    ellipsis: true,
    slots: { customRender: 'name' }
  },
  {
    title: 'File Path',
    dataIndex: 'file_path',
    ellipsis: true,
    slots: { customRender: 'path' }
  },
  // {
  //   title: 'FileSize',
  //   dataIndex: 'size',
  //   title: '文件路径',
  //   dataIndex: 'file_path',
  //   ellipsis: true,
  //   slots: { customRender: 'path' }
  // },
  {
    title: 'Drone',
    dataIndex: 'drone'
  },
  {
    title: 'Payload Type',
    title: '拍摄负载',
    dataIndex: 'payload'
  },
  {
    title: 'Original',
    dataIndex: 'is_original',
    slots: { customRender: 'original' }
    title: '大小',
    dataIndex: 'size',
  },
  // {
  //   title: '拍摄负载',
  //   dataIndex: 'drone'
  // },
  // {
  //   title: 'Original',
  //   dataIndex: 'is_original',
  //   slots: { customRender: 'original' }
  // },
  {
    title: 'Created',
    title: '创建时间',
    dataIndex: 'create_time'
  },
  {
    title: 'Action',
    title: '操作',
    slots: { customRender: 'action' }
  }
]
@@ -101,6 +149,7 @@
  file_name: string,
  file_path: string,
  create_time: string,
  file_id: string,
}
const mediaData = reactive({
@@ -111,8 +160,28 @@
  getFiles()
})
function dateChange (value:any) {
  searchQuery.startTime = value[0]
  searchQuery.endTime = value[1]
  getFiles()
}
function subFileTypeChange (value:any) {
  searchQuery.subFileType = value.join(',')
  getFiles()
}
function payloadChange (value:any) {
  searchQuery.payload = value.join(',')
  getFiles()
}
function inputChange (searchValue: string) {
  getFiles()
}
function getFiles () {
  getMediaFiles(workspaceId, body).then(res => {
  getMediaFiles(workspaceId, body, searchQuery).then(res => {
    mediaData.data = res.data.list
    paginationProp.total = res.data.pagination.total
    paginationProp.current = res.data.pagination.page
@@ -128,12 +197,11 @@
function downloadMedia (media: MediaFile) {
  loading.value = true
  downloadMediaFile(workspaceId, media.fingerprint).then(res => {
    if (res.code && res.code !== 0) {
  downloadMediaFile(workspaceId, media.file_id).then(res => {
    if (!res) {
      return
    }
    const suffix = media.file_name.substring(media.file_name.lastIndexOf('.'))
    const data = new Blob([res.data], { type: suffix === '.mp4' ? 'video/mp4' : 'image/jpeg' })
    const data = new Blob([res])
    downloadFile(data, media.file_name)
  }).finally(() => {
    loading.value = false
@@ -165,4 +233,17 @@
  text-align: start;
  color: #000;
}
.search-panel-wrapper {
  height: 85px;
  background: #ffffff;
  padding: 0 20px;
  display: flex;
  align-items: center;
  .search-part{
    margin-right: 10px;
  }
}
</style>