支持列 align属性
This commit is contained in:
parent
c96753b6ad
commit
c703fefafb
|
|
@ -36,12 +36,13 @@ export default function Render(props) {
|
|||
const title = getLabel(ele.attribute, ele.entity, ele.attr, t);
|
||||
const width = getWidth(ele.attribute, ele.attrType);
|
||||
const type = getType(ele.attribute, ele.attrType);
|
||||
const align = getAlign(ele.attrType);
|
||||
const align = getAlign(ele.attribute);
|
||||
const fixed = getFixed(ele.attribute);
|
||||
const column = {
|
||||
key: ele.path,
|
||||
title,
|
||||
align,
|
||||
fixed: getFixed(ele.attribute),
|
||||
fixed,
|
||||
render: (v, row) => {
|
||||
if (typeof ele.attribute !== 'string' &&
|
||||
ele.attribute.render) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
/// <reference types="react" />
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { DataType, DataTypeParams } from 'oak-domain/lib/types/schema/DataTypes';
|
||||
import { ButtonProps } from 'antd';
|
||||
import { ActionDef } from './Page';
|
||||
export type ED = BaseEntityDict & EntityDict;
|
||||
export type RenderWidth = 1 | 2 | 3 | 4;
|
||||
export type RenderAlign = 'left' | 'right' | 'center';
|
||||
export type RenderFixed = 'left' | 'right';
|
||||
export type OakActionBtnProps = {
|
||||
label: string;
|
||||
action: string;
|
||||
|
|
@ -28,10 +32,11 @@ export type OakAbsDerivedAttrDef = {
|
|||
label: string;
|
||||
width?: number;
|
||||
span?: number;
|
||||
type?: 'image' | 'link' | DataType | 'ref';
|
||||
type?: 'image' | 'link' | 'ref' | DataType;
|
||||
linkUrl?: string;
|
||||
render?: (row: any) => React.ReactNode | undefined;
|
||||
fixed?: 'right' | 'left';
|
||||
render?: (row: any) => React.ReactNode;
|
||||
fixed?: RenderFixed;
|
||||
align?: RenderAlign;
|
||||
};
|
||||
export type OakAbsAttrDef = string | OakAbsDerivedAttrDef;
|
||||
export type OakAbsAttrJudgeDef = {
|
||||
|
|
@ -46,20 +51,20 @@ export type CardDef = {
|
|||
state?: string | React.ReactNode;
|
||||
rows: OakAbsAttrDef[];
|
||||
};
|
||||
export interface OakAbsRefAttrPickerDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED> {
|
||||
export interface OakAbsRefAttrPickerDef<ED2 extends ED, T extends keyof ED2> {
|
||||
type: 'ref';
|
||||
mode: 'select' | 'list' | 'radio';
|
||||
attr: string;
|
||||
entity: T;
|
||||
projection: ED[T]['Selection']['data'];
|
||||
title: (row: Partial<ED[T]['Schema']>) => string;
|
||||
projection: ED2[T]['Selection']['data'];
|
||||
title: (row: Partial<ED2[T]['Schema']>) => string;
|
||||
titleLabel?: string;
|
||||
filter?: ED[T]['Selection']['filter'];
|
||||
sorter?: ED[T]['Selection']['sorter'];
|
||||
filter?: ED2[T]['Selection']['filter'];
|
||||
sorter?: ED2[T]['Selection']['sorter'];
|
||||
getDynamicSelectors?: () => Promise<{
|
||||
filter?: ED[T]['Selection']['filter'];
|
||||
sorter?: ED[T]['Selection']['sorter'];
|
||||
projection?: ED[T]['Selection']['data'];
|
||||
filter?: ED2[T]['Selection']['filter'];
|
||||
sorter?: ED2[T]['Selection']['sorter'];
|
||||
projection?: ED2[T]['Selection']['data'];
|
||||
}>;
|
||||
count?: number;
|
||||
label?: string;
|
||||
|
|
@ -92,7 +97,6 @@ export interface OakAbsNativeAttrUpsertDef<ED extends EntityDict & BaseEntityDic
|
|||
allowNull?: boolean;
|
||||
}
|
||||
export type OakAbsAttrUpsertDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED, T2 extends keyof ED = keyof ED> = OakAbsGeoAttrUpsertDef | OakAbsRefAttrPickerDef<ED, T2> | keyof ED[T]['OpSchema'] | OakAbsNativeAttrUpsertDef<ED, T, keyof ED[T]['OpSchema']>;
|
||||
import { DataType, DataTypeParams } from 'oak-domain/lib/types/schema/DataTypes';
|
||||
export type AttrRender = {
|
||||
label: string;
|
||||
value: any;
|
||||
|
|
@ -124,7 +128,6 @@ export type ColumnDefProps = {
|
|||
export type DataTransformer = (data: object) => AttrRender[];
|
||||
export type DataUpsertTransformer<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = (data: object) => AttrUpsertRender<ED, T>[];
|
||||
export type DataConverter = (data: any[]) => Record<string, any>;
|
||||
export type ED = BaseEntityDict & EntityDict;
|
||||
export type CascadeActionProps = {
|
||||
path: string;
|
||||
action: string;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export declare function getPath(attribute: OakAbsAttrDef): string;
|
|||
export declare function getLabel<ED extends EntityDict & BaseEntityDict>(attribute: OakAbsAttrDef, entity: keyof ED, attr: string, t: (k: string, params?: object) => string): string;
|
||||
export declare function getWidth(attribute: OakAbsAttrDef, attrType: DataType | 'ref' | undefined): number | undefined;
|
||||
export declare function getValue<ED extends EntityDict & BaseEntityDict>(data: any, path: string, entity: keyof ED, attr: string, attrType: DataType | 'ref' | undefined, t: (k: string, params?: object) => string): any;
|
||||
export declare function getAlign(attrType: DataType): 'left' | 'right' | 'center';
|
||||
export declare function getAlign(attribute: OakAbsAttrDef): 'left' | 'right' | 'center';
|
||||
export declare function getFixed(attribute: OakAbsAttrDef): 'left' | 'right' | undefined;
|
||||
export declare function getType(attribute: OakAbsAttrDef, attrType: OakAbsDerivedAttrDef['type']): "link" | "ref" | DataType | undefined;
|
||||
export declare function makeDataTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: keyof ED, attrDefs: OakAbsAttrDef[], t: (k: string, params?: object) => string, colorDict?: ColorDict<ED>): DataTransformer;
|
||||
|
|
|
|||
|
|
@ -156,18 +156,8 @@ export function getValue(data, path, entity, attr, attrType, t) {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
export function getAlign(attrType) {
|
||||
const rightType = [
|
||||
'float',
|
||||
'int',
|
||||
'bigint',
|
||||
'decimal',
|
||||
'money',
|
||||
];
|
||||
if (rightType.includes(attrType)) {
|
||||
return 'right';
|
||||
}
|
||||
return 'left';
|
||||
export function getAlign(attribute) {
|
||||
return isAttributeType(attribute).align || 'left';
|
||||
}
|
||||
export function getFixed(attribute) {
|
||||
return isAttributeType(attribute).fixed;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,13 @@
|
|||
/// <reference types="react" />
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { DataType, DataTypeParams } from 'oak-domain/lib/types/schema/DataTypes';
|
||||
import { ButtonProps } from 'antd';
|
||||
import { ActionDef } from './Page';
|
||||
export type ED = BaseEntityDict & EntityDict;
|
||||
export type RenderWidth = 1 | 2 | 3 | 4;
|
||||
export type RenderAlign = 'left' | 'right' | 'center';
|
||||
export type RenderFixed = 'left' | 'right';
|
||||
export type OakActionBtnProps = {
|
||||
label: string;
|
||||
action: string;
|
||||
|
|
@ -28,10 +32,11 @@ export type OakAbsDerivedAttrDef = {
|
|||
label: string;
|
||||
width?: number;
|
||||
span?: number;
|
||||
type?: 'image' | 'link' | DataType | 'ref';
|
||||
type?: 'image' | 'link' | 'ref' | DataType;
|
||||
linkUrl?: string;
|
||||
render?: (row: any) => React.ReactNode | undefined;
|
||||
fixed?: 'right' | 'left';
|
||||
render?: (row: any) => React.ReactNode;
|
||||
fixed?: RenderFixed;
|
||||
align?: RenderAlign;
|
||||
};
|
||||
export type OakAbsAttrDef = string | OakAbsDerivedAttrDef;
|
||||
export type OakAbsAttrJudgeDef = {
|
||||
|
|
@ -46,20 +51,20 @@ export type CardDef = {
|
|||
state?: string | React.ReactNode;
|
||||
rows: OakAbsAttrDef[];
|
||||
};
|
||||
export interface OakAbsRefAttrPickerDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED> {
|
||||
export interface OakAbsRefAttrPickerDef<ED2 extends ED, T extends keyof ED2> {
|
||||
type: 'ref';
|
||||
mode: 'select' | 'list' | 'radio';
|
||||
attr: string;
|
||||
entity: T;
|
||||
projection: ED[T]['Selection']['data'];
|
||||
title: (row: Partial<ED[T]['Schema']>) => string;
|
||||
projection: ED2[T]['Selection']['data'];
|
||||
title: (row: Partial<ED2[T]['Schema']>) => string;
|
||||
titleLabel?: string;
|
||||
filter?: ED[T]['Selection']['filter'];
|
||||
sorter?: ED[T]['Selection']['sorter'];
|
||||
filter?: ED2[T]['Selection']['filter'];
|
||||
sorter?: ED2[T]['Selection']['sorter'];
|
||||
getDynamicSelectors?: () => Promise<{
|
||||
filter?: ED[T]['Selection']['filter'];
|
||||
sorter?: ED[T]['Selection']['sorter'];
|
||||
projection?: ED[T]['Selection']['data'];
|
||||
filter?: ED2[T]['Selection']['filter'];
|
||||
sorter?: ED2[T]['Selection']['sorter'];
|
||||
projection?: ED2[T]['Selection']['data'];
|
||||
}>;
|
||||
count?: number;
|
||||
label?: string;
|
||||
|
|
@ -92,7 +97,6 @@ export interface OakAbsNativeAttrUpsertDef<ED extends EntityDict & BaseEntityDic
|
|||
allowNull?: boolean;
|
||||
}
|
||||
export type OakAbsAttrUpsertDef<ED extends EntityDict & BaseEntityDict, T extends keyof ED, T2 extends keyof ED = keyof ED> = OakAbsGeoAttrUpsertDef | OakAbsRefAttrPickerDef<ED, T2> | keyof ED[T]['OpSchema'] | OakAbsNativeAttrUpsertDef<ED, T, keyof ED[T]['OpSchema']>;
|
||||
import { DataType, DataTypeParams } from 'oak-domain/lib/types/schema/DataTypes';
|
||||
export type AttrRender = {
|
||||
label: string;
|
||||
value: any;
|
||||
|
|
@ -124,7 +128,6 @@ export type ColumnDefProps = {
|
|||
export type DataTransformer = (data: object) => AttrRender[];
|
||||
export type DataUpsertTransformer<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = (data: object) => AttrUpsertRender<ED, T>[];
|
||||
export type DataConverter = (data: any[]) => Record<string, any>;
|
||||
export type ED = BaseEntityDict & EntityDict;
|
||||
export type CascadeActionProps = {
|
||||
path: string;
|
||||
action: string;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export declare function getPath(attribute: OakAbsAttrDef): string;
|
|||
export declare function getLabel<ED extends EntityDict & BaseEntityDict>(attribute: OakAbsAttrDef, entity: keyof ED, attr: string, t: (k: string, params?: object) => string): string;
|
||||
export declare function getWidth(attribute: OakAbsAttrDef, attrType: DataType | 'ref' | undefined): number | undefined;
|
||||
export declare function getValue<ED extends EntityDict & BaseEntityDict>(data: any, path: string, entity: keyof ED, attr: string, attrType: DataType | 'ref' | undefined, t: (k: string, params?: object) => string): any;
|
||||
export declare function getAlign(attrType: DataType): 'left' | 'right' | 'center';
|
||||
export declare function getAlign(attribute: OakAbsAttrDef): 'left' | 'right' | 'center';
|
||||
export declare function getFixed(attribute: OakAbsAttrDef): 'left' | 'right' | undefined;
|
||||
export declare function getType(attribute: OakAbsAttrDef, attrType: OakAbsDerivedAttrDef['type']): "link" | "ref" | DataType | undefined;
|
||||
export declare function makeDataTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: keyof ED, attrDefs: OakAbsAttrDef[], t: (k: string, params?: object) => string, colorDict?: ColorDict<ED>): DataTransformer;
|
||||
|
|
|
|||
|
|
@ -167,18 +167,8 @@ function getValue(data, path, entity, attr, attrType, t) {
|
|||
return value;
|
||||
}
|
||||
exports.getValue = getValue;
|
||||
function getAlign(attrType) {
|
||||
const rightType = [
|
||||
'float',
|
||||
'int',
|
||||
'bigint',
|
||||
'decimal',
|
||||
'money',
|
||||
];
|
||||
if (rightType.includes(attrType)) {
|
||||
return 'right';
|
||||
}
|
||||
return 'left';
|
||||
function getAlign(attribute) {
|
||||
return isAttributeType(attribute).align || 'left';
|
||||
}
|
||||
exports.getAlign = getAlign;
|
||||
function getFixed(attribute) {
|
||||
|
|
|
|||
|
|
@ -106,12 +106,13 @@ export default function Render(
|
|||
);
|
||||
const width = getWidth(ele.attribute, ele.attrType);
|
||||
const type = getType(ele.attribute, ele.attrType);
|
||||
const align = getAlign(ele.attrType as DataType);
|
||||
const align = getAlign(ele.attribute);
|
||||
const fixed = getFixed(ele.attribute);
|
||||
const column: ColumnType<any> = {
|
||||
key: ele.path,
|
||||
title,
|
||||
align,
|
||||
fixed: getFixed(ele.attribute),
|
||||
fixed,
|
||||
render: (v: string, row: any) => {
|
||||
if (
|
||||
typeof ele.attribute !== 'string' &&
|
||||
|
|
|
|||
|
|
@ -1,10 +1,17 @@
|
|||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import {
|
||||
DataType,
|
||||
DataTypeParams,
|
||||
} from 'oak-domain/lib/types/schema/DataTypes';
|
||||
// @ts-ignore
|
||||
import { ButtonProps } from 'antd';
|
||||
import { ActionDef } from './Page'
|
||||
import { ActionDef, RowWithActions } from './Page'
|
||||
|
||||
export type ED = BaseEntityDict & EntityDict;
|
||||
export type RenderWidth = 1 | 2 | 3 | 4;
|
||||
export type RenderAlign = 'left' | 'right' | 'center';
|
||||
export type RenderFixed = 'left' | 'right';
|
||||
|
||||
export type OakActionBtnProps = {
|
||||
label: string;
|
||||
|
|
@ -34,10 +41,11 @@ export type OakAbsDerivedAttrDef = {
|
|||
label: string;
|
||||
width?: number;
|
||||
span?: number;
|
||||
type?: 'image' | 'link' | DataType | 'ref';
|
||||
type?: 'image' | 'link' | 'ref' | DataType;
|
||||
linkUrl?: string;
|
||||
render?: (row: any) => React.ReactNode | undefined;
|
||||
fixed?: 'right' | 'left';
|
||||
render?: (row: any) => React.ReactNode;
|
||||
fixed?: RenderFixed;
|
||||
align?: RenderAlign;
|
||||
};
|
||||
|
||||
export type OakAbsAttrDef = string | OakAbsDerivedAttrDef;
|
||||
|
|
@ -58,22 +66,22 @@ export type CardDef = {
|
|||
};
|
||||
|
||||
export interface OakAbsRefAttrPickerDef<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
T extends keyof ED
|
||||
ED2 extends ED,
|
||||
T extends keyof ED2
|
||||
> {
|
||||
type: 'ref';
|
||||
mode: 'select' | 'list' | 'radio';
|
||||
attr: string;
|
||||
entity: T;
|
||||
projection: ED[T]['Selection']['data'];
|
||||
title: (row: Partial<ED[T]['Schema']>) => string;
|
||||
projection: ED2[T]['Selection']['data'];
|
||||
title: (row: Partial<ED2[T]['Schema']>) => string;
|
||||
titleLabel?: string;
|
||||
filter?: ED[T]['Selection']['filter'];
|
||||
sorter?: ED[T]['Selection']['sorter'];
|
||||
filter?: ED2[T]['Selection']['filter'];
|
||||
sorter?: ED2[T]['Selection']['sorter'];
|
||||
getDynamicSelectors?: () => Promise<{
|
||||
filter?: ED[T]['Selection']['filter'];
|
||||
sorter?: ED[T]['Selection']['sorter'];
|
||||
projection?: ED[T]['Selection']['data'];
|
||||
filter?: ED2[T]['Selection']['filter'];
|
||||
sorter?: ED2[T]['Selection']['sorter'];
|
||||
projection?: ED2[T]['Selection']['data'];
|
||||
}>; // 这里主要是为了动态构造filter,当需要先选A再将A作为B的filter条件时经常出现
|
||||
count?: number;
|
||||
label?: string;
|
||||
|
|
@ -126,10 +134,7 @@ export type OakAbsAttrUpsertDef<
|
|||
| keyof ED[T]['OpSchema']
|
||||
| OakAbsNativeAttrUpsertDef<ED, T, keyof ED[T]['OpSchema']>;
|
||||
|
||||
import {
|
||||
DataType,
|
||||
DataTypeParams,
|
||||
} from 'oak-domain/lib/types/schema/DataTypes';
|
||||
|
||||
export type AttrRender = {
|
||||
label: string;
|
||||
value: any;
|
||||
|
|
@ -177,7 +182,6 @@ export type DataUpsertTransformer<
|
|||
|
||||
export type DataConverter = (data: any[]) => Record<string, any>;
|
||||
|
||||
export type ED = BaseEntityDict & EntityDict;
|
||||
|
||||
export type CascadeActionProps = {
|
||||
path: string;
|
||||
|
|
|
|||
|
|
@ -222,18 +222,8 @@ export function getValue<ED extends EntityDict & BaseEntityDict>(
|
|||
return value;
|
||||
}
|
||||
|
||||
export function getAlign(attrType: DataType): 'left' | 'right' | 'center' {
|
||||
const rightType: DataType[] = [
|
||||
'float',
|
||||
'int',
|
||||
'bigint',
|
||||
'decimal',
|
||||
'money',
|
||||
];
|
||||
if (rightType.includes(attrType)) {
|
||||
return 'right';
|
||||
}
|
||||
return 'left';
|
||||
export function getAlign(attribute: OakAbsAttrDef): 'left' | 'right' | 'center' {
|
||||
return isAttributeType(attribute).align || 'left';
|
||||
}
|
||||
|
||||
export function getFixed(attribute: OakAbsAttrDef): 'left' | 'right' | undefined {
|
||||
|
|
|
|||
Loading…
Reference in New Issue