Leo 2 years ago
parent
commit
af8265b21e

+ 23 - 1
src/module/datasource/component/DatasourceManage.jsx

@@ -13,7 +13,9 @@ import {
   Button,
   Select,
   Tabs,
+  Input,
 } from 'antd'
+import { SearchOutlined } from '@ant-design/icons'
 import DatasourceData from '../component/DatasourceData'
 import DatasourceEdit from '../component/DatasourceEdit'
 import {
@@ -45,6 +47,8 @@ const DatasourceManage = ({ dataType }, ref) => {
   // 初始化ailab列表数据
   const [ailabDataList, setAilabDataList] = useState([])
 
+  const [filterAilabDataList, setFilterAilabDataList] = useState([])
+
   const [lakeDataList, setLakeDataList] = useState([])
 
   // 表格Loading状态
@@ -119,6 +123,7 @@ const DatasourceManage = ({ dataType }, ref) => {
         }
       })
       setAilabDataList(list)
+      setFilterAilabDataList(list)
     } else {
       message.error(data.msg)
     }
@@ -578,6 +583,22 @@ const DatasourceManage = ({ dataType }, ref) => {
     </Button>
   )
 
+  const searchTable = e => {
+    const list = ailabDataList.filter(item =>
+      item.datatable_name.includes(e.target.value)
+    )
+    setFilterAilabDataList(list)
+  }
+
+  const searchTool = () => (
+    <Input
+      type="link"
+      style={{ width: '210px' }}
+      onChange={searchTable}
+      suffix={<SearchOutlined />}
+    />
+  )
+
   const shareTable = async () => {
     if (selectedProjects.length) {
       const parmas = {
@@ -645,7 +666,7 @@ const DatasourceManage = ({ dataType }, ref) => {
         <Table
           rowSelection={rowSelection}
           columns={ailab_columns}
-          dataSource={ailabDataList}
+          dataSource={filterAilabDataList}
           bordered
           loading={dataLoading}
           footer={
@@ -653,6 +674,7 @@ const DatasourceManage = ({ dataType }, ref) => {
               ? shareBtn
               : null
           }
+          title={searchTool}
         />
       )}
       {dataType === 'datalake' && (

+ 15 - 12
src/module/datasource/component/StepOne.jsx

@@ -35,7 +35,8 @@ export default function StepOne({
   useEffect(() => {
     const ds_id = drawDataForm.getFieldValue('datasource_name')
     const table_name = drawDataForm.getFieldValue('datasource_table')
-    setDsType(drawDataForm.getFieldValue('datasource_type'))
+    const ds_type = drawDataForm.getFieldValue('datasource_type')
+    selectDsType(ds_type)
     if (ds_id) {
       const type = dataSourceList.find(item => item.key === ds_id).datasource
       setDatasourceType(type)
@@ -257,17 +258,19 @@ export default function StepOne({
               ]}>
               <Input.TextArea rows={5} />
             </Form.Item>
-            <Form.Item
-              label="HDFS"
-              name="reader_default_fs"
-              rules={[
-                {
-                  required: true,
-                  message: '请输入HDFS',
-                },
-              ]}>
-              <Input placeholder="Hadoop hdfs文件系统namenode节点地址" />
-            </Form.Item>
+            {dsType === 'datasource' && (
+              <Form.Item
+                label="HDFS"
+                name="reader_default_fs"
+                rules={[
+                  {
+                    required: true,
+                    message: '请输入HDFS',
+                  },
+                ]}>
+                <Input placeholder="Hadoop hdfs文件系统namenode节点地址" />
+              </Form.Item>
+            )}
             <Form.Item
               label="文件类型"
               name="reader_file_type"

+ 15 - 11
src/module/datasource/component/StepTwo.jsx

@@ -36,6 +36,8 @@ export default function LoadFormConfig({
   useEffect(() => {
     const ds_id = loadDataForm.getFieldValue('datasource_name')
     const table_name = loadDataForm.getFieldValue('datasource_table')
+    const ds_type = loadDataForm.getFieldValue('datasource_type')
+    selectDsType(ds_type)
     if (ds_id) {
       const type = dataSourceList.find(item => item.key === ds_id).datasource
       setDatasourceType(type)
@@ -218,17 +220,19 @@ export default function LoadFormConfig({
               ]}>
               <Input.TextArea rows={5} placeholder="要读取的文件路径" />
             </Form.Item>
-            <Form.Item
-              label="HDFS"
-              name="writer_default_fs"
-              rules={[
-                {
-                  required: true,
-                  message: '请输入HDFS',
-                },
-              ]}>
-              <Input placeholder="Hadoop hdfs文件系统namenode节点地址" />
-            </Form.Item>
+            {dsType === 'datasource' && (
+              <Form.Item
+                label="HDFS"
+                name="writer_default_fs"
+                rules={[
+                  {
+                    required: true,
+                    message: '请输入HDFS',
+                  },
+                ]}>
+                <Input placeholder="Hadoop hdfs文件系统namenode节点地址" />
+              </Form.Item>
+            )}
             <Form.Item
               label="写入文件名"
               name="writer_filename"