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 |   41 +++++++++++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/zy-asrs-flow/src/pages/map/components/mapCopySettings.jsx b/zy-asrs-flow/src/pages/map/components/mapCopySettings.jsx
index c279d2e..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'
@@ -15,8 +15,10 @@
     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({
@@ -24,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();
@@ -34,20 +54,12 @@
     }
 
     const handleFinish = (values) => {
-        console.log({
-            ...values
-            , ...props.values
-            , autoIncrement: autoIncrement
-        }); return
         props.submit({
             ...values
             , ...props.values
             , autoIncrement: autoIncrement
+            , type: curSprite?.data?.type
         })
-    }
-
-    const formValuesChange = (value) => {
-        console.log(value);
     }
 
     return (
@@ -73,12 +85,11 @@
             >
                 <Form
                     form={form}
-                    onFieldsChange={formValuesChange}
                     initialValues={{
                         copyGap: 0,
                         autoIncrement: false,
                         incrementValue: 'row',
-                        incrementMode: 'Ascending',
+                        incrementMode: 'ascending',
                     }}
                     onFinish={handleFinish}
                     autoComplete="off"
@@ -131,6 +142,8 @@
                             <Form.Item
                                 label={intl.formatMessage({ id: 'map.settings.sub.copy.shelf.auto-increment', defaultMessage: '鑷闀�' })}
                                 labelCol={{ span: 8 }}
+                                help={autoIncrementError}
+                                validateStatus={autoIncrementError ? "error" : null}
                             >
                                 <Switch value={autoIncrement} onChange={setAutoIncrement} />
                             </Form.Item>
@@ -191,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