| | |
| | | import React, { useState, useRef, useEffect, useMemo } from "react"; |
| | | import React, { useMemo } from "react"; |
| | | import { |
| | | CreateBase, |
| | | useTranslate, |
| | |
| | | import DialogCloseButton from "../components/DialogCloseButton"; |
| | | import StatusSelectInput from "../components/StatusSelectInput"; |
| | | import MemoInput from "../components/MemoInput"; |
| | | import { compDirectChoices } from "../loc/compDirect"; |
| | | |
| | | const StaCreate = (props) => { |
| | | const { open, setOpen } = props; |
| | | |
| | | const translate = useTranslate(); |
| | | const notify = useNotify(); |
| | | const greaterThanZero = useMemo(() => (value) => { |
| | | if (value === undefined || value === null || value === '') { |
| | | return undefined; |
| | | } |
| | | return Number(value) >= 0 ? undefined : translate('validate.gtZero'); |
| | | }, [translate]); |
| | | |
| | | const handleClose = (event, reason) => { |
| | | if (reason !== "backdropClick") { |
| | |
| | | notify('common.response.success'); |
| | | }; |
| | | |
| | | const handleError = async (data) => { |
| | | notify('common.response.fail'); |
| | | const handleError = async (error) => { |
| | | notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); |
| | | }; |
| | | |
| | | return ( |
| | |
| | | <DialogContent> |
| | | <Grid container rowSpacing={2} columnSpacing={2}> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.uuid" |
| | | source="uuid" |
| | | parse={v => v} |
| | | autoFocus |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <ReferenceInput |
| | | source="zoneId" |
| | | reference="zone" |
| | |
| | | label="table.field.sta.zoneId" |
| | | optionText="name" |
| | | filterToQuery={(val) => ({ name: val })} |
| | | validate={required()} |
| | | /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.uuid" |
| | | source="uuid" |
| | | parse={v => v} |
| | | autoFocus |
| | | /> |
| | | </Grid> */} |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.staNo" |
| | | source="staNo" |
| | | parse={v => v} |
| | | validate={required()} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.name" |
| | | source="name" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | </Grid> */} |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <ReferenceInput |
| | | source="staType" |
| | |
| | | label="table.field.sta.code" |
| | | optionText="data" |
| | | filterToQuery={(val) => ({ data: val })} |
| | | validate={required()} |
| | | /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.capacity" |
| | | source="capacity" |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Grid> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.offset" |
| | | source="offset" |
| | | validate={required()} |
| | | /> |
| | | </Grid> */} |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.height" |
| | | source="height" |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Grid> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.depth" |
| | | source="depth" |
| | | helperText={translate('page.sta.depthHint')} |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Grid> */} |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.angle" |
| | | source="angle" |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <SelectInput |
| | | label="table.field.sta.actDir" |
| | | source="actDir" |
| | | choices={compDirectChoices} |
| | | translateChoice |
| | | validate={[required(), greaterThanZero]} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.inboundWait" |
| | | source="inboundWait" |
| | | validate={greaterThanZero} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <NumberInput |
| | | label="table.field.sta.outboundWait" |
| | | source="outboundWait" |
| | | validate={greaterThanZero} |
| | | /> |
| | | </Grid> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.autoing" |
| | | source="autoing" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | </Grid> */} |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.loading" |
| | | source="loading" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | </Grid> */} |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.inEnable" |
| | | source="inEnable" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | </Grid> */} |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.outEnable" |
| | | source="outEnable" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | </Grid> */} |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.sta.zpallet" |
| | | source="zpallet" |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | </Grid> */} |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <ReferenceInput |
| | | source="staSts" |
| | | reference="staSts" |
| | |
| | | label="table.field.sta.staSts" |
| | | optionText="name" |
| | | filterToQuery={(val) => ({ name: val })} |
| | | validate={required()} |
| | | /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | | </Grid> */} |
| | | |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | {/* <Grid item xs={6} display="flex" gap={1}> |
| | | <StatusSelectInput /> |
| | | </Grid> |
| | | </Grid> */} |
| | | <Grid item xs={12} display="flex" gap={1}> |
| | | <Stack direction="column" spacing={1} width={'100%'}> |
| | | <MemoInput /> |