|
@@ -135,6 +135,8 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
// 所有预览map
|
|
|
const [nodeSchemas, setNodeSchemas] = useState({})
|
|
|
|
|
|
+ const [schemasPreview, setSchemasPreview] = useState({})
|
|
|
+
|
|
|
const [nodeSchema, setNodeSchema] = useState({})
|
|
|
|
|
|
//所有节点预览状态
|
|
@@ -162,17 +164,22 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
const { data } = await getDataSourceInfo(params)
|
|
|
if (data.code === 200) {
|
|
|
setDatasources(data.data.items)
|
|
|
+ } else {
|
|
|
+ message.error(data.msg)
|
|
|
}
|
|
|
}
|
|
|
- const onDatasourcesSelect = async val => {
|
|
|
+ const onDatasourcesSelect = async (val, index) => {
|
|
|
if (val !== undefined) {
|
|
|
const { data } = await getTableNameInfo(val)
|
|
|
if (data.code === 200) {
|
|
|
setTableData(data.data)
|
|
|
+ } else {
|
|
|
+ message.error(data.msg)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
const onTableSelect = async (val, index) => {
|
|
|
+ formatSchemaPreview(nodeState.index, false)
|
|
|
if (val !== undefined) {
|
|
|
const { data } = await getTableSchemaInfo({
|
|
|
id: OutputDataForm.getFieldValue(`datasource${index}`),
|
|
@@ -184,6 +191,8 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
return { dataField: strs[1], dataType: strs[2] }
|
|
|
})
|
|
|
handleSyncData(schemas, nodes[index]?.data.output_source, index)
|
|
|
+ } else {
|
|
|
+ message.error(data.msg)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -230,6 +239,7 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
}
|
|
|
|
|
|
setNodeSchema({ index, list: syncList })
|
|
|
+ formatSchemaPreview(index, true)
|
|
|
}
|
|
|
|
|
|
const showStructure = index => {
|
|
@@ -247,11 +257,18 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
nodes.forEach((_, index) => {
|
|
|
const datasource = OutputDataForm.getFieldValue(`datasource${index}`)
|
|
|
const table = OutputDataForm.getFieldValue(`sourceTable${index}`)
|
|
|
- onDatasourcesSelect(datasource)
|
|
|
+ onDatasourcesSelect(datasource, index)
|
|
|
onTableSelect(table, index)
|
|
|
})
|
|
|
}, [nodes])
|
|
|
|
|
|
+ const formatSchemaPreview = (index, status) => {
|
|
|
+ const prewStatus = { ...schemasPreview }
|
|
|
+ prewStatus[index] = status
|
|
|
+ console.log(prewStatus)
|
|
|
+ setSchemasPreview(prewStatus)
|
|
|
+ }
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
const states = { ...nodeStates }
|
|
|
states[nodeState.index] = nodeState.state
|
|
@@ -286,7 +303,7 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
rules={[{ required: true, message: '请选择数据源!' }]}
|
|
|
label={item.name}
|
|
|
className="dtsource">
|
|
|
- <Select allowClear onSelect={onDatasourcesSelect}>
|
|
|
+ <Select onSelect={val => onDatasourcesSelect(val, index)}>
|
|
|
{datasources.map(item => (
|
|
|
<Option key={item.id} value={item.id}>
|
|
|
{item.datasource_name}
|
|
@@ -299,9 +316,7 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
label="选择表"
|
|
|
rules={[{ required: true, message: '请选择表!' }]}
|
|
|
className="item-choseList">
|
|
|
- <Select
|
|
|
- allowClear
|
|
|
- onSelect={val => onTableSelect(val, index)}>
|
|
|
+ <Select onSelect={val => onTableSelect(val, index)}>
|
|
|
{tableData.map(item => (
|
|
|
<Option key={item} value={item}>
|
|
|
{item}
|
|
@@ -313,7 +328,10 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
|
|
|
type={nodeStates[index] ? 'success' : 'warning'}
|
|
|
showIcon
|
|
|
className="stateIcon"></Alert>
|
|
|
- <Button type="primary" onClick={() => showStructure(index)}>
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ disabled={!schemasPreview[index]}
|
|
|
+ onClick={() => showStructure(index)}>
|
|
|
结构预览
|
|
|
</Button>
|
|
|
</Row>
|