|
@@ -1,119 +1,128 @@
|
|
|
-import React, { useEffect, useState } from "react";
|
|
|
-import { Form, Select, Input } from "antd";
|
|
|
+import React, { useState, useMemo } from 'react'
|
|
|
+import { Form, Select, Input } from 'antd'
|
|
|
|
|
|
-const DATASOURCE_TYPE_MYSQL = 'mysql'
|
|
|
+export default function DrawFormConfig({ drawDataForm, dataSourceList }) {
|
|
|
+ const [datasourceType, setDatasourceType] = useState(null)
|
|
|
|
|
|
-export default function DrawFormConfig ({drawDataForm}) {
|
|
|
- const [datasourceType, setDatasourceType] = useState(DATASOURCE_TYPE_MYSQL)
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- if (drawDataForm.getFieldValue('datasource_name')) {
|
|
|
- setDatasourceType(drawDataForm.getFieldValue('datasource_name'))
|
|
|
- }
|
|
|
- }, [])
|
|
|
+ const datasources = useMemo(() => {
|
|
|
+ return dataSourceList.map(item => {
|
|
|
+ return {
|
|
|
+ label: item.datasource_name,
|
|
|
+ value: item.id,
|
|
|
+ key: item.id,
|
|
|
+ datasource: item.datasource,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }, [dataSourceList])
|
|
|
|
|
|
return (
|
|
|
<>
|
|
|
- <p style={{fontWeight: 600, borderLeft: '3px solid #1881DA', paddingLeft: '12px'}}>配置提取源</p>
|
|
|
- <Form
|
|
|
- name="drawForm"
|
|
|
- form={drawDataForm}
|
|
|
- labelCol={{
|
|
|
- span: 2,
|
|
|
- }}
|
|
|
- wrapperCol={{
|
|
|
- span: 6,
|
|
|
- }}
|
|
|
- initialValues={{
|
|
|
- datasource_name: DATASOURCE_TYPE_MYSQL
|
|
|
- }}
|
|
|
- >
|
|
|
- <Form.Item
|
|
|
- label="选择数据源"
|
|
|
- name="datasource_name"
|
|
|
- rules={[
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择数据源!',
|
|
|
- },
|
|
|
- ]}
|
|
|
- >
|
|
|
- <Select
|
|
|
- options={[
|
|
|
- {label: 'My SQL', value: 'mysql'},
|
|
|
- {label: 'hive', value: 'hive'}
|
|
|
- ]}
|
|
|
- onSelect={(val) => {setDatasourceType(val)}}
|
|
|
- allowClear
|
|
|
- />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="选择表"
|
|
|
- name="datasource_form"
|
|
|
- rules={[
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择表',
|
|
|
- },
|
|
|
- ]}
|
|
|
- >
|
|
|
- <Select options={[]} allowClear />
|
|
|
- </Form.Item>
|
|
|
- { datasourceType === 'mysql' ?
|
|
|
- <>
|
|
|
- <Form.Item label="查询字段" name="query_field" wrapperCol={{span: 10}}>
|
|
|
- <Input.TextArea rows={5}/>
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="切分主键" name="datasource_mainkey">
|
|
|
- <Select options={[]} allowClear />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="条件语句" name="centence" wrapperCol={{span: 10}}>
|
|
|
- <Input.TextArea rows={5}/>
|
|
|
- </Form.Item>
|
|
|
- </> : <>
|
|
|
- <Form.Item
|
|
|
- label="选择路径"
|
|
|
- name="dataRoute"
|
|
|
- wrapperCol={{span: 10}}
|
|
|
- rules={[
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择路径!',
|
|
|
- },
|
|
|
- ]}>
|
|
|
- <Input.TextArea rows={5}/>
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="HDFS"
|
|
|
- name="datasource_hdfs"
|
|
|
- rules={[
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入HDFS',
|
|
|
- },
|
|
|
- ]}
|
|
|
- >
|
|
|
- <Input placeholder="hdfs namenode节点地址" />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item
|
|
|
- label="选择表"
|
|
|
- name="file_type"
|
|
|
- rules={[
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择文件类型',
|
|
|
- },
|
|
|
- ]}
|
|
|
- >
|
|
|
- <Select options={[]} allowClear placeholder="文件的类型" />
|
|
|
- </Form.Item>
|
|
|
- <Form.Item label="分隔符" name="datasource_partition">
|
|
|
- <Input placeholder="读取字段的分隔符" />
|
|
|
- </Form.Item>
|
|
|
- </>
|
|
|
- }
|
|
|
-
|
|
|
- </Form>
|
|
|
+ <p
|
|
|
+ style={{
|
|
|
+ fontWeight: 600,
|
|
|
+ borderLeft: '3px solid #1881DA',
|
|
|
+ paddingLeft: '12px',
|
|
|
+ }}>
|
|
|
+ 配置提取源
|
|
|
+ </p>
|
|
|
+ <Form
|
|
|
+ name="drawForm"
|
|
|
+ form={drawDataForm}
|
|
|
+ labelCol={{
|
|
|
+ span: 2,
|
|
|
+ }}
|
|
|
+ wrapperCol={{
|
|
|
+ span: 6,
|
|
|
+ }}>
|
|
|
+ <Form.Item
|
|
|
+ label="选择数据源"
|
|
|
+ name="datasource_name"
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请选择数据源!',
|
|
|
+ },
|
|
|
+ ]}>
|
|
|
+ <Select
|
|
|
+ options={datasources}
|
|
|
+ onSelect={val => {
|
|
|
+ console.log(val)
|
|
|
+ setDatasourceType(val)
|
|
|
+ }}
|
|
|
+ allowClear
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="选择表"
|
|
|
+ name="datasource_form"
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请选择表',
|
|
|
+ },
|
|
|
+ ]}>
|
|
|
+ <Select options={[]} allowClear />
|
|
|
+ </Form.Item>
|
|
|
+ {datasourceType === 'mysql' ? (
|
|
|
+ <>
|
|
|
+ <Form.Item
|
|
|
+ label="查询字段"
|
|
|
+ name="query_field"
|
|
|
+ wrapperCol={{ span: 10 }}>
|
|
|
+ <Input.TextArea rows={5} />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="切分主键" name="datasource_mainkey">
|
|
|
+ <Select options={[]} allowClear />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="条件语句"
|
|
|
+ name="centence"
|
|
|
+ wrapperCol={{ span: 10 }}>
|
|
|
+ <Input.TextArea rows={5} />
|
|
|
+ </Form.Item>
|
|
|
+ </>
|
|
|
+ ) : (
|
|
|
+ <>
|
|
|
+ <Form.Item
|
|
|
+ label="选择路径"
|
|
|
+ name="dataRoute"
|
|
|
+ wrapperCol={{ span: 10 }}
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请选择路径!',
|
|
|
+ },
|
|
|
+ ]}>
|
|
|
+ <Input.TextArea rows={5} />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="HDFS"
|
|
|
+ name="datasource_hdfs"
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请输入HDFS',
|
|
|
+ },
|
|
|
+ ]}>
|
|
|
+ <Input placeholder="hdfs namenode节点地址" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item
|
|
|
+ label="选择表"
|
|
|
+ name="file_type"
|
|
|
+ rules={[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请选择文件类型',
|
|
|
+ },
|
|
|
+ ]}>
|
|
|
+ <Select options={[]} allowClear placeholder="文件的类型" />
|
|
|
+ </Form.Item>
|
|
|
+ <Form.Item label="分隔符" name="datasource_partition">
|
|
|
+ <Input placeholder="读取字段的分隔符" />
|
|
|
+ </Form.Item>
|
|
|
+ </>
|
|
|
+ )}
|
|
|
+ </Form>
|
|
|
</>
|
|
|
)
|
|
|
-}
|
|
|
+}
|