#
vincentlu
1 天以前 c01d9b053852b12e7d3ced66367babb4d499b14b
zy-acs-flow/src/page/guarantee/GuaranteeList.jsx
@@ -1,21 +1,14 @@
import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
import { useNavigate } from 'react-router-dom';
import React, { useState, useCallback } from "react";
import {
    List,
    DatagridConfigurable,
    SearchInput,
    TopToolbar,
    SelectColumnsButton,
    EditButton,
    FilterButton,
    CreateButton,
    ExportButton,
    BulkDeleteButton,
    WrapperField,
    useRecordContext,
    useTranslate,
    useNotify,
    useListContext,
    FunctionField,
    TextField,
    NumberField,
@@ -27,10 +20,8 @@
    DateInput,
    SelectInput,
    NumberInput,
    ReferenceInput,
    ReferenceArrayInput,
    AutocompleteInput,
    DeleteButton,
    EditButton,
} from 'react-admin';
import { Box, Typography, Card, Stack } from '@mui/material';
import { styled } from '@mui/material/styles';
@@ -40,9 +31,10 @@
import MyCreateButton from "../components/MyCreateButton";
import MyExportButton from '../components/MyExportButton';
import PageDrawer from "../components/PageDrawer";
import MyField from "../components/MyField";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
import { describeCronExpression } from "./cronUtils";
import { DEFAULT_SCOPE_TYPE, SCOPE_FILTER_CHOICES, getScopeLabel } from "./guaranteeConstants";
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
@@ -65,7 +57,14 @@
    <TextInput source="uuid" label="table.field.guarantee.uuid" />,
    <TextInput source="name" label="table.field.guarantee.name" />,
    <TextInput source="scopeType" label="table.field.guarantee.scopeType" />,
    <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" />,
@@ -90,6 +89,32 @@
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
    const renderScopeType = useCallback((record) => {
        if (!record) {
            return '';
        }
        return getScopeLabel(record.scopeType, translate);
    }, [translate]);
    const renderScopeValue = useCallback((record) => {
        if (!record) {
            return '';
        }
        if (!record.scopeValue) {
            return record.scopeType === DEFAULT_SCOPE_TYPE
                ? translate('page.guarantee.scope.globalHelper')
                : translate('common.enums.na');
        }
        return record.scopeValue;
    }, [translate]);
    const renderCron = useCallback((record) => {
        if (!record || !record.cronExpr) {
            return translate('common.enums.na');
        }
        return describeCronExpression(record.cronExpr, translate);
    }, [translate]);
    return (
        <Box display="flex">
            <List
@@ -99,7 +124,7 @@
                        theme.transitions.create(['all'], {
                            duration: theme.transitions.duration.enteringScreen,
                        }),
                    marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                    marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                }}
                title={"menu.guarantee"}
                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
@@ -126,9 +151,9 @@
                    <NumberField source="id" />
                    <TextField source="uuid" label="table.field.guarantee.uuid" />
                    <TextField source="name" label="table.field.guarantee.name" />
                    <TextField source="scopeType" label="table.field.guarantee.scopeType" />
                    <TextField source="scopeValue" label="table.field.guarantee.scopeValue" />
                    <TextField source="cronExpr" label="table.field.guarantee.cronExpr" />
                    <FunctionField label="table.field.guarantee.scopeType" render={renderScopeType} />
                    <FunctionField label="table.field.guarantee.scopeValue" render={renderScopeValue} />
                    <FunctionField label="table.field.guarantee.cronExpr" render={renderCron} />
                    <NumberField source="requiredCount" label="table.field.guarantee.requiredCount" />
                    <NumberField source="minSoc" label="table.field.guarantee.minSoc" />
                    <NumberField source="leadTime" label="table.field.guarantee.leadTime" />