From c9e8eab9835c6f72f84552f694582d9a27f6328c Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期五, 11 十月 2024 16:50:31 +0800 Subject: [PATCH] # --- zy-acs-flow/src/map/settings/CopyDrawer.jsx | 42 +++++++++++++++++++++++++++--------------- 1 files changed, 27 insertions(+), 15 deletions(-) diff --git a/zy-acs-flow/src/map/settings/CopyDrawer.jsx b/zy-acs-flow/src/map/settings/CopyDrawer.jsx index 6aa9880..2229124 100644 --- a/zy-acs-flow/src/map/settings/CopyDrawer.jsx +++ b/zy-acs-flow/src/map/settings/CopyDrawer.jsx @@ -46,6 +46,26 @@ ], }; + +const validateIncrement = (value, deviceType, sprite, translate) => { + if (!value) { + return true; + } + switch (deviceType) { + case DEVICE_TYPE.SHELF: + if (!sprite?.data?.row || !sprite?.data?.bay) { + return translate('page.map.settings.map.copy.valid.shelf'); + } + break; + default: + if (!sprite?.data?.no) { + return translate('page.map.settings.map.copy.valid.common'); + } + break; + } + return true; +}; + const getDefaultFormValues = (value = {}) => ({ copyDirect: value.copyDirect || '', copyCount: value.copyCount || '', @@ -88,18 +108,6 @@ const handleClose = () => { onCancel(); } - - const validateIncrement = (value) => { - if (!value) { - return true; - } - if (deviceType === DEVICE_TYPE.SHELF) { - if (!sprite?.data?.row || !sprite?.data?.bay) { - return 'Row or Bay value is required for SHELF device type.'; - } - } - return true; - }; const onFormSubmit = (data) => { console.log(data); @@ -192,7 +200,7 @@ <Controller name="autoIncrement" control={control} - rules={{ validate: validateIncrement }} + rules={{ validate: (value) => validateIncrement(value, deviceType, sprite, translate) }} render={({ field }) => ( <FormControlLabel control={ @@ -228,7 +236,9 @@ value={field.value} exclusive onChange={(event, value) => { - field.onChange(value); + if (value !== null) { + field.onChange(value); + } }} fullWidth > @@ -261,7 +271,9 @@ value={field.value} exclusive onChange={(event, value) => { - field.onChange(value); + if (value !== null) { + field.onChange(value); + } }} fullWidth > -- Gitblit v1.9.1