| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- <template>
- <div class="trajectoryList">
- <Search :mode="state.mode" :selectedRowKeys="state.selectedRowKeys" :onClickDownload="onClickBatchDownload"
- :onClickSearch="onClickSearch" :onClickReset="onClickReset" />
- <div style="background: #FFFFFF;padding: 20px;">
- <div class="trajectoryList-info">
- <div>
- 轨迹回放文件
- </div>
- <div class="trajectoryList-info-right">
- <div class="trajectoryList-info-right-text">
- <div>
- 已选/全部:
- </div>
- <div>
- {{ state.selectedRowKeys.length }}/{{ paginationConfig.total }}
- </div>
- </div>
- <a-button style="padding:0 5px;" :type="state.mode === 'table' ? 'primary' : 'default'"
- :ghost="state.mode === 'table'" size="small" @click="state.mode = 'table'">
- <MenuOutlined />
- </a-button>
- <a-button style="padding:0 5px;" :type="state.mode === 'list' ? 'primary' : 'default'"
- :ghost="state.mode === 'list'" size="small" @click="state.mode = 'list'">
- <AppstoreOutlined />
- </a-button>
- </div>
- </div>
- <div>
- <div class="trajectoryList-table" v-if="state.mode === 'table'">
- <a-table :scroll="{ x: '100%', y: 500 }" :childrenColumnName="null" rowKey="id" :loading="state.listLoading"
- :columns="columns" :dataSource="state.list" :rowClassName="rowClassName" :pagination="paginationConfig"
- :rowSelection="{ selectedRowKeys: state.selectedRowKeys, onChange: onSelectChange }">
- <!-- 文件夹名称 -->
- <template #dir_name="{ record }">
- <a-tooltip :title="record.dir_name">
- <div class="fileName" @click="onClickFile(record)">
- <img :src="fileSrc">
- <div>
- {{ record.dir_name }}
- </div>
- </div>
- </a-tooltip>
- </template>
- <!-- 操作 -->
- <template #action="{ record }">
- <div class="flex-align-center flex-row" style="color: #2d8cf0">
- <a-tooltip title="压缩下载">
- <DownloadOutlined style="margin-right: 10px;" @click="onClickDownload(record)" />
- </a-tooltip>
- <a-tooltip title="轨迹回放">
- <EnvironmentOutlined @click="onClickTrajectory" />
- </a-tooltip>
- </div>
- </template>
- </a-table>
- </div>
- <div class="trajectoryList-list" v-else>
- <a-list :grid="{ gutter: 16, xs: 1, sm: 2, md: 3, lg: 4, xl: 8, xxl: 12 }" :loading="state.listLoading"
- :dataSource="state.list" :pagination="paginationConfig">
- <template #renderItem="{ item }">
- <a-list-item>
- <a-card hoverable @click="onClickFile(item)">
- <template #cover>
- <div style="display: flex;justify-content:center;align-items: center;">
- <img style="width: 70%;" :src="fileSrc" />
- </div>
- </template>
- <a-card-meta>
- <template #description>
- <a-tooltip placement="bottom" :title="item.dir_name">
- <div class="trajectoryList-list-name">
- {{ item.dir_name }}
- </div>
- </a-tooltip>
- </template>
- </a-card-meta>
- </a-card>
- </a-list-item>
- </template>
- </a-list>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script lang="ts" setup>
- import { reactive, onMounted } from 'vue';
- import { MenuOutlined, AppstoreOutlined, DownloadOutlined, EnvironmentOutlined } from '@ant-design/icons-vue';
- import Search from './components/Search.vue';
- import fileSrc from '/@/assets/media/file.svg';
- import { apis } from '/@/api/custom';
- import router from '/@/router/index';
- interface State {
- listLoading: boolean,
- list: any[],
- selectedRowKeys: string[],
- mode: 'table' | 'list',
- };
- const state: State = reactive({
- listLoading: false,
- list: [],
- selectedRowKeys: [],
- mode: 'table',
- })
- const paginationConfig = reactive({
- pageSizeOptions: ['20', '50', '100'],
- showQuickJumper: true,
- showSizeChanger: true,
- pageSize: 20,
- current: 1,
- total: 0,
- onChange: async (current: number) => {
- paginationConfig.current = current;
- await fetchList();
- },
- onShowSizeChange: async (current: number, pageSize: number) => {
- paginationConfig.pageSize = pageSize;
- await fetchList();
- }
- })
- const fetchList = async () => {
- state.listLoading = true;
- try {
- const res = await apis.fetchMediaFileList({ page: paginationConfig.current, page_size: paginationConfig.pageSize });
- state.list = res.data.list;
- paginationConfig.current = res.data.pagination.page;
- paginationConfig.pageSize = res.data.pagination.page_size;
- paginationConfig.total = res.data.pagination.total;
- } catch (e) {
- console.error(e);
- } finally {
- state.listLoading = false;
- }
- }
- onMounted(async () => {
- // await fetchList();
- })
- const columns = [
- {
- title: '文件夹名称',
- dataIndex: 'dir_name',
- width: 250,
- ellipsis: true,
- sorter: (a: any, b: any) => a.dir_name.localeCompare(b.dir_name),
- slots: { customRender: 'dir_name' }
- },
- {
- title: '设备型号',
- dataIndex: 'device_name',
- width: 150,
- ellipsis: true,
- },
- {
- title: '拍摄负载',
- dataIndex: 'payload',
- width: 150,
- ellipsis: true,
- },
- {
- title: '容量大小',
- dataIndex: 'is_original',
- width: 150,
- ellipsis: true,
- customRender: ({ text }: any) => {
- return text || '--';
- }
- },
- {
- title: '创建时间',
- dataIndex: 'create_time',
- width: 200,
- sorter: (a: any, b: any) => a.create_time.localeCompare(b.create_time),
- },
- {
- title: '航线名称',
- dataIndex: 'wayline_name',
- width: 150,
- },
- {
- title: '任务类型',
- dataIndex: 'template_type',
- width: 150,
- customRender: ({ text }: any) => {
- return text || '--';
- }
- },
- {
- title: '创建人',
- dataIndex: 'username',
- width: 150,
- },
- {
- title: '操作',
- dataIndex: 'actions',
- fixed: 'right',
- width: 80,
- slots: { customRender: 'action' },
- },
- ]
- const rowClassName = (record: any, index: number) => {
- const className = []
- if ((index & 1) === 0) {
- className.push('table-striped')
- }
- return className.toString().replaceAll(',', ' ')
- }
- // 点击批量下载
- const onClickBatchDownload = async () => {
- console.log(state.selectedRowKeys, '点击批量下载');
- }
- // 点击搜索
- const onClickSearch = async () => {
- console.log('点击搜索');
- }
- // 点击重置
- const onClickReset = async () => {
- console.log('点击重置');
- }
- // 点击文件夹
- const onClickFile = (record: any) => {
- router.push({ path: `/media/${record.id}` })
- }
- // 勾选
- const onSelectChange = (selectedRowKeys: string[]) => {
- state.selectedRowKeys = selectedRowKeys;
- }
- // 点击下载
- const onClickDownload = async (record: any) => {
- state.listLoading = true;
- try {
- } catch (e) {
- console.error(e);
- } finally {
- state.listLoading = false;
- }
- }
- // 点击轨迹回放
- const onClickTrajectory = () => {
- router.push({ path: '/trajectory' })
- }
- </script>
- <style lang="scss">
- .trajectoryList {
- padding: 20px;
- &-info {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 20px;
- &-right {
- display: flex;
- align-items: center;
- &-text {
- display: flex;
- align-items: center;
- margin-right: 20px;
- }
- }
- }
- .fileName {
- display: flex;
- align-items: center;
- cursor: pointer;
- img {
- width: 36px;
- height: 36px;
- margin-right: 5px;
- }
- }
- &-list {
- &-name {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- }
- }
- .ant-table {
- border-top: 1px solid rgb(0, 0, 0, 0.06);
- border-bottom: 1px solid rgb(0, 0, 0, 0.06);
- }
- .ant-table-tbody tr td {
- border: 0;
- }
- .table-striped {
- background-color: #f7f9fa;
- }
- .ant-card-body {
- padding: 0 10px 10px;
- }
- </style>
|