|
@@ -7,7 +7,7 @@ import React, { useState, useEffect } from 'react'
|
|
|
import DataTableStruct from './DataTableStruct'
|
|
|
import styled from 'styled-components'
|
|
|
import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons'
|
|
|
-import { getDataSourceList } from '../services'
|
|
|
+import { getDataSourceList, getTableSchema } from '../services'
|
|
|
|
|
|
const { Step } = Steps
|
|
|
|
|
@@ -22,8 +22,9 @@ const SyncTask = styled.div`
|
|
|
`
|
|
|
|
|
|
export default function SyncTaskAdd() {
|
|
|
- //
|
|
|
+ // 步骤三ref
|
|
|
const stepThreeRef = React.createRef()
|
|
|
+
|
|
|
// 步骤数
|
|
|
const [currentStep, setCurrentStep] = useState(0)
|
|
|
|
|
@@ -39,12 +40,42 @@ export default function SyncTaskAdd() {
|
|
|
// 完成状态
|
|
|
const [isfinishBuild, setIsFinishBuild] = useState(false)
|
|
|
|
|
|
+ // 提取源表单表结构
|
|
|
+ const [drawDataStruct, setDrawDataStruct] = useState([])
|
|
|
+ const updateDrawDataStruct = async (ds_id, table_name) => {await updateTableStruct(ds_id, table_name, setDrawDataStruct)}
|
|
|
+
|
|
|
+ // 加载源表单表结构
|
|
|
+ const [loadDataStruct, setLoadDataStruct] = useState([])
|
|
|
+ const updateLoadDataStruct = async (id, table_name) => {await updateTableStruct(id, table_name, setLoadDataStruct)}
|
|
|
+
|
|
|
+ // 更新表结构
|
|
|
+ const updateTableStruct = async (id, table_name, setFunc) => {
|
|
|
+ const { data } = await getTableSchema({id, table_name})
|
|
|
+ if (data.code === 200) {
|
|
|
+ const tableList = data.data.map(item => {
|
|
|
+ const splitData = item.split(':')
|
|
|
+ return {
|
|
|
+ key: splitData[0],
|
|
|
+ id: splitData[0],
|
|
|
+ field: splitData[1],
|
|
|
+ type: splitData[2]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ setFunc(tableList)
|
|
|
+ } else {
|
|
|
+ message.error('表结构数据加载失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 配置提取源表单
|
|
|
const [drawDataForm] = Form.useForm()
|
|
|
|
|
|
// 配置加载源表单
|
|
|
const [loadDataForm] = Form.useForm()
|
|
|
|
|
|
+ // 规则表单
|
|
|
+ const [ruleForm] = Form.useForm()
|
|
|
+
|
|
|
// 同步参数表单
|
|
|
const [syncDataForm] = Form.useForm()
|
|
|
|
|
@@ -68,6 +99,9 @@ export default function SyncTaskAdd() {
|
|
|
case 1:
|
|
|
setCurrentForm(loadDataForm)
|
|
|
break
|
|
|
+ case 2:
|
|
|
+ setCurrentForm(ruleForm)
|
|
|
+ break;
|
|
|
case 3:
|
|
|
setCurrentForm(syncDataForm)
|
|
|
break
|
|
@@ -135,15 +169,8 @@ export default function SyncTaskAdd() {
|
|
|
|
|
|
// 构建表单
|
|
|
const build = () => {
|
|
|
- currentForm
|
|
|
- .validateFields()
|
|
|
- .then(() => {
|
|
|
- console.log('build')
|
|
|
- finishBuild()
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- message.error('请检查表单数据是否完整')
|
|
|
- })
|
|
|
+ console.log('loadDataForm.getFieldsValue()', loadDataForm.getFieldValue());
|
|
|
+ // finishBuild()
|
|
|
}
|
|
|
|
|
|
// 完成提交
|
|
@@ -157,8 +184,15 @@ export default function SyncTaskAdd() {
|
|
|
|
|
|
// 提交表单
|
|
|
const submit = () => {
|
|
|
- console.log('submit')
|
|
|
- finishSubmit()
|
|
|
+ currentForm
|
|
|
+ .validateFields()
|
|
|
+ .then(() => {
|
|
|
+ console.log('submit')
|
|
|
+ finishSubmit()
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ message.error('请检查表单数据是否完整')
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
return (
|
|
@@ -173,35 +207,26 @@ export default function SyncTaskAdd() {
|
|
|
|
|
|
{/* 表单项 */}
|
|
|
{/* 配置提取源 */}
|
|
|
- {currentStep === 0 ? (
|
|
|
- <StepOne drawDataForm={drawDataForm} dataSourceList={dataSourceList} />
|
|
|
- ) : (
|
|
|
- ''
|
|
|
- )}
|
|
|
+ {currentStep === 0 && <StepOne drawDataForm={drawDataForm} dataSourceList={dataSourceList} updateTableStruct={updateDrawDataStruct}/>}
|
|
|
{/* 配置加载源 */}
|
|
|
- {currentStep === 1 ? (
|
|
|
- <StepTwo loadDataForm={loadDataForm} dataSourceList={dataSourceList} />
|
|
|
- ) : (
|
|
|
- ''
|
|
|
- )}
|
|
|
+ {currentStep === 1 && <StepTwo loadDataForm={loadDataForm} dataSourceList={dataSourceList} updateTableStruct={updateLoadDataStruct}/>}
|
|
|
|
|
|
{/* 配置转换规则 */}
|
|
|
- {currentStep === 2 ? (
|
|
|
+ {currentStep === 2 &&
|
|
|
<StepThree
|
|
|
onRef={stepThreeRef}
|
|
|
drawDataForm={drawDataForm}
|
|
|
loadDataForm={loadDataForm}
|
|
|
+ ruleForm={ruleForm}
|
|
|
/>
|
|
|
- ) : (
|
|
|
- ''
|
|
|
- )}
|
|
|
+ }
|
|
|
|
|
|
{/* 设置同步参数 */}
|
|
|
- {currentStep === 3 ? <StepFour syncDataForm={syncDataForm} /> : ''}
|
|
|
+ {currentStep === 3 && <StepFour syncDataForm={syncDataForm} />}
|
|
|
|
|
|
{/* 按扭操作 */}
|
|
|
{/* 表结构预览 */}
|
|
|
- {currentStep === 0 || currentStep === 1 ? (
|
|
|
+ {(currentStep === 0 || currentStep === 1 ) &&
|
|
|
<>
|
|
|
<Button
|
|
|
type="primary"
|
|
@@ -219,17 +244,12 @@ export default function SyncTaskAdd() {
|
|
|
width={600}
|
|
|
mask={false}
|
|
|
destroyOnClose={true}
|
|
|
- closeIcon={<MenuUnfoldOutlined style={{ color: '#1881DA' }} />}>
|
|
|
- {currentStep === 0 ? (
|
|
|
- <DataTableStruct formData={drawDataForm} />
|
|
|
- ) : (
|
|
|
- <DataTableStruct formData={loadDataForm} />
|
|
|
- )}
|
|
|
+ closeIcon={<MenuUnfoldOutlined style={{ color: '#1881DA' }} />}
|
|
|
+ >
|
|
|
+ <DataTableStruct formData={currentForm} tableData={currentStep === 0 ? drawDataStruct : loadDataStruct}/>
|
|
|
</Drawer>
|
|
|
</>
|
|
|
- ) : (
|
|
|
- ''
|
|
|
- )}
|
|
|
+ }
|
|
|
|
|
|
{/* 按扭操作 */}
|
|
|
<Space style={{ margin: '20px' }}>
|
|
@@ -237,7 +257,8 @@ export default function SyncTaskAdd() {
|
|
|
onClick={() => {
|
|
|
changeStep(-1)
|
|
|
}}
|
|
|
- disabled={currentStep === 0 || building}>
|
|
|
+ disabled={currentStep === 0 || building}
|
|
|
+ >
|
|
|
上一步
|
|
|
</Button>
|
|
|
{currentStep === 3 ? (
|