|
|
@@ -1,5 +1,5 @@
|
|
|
import { useIntl } from '@@/plugin-locale/localeExports';
|
|
|
-import { Button, Tooltip } from 'antd';
|
|
|
+import { Button, Card, Tooltip } from 'antd';
|
|
|
import type { ActionType, ProColumns, RequestData } from '@jetlinks/pro-table';
|
|
|
import ProTable from '@jetlinks/pro-table';
|
|
|
|
|
|
@@ -17,6 +17,7 @@ import type { Form } from '@formily/core';
|
|
|
import SearchComponent from '@/components/SearchComponent';
|
|
|
import type { ProFormInstance } from '@ant-design/pro-form';
|
|
|
import type { SearchConfig } from '@ant-design/pro-form/lib/components/Submitter';
|
|
|
+import { useDomFullHeight } from '@/hooks';
|
|
|
|
|
|
export type Option = {
|
|
|
model: 'edit' | 'preview' | 'add';
|
|
|
@@ -52,6 +53,7 @@ export type Props<T> = {
|
|
|
};
|
|
|
|
|
|
const BaseCrud = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
+ const { minHeight } = useDomFullHeight(`.BaseCrud`);
|
|
|
const intl = useIntl();
|
|
|
const ref = useRef<ProFormInstance>();
|
|
|
const {
|
|
|
@@ -76,6 +78,7 @@ const BaseCrud = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
} = props;
|
|
|
|
|
|
const [param, setParam] = useState({});
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
<SearchComponent<T>
|
|
|
@@ -86,88 +89,90 @@ const BaseCrud = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
}}
|
|
|
target={moduleName}
|
|
|
/>
|
|
|
- <ProTable<T>
|
|
|
- params={param}
|
|
|
- formRef={ref}
|
|
|
- columns={columns}
|
|
|
- actionRef={actionRef}
|
|
|
- scroll={scroll}
|
|
|
- options={{ fullScreen: true }}
|
|
|
- request={
|
|
|
- request ||
|
|
|
- (async (params = {}) =>
|
|
|
- service.query({
|
|
|
- ...params,
|
|
|
- sorts: [{ name: 'createTime', order: 'desc' }], // 默认排序
|
|
|
- }))
|
|
|
- }
|
|
|
- editable={{
|
|
|
- type: 'multiple',
|
|
|
- }}
|
|
|
- rowKey="id"
|
|
|
- search={
|
|
|
- search === false
|
|
|
- ? false
|
|
|
- : {
|
|
|
- labelWidth: 'auto',
|
|
|
- }
|
|
|
- }
|
|
|
- form={{
|
|
|
- syncToUrl: false,
|
|
|
- }}
|
|
|
- pagination={
|
|
|
- pagination === false
|
|
|
- ? false
|
|
|
- : {
|
|
|
- pageSize: 10,
|
|
|
- }
|
|
|
- }
|
|
|
- dateFormatter="string"
|
|
|
- headerTitle={
|
|
|
- <Tooltip title={props.disableAdd ? '暂无权限,请联系管理员' : ''}>
|
|
|
- <Button
|
|
|
- disabled={props.disableAdd}
|
|
|
- onClick={CurdModel.add}
|
|
|
- key="button"
|
|
|
- icon={<PlusOutlined />}
|
|
|
- type="primary"
|
|
|
- >
|
|
|
- {intl.formatMessage({
|
|
|
- id: 'pages.data.option.add',
|
|
|
- defaultMessage: '新增',
|
|
|
- })}
|
|
|
- </Button>
|
|
|
- </Tooltip>
|
|
|
- }
|
|
|
- defaultParams={defaultParams}
|
|
|
- // toolBarRender={() =>
|
|
|
- // toolBar || [
|
|
|
- // <Button onClick={CurdModel.add} key="button" icon={<PlusOutlined />} type="primary">
|
|
|
- // {intl.formatMessage({
|
|
|
- // id: 'pages.data.option.add',
|
|
|
- // defaultMessage: '新增',
|
|
|
- // })}
|
|
|
- // </Button>,
|
|
|
- // menu && (
|
|
|
- // <Dropdown key="menu" overlay={menu}>
|
|
|
- // <Button>
|
|
|
- // <EllipsisOutlined />
|
|
|
- // </Button>
|
|
|
- // </Dropdown>
|
|
|
- // ),
|
|
|
- // ]
|
|
|
- // }
|
|
|
- />
|
|
|
- <Save
|
|
|
- reload={() => actionRef.current?.reload()}
|
|
|
- service={service}
|
|
|
- schema={schema}
|
|
|
- schemaConfig={schemaConfig}
|
|
|
- modelConfig={modelConfig}
|
|
|
- formEffect={formEffect}
|
|
|
- customForm={form}
|
|
|
- footer={footer}
|
|
|
- />
|
|
|
+ <Card className="BaseCrud" style={{ minHeight }}>
|
|
|
+ <ProTable<T>
|
|
|
+ params={param}
|
|
|
+ formRef={ref}
|
|
|
+ columns={columns}
|
|
|
+ actionRef={actionRef}
|
|
|
+ scroll={scroll}
|
|
|
+ options={{ fullScreen: true }}
|
|
|
+ request={
|
|
|
+ request ||
|
|
|
+ (async (params = {}) =>
|
|
|
+ service.query({
|
|
|
+ ...params,
|
|
|
+ sorts: [{ name: 'createTime', order: 'desc' }], // 默认排序
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ editable={{
|
|
|
+ type: 'multiple',
|
|
|
+ }}
|
|
|
+ rowKey="id"
|
|
|
+ search={
|
|
|
+ search === false
|
|
|
+ ? false
|
|
|
+ : {
|
|
|
+ labelWidth: 'auto',
|
|
|
+ }
|
|
|
+ }
|
|
|
+ form={{
|
|
|
+ syncToUrl: false,
|
|
|
+ }}
|
|
|
+ pagination={
|
|
|
+ pagination === false
|
|
|
+ ? false
|
|
|
+ : {
|
|
|
+ pageSize: 10,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dateFormatter="string"
|
|
|
+ headerTitle={
|
|
|
+ <Tooltip title={props.disableAdd ? '暂无权限,请联系管理员' : ''}>
|
|
|
+ <Button
|
|
|
+ disabled={props.disableAdd}
|
|
|
+ onClick={CurdModel.add}
|
|
|
+ key="button"
|
|
|
+ icon={<PlusOutlined />}
|
|
|
+ type="primary"
|
|
|
+ >
|
|
|
+ {intl.formatMessage({
|
|
|
+ id: 'pages.data.option.add',
|
|
|
+ defaultMessage: '新增',
|
|
|
+ })}
|
|
|
+ </Button>
|
|
|
+ </Tooltip>
|
|
|
+ }
|
|
|
+ defaultParams={defaultParams}
|
|
|
+ // toolBarRender={() =>
|
|
|
+ // toolBar || [
|
|
|
+ // <Button onClick={CurdModel.add} key="button" icon={<PlusOutlined />} type="primary">
|
|
|
+ // {intl.formatMessage({
|
|
|
+ // id: 'pages.data.option.add',
|
|
|
+ // defaultMessage: '新增',
|
|
|
+ // })}
|
|
|
+ // </Button>,
|
|
|
+ // menu && (
|
|
|
+ // <Dropdown key="menu" overlay={menu}>
|
|
|
+ // <Button>
|
|
|
+ // <EllipsisOutlined />
|
|
|
+ // </Button>
|
|
|
+ // </Dropdown>
|
|
|
+ // ),
|
|
|
+ // ]
|
|
|
+ // }
|
|
|
+ />
|
|
|
+ <Save
|
|
|
+ reload={() => actionRef.current?.reload()}
|
|
|
+ service={service}
|
|
|
+ schema={schema}
|
|
|
+ schemaConfig={schemaConfig}
|
|
|
+ modelConfig={modelConfig}
|
|
|
+ formEffect={formEffect}
|
|
|
+ customForm={form}
|
|
|
+ footer={footer}
|
|
|
+ />
|
|
|
+ </Card>
|
|
|
</>
|
|
|
);
|
|
|
};
|