|
@@ -5,8 +5,13 @@ import arrowImgUrl from '../style/img/arrow.png'
|
|
|
import syncImgUrl from '../style/img/sync.png'
|
|
|
import warningImgUrl from '../style/img/warning.png'
|
|
|
import deleteImgUrl from '../style/img/delete.png'
|
|
|
-import { getTableSchema, ailabSchema, lakeSchema } from '../services'
|
|
|
-import { Button, Space, Tooltip } from 'antd'
|
|
|
+import {
|
|
|
+ getTableSchema,
|
|
|
+ ailabSchema,
|
|
|
+ lakeSchema,
|
|
|
+ getLakeTable,
|
|
|
+} from '../services'
|
|
|
+import { Button, message, Space, Tooltip } from 'antd'
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
|
|
const StepThreeDiv = styled.div`
|
|
@@ -98,6 +103,8 @@ export default function StepThree({
|
|
|
// 映射管理
|
|
|
const [syncMappings, setSyncMappings] = useState([])
|
|
|
|
|
|
+ const [lakeList, setLakeList] = useState([])
|
|
|
+
|
|
|
// 暴露同步map
|
|
|
useImperativeHandle(onRef, () => {
|
|
|
return {
|
|
@@ -105,12 +112,31 @@ export default function StepThree({
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ const getLakeList = async () => {
|
|
|
+ const { data } = await getLakeTable()
|
|
|
+ if (data.code === 200) {
|
|
|
+ const list = data.data.map(item => {
|
|
|
+ return {
|
|
|
+ tb_name: item.table_name,
|
|
|
+ db_name: item.database_name,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ setLakeList(list)
|
|
|
+ } else {
|
|
|
+ message.error(data.msg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
const fetchDatasource = async (id, table_name, ds_type) => {
|
|
|
+ const lake = lakeList.find(item => item.tb_name === table_name)
|
|
|
const { data } =
|
|
|
ds_type === 'datasource'
|
|
|
? await getTableSchema({ id, table_name })
|
|
|
: ds_type === 'datalake'
|
|
|
- ? await lakeSchema(table_name)
|
|
|
+ ? await lakeSchema({
|
|
|
+ table_name: lake?.tb_name,
|
|
|
+ db_name: lake?.db_name,
|
|
|
+ })
|
|
|
: await ailabSchema(table_name)
|
|
|
if (data.code === 200) {
|
|
|
const list = formatData(data.data)
|
|
@@ -119,11 +145,15 @@ export default function StepThree({
|
|
|
}
|
|
|
|
|
|
const fetchSyncData = async (id, table_name, ds_type) => {
|
|
|
+ const lake = lakeList.find(item => item.tb_name === table_name)
|
|
|
const { data } =
|
|
|
ds_type === 'datasource'
|
|
|
? await getTableSchema({ id, table_name })
|
|
|
: ds_type === 'datalake'
|
|
|
- ? await lakeSchema(table_name)
|
|
|
+ ? await lakeSchema({
|
|
|
+ table_name: lake?.tb_name,
|
|
|
+ db_name: lake?.db_name,
|
|
|
+ })
|
|
|
: await ailabSchema(table_name)
|
|
|
if (data.code === 200) {
|
|
|
const list = formatData(data.data)
|
|
@@ -144,6 +174,10 @@ export default function StepThree({
|
|
|
return list
|
|
|
}
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ getLakeList()
|
|
|
+ }, [])
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
const ds_id = drawDataForm.getFieldValue('datasource_name')
|
|
|
const table_name = drawDataForm.getFieldValue('datasource_table')
|
|
@@ -151,7 +185,7 @@ export default function StepThree({
|
|
|
if (table_name && ds_type) {
|
|
|
fetchDatasource(ds_id, table_name, ds_type)
|
|
|
}
|
|
|
- }, [drawDataForm])
|
|
|
+ }, [drawDataForm, lakeList])
|
|
|
|
|
|
useEffect(() => {
|
|
|
const ds_id = loadDataForm.getFieldValue('datasource_name')
|
|
@@ -160,7 +194,7 @@ export default function StepThree({
|
|
|
if (table_name && ds_type) {
|
|
|
fetchSyncData(ds_id, table_name, ds_type)
|
|
|
}
|
|
|
- }, [loadDataForm])
|
|
|
+ }, [loadDataForm, lakeList])
|
|
|
|
|
|
useEffect(() => {
|
|
|
setSyncMappings(syncMapSaving)
|
|
@@ -362,7 +396,7 @@ export default function StepThree({
|
|
|
}
|
|
|
|
|
|
StepThree.propTypes = {
|
|
|
- onRef: PropTypes.func,
|
|
|
+ onRef: PropTypes.object,
|
|
|
drawDataForm: PropTypes.object,
|
|
|
loadDataForm: PropTypes.object,
|
|
|
syncMapSaving: PropTypes.array,
|