| | |
| | | const handleError = async (error) => { |
| | | notify(error.message || 'common.response.fail', { type: 'error', messageArgs: { _: error.message } }); |
| | | }; |
| | | const validateForm = (values) => { |
| | | const errors = {}; |
| | | if (!values.shipperId) { |
| | | errors.shipperId = translate('form.matnr.shipper'); |
| | | } |
| | | if (!values.groupId) { |
| | | errors.groupId = translate('form.matnr.groupId'); |
| | | } |
| | | if (!values.name) { |
| | | errors.name = translate('form.matnr.name'); |
| | | } |
| | | return errors; |
| | | }; |
| | | // const validateForm = (values) => { |
| | | // const errors = {}; |
| | | // if (!values.name) errors.name = translate('form.matnr.name'); |
| | | // if (!values.shipperId) errors.shipperId = translate('form.matnr.shipper'); |
| | | // if (!values.groupId) errors.groupId = translate('form.matnr.groupId'); |
| | | // if (!values.code) errors.code = translate('form.matnr.code'); |
| | | |
| | | // return errors; |
| | | // }; |
| | | |
| | | return ( |
| | | <> |
| | |
| | | disableRestoreFocus |
| | | maxWidth="md" // 'xs' | 'sm' | 'md' | 'lg' | 'xl' |
| | | > |
| | | <Form validate={validateForm}> |
| | | <Form > |
| | | <DialogTitle id="form-dialog-title" sx={{ |
| | | position: 'sticky', |
| | | top: 0, |
| | |
| | | <Grid item xs={6} display="flex" gap={1}> |
| | | <TextInput |
| | | label="table.field.matnr.code" |
| | | required |
| | | validate={[required()]} |
| | | source="code" |
| | | parse={v => v} |
| | | /> |
| | |
| | | > |
| | | <AutocompleteInput |
| | | label="table.field.matnr.groupId" |
| | | optionText="code" |
| | | optionText="name" |
| | | validate={[required()]} |
| | | filterToQuery={(val) => ({ code: val })} |
| | | filterToQuery={(val) => ({ name: val })} |
| | | /> |
| | | </ReferenceInput> |
| | | </Grid> |
| | |
| | | <TextInput |
| | | label="table.field.matnr.erpCode" |
| | | source="erpCode" |
| | | required |
| | | validate={[required()]} |
| | | parse={v => v} |
| | | /> |
| | | </Grid> |