From 2e350c0ea8a90a5fdf4c5cf974a4b7e4c34ddc36 Mon Sep 17 00:00:00 2001 From: xlsea Date: Mon, 3 Jun 2024 10:43:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat(sj=5F1.0.0=5Fbeta4):=20=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E4=BB=BB=E5=8A=A1Card=E6=B7=BB=E5=8A=A0=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/common/router.ts | 7 +- src/views/home/modules/card-data.vue | 70 ++++++++++--------- .../job/batch/modules/job-batch-search.vue | 6 ++ src/views/workflow/form/add/index.vue | 2 +- 4 files changed, 51 insertions(+), 34 deletions(-) diff --git a/src/hooks/common/router.ts b/src/hooks/common/router.ts index 89374b7..21fe3db 100644 --- a/src/hooks/common/router.ts +++ b/src/hooks/common/router.ts @@ -21,10 +21,11 @@ export function useRouterPush(inSetup = true) { interface RouterPushOptions { query?: Record; params?: Record; + state?: Record; } async function routerPushByKey(key: RouteKey, options?: RouterPushOptions) { - const { query, params } = options || {}; + const { query, params, state } = options || {}; const routeLocation: RouteLocationRaw = { name: key @@ -38,6 +39,10 @@ export function useRouterPush(inSetup = true) { routeLocation.params = params; } + if (state) { + routeLocation.state = state; + } + return routerPush(routeLocation); } diff --git a/src/views/home/modules/card-data.vue b/src/views/home/modules/card-data.vue index ce24322..3a855a5 100644 --- a/src/views/home/modules/card-data.vue +++ b/src/views/home/modules/card-data.vue @@ -77,20 +77,18 @@ const props = withDefaults(defineProps(), { }) }); -/** 卡片 key 类型, 与卡片的路由的 name 一致, 便于直接使用 routerPushByKey */ -type KeyType = 'job_task' | 'retry_task' | 'workflow_task' | 'pods'; - interface CardData { - key: KeyType; + key: string; title: string; tip: string; value: number; + click?: () => void; color: { start: string; end: string; }; icon: string; - bottom: { label: string; value: number }[]; + bottom: { label: string; value: number; click?: () => void }[]; } // eslint-disable-next-line complexity @@ -100,6 +98,7 @@ const cardData = computed(() => [ title: $t('page.home.jobTask'), tip: $t('page.home.jobTaskTip'), value: props.modelValue?.jobTask.totalNum ?? 0, + click: () => routerPushByKey('job_task'), color: { start: '#f5b386', end: '#FFD6BA' @@ -108,19 +107,23 @@ const cardData = computed(() => [ bottom: [ { label: $t('common.success'), - value: props.modelValue?.jobTask.successNum ?? 0 + value: props.modelValue?.jobTask.successNum ?? 0, + click: () => routerPushByKey('job_batch', { state: { taskBatchStatus: '3' } }) }, { label: $t('common.fail'), - value: props.modelValue?.jobTask.failNum ?? 0 + value: props.modelValue?.jobTask.failNum ?? 0, + click: () => routerPushByKey('job_batch', { state: { taskBatchStatus: '4' } }) }, { label: $t('common.stop'), - value: props.modelValue?.jobTask.stopNum ?? 0 + value: props.modelValue?.jobTask.stopNum ?? 0, + click: () => routerPushByKey('job_batch', { state: { taskBatchStatus: '5' } }) }, { label: $t('common.cancel'), - value: props.modelValue?.jobTask.cancelNum ?? 0 + value: props.modelValue?.jobTask.cancelNum ?? 0, + click: () => routerPushByKey('job_batch', { state: { taskBatchStatus: '6' } }) } ] }, @@ -129,6 +132,7 @@ const cardData = computed(() => [ title: $t('page.home.retryTask'), tip: $t('page.home.retryTaskTip'), value: props.modelValue?.retryTask.totalNum ?? 0, + click: () => routerPushByKey('retry_task'), unit: '', color: { start: '#40e9c5', @@ -159,6 +163,7 @@ const cardData = computed(() => [ title: $t('page.home.workflow'), tip: $t('page.home.workflowTip'), value: props.modelValue?.workFlowTask.totalNum, + click: () => routerPushByKey('workflow_task'), unit: '', color: { start: '#ec6f6f', @@ -189,6 +194,7 @@ const cardData = computed(() => [ title: $t('page.home.onlineServiceCount'), tip: $t('page.home.onlineServiceTip'), value: props.modelValue?.onLineService.total ?? 0, + click: () => routerPushByKey('pods'), unit: '', color: { start: '#b686d4', @@ -234,27 +240,25 @@ function getGradientColor(color: CardData['color']) { - -
-
- -

{{ item.title }}

+ +
+
+
+ +

{{ item.title }}

+
+ + + {{ item.tip }} + +
+
+
- - - {{ item.tip }} - -
-
-
@@ -295,7 +301,7 @@ function getGradientColor(color: CardData['color']) { } .n-divider--vertical { - margin: 0 1px 0 5px; + margin: 0 5px 0 5px; } :deep(.n-progress-icon--as-text) { diff --git a/src/views/job/batch/modules/job-batch-search.vue b/src/views/job/batch/modules/job-batch-search.vue index 2df1836..ea29c97 100644 --- a/src/views/job/batch/modules/job-batch-search.vue +++ b/src/views/job/batch/modules/job-batch-search.vue @@ -23,6 +23,12 @@ function reset() { function search() { emit('search'); } + +const taskBatchStatus = history.state.taskBatchStatus; + +if (taskBatchStatus) { + model.value.taskBatchStatus = Number(taskBatchStatus) as Api.Common.TaskBatchStatus; +}