From 131bc212f0cfe964c9a38bbe6178aca4f4a16677 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 03 二月 2024 17:50:30 +0800 Subject: [PATCH] Merge branch 'master' into positec --- src/menu/components/chart/antv-dashboard/chartcompile/index.jsx | 195 +++++------------------------------------------- 1 files changed, 22 insertions(+), 173 deletions(-) diff --git a/src/menu/components/chart/antv-dashboard/chartcompile/index.jsx b/src/menu/components/chart/antv-dashboard/chartcompile/index.jsx index 71f4cc1..e1d3c40 100644 --- a/src/menu/components/chart/antv-dashboard/chartcompile/index.jsx +++ b/src/menu/components/chart/antv-dashboard/chartcompile/index.jsx @@ -1,19 +1,18 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { fromJS } from 'immutable' -import { Modal, Form, Row, Col, Select, Radio, Tooltip, Input, InputNumber, notification, Tabs, Button } from 'antd' -import { QuestionCircleOutlined, EditOutlined } from '@ant-design/icons' +import { Modal, Form, notification, Tabs, Button } from 'antd' +import { EditOutlined } from '@ant-design/icons' import Utils from '@/utils/utils.js' import { getBaseForm, getOptionForm, getRadioOptionForm } from './formconfig' import asyncComponent from '@/utils/asyncComponent' -import ColorSketch from '@/mob/colorsketch' import './index.scss' const { TabPane } = Tabs const EditTable = asyncComponent(() => import('@/templates/zshare/editTable')) -const NormalForm = asyncComponent(() => import('@/menu/components/share/normalform')) +const ModalForm = asyncComponent(() => import('@/components/normalform/modalform')) class LineChartDrawerForm extends Component { static propTpyes = { @@ -61,156 +60,20 @@ }) } - getFields() { - const { formlist } = this.state - const { getFieldDecorator } = this.props.form - const fields = [] - - if (!formlist) { - return fields - } - - formlist.forEach((item, index) => { - if (item.hidden || item.forbid) return - - if (item.type === 'text') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: '璇疯緭鍏�' + item.label + '!' - } - ] - })(<Input placeholder="" autoComplete="off" disabled={item.readonly} onPressEnter={this.onSubmit}/>)} - </Form.Item> - </Col> - ) - } else if (item.type === 'number') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: '璇疯緭鍏�' + item.label + '!' - } - ] - })(<InputNumber min={item.min} max={item.max} precision={item.decimal} onPressEnter={this.onSubmit}/>)} - </Form.Item> - </Col> - ) - } else if (item.type === 'select') { // 涓嬫媺 - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: '璇烽�夋嫨' + item.label + '!' - } - ] - })( - <Select mode={item.multi ? 'multiple' : ''}> - {item.options.map((option, index) => - <Select.Option key={index} value={option.field}> - {option.label} - </Select.Option> - )} - </Select> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'radio') { - fields.push( - <Col span={12} key={index}> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal, - rules: [ - { - required: !!item.required, - message: '璇烽�夋嫨' + item.label + '!' - } - ] - })( - <Radio.Group disabled={item.readonly}> - {item.options.map(option => { - return ( - <Radio key={option.value} value={option.value}>{option.text}</Radio> - ) - })} - </Radio.Group> - )} - </Form.Item> - </Col> - ) - } else if (item.type === 'color') { - fields.push( - <Col span={12} key={index} className="color-col"> - <Form.Item label={item.tooltip ? - <Tooltip placement="topLeft" title={item.tooltip}> - <QuestionCircleOutlined className="mk-form-tip" /> - {item.label} - </Tooltip> : item.label - }> - {getFieldDecorator(item.key, { - initialValue: item.initVal - })( - <ColorSketch /> - )} - </Form.Item> - </Col> - ) - } - }) - return fields - } - onSubmit = () => { const { config } = this.props const { plot, view } = this.state if (view === 'normal') { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - let _plot = {...plot, ...values} - - this.setState({ - plot: _plot, - visible: false - }) - - this.props.plotchange({...config, plot: _plot}) - } + this.normalRef.handleConfirm().then(values => { + let _plot = {...plot, ...values} + + this.setState({ + plot: _plot, + visible: false + }) + + this.props.plotchange({...config, plot: _plot}) }) } else if (view === 'base') { this.baseRef.handleConfirm().then(res => { @@ -236,15 +99,13 @@ const { plot, view } = this.state if (view === 'normal') { - this.props.form.validateFieldsAndScroll((err, values) => { - if (!err) { - let _plot = {...plot, ...values} + this.normalRef.handleConfirm().then(values => { + let _plot = {...plot, ...values} - this.setState({ - plot: _plot, - view: tab - }) - } + this.setState({ + plot: _plot, + view: tab + }) }) } else if (view === 'base') { this.baseRef.handleConfirm().then(res => { @@ -295,20 +156,10 @@ render() { const { config } = this.props - const { visible, plot, colorColumns, view, baseFormlist } = this.state - const formItemLayout = { - labelCol: { - xs: { span: 24 }, - sm: { span: 6 } - }, - wrapperCol: { - xs: { span: 24 }, - sm: { span: 18 } - } - } + const { visible, plot, colorColumns, view, baseFormlist, formlist } = this.state return ( - <div className="line-chart-drawer-form"> + <div className="dashboard-chart-drawer-form"> <EditOutlined title="缂栬緫" onClick={this.showDrawer} /> <Modal wrapClassName="mk-pop-modal" @@ -322,12 +173,10 @@ {config.name ? <div className="mk-com-name">{config.name} - 缂栬緫</div> : null} <Tabs activeKey={view} className="menu-chart-edit-box" onChange={this.changeTab}> <TabPane tab="缁勪欢璁剧疆" key="base"> - <NormalForm formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/> + <ModalForm formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/> </TabPane> <TabPane tab="鍥捐〃璁剧疆" key="normal"> - <Form {...formItemLayout}> - <Row gutter={16}>{this.getFields()}</Row> - </Form> + <ModalForm formlist={formlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.normalRef = inst}/> </TabPane> {plot ? <TabPane tab="棰滆壊璁剧疆" key="color"> <div> -- Gitblit v1.8.0