From 196ad66f41fe77fff13b15b05095dc7661251a5d Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 18 十月 2024 13:27:28 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/insight/agv/AgvControl.jsx | 208 +++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 148 insertions(+), 60 deletions(-) diff --git a/zy-acs-flow/src/map/insight/agv/AgvControl.jsx b/zy-acs-flow/src/map/insight/agv/AgvControl.jsx index 09aec4c..6b98bdd 100644 --- a/zy-acs-flow/src/map/insight/agv/AgvControl.jsx +++ b/zy-acs-flow/src/map/insight/agv/AgvControl.jsx @@ -18,8 +18,10 @@ import CheckOutlinedIcon from '@mui/icons-material/CheckOutlined'; import RestartAltIcon from '@mui/icons-material/RestartAlt'; import useCoolHook from './useCoolHook'; +import { handleControlAgv } from '../../http'; -function AgvControl({ open, onClose }) { +function AgvControl(props) { + const { curAgvNo } = props; const theme = useTheme(); const translate = useTranslate(); @@ -36,17 +38,20 @@ }); const taskModes = [ - { value: 'MOVE', label: '绉诲姩' }, - { value: 'TO_CHARGE', label: '鍘诲厖鐢�' }, - { value: 'TO_STANDBY', label: '鍘诲緟鏈轰綅' }, - { value: 'LOC_TO_LOC', label: '搴撲綅鍒板簱浣�' }, - { value: 'LOC_TO_STA', label: '搴撲綅鍒扮珯鐐�' }, - { value: 'STA_TO_LOC', label: '绔欑偣鍒板簱浣�' }, - { value: 'STA_TO_STA', label: '绔欑偣鍒扮珯鐐�' }, + { value: 'MOVE', label: translate('page.map.insight.control.type.MOVE') }, + { value: 'TO_CHARGE', label: translate('page.map.insight.control.type.TO_CHARGE') }, + { value: 'TO_STANDBY', label: translate('page.map.insight.control.type.TO_STANDBY') }, + { value: 'LOC_TO_LOC', label: translate('page.map.insight.control.type.LOC_TO_LOC') }, + { value: 'LOC_TO_STA', label: translate('page.map.insight.control.type.LOC_TO_STA') }, + { value: 'STA_TO_LOC', label: translate('page.map.insight.control.type.STA_TO_LOC') }, + { value: 'STA_TO_STA', label: translate('page.map.insight.control.type.STA_TO_STA') }, ]; const onSubmit = (data) => { - console.log(data); + if (curAgvNo) { + console.log(data); + handleControlAgv(curAgvNo, data); + } }; const taskMode = watch('taskMode'); @@ -72,9 +77,30 @@ }; 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 ( <> @@ -124,12 +150,12 @@ <Controller name="startCode" control={control} - rules={{ required: '璧峰鍦伴潰鐮佷笉鑳戒负绌�' }} + rules={{ required: translate('ra.validation.required') }} render={({ field, fieldState }) => ( <TextField {...field} fullWidth - label="璧峰鍦伴潰鐮�" + label={translate('page.map.insight.control.startCode')} error={!!fieldState.error} helperText={fieldState.error?.message} /> @@ -143,16 +169,17 @@ <Controller name="endCode" control={control} + rules={{ required: translate('ra.validation.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); @@ -160,7 +187,7 @@ renderInput={(params) => ( <TextField {...params} - label="鐩爣鍦伴潰鐮�" + label={translate('page.map.insight.control.endCode')} error={!!fieldState.error} helperText={fieldState.error?.message} /> @@ -177,16 +204,32 @@ <Controller name="startLocNo" control={control} - rules={{ required: '璧峰搴撲綅涓嶈兘涓虹┖' }} - render={({ field, fieldState }) => ( - <TextField - {...field} - fullWidth - label="璧峰搴撲綅" - error={!!fieldState.error} - helperText={fieldState.error?.message} - /> - )} + rules={{ required: translate('ra.validation.required') }} + 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={translate('page.map.insight.control.startLoc')} + error={!!fieldState.error} + helperText={fieldState.error?.message} + /> + )} + /> + ); + }} /> </Grid> )} @@ -196,16 +239,32 @@ <Controller name="endLocNo" control={control} - rules={{ required: '鐩爣搴撲綅涓嶈兘涓虹┖' }} - render={({ field, fieldState }) => ( - <TextField - {...field} - fullWidth - label="鐩爣搴撲綅" - error={!!fieldState.error} - helperText={fieldState.error?.message} - /> - )} + rules={{ required: translate('ra.validation.required') }} + 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={translate('page.map.insight.control.endLoc')} + error={!!fieldState.error} + helperText={fieldState.error?.message} + /> + )} + /> + ); + }} /> </Grid> )} @@ -215,16 +274,32 @@ <Controller name="startStaNo" control={control} - rules={{ required: '璧峰绔欑偣涓嶈兘涓虹┖' }} - render={({ field, fieldState }) => ( - <TextField - {...field} - fullWidth - label="璧峰绔欑偣" - error={!!fieldState.error} - helperText={fieldState.error?.message} - /> - )} + rules={{ required: translate('ra.validation.required') }} + 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={translate('page.map.insight.control.startSta')} + error={!!fieldState.error} + helperText={fieldState.error?.message} + /> + )} + /> + ); + }} /> </Grid> )} @@ -234,16 +309,32 @@ <Controller name="endStaNo" control={control} - rules={{ required: '鐩爣绔欑偣涓嶈兘涓虹┖' }} - render={({ field, fieldState }) => ( - <TextField - {...field} - fullWidth - label="鐩爣绔欑偣" - error={!!fieldState.error} - helperText={fieldState.error?.message} - /> - )} + rules={{ required: translate('ra.validation.required') }} + 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={translate('page.map.insight.control.endSta')} + error={!!fieldState.error} + helperText={fieldState.error?.message} + /> + )} + /> + ); + }} /> </Grid> )} @@ -264,9 +355,6 @@ variant="outlined" color="primary" type="submit" - onClick={() => { - - }} sx={{ borderColor: theme => theme.palette.primary.main, color: theme => theme.palette.primary.main, -- Gitblit v1.9.1