From edc8ebfb8f3c287d4fc40df3c6c8b0fe59b87f2c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 28 十一月 2023 10:08:31 +0800
Subject: [PATCH] 2023-11-28

---
 src/menu/components/chart/antv-bar/chartcompile/index.jsx |   65 ++++++++++----------------------
 1 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
index e0536d6..da6cd0d 100644
--- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx
+++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
@@ -193,18 +193,22 @@
     })
   }
 
-  enabledChange = (e) => {
-    const { plot } = this.state
-    let val = e.target.value
+  optionChange = (val, key) => {
+    let _plot = {...this.state.plot, [key]: val}
+    
+    if (key === 'ramp' && val === 'true') {
+      _plot.colors = _plot.colors || []
+      _plot.colors = _plot.colors.map(item => {
+        item.color1 = item.color1 || item.color
+        return item
+      })
+    }
 
-    this.setState({plot: {...plot, enabled: val}})
-  }
-
-  zoomChange = (e) => {
-    const { plot } = this.state
-    let val = e.target.value
-
-    this.setState({plot: {...plot, zoomYaxis: val}, cusColumns: this.getCusColumns(val)})
+    this.setState({plot: _plot}, () => {
+      if (key === 'zoomYaxis') {
+        this.setState({cusColumns: this.getCusColumns(val)})
+      }
+    })
   }
 
   getCusColumns = (zoomYaxis) => {
@@ -345,35 +349,6 @@
     }
 
     return cusColumns
-  }
-
-  mutilBarChange = (e) => {
-    const { plot } = this.state
-    let val = e.target.value
-
-    this.setState({plot: {...plot, mutilBar: val}})
-  }
-
-  rampChange = (e) => {
-    const { plot } = this.state
-    let val = e.target.value
-    let colors = plot.colors || []
-
-    if (val === 'true') {
-      colors = colors.map(item => {
-        item.color1 = item.color1 || item.color
-        return item
-      })
-    }
-
-    this.setState({plot: {...plot, colors, ramp: val}})
-  }
-
-  rampDirectionChange = (e) => {
-    const { plot } = this.state
-    let val = e.target.value
-
-    this.setState({plot: {...plot, rampDirection: val}})
   }
 
   onSubmit = () => {
@@ -657,7 +632,7 @@
                 <Col span={8} style={{height: '40px', top: '-5px', zIndex: 1}}>
                   <Form {...formItemLayout}>
                     <Form.Item label="娓愬彉鑹�" style={{marginBottom: 10}}>
-                      <Radio.Group value={plot.ramp || 'false'} onChange={this.rampChange}>
+                      <Radio.Group value={plot.ramp || 'false'} onChange={(e) => this.optionChange(e.target.value, 'ramp')}>
                         <Radio value="false">涓嶄娇鐢�</Radio>
                         <Radio value="true">浣跨敤</Radio>
                       </Radio.Group>
@@ -667,7 +642,7 @@
                 {plot.chartType === 'line' ? <Col span={8} style={{height: '40px', top: '-5px', zIndex: 1}}>
                   <Form {...formItemLayout}>
                     <Form.Item label="娓愬彉鏂瑰悜" style={{marginBottom: 10}}>
-                      <Radio.Group value={plot.rampDirection || 'horizontal'} onChange={this.rampDirectionChange}>
+                      <Radio.Group value={plot.rampDirection || 'horizontal'} onChange={(e) => this.optionChange(e.target.value, 'rampDirection')}>
                         <Radio value="horizontal">姘村钩</Radio>
                         <Radio value="vertical">鍨傜洿</Radio>
                       </Radio.Group>
@@ -688,7 +663,7 @@
               <Col span={8}>
                 <Form {...formItemLayout}>
                   <Form.Item label="鏄惁鍚敤" style={{marginBottom: 10}}>
-                    <Radio.Group value={plot.enabled || 'false'} onChange={this.enabledChange}>
+                    <Radio.Group value={plot.enabled || 'false'} onChange={(e) => this.optionChange(e.target.value, 'enabled')}>
                       <Radio value="true">鏄�</Radio>
                       <Radio value="false">鍚�</Radio>
                     </Radio.Group>
@@ -698,7 +673,7 @@
               <Col span={8}>
                 <Form {...formItemLayout}>
                   <Form.Item label="澶氭煴鎺掑垪" style={{marginBottom: 10}}>
-                    <Radio.Group value={plot.mutilBar || 'dodge'} onChange={this.mutilBarChange}>
+                    <Radio.Group value={plot.mutilBar || 'dodge'} onChange={(e) => this.optionChange(e.target.value, 'mutilBar')}>
                       <Radio value="dodge">鍒嗙粍</Radio>
                       <Radio value="stack">鍫嗗彔</Radio>
                       <Radio value="overlap">閲嶅彔</Radio>
@@ -709,7 +684,7 @@
               <Col span={8}>
                 <Form {...formItemLayout}>
                   <Form.Item label="Y杞村尯闂�" style={{marginBottom: 10}}>
-                    <Radio.Group value={plot.zoomYaxis} onChange={this.zoomChange}>
+                    <Radio.Group value={plot.zoomYaxis} onChange={(e) => this.optionChange(e.target.value, 'zoomYaxis')}>
                       <Radio value="default">榛樿</Radio>
                       <Radio value="custom">鑷畾涔�</Radio>
                       <Radio value="adjust">鑷�傚簲</Radio>

--
Gitblit v1.8.0