Browse Source

媒体列表对接

李富豪 1 year ago
parent
commit
6ea9eca14a
2 changed files with 39 additions and 28 deletions
  1. 17 3
      Web/src/api/custom/index.ts
  2. 22 25
      Web/src/pages/page-web/projects/media/index/index.vue

+ 17 - 3
Web/src/api/custom/index.ts

@@ -1,7 +1,8 @@
 import request from '/@/api/http/request';
-import {ELocalStorageKey} from "/@/types";
+import { ELocalStorageKey } from "/@/types";
+
+const workspaceId: string = localStorage.getItem(ELocalStorageKey.WorkspaceId) || '';
 
-const workspaceId: string = localStorage.getItem(ELocalStorageKey.WorkspaceId) || ''
 // Api参数类型
 export type FetchFeedbackRecordListApiParams = {
     page: number,
@@ -17,10 +18,16 @@ export type FetchChangeRecordListApiParams = {
     logsInformation?: string,//模糊查询内容
 };
 
+export type FetchMediaFileListApiParams = {
+    page: number,
+    page_size: number,
+};
+
 // Api函数类型
 export type FetchFeedbackRecordListApi = (data: FetchFeedbackRecordListApiParams) => Promise<any>;
 export type FetchChangeRecordListApi = (params: FetchFeedbackRecordListApiParams) => Promise<any>;
 export type FetchProjectListApi = () => Promise<any>;
+export type FetchMediaFileListApi = (params: FetchMediaFileListApiParams) => Promise<any>;
 
 // 获取反馈记录列表
 const fetchFeedbackRecordListApi: FetchFeedbackRecordListApi = async (data) => {
@@ -30,7 +37,7 @@ const fetchFeedbackRecordListApi: FetchFeedbackRecordListApi = async (data) => {
 
 // 获取变化记录列表
 const fetchChangeRecordListApi: FetchChangeRecordListApi = async (params) => {
-    const res = await request.get('/manage/api/v1/oprlogs/'+workspaceId+'/devices/logs',{ params: params });
+    const res = await request.get('/manage/api/v1/oprlogs/' + workspaceId + '/devices/logs', { params: params });
     return res.data;
 };
 
@@ -40,8 +47,15 @@ const fetchProjectListApi: FetchProjectListApi = async () => {
     return res.data;
 };
 
+// 获取文件夹列表
+const fetchMediaFileListApi: FetchMediaFileListApi = async (params) => {
+    const res = await request.get('/media/api/v1/files/' + workspaceId + '/dirs', { params: params });
+    return res.data;
+}
+
 export const apis = {
     fetchFeedbackRecordList: fetchFeedbackRecordListApi,
     fetchChangeRecordList: fetchChangeRecordListApi,
     fetchProjectList: fetchProjectListApi,
+    fetchMediaFileList: fetchMediaFileListApi,
 };

+ 22 - 25
Web/src/pages/page-web/projects/media/index/index.vue

@@ -27,17 +27,16 @@
         </div>
       </div>
       <div class="mediaList-table" v-if="state.mode === 'table'">
-        <a-table :scroll="{ x: '100%', y: 500 }" :childrenColumnName="null" rowKey="file_id"
-          :loading="state.listLoading" :columns="columns" :dataSource="state.list" :rowClassName="rowClassName"
-          :pagination="paginationConfig"
+        <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 #file_name="{ record }">
-            <a-tooltip :title="record.file_name">
+          <template #dir_name="{ record }">
+            <a-tooltip :title="record.dir_name">
               <div class="fileName" @click="onClickFile(record)">
                 <img :src="fileSrc">
                 <div>
-                  {{ record.file_name }}
+                  {{ record.dir_name }}
                 </div>
               </div>
             </a-tooltip>
@@ -69,7 +68,7 @@
                 <a-card-meta>
                   <template #description>
                     <div>
-                      {{ item.file_name }}
+                      {{ item.dir_name }}
                     </div>
                   </template>
                 </a-card-meta>
@@ -87,12 +86,11 @@ 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 { getMediaFiles, downloadMediaFile } from '/@/api/media';
+import { apis } from '/@/api/custom';
 import { downloadFile } from '/@/utils/common';
 import router from '/@/router/index';
 
 interface State {
-  workspaceId: string,
   listLoading: boolean,
   list: any[],
   selectedRowKeys: string[],
@@ -100,7 +98,6 @@ interface State {
 };
 
 const state: State = reactive({
-  workspaceId: localStorage.getItem('workspace_id') || '',
   listLoading: false,
   list: [],
   selectedRowKeys: [],
@@ -127,7 +124,7 @@ const paginationConfig = reactive({
 const fetchList = async () => {
   state.listLoading = true;
   try {
-    const res = await getMediaFiles(state.workspaceId, { page: paginationConfig.current, page_size: paginationConfig.pageSize });
+    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;
@@ -146,15 +143,15 @@ onMounted(async () => {
 const columns = [
   {
     title: '文件夹名称',
-    dataIndex: 'file_name',
+    dataIndex: 'dir_name',
     width: 250,
     ellipsis: true,
-    sorter: (a: any, b: any) => a.file_name.localeCompare(b.file_name),
-    slots: { customRender: 'file_name' }
+    sorter: (a: any, b: any) => a.dir_name.localeCompare(b.dir_name),
+    slots: { customRender: 'dir_name' }
   },
   {
     title: '设备型号',
-    dataIndex: 'drone',
+    dataIndex: 'device_name',
     width: 150,
     ellipsis: true,
   },
@@ -178,17 +175,17 @@ const columns = [
   },
   {
     title: '航线名称',
-    dataIndex: 'create_time',
+    dataIndex: 'wayline_name',
     width: 150,
   },
   {
     title: '任务类型',
-    dataIndex: 'create_time',
+    dataIndex: 'template_type',
     width: 150,
   },
   {
     title: '创建人',
-    dataIndex: 'create_time',
+    dataIndex: 'username',
     width: 150,
   },
   {
@@ -215,7 +212,7 @@ const onClickBatchDownload = async () => {
 
 // 点击文件夹
 const onClickFile = (record: any) => {
-  router.push({ path: `/media/${record.file_id}` })
+  router.push({ path: `/media/${record.id}` })
 }
 
 // 勾选
@@ -227,12 +224,12 @@ const onSelectChange = (selectedRowKeys: string[]) => {
 const onClickDownload = async (record: any) => {
   state.listLoading = true;
   try {
-    const res = await downloadMediaFile(state.workspaceId, record.file_id);
-    if (!res) {
-      return
-    }
-    const data = new Blob([res]);
-    downloadFile(data, record.file_name);
+    // const res = await downloadMediaFile(state.workspaceId, record.id);
+    // if (!res) {
+    //   return
+    // }
+    // const data = new Blob([res]);
+    // downloadFile(data, record.dir_name);
   } catch (e) {
     console.error(e);
   } finally {