| | |
| | | import { |
| | | Edit, |
| | | SimpleForm, |
| | | FormDataConsumer, |
| | | useTranslate, |
| | | TextInput, |
| | | NumberInput, |
| | | BooleanInput, |
| | | DateInput, |
| | | SelectInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | SaveButton, |
| | | Toolbar, |
| | | Labeled, |
| | | NumberField, |
| | | required, |
| | | useRecordContext, |
| | | DeleteButton, |
| | | } from 'react-admin'; |
| | | import { useWatch, useFormContext } from "react-hook-form"; |
| | | import { Stack, Grid, Box, Typography } from '@mui/material'; |
| | | import * as Common from '@/utils/common'; |
| | | import { EDIT_MODE, REFERENCE_INPUT_PAGESIZE } from '@/config/setting'; |
| | | import { EDIT_MODE } from '@/config/setting'; |
| | | import EditBaseAside from "../components/EditBaseAside"; |
| | | import CustomerTopToolBar from "../components/EditTopToolBar"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import ScopeField from "./ScopeField"; |
| | | import CronField from "./CronField"; |
| | | import { DEFAULT_SCOPE_TYPE } from "./guaranteeConstants"; |
| | | |
| | | const FormToolbar = () => { |
| | | const { getValues } = useFormContext(); |
| | | |
| | | return ( |
| | | <Toolbar sx={{ justifyContent: 'space-between' }}> |
| | | <SaveButton /> |
| | |
| | | label="table.field.guarantee.name" |
| | | source="name" |
| | | parse={v => v} |
| | | validate={[required()]} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.guarantee.scopeType" |
| | | source="scopeType" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.guarantee.scopeValue" |
| | | source="scopeValue" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <TextInput |
| | | label="table.field.guarantee.cronExpr" |
| | | source="cronExpr" |
| | | parse={v => v} |
| | | /> |
| | | </Stack> |
| | | <ScopeField /> |
| | | <Box mt={2}> |
| | | <CronField /> |
| | | </Box> |
| | | <Stack direction='row' gap={2}> |
| | | <NumberInput |
| | | label="table.field.guarantee.requiredCount" |
| | | source="requiredCount" |
| | | validate={[required()]} |
| | | min={1} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <NumberInput |
| | | label="table.field.guarantee.minSoc" |
| | | source="minSoc" |
| | | validate={[required()]} |
| | | min={1} |
| | | max={100} |
| | | /> |
| | | </Stack> |
| | | <Stack direction='row' gap={2}> |
| | | <NumberInput |
| | | label="table.field.guarantee.leadTime" |
| | | source="leadTime" |
| | | validate={[required()]} |
| | | min={1} |
| | | /> |
| | | </Stack> |
| | | |
| | |
| | | ) |
| | | } |
| | | |
| | | export default GuaranteeEdit; |
| | | const GuaranteeEditWrapper = () => ( |
| | | <Edit |
| | | redirect="list" |
| | | mutationMode={EDIT_MODE} |
| | | actions={<CustomerTopToolBar />} |
| | | aside={<EditBaseAside />} |
| | | transform={(data) => ({ |
| | | ...data, |
| | | cronExpr: (data.cronExpr || '').trim(), |
| | | scopeValue: data.scopeType === DEFAULT_SCOPE_TYPE ? null : data.scopeValue, |
| | | })} |
| | | > |
| | | <GuaranteeEdit /> |
| | | </Edit> |
| | | ); |
| | | |
| | | export default GuaranteeEditWrapper; |