| | |
| | | import RestartAltIcon from '@mui/icons-material/RestartAlt'; |
| | | import useCoolHook from './useCoolHook'; |
| | | |
| | | function AgvControl({ open, onClose }) { |
| | | function AgvControl(props) { |
| | | const theme = useTheme(); |
| | | const translate = useTranslate(); |
| | | |
| | |
| | | }; |
| | | |
| | | const { |
| | | options: codeOptions, |
| | | setInputValue: setCodeInputValue, |
| | | options: endCodeOptions, |
| | | setInputValue: setEndCodeInputValue, |
| | | } = useCoolHook('/code/page', 'data'); |
| | | |
| | | const { |
| | | options: startLocOptions, |
| | | setInputValue: setStartLocInputValue, |
| | | } = useCoolHook('/loc/page', 'locNo'); |
| | | |
| | | const { |
| | | options: endLocOptions, |
| | | setInputValue: setEndLocInputValue, |
| | | } = useCoolHook('/loc/page', 'locNo'); |
| | | |
| | | const { |
| | | options: startStaOptions, |
| | | setInputValue: setStartStaInputValue, |
| | | } = useCoolHook('/sta/page', 'staNo'); |
| | | |
| | | const { |
| | | options: endStaOptions, |
| | | setInputValue: setEndStaInputValue, |
| | | } = useCoolHook('/sta/page', 'staNo'); |
| | | |
| | | |
| | | return ( |
| | | <> |
| | |
| | | <Controller |
| | | name="endCode" |
| | | control={control} |
| | | rules={{ required: '目标地面码不能为空' }} |
| | | render={({ field, fieldState }) => { |
| | | const selectedOption = codeOptions.find(option => option.id === field.value) || null; |
| | | const selectedOption = endCodeOptions.find(option => option.id === field.value) || null; |
| | | return ( |
| | | <Autocomplete |
| | | options={codeOptions} |
| | | options={endCodeOptions} |
| | | getOptionLabel={(option) => option.label} |
| | | isOptionEqualToValue={(option, value) => option.id === value.id} |
| | | value={selectedOption} |
| | | onInputChange={(event, value) => { |
| | | setCodeInputValue(value); |
| | | setEndCodeInputValue(value); |
| | | }} |
| | | onChange={(event, value) => { |
| | | field.onChange(value ? value.id : null); |
| | |
| | | name="startLocNo" |
| | | control={control} |
| | | rules={{ required: '起始库位不能为空' }} |
| | | render={({ field, fieldState }) => ( |
| | | <TextField |
| | | {...field} |
| | | fullWidth |
| | | label="起始库位" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | render={({ field, fieldState }) => { |
| | | const selectedOption = startLocOptions.find(option => option.id === field.value) || null; |
| | | return ( |
| | | <Autocomplete |
| | | options={startLocOptions} |
| | | getOptionLabel={(option) => option.label} |
| | | isOptionEqualToValue={(option, value) => option.id === value.id} |
| | | value={selectedOption} |
| | | onInputChange={(event, value) => { |
| | | setStartLocInputValue(value); |
| | | }} |
| | | onChange={(event, value) => { |
| | | field.onChange(value ? value.id : null); |
| | | }} |
| | | renderInput={(params) => ( |
| | | <TextField |
| | | {...params} |
| | | label="起始库位" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | /> |
| | | ); |
| | | }} |
| | | /> |
| | | </Grid> |
| | | )} |
| | |
| | | name="endLocNo" |
| | | control={control} |
| | | rules={{ required: '目标库位不能为空' }} |
| | | render={({ field, fieldState }) => ( |
| | | <TextField |
| | | {...field} |
| | | fullWidth |
| | | label="目标库位" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | render={({ field, fieldState }) => { |
| | | const selectedOption = endLocOptions.find(option => option.id === field.value) || null; |
| | | return ( |
| | | <Autocomplete |
| | | options={endLocOptions} |
| | | getOptionLabel={(option) => option.label} |
| | | isOptionEqualToValue={(option, value) => option.id === value.id} |
| | | value={selectedOption} |
| | | onInputChange={(event, value) => { |
| | | setEndLocInputValue(value); |
| | | }} |
| | | onChange={(event, value) => { |
| | | field.onChange(value ? value.id : null); |
| | | }} |
| | | renderInput={(params) => ( |
| | | <TextField |
| | | {...params} |
| | | label="目标库位" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | /> |
| | | ); |
| | | }} |
| | | /> |
| | | </Grid> |
| | | )} |
| | |
| | | name="startStaNo" |
| | | control={control} |
| | | rules={{ required: '起始站点不能为空' }} |
| | | render={({ field, fieldState }) => ( |
| | | <TextField |
| | | {...field} |
| | | fullWidth |
| | | label="起始站点" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | render={({ field, fieldState }) => { |
| | | const selectedOption = startStaOptions.find(option => option.id === field.value) || null; |
| | | return ( |
| | | <Autocomplete |
| | | options={startStaOptions} |
| | | getOptionLabel={(option) => option.label} |
| | | isOptionEqualToValue={(option, value) => option.id === value.id} |
| | | value={selectedOption} |
| | | onInputChange={(event, value) => { |
| | | setStartStaInputValue(value); |
| | | }} |
| | | onChange={(event, value) => { |
| | | field.onChange(value ? value.id : null); |
| | | }} |
| | | renderInput={(params) => ( |
| | | <TextField |
| | | {...params} |
| | | label="起始站点" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | /> |
| | | ); |
| | | }} |
| | | /> |
| | | </Grid> |
| | | )} |
| | |
| | | name="endStaNo" |
| | | control={control} |
| | | rules={{ required: '目标站点不能为空' }} |
| | | render={({ field, fieldState }) => ( |
| | | <TextField |
| | | {...field} |
| | | fullWidth |
| | | label="目标站点" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | render={({ field, fieldState }) => { |
| | | const selectedOption = endStaOptions.find(option => option.id === field.value) || null; |
| | | return ( |
| | | <Autocomplete |
| | | options={endStaOptions} |
| | | getOptionLabel={(option) => option.label} |
| | | isOptionEqualToValue={(option, value) => option.id === value.id} |
| | | value={selectedOption} |
| | | onInputChange={(event, value) => { |
| | | setEndStaInputValue(value); |
| | | }} |
| | | onChange={(event, value) => { |
| | | field.onChange(value ? value.id : null); |
| | | }} |
| | | renderInput={(params) => ( |
| | | <TextField |
| | | {...params} |
| | | label="目标站点" |
| | | error={!!fieldState.error} |
| | | helperText={fieldState.error?.message} |
| | | /> |
| | | )} |
| | | /> |
| | | ); |
| | | }} |
| | | /> |
| | | </Grid> |
| | | )} |