This is an automated email from the ASF dual-hosted git repository.
caishunfeng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 45b4445e12 improve task flow date time exception handle (#9732)
45b4445e12 is described below
commit 45b4445e121cc4f0da9e29935830f04cb3d1589b
Author: Mr.An <[email protected]>
AuthorDate: Mon Apr 25 17:10:18 2022 +0800
improve task flow date time exception handle (#9732)
---
dolphinscheduler-ui-next/src/common/common.ts | 18 ++++++++------
.../src/views/projects/task/instance/use-table.ts | 29 ++++++----------------
.../views/projects/workflow/instance/use-table.ts | 19 +++-----------
3 files changed, 23 insertions(+), 43 deletions(-)
diff --git a/dolphinscheduler-ui-next/src/common/common.ts
b/dolphinscheduler-ui-next/src/common/common.ts
index 82be234764..29a58ac627 100644
--- a/dolphinscheduler-ui-next/src/common/common.ts
+++ b/dolphinscheduler-ui-next/src/common/common.ts
@@ -33,7 +33,7 @@ import {
IssuesCloseOutlined,
SendOutlined
} from '@vicons/antd'
-import { parseISO } from 'date-fns'
+import { format, parseISO } from 'date-fns'
import _ from 'lodash'
import { ITaskStateConfig } from './types'
@@ -314,10 +314,14 @@ export const warningTypeList = [
}
]
-export const parseTime = (dateTime: string | number) => {
- if (_.isString(dateTime) === true) {
- return parseISO(dateTime as string)
- } else {
- return new Date(dateTime)
- }
+export const parseTime = (dateTime: string | number): Date => {
+ return _.isString(dateTime) === true
+ ? parseISO(dateTime as string)
+ : new Date(dateTime)
+}
+
+export const renderTableTime = (
+ dateTime: string | number | null | undefined
+): string => {
+ return dateTime ? format(parseTime(dateTime), 'yyyy-MM-dd HH:mm:ss') : '-'
}
diff --git
a/dolphinscheduler-ui-next/src/views/projects/task/instance/use-table.ts
b/dolphinscheduler-ui-next/src/views/projects/task/instance/use-table.ts
index 0daa53e2e4..6bcfc2572b 100644
--- a/dolphinscheduler-ui-next/src/views/projects/task/instance/use-table.ts
+++ b/dolphinscheduler-ui-next/src/views/projects/task/instance/use-table.ts
@@ -32,7 +32,7 @@ import {
} from '@vicons/antd'
import { format } from 'date-fns'
import { useRoute, useRouter } from 'vue-router'
-import { parseTime, tasksState } from '@/common/common'
+import { parseTime, renderTableTime, tasksState } from '@/common/common'
import {
COLUMN_WIDTH_CONFIG,
calculateTableWidth,
@@ -123,17 +123,20 @@ export function useTable() {
{
title: t('project.task.submit_time'),
...COLUMN_WIDTH_CONFIG['time'],
- key: 'submitTime'
+ key: 'submitTime',
+ render: (row: IRecord) => renderTableTime(row.submitTime)
},
{
title: t('project.task.start_time'),
...COLUMN_WIDTH_CONFIG['time'],
- key: 'startTime'
+ key: 'startTime',
+ render: (row: IRecord) => renderTableTime(row.startTime)
},
{
title: t('project.task.end_time'),
...COLUMN_WIDTH_CONFIG['time'],
- key: 'endTime'
+ key: 'endTime',
+ render: (row: IRecord) => renderTableTime(row.endTime)
},
{
title: t('project.task.duration'),
@@ -298,23 +301,7 @@ export function useTable() {
const { state } = useAsyncState(
queryTaskListPaging(data, { projectCode }).then(
(res: TaskInstancesRes) => {
- variables.tableData = res.totalList.map((item, unused) => {
- item.submitTime = format(
- parseTime(item.submitTime),
- 'yyyy-MM-dd HH:mm:ss'
- )
- item.startTime = format(
- parseTime(item.startTime),
- 'yyyy-MM-dd HH:mm:ss'
- )
- item.endTime = format(
- parseTime(item.endTime),
- 'yyyy-MM-dd HH:mm:ss'
- )
- return {
- ...item
- }
- }) as any
+ variables.tableData = res.totalList as IRecord[]
variables.totalPage = res.totalPage
variables.loadingRef = false
}
diff --git
a/dolphinscheduler-ui-next/src/views/projects/workflow/instance/use-table.ts
b/dolphinscheduler-ui-next/src/views/projects/workflow/instance/use-table.ts
index 9bc0a566e6..898c153aa4 100644
--- a/dolphinscheduler-ui-next/src/views/projects/workflow/instance/use-table.ts
+++ b/dolphinscheduler-ui-next/src/views/projects/workflow/instance/use-table.ts
@@ -16,7 +16,6 @@
*/
import _ from 'lodash'
-import { format } from 'date-fns'
import { reactive, h, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
@@ -29,8 +28,7 @@ import {
} from '@/service/modules/process-instances'
import { execute } from '@/service/modules/executors'
import TableAction from './components/table-action'
-import { runningType } from '@/common/common'
-import { parseTime } from '@/common/common'
+import { renderTableTime, runningType } from '@/common/common'
import styles from './index.module.scss'
import { renderStateCell } from '../../task/instance/use-table'
import {
@@ -119,28 +117,19 @@ export function useTable() {
title: t('project.workflow.scheduling_time'),
key: 'scheduleTime',
...COLUMN_WIDTH_CONFIG['time'],
- render: (_row: IWorkflowInstance) =>
- _row.scheduleTime
- ? format(parseTime(_row.scheduleTime), 'yyyy-MM-dd HH:mm:ss')
- : '-'
+ render: (_row: IWorkflowInstance) => renderTableTime(_row.scheduleTime)
},
{
title: t('project.workflow.start_time'),
key: 'startTime',
...COLUMN_WIDTH_CONFIG['time'],
- render: (_row: IWorkflowInstance) =>
- _row.startTime
- ? format(parseTime(_row.startTime), 'yyyy-MM-dd HH:mm:ss')
- : '-'
+ render: (_row: IWorkflowInstance) => renderTableTime(_row.startTime)
},
{
title: t('project.workflow.end_time'),
key: 'endTime',
...COLUMN_WIDTH_CONFIG['time'],
- render: (_row: IWorkflowInstance) =>
- _row.endTime
- ? format(parseTime(_row.endTime), 'yyyy-MM-dd HH:mm:ss')
- : '-'
+ render: (_row: IWorkflowInstance) => renderTableTime(_row.endTime)
},
{
title: t('project.workflow.duration'),