#
vincentlu
1 天以前 a0a30a103b30a972942eb5cf4b4c0b45a1c2e562
zy-acs-flow/src/page/guarantee/GuaranteeList.jsx
@@ -14,25 +14,18 @@
    NumberField,
    DateField,
    BooleanField,
    ReferenceField,
    TextInput,
    DateTimeInput,
    DateInput,
    SelectInput,
    NumberInput,
    DeleteButton,
    EditButton,
} from 'react-admin';
import { Box, Typography, Card, Stack } from '@mui/material';
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';
import GuaranteeCreate from "./GuaranteeCreate";
import GuaranteePanel from "./GuaranteePanel";
import EmptyData from "../components/EmptyData";
import MyCreateButton from "../components/MyCreateButton";
import MyExportButton from '../components/MyExportButton';
import PageDrawer from "../components/PageDrawer";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
import { OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import { describeCronExpression } from "./cronUtils";
import { DEFAULT_SCOPE_TYPE, SCOPE_FILTER_CHOICES, getScopeLabel } from "./guaranteeConstants";
@@ -52,26 +45,13 @@
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <DateInput label='common.time.after' source="timeStart" alwaysOn />,
    <DateInput label='common.time.before' source="timeEnd" alwaysOn />,
    <TextInput source="uuid" label="table.field.guarantee.uuid" />,
    <TextInput source="name" label="table.field.guarantee.name" />,
    <SelectInput
        source="scopeType"
        label="table.field.guarantee.scopeType"
        choices={SCOPE_FILTER_CHOICES}
        translateChoice
        allowEmpty
        resettable
    />,
    <TextInput source="scopeValue" label="table.field.guarantee.scopeValue" />,
    <TextInput source="cronExpr" label="table.field.guarantee.cronExpr" />,
    <NumberInput source="requiredCount" label="table.field.guarantee.requiredCount" />,
    <NumberInput source="minSoc" label="table.field.guarantee.minSoc" />,
    <NumberInput source="leadTime" label="table.field.guarantee.leadTime" />,
    <TextInput label="common.field.memo" source="memo" />,
    <SelectInput
        label="common.field.status"
        source="status"
@@ -79,15 +59,15 @@
            { id: '1', name: 'common.enums.statusTrue' },
            { id: '0', name: 'common.enums.statusFalse' },
        ]}
        alwaysOn
        resettable
    />,
]
];
const GuaranteeList = () => {
    const translate = useTranslate();
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
    const renderScopeType = useCallback((record) => {
        if (!record) {
@@ -124,7 +104,7 @@
                        theme.transitions.create(['all'], {
                            duration: theme.transitions.duration.enteringScreen,
                        }),
                    marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                    marginRight: 0,
                }}
                title={"menu.guarantee"}
                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
@@ -146,10 +126,8 @@
                    rowClick={(id, resource, record) => false}
                    expand={() => <GuaranteePanel />}
                    expandSingle={true}
                    omit={['id', 'createTime', 'createBy', 'memo']}
                    omit={['createBy', 'memo']}
                >
                    <NumberField source="id" />
                    <TextField source="uuid" label="table.field.guarantee.uuid" />
                    <TextField source="name" label="table.field.guarantee.name" />
                    <FunctionField label="table.field.guarantee.scopeType" render={renderScopeType} />
                    <FunctionField label="table.field.guarantee.scopeValue" render={renderScopeValue} />
@@ -158,32 +136,15 @@
                    <NumberField source="minSoc" label="table.field.guarantee.minSoc" />
                    <NumberField source="leadTime" label="table.field.guarantee.leadTime" />
                    <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
                        <TextField source="nickname" />
                    </ReferenceField>
                    <DateField source="updateTime" label="common.field.updateTime" showTime />
                    <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}>
                        <TextField source="nickname" />
                    </ReferenceField>
                    <DateField source="createTime" label="common.field.createTime" showTime />
                    <BooleanField source="statusBool" label="common.field.status" sortable={false} />
                    <TextField source="memo" label="common.field.memo" sortable={false} />
                    <DateField source="updateTime" label="common.field.updateTime" showTime />
                    <WrapperField cellClassName="opt" label="common.field.opt">
                        <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
                        <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
                    </WrapperField>
                </StyledDatagrid>
            </List>
            <GuaranteeCreate
                open={createDialog}
                setOpen={setCreateDialog}
            />
            <PageDrawer
                title='Guarantee Detail'
                drawerVal={drawerVal}
                setDrawerVal={setDrawerVal}
            >
            </PageDrawer>
            <GuaranteeCreate open={createDialog} setOpen={setCreateDialog} />
        </Box>
    )
}