0.0.30 • Published 10 months ago
@gingkoo/pandora-metabase v0.0.30
Pandora-Metabase 使用指南
功能概述
Pandora-Metabase 是一个用于动态生成 SQL 查询的工具库,支持通过可视化界面配置表结构、字段及查询逻辑。
主要功能
- 动态获取表字段:使用
getColumns方法可以动态获取指定表的最新字段信息。 - 可视化 SQL 构建:通过
MetaBase组件,用户能够以图形化的方式构建 SQL 查询,支持多种元数据类型,如MetaData,MetaJoin,MetaFilter等。 - 灵活扩展:提供了丰富的接口和类型定义,便于根据具体需求进行定制和扩展。
类型定义
export type MetaListType =
| MetaData
| MetaJoin
| MetaCustom
| MetaFilter
| MetaSummarize
| MetaSort
| MetaLimit;
// Columns 集合
export interface MetaData_ColumnsType {
name: string; // 字段名
name_zh: string; // 字段中文名称
database_type: SQL_COLUMN_TYPE | string; // 数据库中的字段类型
special_type: SpecialType | string; // 特殊类型,如主键、外键等
select: boolean; // 是否在查询中选中该字段
}
export type ToolbarType =
| 'filter'
| 'summarize'
| 'joinData'
| 'permissionTable'
| 'customColumn'
| 'sort'
| 'rowLimit';
export interface MetaBaseProps {
loading?: boolean; // 加载状态
btnText?: string; //按钮文字
showFields?:boolean ; //是否显示字段
tableNameTpl?: string; //表名
fieldNameTpl?: string; //字段名
/**
* 工具栏列表
* 默认 ['filter','summarize','joinData','permissionTable','customColumn','sort','rowLimit']
*/
toolbar?:ToolbarType[]|false;
readonly?: boolean; //是否只读
getTables: (datasourceId: string) => Promise<any>; //获取表
getColumns: (table: string, datasourceId: string) => Promise<any>;//获取数据源
onOk: (params: any) => Promise<void>;
}
export interface SqlVisionBuilderRef {
setDatasource: (list: DatasourceType[]) => void; // 设置数据源列表
setPreData: (data: MetaListType[]) => void; // 设置回显数据
reset: () => void; // 重置到上次设置的数据
}代码示例
const [table, setTable] = useState([]);
const [value, setValue] = useState<MetaListType[]>([]);
<MetaBase
value={value}
showFields={false}
toolbar={[
'filter',
'summarize',
'joinData',
'permissionTable',
'customColumn',
'sort',
'rowLimit',
]}
getTables={async (id: string) => {
let tables = [
'YBT_PM_BHJQTDBXY',
];
return tables.map((item) => {
return {
name: item,
alias: item,
};
});
}}
getColumns={async (name: string) => {
let data: MetaData_ColumnsType[] = [
{
database_type: 'STRING',
name: 'C_RSV5',
select: true,
special_type: '',
name_zh: '备用字段(项目组可使用)',
},
];
return data;
}}
onOk={(v) => {
console.log(v);
}}
/>0.0.30
10 months ago
0.0.29
10 months ago
0.0.28
10 months ago
0.0.27
10 months ago
0.0.26
10 months ago
0.0.25
10 months ago
0.0.24
10 months ago
0.0.23
10 months ago
0.0.22
10 months ago
0.0.21
10 months ago
0.0.20
10 months ago
0.0.19
10 months ago
0.0.18
10 months ago
0.0.17
10 months ago
0.0.16
10 months ago
0.0.15
10 months ago
0.0.14
10 months ago
0.0.13
10 months ago
0.0.12
10 months ago
0.0.1-alpha.18
10 months ago
0.0.1-alpha.17
11 months ago
0.0.1-alpha.16
11 months ago
0.0.1-alpha.15
11 months ago
0.0.1-alpha.14
11 months ago
0.0.1-alpha.13
11 months ago
0.0.1-alpha.12
11 months ago
0.0.1-alpha.11
12 months ago
0.0.1-alpha.10
12 months ago
0.0.1-alpha.9
12 months ago
0.0.1-alpha.8
12 months ago
0.0.1-alpha.7
12 months ago
0.0.1-alpha.6
12 months ago
0.0.1-alpha.5
12 months ago
0.0.1-alpha.4
12 months ago
0.0.1-alpha.3
12 months ago
0.0.1-alpha.2
12 months ago
0.0.1-alpha.1
12 months ago