From 69db12287a007990de956bef9cef6c2dec65ace7 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 07 五月 2020 09:18:40 +0800 Subject: [PATCH] 2020-05-07 --- src/templates/sharecomponent/chartcomponent/chartcompile/index.jsx | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/templates/sharecomponent/chartcomponent/chartcompile/index.jsx b/src/templates/sharecomponent/chartcomponent/chartcompile/index.jsx index b9b0a2c..611b19c 100644 --- a/src/templates/sharecomponent/chartcomponent/chartcompile/index.jsx +++ b/src/templates/sharecomponent/chartcomponent/chartcompile/index.jsx @@ -1,6 +1,6 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' -// import { is, fromJS } from 'immutable' +import { fromJS } from 'immutable' import { Drawer, Form, Button, Col, Row, Select, Icon, Radio, Tooltip, Input, InputNumber } from 'antd' import { getChartOptionForm } from '@/templates/zshare/formconfig' @@ -15,7 +15,9 @@ } state = { + view: 'normal', visible: false, + plot: null, formlist: null } @@ -24,18 +26,12 @@ this.setState({ visible: true, + plot: fromJS(plot).toJS(), formlist: getChartOptionForm(plot, config.columns, config.setting) }) } - onClose = (type) => { - if (type !== 'submit') { - this.setState({ - visible: false - }) - return - } - + onSubmit = () => { this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { this.setState({ @@ -181,7 +177,26 @@ return fields } + changeView = () => { + let _view = this.state.view === 'normal' ? 'custom' : 'normal' + + if (_view === 'custom') { + this.props.form.validateFieldsAndScroll((err, values) => { + if (!err) { + let _plot = {...this.state.plot, ...values} + + this.setState({ + plot: _plot, + view: _view + }) + } + }) + } + this.setState({view: _view}) + } + render() { + const { view } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -200,13 +215,21 @@ title="鍥捐〃缂栬緫" className="chart-drawer-form" width={720} - onClose={this.onClose} + onClose={() => this.setState({ visible: false })} visible={this.state.visible} bodyStyle={{ paddingBottom: 80 }} > - <Form {...formItemLayout}> + {view !== 'custom' ? <Form {...formItemLayout}> <Row gutter={16}>{this.getFields()}</Row> - </Form> + <Row gutter={16}> + <Button onClick={this.changeView} style={{border: 0, boxShadow: 'unset',float: 'right', color: '#1890ff', marginRight: 12, cursor: 'pointer'}}>鑷畾涔夎缃�<Icon style={{marginLeft: 5}} type="right" /></Button> + </Row> + </Form> : null} + {/* <Form {...formItemLayout}> + <Row gutter={16}> + <Button onClick={this.changeView} style={{border: 0, boxShadow: 'unset',float: 'right', color: '#1890ff', marginRight: 12, cursor: 'pointer'}}>鑷畾涔夎缃�<Icon style={{marginLeft: 5}} type="right" /></Button> + </Row> + </Form> */} <div style={{ position: 'absolute', @@ -219,10 +242,10 @@ textAlign: 'right', }} > - <Button onClick={this.onClose} style={{ marginRight: 8 }}> + <Button onClick={() => this.setState({ visible: false })} style={{ marginRight: 8 }}> 鍙栨秷 </Button> - <Button onClick={() => this.onClose('submit')} type="primary"> + <Button onClick={() => this.onSubmit()} type="primary"> 鎻愪氦 </Button> </div> -- Gitblit v1.8.0