|
@@ -171,7 +171,6 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
|
|
|
}
|
|
|
}
|
|
|
const onTableSelect = async (val, index) => {
|
|
|
- formatSchemaPreview(nodeState.index, false)
|
|
|
if (val !== undefined) {
|
|
|
const { data } = await getLocalTableSchema(val)
|
|
|
if (data.code === 200) {
|
|
@@ -187,9 +186,14 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
|
|
|
}
|
|
|
|
|
|
const handleSyncData = (datasourceSchemas, nodeDataSchemas, index) => {
|
|
|
+ //不符合比对条件的
|
|
|
const list = []
|
|
|
+ //符合比对条件的
|
|
|
const syncList = []
|
|
|
+ //整体结果
|
|
|
+ let node_result = true
|
|
|
nodeDataSchemas.forEach(item => {
|
|
|
+ // 字段相同
|
|
|
const syncItem = datasourceSchemas.find(
|
|
|
val => val.dataField === item.dataField
|
|
|
)
|
|
@@ -197,13 +201,20 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
|
|
|
const handleType = syncItem.dataType.split('(')[0]
|
|
|
const result =
|
|
|
item.dataType === handleType ||
|
|
|
- (item.dataType === 'string' && handleType === 'varchar')
|
|
|
+ (['varchar', 'string'].includes(item.dataType) &&
|
|
|
+ ['varchar', 'string'].includes(handleType)) ||
|
|
|
+ (['int', 'bigint'].includes(item.dataType) &&
|
|
|
+ ['int', 'bigint'].includes(handleType))
|
|
|
+
|
|
|
+ if (!result) node_result = false
|
|
|
syncList.push({ datasource: syncItem, dag: item, result })
|
|
|
+ // 将符合要求的从比对数组剔除
|
|
|
datasourceSchemas = datasourceSchemas.filter(val => val !== syncItem)
|
|
|
} else {
|
|
|
list.push(item)
|
|
|
}
|
|
|
})
|
|
|
+ //两个数组不符合同字段要求剩余部分比对
|
|
|
if (list.length > datasourceSchemas.length) {
|
|
|
list.forEach((item, index) => {
|
|
|
syncList.push({
|
|
@@ -221,14 +232,13 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
- if (list.length === 0) {
|
|
|
+ if (list.length === 0 && node_result) {
|
|
|
setNodeState({ index, state: true })
|
|
|
} else {
|
|
|
setNodeState({ index, state: false })
|
|
|
}
|
|
|
|
|
|
setNodeSchema({ index, list: syncList })
|
|
|
- formatSchemaPreview(index, true)
|
|
|
}
|
|
|
|
|
|
const showStructure = index => {
|
|
@@ -255,12 +265,14 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
|
|
|
const prewStatus = { ...schemasPreview }
|
|
|
prewStatus[index] = status
|
|
|
setSchemasPreview(prewStatus)
|
|
|
+ console.log(index, prewStatus)
|
|
|
}
|
|
|
|
|
|
useEffect(() => {
|
|
|
const states = { ...nodeStates }
|
|
|
states[nodeState.index] = nodeState.state
|
|
|
setNodeStates(states)
|
|
|
+ formatSchemaPreview(nodeState.index, true)
|
|
|
}, [nodeState])
|
|
|
|
|
|
useEffect(() => {
|
|
@@ -310,7 +322,10 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
|
|
|
<Select
|
|
|
showSearch
|
|
|
optionFilterProp="label"
|
|
|
- onSelect={val => onTableSelect(val, index)}>
|
|
|
+ onChange={val => {
|
|
|
+ formatSchemaPreview(index, false)
|
|
|
+ onTableSelect(val, index)
|
|
|
+ }}>
|
|
|
{tableData.map(item => (
|
|
|
<Option key={item} value={item}>
|
|
|
{item}
|