Merge branch 'dev' of gitea.51mars.com:Oak-Team/oak-frontend-base into dev
This commit is contained in:
commit
98d9ce36d0
|
|
@ -12,7 +12,7 @@ import ActionBtn from '../actionBtn';
|
|||
import TableCell from './renderCell';
|
||||
import { TableContext } from '../listPro';
|
||||
import Style from './web.module.less';
|
||||
|
||||
import { useFeatures } from '../../platforms/web';
|
||||
|
||||
export default function Render(
|
||||
props: WebComponentProps<
|
||||
|
|
@ -44,6 +44,7 @@ export default function Render(
|
|||
scroll?: TableProps<RowWithActions<ED, keyof ED>>['scroll'];
|
||||
locale?: TableProps<RowWithActions<ED, keyof ED>>['locale'];
|
||||
opWidth?: number;
|
||||
oakPath?: string;
|
||||
},
|
||||
{
|
||||
getColor: (attr: string, value: any) => `#${string}` | undefined;
|
||||
|
|
@ -71,6 +72,7 @@ export default function Render(
|
|||
scroll,
|
||||
locale,
|
||||
opWidth,
|
||||
oakPath,
|
||||
} = oakData;
|
||||
const [tableColumns, setTableColumns] = useState([] as ColumnsType<any>);
|
||||
const { tableAttributes, setSchema } = useContext(TableContext);
|
||||
|
|
@ -176,7 +178,7 @@ export default function Render(
|
|||
return column;
|
||||
}
|
||||
);
|
||||
if (!disableSerialNumber && tablePagination) {
|
||||
if (!disableSerialNumber) {
|
||||
// 存在分页配置 启用#序号
|
||||
tableColumns.unshift({
|
||||
fixed: 'left',
|
||||
|
|
@ -229,6 +231,11 @@ export default function Render(
|
|||
setTableColumns(tableColumns);
|
||||
}
|
||||
}, [data, zhCNKeys, schema, tableAttributes]);
|
||||
const features = useFeatures<{
|
||||
runningTree: any;
|
||||
// locales: Locales<any, any, any, any>;
|
||||
}>();
|
||||
const pagination = oakPath && features.runningTree.getPagination(oakPath);
|
||||
return (
|
||||
<Table
|
||||
rowKey="id"
|
||||
|
|
@ -248,10 +255,10 @@ export default function Render(
|
|||
dataSource={
|
||||
!disableSerialNumber
|
||||
? data?.map((ele, index) => {
|
||||
if (tablePagination) {
|
||||
const total = tablePagination.total || 0;
|
||||
const pageSize = tablePagination.pageSize || 20; //条数
|
||||
const current = tablePagination.current || 1; //当前页
|
||||
if (pagination) {
|
||||
const total = pagination.total || 0;
|
||||
const pageSize = pagination.pageSize || 20; //条数
|
||||
const current = pagination.current || 1; //当前页
|
||||
(ele as any)['#'] =
|
||||
pageSize * (current - 1) + (index + 1);
|
||||
}
|
||||
|
|
@ -260,7 +267,7 @@ export default function Render(
|
|||
: data
|
||||
}
|
||||
columns={tableColumns}
|
||||
pagination={tablePagination}
|
||||
pagination={false}
|
||||
locale={locale}
|
||||
scroll={
|
||||
data?.length > 0
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ import ToolBar from '../list/toolBar';
|
|||
import ButtonGroup from '../list/buttonGroup';
|
||||
import Style from './index.module.less';
|
||||
import { useWidth } from '../../platforms/web/responsive/useWidth';
|
||||
|
||||
import { useFeatures } from '../../platforms/web';
|
||||
import { Locales } from '../../features/locales';
|
||||
import Pagination from '../pagination';
|
||||
import { assert } from 'oak-domain/lib/utils/assert';
|
||||
type Props<ED2 extends ED, T extends keyof ED2> = {
|
||||
title?: string | React.ReactNode;
|
||||
extraContent?: React.ReactNode;
|
||||
|
|
@ -32,13 +35,14 @@ type Props<ED2 extends ED, T extends keyof ED2> = {
|
|||
attributes: OakAbsAttrDef[];
|
||||
data: RowWithActions<ED2, T>[];
|
||||
loading?: boolean;
|
||||
tablePagination?: TableProps<RowWithActions<ED2, T>>['pagination'];
|
||||
tablePagination?: React.ReactNode;
|
||||
rowSelection?: TableProps<RowWithActions<ED2, T>>['rowSelection'];
|
||||
disableSerialNumber?: boolean; //是否禁用序号 默认启用
|
||||
size?: 'large' | 'middle' | 'small';
|
||||
scroll?: TableProps<RowWithActions<ED2, T>>['scroll'];
|
||||
locale?: TableProps<RowWithActions<ED2, T>>['locale'];
|
||||
opWidth?: number;
|
||||
oakPath?: string;
|
||||
};
|
||||
|
||||
export type TableAttributeType = {
|
||||
|
|
@ -87,11 +91,17 @@ const ProList = <ED2 extends ED, T extends keyof ED2>(props: Props<ED2, T>) => {
|
|||
scroll,
|
||||
locale,
|
||||
opWidth,
|
||||
oakPath,
|
||||
} = props;
|
||||
|
||||
assert(tablePagination);
|
||||
const [tableAttributes, setTableAttributes] = useState<
|
||||
TableAttributeType[]
|
||||
>([]);
|
||||
const features = useFeatures<{
|
||||
runningTree: any;
|
||||
// locales: Locales<any, any, any, any>;
|
||||
}>();
|
||||
// const pagination = oakPath && features.runningTree.getPagination(oakPath);
|
||||
const [schema, setSchema] = useState(undefined);
|
||||
const width = useWidth();
|
||||
const isMobile = width === 'xs';
|
||||
|
|
@ -135,7 +145,9 @@ const ProList = <ED2 extends ED, T extends keyof ED2>(props: Props<ED2, T>) => {
|
|||
title={title}
|
||||
extraContent={extraContent}
|
||||
buttonGroup={buttonGroup}
|
||||
reload={onReload}
|
||||
reload={() => {
|
||||
onReload ? onReload() : features.runningTree.refresh(oakPath);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isMobile && <ButtonGroup items={buttonGroup} />}
|
||||
|
|
@ -150,11 +162,35 @@ const ProList = <ED2 extends ED, T extends keyof ED2>(props: Props<ED2, T>) => {
|
|||
data={data}
|
||||
loading={loading}
|
||||
size={size}
|
||||
tablePagination={tablePagination}
|
||||
// tablePagination={tablePagination}
|
||||
rowSelection={rowSelection}
|
||||
disableSerialNumber={disableSerialNumber}
|
||||
opWidth={opWidth}
|
||||
oakPath={oakPath}
|
||||
/>
|
||||
{
|
||||
tablePagination ? (
|
||||
<div>
|
||||
{tablePagination}
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
{
|
||||
oakPath && (
|
||||
<div style={{ display: 'flex', flexDirection: 'row-reverse', alignItems: 'center' }}>
|
||||
<Pagination
|
||||
oakPath={oakPath}
|
||||
entity={entity as string}
|
||||
oakAutoUnmount={true}
|
||||
showQuickJumper={true}
|
||||
/>
|
||||
{/* <div>{`${features.locales.t('total number of rows')}:${pagination.total > 999 ? `${pagination.total} +` : pagination.total}`}</div> */}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</TableContext.Provider>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -99,6 +99,7 @@ export default function Render(
|
|||
responsive={responsive}
|
||||
role={role}
|
||||
totalBoundaryShowSizeChanger={totalBoundaryShowSizeChanger}
|
||||
showSizeChanger={true}
|
||||
rootClassName={rootClassName}
|
||||
showTotal={showTotal}
|
||||
onShowSizeChange={(current: number, pageSize: number) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue