0.0.30 • Published 6 months ago

@gingkoo/pandora-metabase v0.0.30

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

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

6 months ago

0.0.29

6 months ago

0.0.28

6 months ago

0.0.27

6 months ago

0.0.26

6 months ago

0.0.25

6 months ago

0.0.24

6 months ago

0.0.23

6 months ago

0.0.22

6 months ago

0.0.21

6 months ago

0.0.20

6 months ago

0.0.19

6 months ago

0.0.18

6 months ago

0.0.17

6 months ago

0.0.16

6 months ago

0.0.15

6 months ago

0.0.14

6 months ago

0.0.13

6 months ago

0.0.12

6 months ago

0.0.1-alpha.18

6 months ago

0.0.1-alpha.17

7 months ago

0.0.1-alpha.16

7 months ago

0.0.1-alpha.15

7 months ago

0.0.1-alpha.14

7 months ago

0.0.1-alpha.13

7 months ago

0.0.1-alpha.12

8 months ago

0.0.1-alpha.11

8 months ago

0.0.1-alpha.10

8 months ago

0.0.1-alpha.9

8 months ago

0.0.1-alpha.8

8 months ago

0.0.1-alpha.7

8 months ago

0.0.1-alpha.6

8 months ago

0.0.1-alpha.5

8 months ago

0.0.1-alpha.4

8 months ago

0.0.1-alpha.3

8 months ago

0.0.1-alpha.2

8 months ago

0.0.1-alpha.1

8 months ago