From 9c056474ca77bfae3044e24f7bdff3804ecbb9bb Mon Sep 17 00:00:00 2001 From: huyueb <1062887235@qq.com> Date: Fri, 22 Sep 2017 14:47:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=90=E4=BA=A4edittype=E7=BB=84?= =?UTF-8?q?=E4=BB=B6render?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/render/CheckboxRender.js | 59 ++++++++++++++++++++++++++++ src/render/DateRender.js | 0 src/render/InputRender.js | 76 ++++++++++++++++++++++++++++++++++++ src/render/RadioRender.js | 0 4 files changed, 135 insertions(+) create mode 100644 src/render/CheckboxRender.js create mode 100644 src/render/DateRender.js create mode 100644 src/render/InputRender.js create mode 100644 src/render/RadioRender.js diff --git a/src/render/CheckboxRender.js b/src/render/CheckboxRender.js new file mode 100644 index 0000000..b161dcc --- /dev/null +++ b/src/render/CheckboxRender.js @@ -0,0 +1,59 @@ +import React, { Component } from "react"; +import Icon from "bee-icon"; +import Checkbox from "bee-checkbox"; + +export default class CheckboxRender extends Component { + state = { + value: this.props.value, + editable: false + }; + handleChange = e => { + const value = e.target.value; + this.setState({ value }); + }; + check = () => { + this.setState({ editable: false }); + if (this.props.onChange) { + this.props.onChange(this.state.value); + } + }; + edit = () => { + this.setState({ editable: true }); + }; + handleKeydown = event => { + console.log(event.keyCode); + if (event.keyCode == 13) { + this.check(); + } + }; + render() { + const { value, editable } = this.state; + let { isclickTrigger } = this.props; + let cellContent = ""; + if (editable) { + cellContent = ( +
+ +
+ ); + } else { + cellContent = ( +
+ {value || " "} + +
+ ); + } + return
{cellContent}
; + } +} diff --git a/src/render/DateRender.js b/src/render/DateRender.js new file mode 100644 index 0000000..e69de29 diff --git a/src/render/InputRender.js b/src/render/InputRender.js new file mode 100644 index 0000000..9271670 --- /dev/null +++ b/src/render/InputRender.js @@ -0,0 +1,76 @@ +import React, { Component } from "react"; +import Icon from "bee-icon"; +import Input from "bee-form-control"; + +export default class InputRender extends Component { + state = { + value: this.props.value, + editable: false + }; + handleChange = e => { + const value = e.target.value; + this.setState({ value }); + }; + check = () => { + this.setState({ editable: false }); + if (this.props.onChange) { + this.props.onChange(this.state.value); + } + }; + edit = () => { + this.setState({ editable: true }); + }; + handleKeydown = event => { + console.log(event.keyCode); + if (event.keyCode == 13) { + this.check(); + } + }; + render() { + const { value, editable } = this.state; + let { isclickTrigger } = this.props; + let cellContent = ""; + if (editable) { + cellContent = isclickTrigger ? ( +
+ +
+ ) : ( +
+ + +
+ ); + } else { + cellContent = isclickTrigger ? ( +
+ {value || " "} +
+ ) : ( +
+ {value || " "} + +
+ ); + } + return
{cellContent}
; + } +} diff --git a/src/render/RadioRender.js b/src/render/RadioRender.js new file mode 100644 index 0000000..e69de29