From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 四月 2022 19:23:18 +0800
Subject: [PATCH] 2022-04-26

---
 src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx b/src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx
new file mode 100644
index 0000000..6b16aea
--- /dev/null
+++ b/src/tabviews/custom/components/table/edit-table/normalTable/cusSwitch/index.jsx
@@ -0,0 +1,49 @@
+import React, {Component} from 'react'
+import PropTypes from 'prop-types'
+// import { is, fromJS } from 'immutable'
+import { Switch } from 'antd'
+
+import './index.scss'
+
+class ColorSketch extends Component {
+  static propTpyes = {
+    defaultValue: PropTypes.any,
+    autoFocus: PropTypes.any,
+    config: PropTypes.object,
+    onChange: PropTypes.func
+  }
+  state = {
+    status: false
+  }
+
+  UNSAFE_componentWillMount () {
+    const { defaultValue, config } = this.props
+    
+    let status = false
+
+    if (defaultValue === config.openVal) {
+      status = true
+    }
+    
+    this.setState({status})
+  }
+
+  changeStatus = (val) => {
+    const { config } = this.props
+    this.setState({ status: val }, () => {
+      let _val = val ? config.openVal : config.closeVal
+      let _text = val ? config.openText : config.closeText
+      this.props.onChange(_val, _text)
+    })
+  }
+
+  render() {
+    const { config, autoFocus } = this.props
+    const { status } = this.state
+    return (
+      <Switch checkedChildren={config.openText} autoFocus={autoFocus} onBlur={this.props.onBlur} unCheckedChildren={config.closeText} checked={status} onChange={this.changeStatus} />
+    )
+  }
+}
+
+export default ColorSketch
\ No newline at end of file

--
Gitblit v1.8.0