From c05ee091c5e3f3086260c8c53538a5ea007d1a6a Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 14 三月 2024 16:13:56 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/pages/map/components/mapCopySettings.jsx |   52 +++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/components/mapCopySettings.jsx b/zy-asrs-flow/src/pages/map/components/mapCopySettings.jsx
index 1820264..64767ad 100644
--- a/zy-asrs-flow/src/pages/map/components/mapCopySettings.jsx
+++ b/zy-asrs-flow/src/pages/map/components/mapCopySettings.jsx
@@ -1,5 +1,5 @@
 import React, { useState, useRef, useEffect } from 'react';
-import { Col, Form, Input, Row, Switch, Slider, Select, Drawer, Space, Button, InputNumber, Segmented } from 'antd';
+import { Col, Form, Input, Row, Switch, Slider, message, Drawer, Space, Button, InputNumber, Segmented } from 'antd';
 import { FormattedMessage, useIntl, useModel } from '@umijs/max';
 import { createStyles } from 'antd-style';
 import * as Utils from '../utils'
@@ -14,8 +14,11 @@
     const { styles } = useStyles();
     const { curSprite } = props;
     const [form] = Form.useForm();
+    const [autoIncrement, setAutoIncrement] = useState(false);
+    const [autoIncrementError, setAutoIncrementError] = useState(null);
 
     useEffect(() => {
+        setAutoIncrement(false);
         form.resetFields();
         if (curSprite && props) {
             form.setFieldsValue({
@@ -23,6 +26,24 @@
             });
         }
     }, [form, props]);
+
+    useEffect(() => {
+        if (autoIncrement === true && curSprite) {
+            switch (curSprite.data?.type) {
+                case Utils.SENSOR_TYPE.SHELF:
+                    if (!curSprite.data?.row || !curSprite.data?.bay) {
+                        setAutoIncrementError(intl.formatMessage({ id: 'map.settings.sub.copy.warn.config.shelf', defaultMessage: '璇峰厛璁剧疆璐ф灦鍙傛暟锛�' }));
+                    } else {
+                        setAutoIncrementError(null);
+                    }
+                    break;
+                default:
+                    break;
+            }
+        } else {
+            setAutoIncrementError(null);
+        }
+    }, [autoIncrement])
 
     const handleCancel = () => {
         props.onClose();
@@ -33,12 +54,12 @@
     }
 
     const handleFinish = (values) => {
-        console.log(values); return
-        props.submit({ ...values, ...props.values })
-    }
-
-    const formValuesChange = (value) => {
-        console.log(value);
+        props.submit({
+            ...values
+            , ...props.values
+            , autoIncrement: autoIncrement
+            , type: curSprite?.data?.type
+        })
     }
 
     return (
@@ -64,12 +85,11 @@
             >
                 <Form
                     form={form}
-                    onFieldsChange={formValuesChange}
                     initialValues={{
                         copyGap: 0,
                         autoIncrement: false,
                         incrementValue: 'row',
-                        incrementMode: 'Ascending',
+                        incrementMode: 'ascending',
                     }}
                     onFinish={handleFinish}
                     autoComplete="off"
@@ -117,17 +137,19 @@
                             </Form.Item>
                         </Col>
 
+                        {/* switch auto increment  */}
                         <Col span={24}>
                             <Form.Item
-                                name='autoIncrement'
                                 label={intl.formatMessage({ id: 'map.settings.sub.copy.shelf.auto-increment', defaultMessage: '鑷闀�' })}
                                 labelCol={{ span: 8 }}
+                                help={autoIncrementError}
+                                validateStatus={autoIncrementError ? "error" : null}
                             >
-                                <Switch />
+                                <Switch value={autoIncrement} onChange={setAutoIncrement} />
                             </Form.Item>
                         </Col>
 
-                        {form.getFieldValue('autoIncrement') === true && curSprite?.data?.type === Utils.SENSOR_TYPE.AGV && (
+                        {autoIncrement && curSprite?.data?.type === Utils.SENSOR_TYPE.AGV && (
                             <>
                                 <Col span={24}>
                                     <Form.Item
@@ -146,7 +168,7 @@
                             </>
                         )}
 
-                        {form.getFieldValue('autoIncrement') === true && curSprite?.data?.type === Utils.SENSOR_TYPE.SHELF && (
+                        {autoIncrement && curSprite?.data?.type === Utils.SENSOR_TYPE.SHELF && (
                             <>
                                 <Col span={24}>
                                     <Form.Item
@@ -182,11 +204,11 @@
                                             options={[
                                                 {
                                                     label: intl.formatMessage({ id: 'map.settings.sub.copy.ascend', defaultMessage: '鍗囧簭' }),
-                                                    value: 'Ascending'
+                                                    value: 'ascending'
                                                 },
                                                 {
                                                     label: intl.formatMessage({ id: 'map.settings.sub.copy.descend', defaultMessage: '闄嶅簭' }),
-                                                    value: 'Descending'
+                                                    value: 'descending'
                                                 },
                                             ]}
                                             onChange={(value) => {

--
Gitblit v1.9.1