Commit 58042f38 authored by wenmo's avatar wenmo

元数据查看列

parent 0bb87154
...@@ -8,12 +8,20 @@ import {useState} from "react"; ...@@ -8,12 +8,20 @@ import {useState} from "react";
import styles from "./index.less"; import styles from "./index.less";
import { import {
ReloadOutlined, ReloadOutlined,
PlusOutlined, DatabaseOutlined,
DownOutlined DownOutlined,
TableOutlined, FireOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import React from "react"; import React from "react";
import {showMetaDataTable} from "@/components/Studio/StudioEvent/DDL"; import {showMetaDataTable} from "@/components/Studio/StudioEvent/DDL";
import { Scrollbars } from 'react-custom-scrollbars'; import { Scrollbars } from 'react-custom-scrollbars';
import {
ModalForm,
} from '@ant-design/pro-form';
import ProDescriptions from "@ant-design/pro-descriptions";
import StudioPreview from "@/components/Studio/StudioConsole/StudioPreview";
import Columns from "@/pages/DataBase/Columns";
import {TreeDataNode} from "@/components/Studio/StudioTree/Function";
const { DirectoryTree } = Tree; const { DirectoryTree } = Tree;
const {Option} = Select; const {Option} = Select;
...@@ -23,6 +31,8 @@ const StudioMetaData = (props: any) => { ...@@ -23,6 +31,8 @@ const StudioMetaData = (props: any) => {
const {database,toolHeight, dispatch} = props; const {database,toolHeight, dispatch} = props;
const [databaseId, setDataBaseId] = useState<number>(); const [databaseId, setDataBaseId] = useState<number>();
const [treeData, setTreeData] = useState<[]>([]); const [treeData, setTreeData] = useState<[]>([]);
const [modalVisit, setModalVisit] = useState(false);
const [row, setRow] = useState<TreeDataNode>();
const onRefreshTreeData = ()=>{ const onRefreshTreeData = ()=>{
if(!databaseId)return; if(!databaseId)return;
...@@ -30,15 +40,20 @@ const StudioMetaData = (props: any) => { ...@@ -30,15 +40,20 @@ const StudioMetaData = (props: any) => {
res.then((result) => { res.then((result) => {
let tables = result.datas; let tables = result.datas;
for(let i=0;i<tables.length;i++){ for(let i=0;i<tables.length;i++){
tables[i].title=tables[i].name;
tables[i].key=tables[i].name;
tables[i].icon = <DatabaseOutlined />;
tables[i].children=tables[i].tables; tables[i].children=tables[i].tables;
for(let j=0;j<tables[i].children.length;j++){ for(let j=0;j<tables[i].children.length;j++){
tables[i].children[j].title=tables[i].children[j].name; tables[i].children[j].title=tables[i].children[j].name;
tables[i].children[j].key=tables[i].children[j].name; tables[i].children[j].key=tables[i].name+'.'+tables[i].children[j].name;
tables[i].children[j].icon=<TableOutlined />;
tables[i].children[j].isLeaf=true;
tables[i].children[j].schema=tables[i].name;
tables[i].children[j].table=tables[i].children[j].name;
} }
tables[i].title=tables[i].name;
tables[i].key=tables[i].name;
} }
setTreeData(result.datas); setTreeData(tables);
}); });
}; };
...@@ -58,6 +73,14 @@ const StudioMetaData = (props: any) => { ...@@ -58,6 +73,14 @@ const StudioMetaData = (props: any) => {
return itemList; return itemList;
}; };
const openColumnInfo = (e: React.MouseEvent, node: TreeDataNode) => {
console.log(node);
if(node.isLeaf){
setRow(node);
setModalVisit(true);
}
}
return ( return (
<> <>
<Select <Select
...@@ -68,7 +91,7 @@ const StudioMetaData = (props: any) => { ...@@ -68,7 +91,7 @@ const StudioMetaData = (props: any) => {
> >
{getDataBaseOptions()} {getDataBaseOptions()}
</Select> </Select>
<Tooltip title="刷新元数据"> <Tooltip title="刷新元数据">
<Button <Button
type="text" type="text"
icon={<ReloadOutlined/>} icon={<ReloadOutlined/>}
...@@ -76,13 +99,39 @@ const StudioMetaData = (props: any) => { ...@@ -76,13 +99,39 @@ const StudioMetaData = (props: any) => {
/> />
</Tooltip> </Tooltip>
<Scrollbars style={{height: (toolHeight - 32)}}> <Scrollbars style={{height: (toolHeight - 32)}}>
{treeData.length>0?(
<DirectoryTree <DirectoryTree
multiple showIcon
switcherIcon={<DownOutlined/>} switcherIcon={<DownOutlined/>}
treeData={treeData} treeData={treeData}
height={400} onRightClick={({event, node}: any) => {
/> openColumnInfo(event, node)
}}
/>):(<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />)}
</Scrollbars> </Scrollbars>
<ModalForm
// title="新建表单"
title={ (row?(row.key)+'的':'')+'字段信息'}
visible={modalVisit}
onFinish={async () => {
// setRow(undefined);
// setModalVisit(false);
}}
modalProps={{
maskClosable:false
}}
onVisibleChange={setModalVisit}
submitter={{
submitButtonProps: {
style: {
display: 'none',
},
},
}}
>
{row?
(<Columns dbId={databaseId} schema={row.schema} table={row.table}/>) : (<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />)}
</ModalForm>
</> </>
); );
}; };
......
export type Column = {
name: string,
type: string,
comment: string,
keyFlag: boolean,
keyIdentityFlag: boolean,
fill: string,
isNotNull: string,
javaType: string,
columnFamily: string,
};
import React from "react"; import React from "react";
import { Button, Tooltip } from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import type { ProColumns } from '@ant-design/pro-table';
import ProTable, { TableDropdown } from '@ant-design/pro-table';
import { Column } from "./data";
import {getData, queryData} from "@/components/Common/crud";
const Columns: React.FC<{}> = (props: any) => {
return (<></>);
const Columns = (props: any) => {
const {dbId,table,schema} = props;
const columns: ProColumns<Column>[] = [
{
title: '列名',
dataIndex: 'name',
render: (_) => <a>{_}</a>,
/*formItemProps: {
lightProps: {
labelFormatter: (value) => `app-${value}`,
},
},*/
},
{
title: '注释',
dataIndex: 'comment',
},
{
title: '类型',
dataIndex: 'type',
},
{
title: '主键',
dataIndex: 'keyFlag',
},{
title: '自增',
dataIndex: 'keyIdentityFlag',
},{
title: '默认值',
dataIndex: 'fill',
},{
title: '非空',
dataIndex: 'isNotNull',
},{
title: 'Java 类型',
dataIndex: 'javaType',
},
/*{
title: '类型',
dataIndex: 'type',
valueType: 'select',
valueEnum: {
all: { text: '全部' },
付小小: { text: '付小小' },
曲丽丽: { text: '曲丽丽' },
林东东: { text: '林东东' },
陈帅帅: { text: '陈帅帅' },
兼某某: { text: '兼某某' },
},
},*/
/*{
title: '操作',
width: '164px',
key: 'option',
valueType: 'option',
render: () => [
<a key="link">链路</a>,
<a key="link2">报警</a>,
<a key="link3">监控</a>,
<TableDropdown
key="actionGroup"
menus={[
{ key: 'copy', name: '复制' },
{ key: 'delete', name: '删除' },
]}
/>,
],
},*/
];
return (
<ProTable<Column>
columns={columns}
style={{width: '100%'}}
request={async() =>
{
const msg = await getData('api/database/listColumns', {id:dbId,schemaName:schema,tableName:table});
return {
data: msg.datas,
success: msg.code===0,
};
}
}
rowKey="name"
pagination={{
pageSize: 10,
}}
search={{
filterType: 'light',
}}
/*toolBarRender={() => [
<Button key="show">查看日志</Button>,
<Button type="primary" key="primary">
创建应用
</Button>,
]}*/
/>
);
}; };
export default Columns; export default Columns;
...@@ -514,6 +514,9 @@ export default (): React.ReactNode => { ...@@ -514,6 +514,9 @@ export default (): React.ReactNode => {
<li> <li>
<Link>新增 Mysql,Oracle,PostGreSql,ClickHouse,Doris,Java 方言及图标</Link> <Link>新增 Mysql,Oracle,PostGreSql,ClickHouse,Doris,Java 方言及图标</Link>
</li> </li>
<li>
<Link>新增 元数据查看列信息</Link>
</li>
</ul> </ul>
</Paragraph> </Paragraph>
</Timeline.Item> </Timeline.Item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment