| | |
| | | useTranslate, |
| | | TextInput, |
| | | NumberInput, |
| | | BooleanInput, |
| | | DateInput, |
| | | SaveButton, |
| | | SelectInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | Toolbar, |
| | | required, |
| | | useDataProvider, |
| | | useNotify, |
| | | Form, |
| | | useCreateController, |
| | | } from 'react-admin'; |
| | | import { |
| | | Dialog, |
| | |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import ScopeField from "./ScopeField"; |
| | | import CronField from "./CronField"; |
| | | import { DEFAULT_CRON_EXPRESSION } from "./cronUtils"; |
| | | import { DEFAULT_SCOPE_TYPE } from "./guaranteeConstants"; |
| | | |
| | | const GuaranteeCreate = (props) => { |
| | | const { open, setOpen } = props; |
| | | |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | |
| | | const defaultRecord = { |
| | | scopeType: DEFAULT_SCOPE_TYPE, |
| | | cronExpr: DEFAULT_CRON_EXPRESSION, |
| | | requiredCount: 10, |
| | | minSoc: 50, |
| | | leadTime: 60, |
| | | status: 1, |
| | | }; |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | |
| | | return ( |
| | | <> |
| | | <CreateBase |
| | | record={{}} |
| | | record={defaultRecord} |
| | | transform={(data) => { |
| | | return data; |
| | | return { |
| | | ...data, |
| | | cronExpr: (data.cronExpr || '').trim(), |
| | | scopeValue: data.scopeType === DEFAULT_SCOPE_TYPE ? null : data.scopeValue, |
| | | }; |
| | | }} |
| | | mutationOptions={{ onSuccess: handleSuccess, onError: handleError }} |
| | | > |
| | |
| | | label="table.field.guarantee.name" |
| | | source="name" |
| | | parse={v => v} |
| | | validate={[required()]} |
| | | fullWidth |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.guarantee.scopeType" |
| | | source="scopeType" |
| | | parse={v => v} |
| | | /> |
| | | <Grid item xs={12}> |
| | | <ScopeField /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.guarantee.scopeValue" |
| | | source="scopeValue" |
| | | parse={v => v} |
| | | /> |
| | | <Grid item xs={12}> |
| | | <CronField /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.guarantee.cronExpr" |
| | | source="cronExpr" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <Grid item xs={4} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.guarantee.requiredCount" |
| | | source="requiredCount" |
| | | validate={[required()]} |
| | | min={1} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <Grid item xs={4} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.guarantee.minSoc" |
| | | source="minSoc" |
| | | validate={[required()]} |
| | | min={1} |
| | | max={100} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <Grid item xs={4} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.guarantee.leadTime" |
| | | source="leadTime" |
| | | validate={[required()]} |
| | | min={1} |
| | | /> |
| | | </Grid> |
| | | |