From 38d86d121e440ee605301517b4db955d2c8e8b72 Mon Sep 17 00:00:00 2001 From: Kriszu <39726513+wangsizhu0504@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:12:42 +0800 Subject: [PATCH] [Improve]: App view table column add drag and drop, tag width adaptive (#3497) * [Improve]: app form add name drag and drop, tag width adaptive * style: app style * fix: table column width * fix: dom calc error --- .../src/design/ant/index.less | 7 +- .../src/views/flink/app/View.vue | 103 ++++++++++++++++-- .../src/views/flink/app/components/State.tsx | 45 ++++++-- .../src/views/flink/app/data/index.ts | 51 +-------- .../flink/app/hooks/useAppTableColumns.ts | 101 +++++++++++++++++ 5 files changed, 236 insertions(+), 71 deletions(-) create mode 100644 streampark-console/streampark-console-webapp/src/views/flink/app/hooks/useAppTableColumns.ts diff --git a/streampark-console/streampark-console-webapp/src/design/ant/index.less b/streampark-console/streampark-console-webapp/src/design/ant/index.less index e366d904c9..5d4f5ce844 100644 --- a/streampark-console/streampark-console-webapp/src/design/ant/index.less +++ b/streampark-console/streampark-console-webapp/src/design/ant/index.less @@ -69,10 +69,11 @@ span.anticon:not(.app-iconify) { .bold-tag, .bold-tag>.ant-tag { - border-radius: 0 !important; - font-weight: 600; - padding: 0 4px !important; + border-radius: 1px !important; + padding: 0 3px !important; cursor: default; + font-size: 10px; + line-height: 16px; } .app-bar, diff --git a/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue b/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue index 52df538112..641a2dc8d8 100644 --- a/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue +++ b/streampark-console/streampark-console-webapp/src/views/flink/app/View.vue @@ -25,13 +25,13 @@ import { useI18n } from '/@/hooks/web/useI18n'; import { AppStateEnum, JobTypeEnum, OptionStateEnum, ReleaseStateEnum } from '/@/enums/flinkEnum'; import { useTimeoutFn } from '@vueuse/core'; - import { Tooltip, Badge, Divider, Tag } from 'ant-design-vue'; + import { Tooltip, Badge, Divider, Tag, Popover } from 'ant-design-vue'; import { fetchAppRecord } from '/@/api/flink/app'; import { useTable } from '/@/components/Table'; import { PageWrapper } from '/@/components/Page'; import { BasicTable, TableAction } from '/@/components/Table'; import { AppListRecord } from '/@/api/flink/app.type'; - import { getAppColumns, releaseTitleMap } from './data'; + import { releaseTitleMap } from './data'; import { handleView } from './utils'; import { useDrawer } from '/@/components/Drawer'; import { useModal } from '/@/components/Modal'; @@ -41,8 +41,14 @@ import LogModal from './components/AppView/LogModal.vue'; import BuildDrawer from './components/AppView/BuildDrawer.vue'; import AppDashboard from './components/AppView/AppDashboard.vue'; - import State from './components/State'; + import State, { + buildStatusMap, + optionStateMap, + releaseStateMap, + stateMap, + } from './components/State'; import { useSavepoint } from './hooks/useSavepoint'; + import { useAppTableColumns } from './hooks/useAppTableColumns'; const { t } = useI18n(); const optionApps = { @@ -56,11 +62,17 @@ const yarn = ref>(null); const currentTablePage = ref(1); + const { onTableColumnResize, getAppColumns } = useAppTableColumns(); const { openSavepoint } = useSavepoint(handleOptionApp); const [registerStartModal, { openModal: openStartModal }] = useModal(); const [registerStopModal, { openModal: openStopModal }] = useModal(); const [registerLogModal, { openModal: openLogModal }] = useModal(); const [registerBuildDrawer, { openDrawer: openBuildDrawer }] = useDrawer(); + const titleLenRef = ref({ + maxState: '', + maxRelease: '', + maxBuild: '', + }); const [registerTable, { reload, getLoading, setPagination }] = useTable({ rowKey: 'id', @@ -112,12 +124,55 @@ } } }); + const stateLenMap = dataSource.reduce( + ( + prev: { + maxState: string; + maxRelease: string; + maxBuild: string; + }, + cur: any, + ) => { + const { state, optionState, release, buildStatus } = cur; + // state title len + if (optionState === OptionStateEnum.NONE) { + const stateStr = stateMap[state]?.title; + if (stateStr && stateStr.length > prev.maxState.length) { + prev.maxState = stateStr; + } + } else { + const stateStr = optionStateMap[optionState]?.title; + if (stateStr && stateStr.length > prev.maxState.length) { + prev.maxState = stateStr; + } + } + + //release title len + const releaseStr = releaseStateMap[release]?.title; + if (releaseStr && releaseStr.length > prev.maxRelease.length) { + prev.maxRelease = releaseStr; + } + + //build title len + const buildStr = buildStatusMap[buildStatus]?.title; + if (buildStr && buildStr.length > prev.maxBuild.length) { + prev.maxBuild = buildStr; + } + return prev; + }, + { + maxState: '', + maxRelease: '', + maxBuild: '', + }, + ); + Object.assign(titleLenRef.value, stateLenMap); + return dataSource; }, fetchSetting: { listField: 'records' }, immediate: true, canResize: false, - columns: getAppColumns(), showIndexColumn: false, showTableSetting: true, useSearchForm: true, @@ -196,7 +251,13 @@