diff --git a/packages/dag/src/components/FormPanel.vue b/packages/dag/src/components/FormPanel.vue index eb057119d..7370243af 100644 --- a/packages/dag/src/components/FormPanel.vue +++ b/packages/dag/src/components/FormPanel.vue @@ -223,7 +223,7 @@ export default { this.updateTimer = setTimeout(() => { const node = this.nodeById(form.values.id) if (node && !deepEqual(toJS(form.values), node, ['alarmRules.0._ms', 'alarmRules.0._point'])) { - console.log('还是更新了') + console.debug('updateNodeProps in debounce') this.updateNodeProps(form) } }, 40) diff --git a/packages/dag/src/locale/lang/en.js b/packages/dag/src/locale/lang/en.js index dd8c8dde7..9569b922b 100644 --- a/packages/dag/src/locale/lang/en.js +++ b/packages/dag/src/locale/lang/en.js @@ -819,5 +819,7 @@ export default { packages_dag_counting_num_of_rows_table: 'Counting the number of rows in the table', packages_dag_noPkSyncMode: 'No Primary Key Table Sync Mode', packages_dag_noPkSyncMode_ADD_HASH: 'Add Hash Column', - packages_dag_noPkSyncMode_ALL_COLUMNS: 'Full Column Index' + packages_dag_noPkSyncMode_ALL_COLUMNS: 'Full Column Index', + packages_dag_join_keys_empty: 'Association conditions for {tableName} cannot be empty', + packages_dag_join_keys_field_empty: 'Field in association condition #{index} for {tableName} cannot be empty.' } diff --git a/packages/dag/src/locale/lang/zh-CN.js b/packages/dag/src/locale/lang/zh-CN.js index b6615667d..4fd0fb9a8 100644 --- a/packages/dag/src/locale/lang/zh-CN.js +++ b/packages/dag/src/locale/lang/zh-CN.js @@ -764,5 +764,7 @@ export default { packages_dag_counting_num_of_rows_table: '正在统计表行数', packages_dag_noPkSyncMode: '无主键表同步方式', packages_dag_noPkSyncMode_ADD_HASH: '新增哈希列', - packages_dag_noPkSyncMode_ALL_COLUMNS: '全字段索引' + packages_dag_noPkSyncMode_ALL_COLUMNS: '全字段索引', + packages_dag_join_keys_empty: '{tableName} 的关联条件不能为空', + packages_dag_join_keys_field_empty: '{tableName} 的关联条件第 {index} 项的字段不能为空' } diff --git a/packages/dag/src/locale/lang/zh-TW.js b/packages/dag/src/locale/lang/zh-TW.js index 07c1571ce..58f53468a 100644 --- a/packages/dag/src/locale/lang/zh-TW.js +++ b/packages/dag/src/locale/lang/zh-TW.js @@ -759,5 +759,7 @@ export default { packages_dag_counting_num_of_rows_table: '正在統計表行數', packages_dag_noPkSyncMode: '無主鍵表同步方式', packages_dag_noPkSyncMode_ADD_HASH: '新增哈希列', - packages_dag_noPkSyncMode_ALL_COLUMNS: '全字段索引' + packages_dag_noPkSyncMode_ALL_COLUMNS: '全字段索引', + packages_dag_join_keys_empty: '{tableName} 的關聯條件不能為空', + packages_dag_join_keys_field_empty: '{tableName} 的關聯條件第 {index} 項的字段不能為空' } diff --git a/packages/dag/src/mixins/editor.js b/packages/dag/src/mixins/editor.js index b45219f3c..3580e6944 100644 --- a/packages/dag/src/mixins/editor.js +++ b/packages/dag/src/mixins/editor.js @@ -1690,38 +1690,76 @@ export default { if (this.dataflow.syncType === 'migrate') return const nodes = this.allNodes.filter(node => node.type === 'merge_table_processor') - const allPromise = [] - const handle = async input => { - const fields = await this.scope.loadNodeFieldOptions(input) + const validateMergeProperties = (items, isFirstLevel = true) => { + for (const item of items) { + // 跳过第一级,只检查 children 层级的 joinKeys + if (!isFirstLevel) { + // 检查 joinKeys 是否为空数组 + if (!item.joinKeys?.length) { + return i18n.t('packages_dag_join_keys_empty', { tableName: item.tableName }) + } - if ( - fields?.length && - !fields.some(item => { - return item.isPrimaryKey || item.indicesUnique - }) - ) { - // 缺少主键或唯一索引 - return Promise.reject(input) + // 检查每个 joinKey 的 source/target + for (const [index, joinKey] of item.joinKeys.entries()) { + if (!joinKey.source || !joinKey.target) { + return i18n.t('packages_dag_join_keys_field_empty', { tableName: item.tableName, index: index + 1 }) + } + } + } + + // 递归检查子项 + if (item.children?.length) { + const childrenError = validateMergeProperties(item.children, false) + if (childrenError) { + return childrenError + } + } } + return '' } for (let node of nodes) { - for (let input of node.$inputs) { - allPromise.push(handle(input)) + const error = validateMergeProperties(node.mergeProperties) + if (error) { + this.setNodeErrorMsg({ + id: node.id, + msg: error + }) + return error } } - try { - await Promise.all(allPromise) - } catch (id) { - this.setNodeErrorMsg({ - id, - msg: i18n.t('packages_dag_missing_primary_key_or_index') - }) - this.handleLocateNode(this.nodeById(id)) - return i18n.t('packages_dag_merge_table_missing_key_or_index') - } + // const handle = async input => { + // const fields = await this.scope.loadNodeFieldOptions(input) + + // if ( + // fields?.length && + // !fields.some(item => { + // return item.isPrimaryKey || item.indicesUnique + // }) + // ) { + // // 缺少主键或唯一索引 + // return Promise.reject(input) + // } + // } + + // for (let node of nodes) { + // for (let input of node.$inputs) { + // allPromise.push(handle(input)) + // } + // } + + // try { + // await Promise.all(allPromise) + // } catch (id) { + // this.setNodeErrorMsg({ + // id, + // msg: i18n.t('packages_dag_missing_primary_key_or_index') + // }) + // this.handleLocateNode(this.nodeById(id)) + // return i18n.t('packages_dag_merge_table_missing_key_or_index') + // } }, async eachValidate(...fns) { @@ -1759,8 +1797,8 @@ export default { this.validateCustomSql, this.validateUnwind, this.validateTableRename, - this.validateMigrateUnion - // this.validateMergeTableProcessor + this.validateMigrateUnion, + this.validateMergeTableProcessor ) }, diff --git a/packages/dag/src/nodes/MergeTable.js b/packages/dag/src/nodes/MergeTable.js index 0b09a2b16..44c9b605b 100644 --- a/packages/dag/src/nodes/MergeTable.js +++ b/packages/dag/src/nodes/MergeTable.js @@ -120,8 +120,6 @@ export class MergeTable extends NodeType { title: i18n.t('packages_dag_nodes_mergetable_zhucongpeizhi'), type: 'array', required: true, - 'x-decorator': 'FormItem', - 'x-decorator-props': {}, 'x-component': 'MergeTableTree', 'x-component-props': { treeWidth: 200,