From e7cf5f61ef404dc65371dabf71a19fda3037fd6a Mon Sep 17 00:00:00 2001 From: lijiahangmax Date: Wed, 7 Feb 2024 16:24:41 +0800 Subject: [PATCH] =?UTF-8?q?:hammer:=20sftp=20=E8=A1=A8=E5=A4=B4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- orion-ops-ui/src/types/table.ts | 10 +- .../components/sftp/sftp-table-header.vue | 201 ++++++++++++++++++ .../terminal/components/sftp/sftp-table.vue | 145 ++++++++++++- .../terminal/components/sftp/sftp-view.vue | 63 +++--- .../components/sftp/types/table.columns.ts | 16 +- .../host/terminal/types/terminal.const.ts | 39 ++++ 6 files changed, 415 insertions(+), 59 deletions(-) create mode 100644 orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table-header.vue diff --git a/orion-ops-ui/src/types/table.ts b/orion-ops-ui/src/types/table.ts index f7c006fb..a4c4f277 100644 --- a/orion-ops-ui/src/types/table.ts +++ b/orion-ops-ui/src/types/table.ts @@ -7,7 +7,7 @@ import { TablePageSizeOptions } from '@/types/const'; /** * 创建列表分页 */ -export const usePagination = (): PaginationProps => { +export const usePagination = (ext?: PaginationProps): PaginationProps => { const appStore = useAppStore(); return reactive({ total: 0, @@ -15,17 +15,19 @@ export const usePagination = (): PaginationProps => { pageSize: isNumber(appStore.defaultTablePageSize) ? appStore.defaultTablePageSize : TablePageSizeOptions[0], showTotal: true, showPageSize: true, - pageSizeOptions: TablePageSizeOptions + pageSizeOptions: TablePageSizeOptions, + ...ext }); }; /** * 创建行选择器 */ -export const useRowSelection = (type = 'checkbox'): TableRowSelection => { +export const useRowSelection = (ext?: TableRowSelection): TableRowSelection => { return reactive({ - type: type as any, + type: 'checkbox', showCheckedAll: true, onlyCurrent: true, + ...ext }); }; diff --git a/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table-header.vue b/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table-header.vue new file mode 100644 index 00000000..01c1b92c --- /dev/null +++ b/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table-header.vue @@ -0,0 +1,201 @@ + + + + + + + diff --git a/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table.vue b/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table.vue index 8a59f778..7a16010c 100644 --- a/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table.vue +++ b/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-table.vue @@ -27,10 +27,88 @@ + + + + @@ -46,33 +124,62 @@ import type { SftpFile } from '../../types/terminal.type'; import { ref } from 'vue'; import { useRowSelection } from '@/types/table'; + import { dateFormat } from '@/utils'; import columns from './types/table.columns'; + import useCopy from '@/hooks/copy'; + import { FILE_TYPE } from '../../types/terminal.const'; const props = defineProps<{ list: Array; loading: boolean; }>(); - const rowSelection = useRowSelection(); + const rowSelection = useRowSelection({ width: 40 }); + const { copy } = useCopy(); + const selectedKeys = ref>([]); - const editRecord = ref({}); + const editName = ref(''); // 设置选中状态 const setEditable = (record: TableData) => { - editRecord.value = record; + editName.value = record.name; record.hover = true; }; // 设置未选中状态 const unsetEditable = (record: TableData) => { setTimeout(() => { - if (record.name === editRecord.value.name && !record.hover) { - editRecord.value = {}; + // 等待后如果还是当前行 但是未被选中则代表已经被失焦 + if (record.name === editName.value && !record.hover) { + editName.value = ''; } }, 20); record.hover = false; }; + // 删除文件 + const deleteFile = (path: string) => { + }; + + // 下载文件 + const downloadFile = (path: string) => { + }; + + // 移动文件 + const moveFile = (path: string) => { + }; + + // 文件提权 + const chmodFile = (path: string) => { + }; + + // 格式化文件类型 + const formatFileType = (attr: string) => { + return Object.values(FILE_TYPE).find(s => { + return s.value === attr.charAt(0); + }) || FILE_TYPE.NORMAL_FILE; + }; + diff --git a/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-view.vue b/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-view.vue index 26892565..15a4fe00 100644 --- a/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-view.vue +++ b/orion-ops-ui/src/views/host/terminal/components/sftp/sftp-view.vue @@ -1,24 +1,19 @@