From 96b31c81ffbfdf76bc62f4d804afb17d001ba2bc Mon Sep 17 00:00:00 2001 From: Amy0104 <97265214+Amy0104@users.noreply.github.com> Date: Sat, 7 May 2022 13:50:03 +0800 Subject: [PATCH] [Fix][UI Next][V1.0.0-Beta] Fix data quality data not displayed. (#9930) --- .../task/components/node/fields/use-rules.ts | 59 +++++++++++++------ .../task/components/node/format-data.ts | 55 ++++++++++------- .../projects/task/components/node/types.ts | 3 + 3 files changed, 78 insertions(+), 39 deletions(-) diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-rules.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-rules.ts index 977be8517c..5f76fcf5a6 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-rules.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-rules.ts @@ -101,7 +101,7 @@ export function useRules( responseItem.emit.forEach((emit) => { if (emit === 'change') { item.props.onUpdateValue = (value: string | number) => { - onFieldChange(value, item.field) + onFieldChange(value, item.field, true) } } }) @@ -127,45 +127,64 @@ export function useRules( if (item.field === 'target_field') { item.options = targetTableColumnOptions } + + if (model[item.field] !== void 0) { + onFieldChange(model[item.field], item.field, false) + item.value = model[item.field] + } + return item } - - const onFieldChange = async (value: string | number, field: string) => { + const onFieldChange = async ( + value: string | number, + field: string, + reset: boolean + ) => { if (field === 'src_connector_type' && typeof value === 'number') { const result = await getDatasourceOptionsById(value) srcDatasourceOptions.value = result || [] - srcTableOptions.value = [] - model.src_datasource_id = null - model.src_table = null - model.src_field = null + if (reset) { + srcTableOptions.value = [] + model.src_datasource_id = null + model.src_table = null + model.src_field = null + } return } if (field === 'target_connector_type' && typeof value === 'number') { const result = await getDatasourceOptionsById(value) targetDatasourceOptions.value = result || [] - targetTableOptions.value = [] - model.target_datasource_id = null - model.target_table = null - model.target_field = null + if (reset) { + targetTableOptions.value = [] + model.target_datasource_id = null + model.target_table = null + model.target_field = null + } return } if (field === 'writer_connector_type' && typeof value === 'number') { const result = await getDatasourceOptionsById(value) writerDatasourceOptions.value = result || [] - model.writer_datasource_id = null + if (reset) { + model.writer_datasource_id = null + } return } if (field === 'src_datasource_id' && typeof value === 'number') { const result = await getDatasourceTablesById(value) srcTableOptions.value = result || [] - model.src_table = null - model.src_field = null + if (reset) { + model.src_table = null + model.src_field = null + } } if (field === 'target_datasource_id' && typeof value === 'number') { const result = await getDatasourceTablesById(value) targetTableOptions.value = result || [] - model.target_table = null - model.target_field = null + if (reset) { + model.target_table = null + model.target_field = null + } } if (field === 'src_table' && typeof value === 'string') { const result = await getDatasourceTableColumnsById( @@ -173,7 +192,9 @@ export function useRules( value ) srcTableColumnOptions.value = result || [] - model.src_field = null + if (reset) { + model.src_field = null + } } if (field === 'target_table' && typeof value === 'string') { const result = await getDatasourceTableColumnsById( @@ -181,7 +202,9 @@ export function useRules( value ) targetTableColumnOptions.value = result || [] - model.target_field = null + if (reset) { + model.target_field = null + } } } diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts index 2f8547a688..d391203e47 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts @@ -272,11 +272,14 @@ export function formatParams(data: INodeData): { taskParams.ruleInputParameter = { check_type: data.check_type, comparison_execute_sql: data.comparison_execute_sql, + comparison_type: data.comparison_type, comparison_name: data.comparison_name, failure_strategy: data.failure_strategy, operator: data.operator, src_connector_type: data.src_connector_type, src_datasource_id: data.src_datasource_id, + src_filter: data.src_filter, + src_field: data.src_field, src_table: data.src_table, statistics_execute_sql: data.statistics_execute_sql, statistics_name: data.statistics_name, @@ -477,29 +480,39 @@ export function formatModel(data: ITaskData) { params.relation = data.taskParams?.dependence.relation } if (data.taskParams?.ruleInputParameter) { - params.check_type = data.check_type - params.comparison_execute_sql = data.comparison_execute_sql - params.comparison_name = data.comparison_name - params.failure_strategy = data.failure_strategy - params.operator = data.operator - params.src_connector_type = data.src_connector_type - params.src_datasource_id = data.src_datasource_id - params.src_table = data.src_table - params.statistics_execute_sql = data.statistics_execute_sql - params.statistics_name = data.statistics_name - params.target_connector_type = data.target_connector_type - params.target_datasource_id = data.target_datasource_id - params.target_table = data.target_table - params.threshold = data.threshold + params.check_type = data.taskParams.ruleInputParameter.check_type + params.comparison_execute_sql = + data.taskParams.ruleInputParameter.comparison_execute_sql + params.comparison_type = data.taskParams.ruleInputParameter.comparison_type + params.comparison_name = data.taskParams.ruleInputParameter.comparison_name + params.failure_strategy = + data.taskParams.ruleInputParameter.failure_strategy + params.operator = data.taskParams.ruleInputParameter.operator + params.src_connector_type = + data.taskParams.ruleInputParameter.src_connector_type + params.src_datasource_id = + data.taskParams.ruleInputParameter.src_datasource_id + params.src_table = data.taskParams.ruleInputParameter.src_table + params.src_filter = data.taskParams.ruleInputParameter.src_filter + params.src_field = data.taskParams.ruleInputParameter.src_field + params.statistics_execute_sql = + data.taskParams.ruleInputParameter.statistics_execute_sql + params.statistics_name = data.taskParams.ruleInputParameter.statistics_name + params.target_connector_type = + data.taskParams.ruleInputParameter.target_connector_type + params.target_datasource_id = + data.taskParams.ruleInputParameter.target_datasource_id + params.target_table = data.taskParams.ruleInputParameter.target_table + params.threshold = data.taskParams.ruleInputParameter.threshold } if (data.taskParams?.sparkParameters) { - params.deployMode = data.deployMode - params.driverCores = data.driverCores - params.driverMemory = data.driverMemory - params.executorCores = data.executorCores - params.executorMemory = data.executorMemory - params.numExecutors = data.numExecutors - params.others = data.others + params.deployMode = data.taskParams.sparkParameters.deployMode + params.driverCores = data.taskParams.sparkParameters.driverCores + params.driverMemory = data.taskParams.sparkParameters.driverMemory + params.executorCores = data.taskParams.sparkParameters.executorCores + params.executorMemory = data.taskParams.sparkParameters.executorMemory + params.numExecutors = data.taskParams.sparkParameters.numExecutors + params.others = data.taskParams.sparkParameters.others } if (data.taskParams?.jobFlowDefineJson) { diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts index 5c74d29065..d334de299f 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/types.ts @@ -191,11 +191,14 @@ interface IRuleParameters { check_type?: string comparison_execute_sql?: string comparison_name?: string + comparison_type?: number failure_strategy?: string operator?: string src_connector_type?: number src_datasource_id?: number src_table?: string + src_filter?: string + src_field?: string statistics_execute_sql?: string statistics_name?: string target_connector_type?: number