@@ -1088,6 +1088,26 @@ export default {
10881088 return nodes
10891089 } ,
10901090
1091+ findAllChildNodes ( id ) {
1092+ let node = this . scope . findNodeById ( id )
1093+ const nodes = [ ]
1094+ let ids = node . $outputs || [ ]
1095+
1096+ ids . forEach ( id => {
1097+ let child = this . scope . findNodeById ( id )
1098+
1099+ if ( ! child ) return
1100+
1101+ nodes . push ( child )
1102+
1103+ if ( child . $outputs ?. length ) {
1104+ nodes . push ( ...this . findChildNodes ( id ) )
1105+ }
1106+ } )
1107+
1108+ return nodes
1109+ } ,
1110+
10911111 handleDisableNode ( node , value = true ) {
10921112 this . $set ( node , 'disabled' , value )
10931113 this . $set ( node . attrs , 'disabled' , value )
@@ -1728,38 +1748,26 @@ export default {
17281748 } )
17291749 return error
17301750 }
1731- }
17321751
1733- // const handle = async input => {
1734- // const fields = await this.scope.loadNodeFieldOptions(input)
1735-
1736- // if (
1737- // fields?.length &&
1738- // !fields.some(item => {
1739- // return item.isPrimaryKey || item.indicesUnique
1740- // })
1741- // ) {
1742- // // 缺少主键或唯一索引
1743- // return Promise.reject(input)
1744- // }
1745- // }
1746-
1747- // for (let node of nodes) {
1748- // for (let input of node.$inputs) {
1749- // allPromise.push(handle(input))
1750- // }
1751- // }
1752-
1753- // try {
1754- // await Promise.all(allPromise)
1755- // } catch (id) {
1756- // this.setNodeErrorMsg({
1757- // id,
1758- // msg: i18n.t('packages_dag_missing_primary_key_or_index')
1759- // })
1760- // this.handleLocateNode(this.nodeById(id))
1761- // return i18n.t('packages_dag_merge_table_missing_key_or_index')
1762- // }
1752+ // 校验主从合并后面是否有js节点
1753+ const nextNodes = this . findAllChildNodes ( node . id )
1754+
1755+ if ( nextNodes . some ( nextNode => nextNode . type === 'js_processor' || nextNode . type === 'standard_js_processor' ) ) {
1756+ return i18n . t ( 'packages_dag_merge_table_js_node_error' )
1757+ }
1758+
1759+ // 目标需要有 master_slave_merge 能力
1760+ const targetNode = nextNodes . find (
1761+ nextNode =>
1762+ nextNode . type === 'table' && ! nextNode . attrs ?. capabilities ?. find ( ( { id } ) => id === 'master_slave_merge' )
1763+ )
1764+
1765+ if ( targetNode ) {
1766+ return i18n . t ( 'packages_dag_merge_table_table_not_allow_target' , {
1767+ val : targetNode . databaseType
1768+ } )
1769+ }
1770+ }
17631771 } ,
17641772
17651773 async eachValidate ( ...fns ) {
0 commit comments