king
2021-08-31 72419e2f826031a158173f46d723a672064e37cd
src/menu/components/chart/antv-pie/chartcompile/index.jsx
@@ -4,7 +4,7 @@
import { Modal, Form, Row, Col, Select, Icon, Radio, Tooltip, Input, InputNumber, Tabs, Button } from 'antd'
import Utils from '@/utils/utils.js'
import { getPieChartOptionForm } from './formconfig'
import { getBaseForm, getOptionForm } from './formconfig'
import asyncComponent from '@/utils/asyncComponent'
import ColorSketch from '@/mob/colorsketch'
import './index.scss'
@@ -12,13 +12,12 @@
const { TabPane } = Tabs
const EditTable = asyncComponent(() => import('@/templates/zshare/editTable'))
const NormalForm = asyncComponent(() => import('@/menu/components/share/normalform'))
class LineChartDrawerForm extends Component {
  static propTpyes = {
    MenuType: PropTypes.any,
    dict: PropTypes.object,
    plot: PropTypes.object,
    sysRoles: PropTypes.array,
    config: PropTypes.object,
    plotchange: PropTypes.func
  }
@@ -27,6 +26,7 @@
    visible: false,
    plot: null,
    formlist: null,
    baseFormlist: null,
    view: 'normal',
    colorColumns: [
      {
@@ -50,13 +50,14 @@
  }
  showDrawer = () => {
    const { config, sysRoles, MenuType } = this.props
    const { config } = this.props
    this.setState({
      visible: true,
      view: 'normal',
      plot: fromJS(config.plot).toJS(),
      formlist: getPieChartOptionForm(config.plot, config.columns, sysRoles, MenuType)
      baseFormlist: getBaseForm(config.plot),
      formlist: getOptionForm(config.plot, config.columns)
    })
  }
@@ -69,6 +70,10 @@
        formlist: formlist.map(item => {
          if (item.key === 'innerRadius') {
            item.hidden = val === 'pie'
          } else if (item.key === 'type') {
            item.hidden = val !== 'nest'
          } else if (item.key === 'legend') {
            item.hidden = val === 'nest'
          }
          return item
        })
@@ -156,7 +161,7 @@
              })(
                <Select mode={item.multi ? 'multiple' : ''}>
                  {item.options.map((option, index) =>
                    <Select.Option key={index} value={option.field}>
                    <Select.Option key={index} value={option.field || option.value}>
                      {option.label}
                    </Select.Option>
                  )}
@@ -183,7 +188,7 @@
                  }
                ]
              })(
                <Radio.Group disabled={item.readonly} onChange={(e) => this.radioChange(e, item.key)}>
                <Radio.Group style={{whiteSpace: 'nowrap'}} disabled={item.readonly} onChange={(e) => this.radioChange(e, item.key)}>
                  {item.options.map(option => {
                    return (
                      <Radio key={option.value} value={option.value}>{option.text}</Radio>
@@ -216,26 +221,6 @@
    return fields
  }
  axisChange = (e) => {
    const { plot } = this.state
    let val = e.target.value
    let fieldvalue = {}
    plot.customs.forEach(item => {
      if (this.props.form.getFieldValue(item.field + '$axis') === val) {
        fieldvalue[item.field + '$axis'] = 'unset'
      }
    })
    this.props.form.setFieldsValue(fieldvalue)
  }
  enabledChange = (e) => {
    let val = e.target.value
    this.setState({enabled: val})
  }
  onSubmit = () => {
    const { config } = this.props
    const { plot, view } = this.state
@@ -253,6 +238,17 @@
          this.props.plotchange({...config, plot: _plot})
        }
      })
    } else if (view === 'base') {
      this.baseRef.handleConfirm().then(res => {
        let _plot = {...plot, ...res}
        this.setState({
          plot: _plot,
          visible: false
        })
        this.props.plotchange({...config, plot: _plot})
      })
    } else {
      this.setState({
        visible: false
@@ -263,9 +259,9 @@
  }
  changeTab = (tab) => {
    const { plot } = this.state
    const { plot, view } = this.state
    if (tab === 'color') {
    if (view === 'normal') {
      this.props.form.validateFieldsAndScroll((err, values) => {
        if (!err) {
          let _plot = {...plot, ...values}
@@ -275,6 +271,15 @@
            view: tab
          })
        }
      })
    } else if (view === 'base') {
      this.baseRef.handleConfirm().then(res => {
        let _plot = {...plot, ...res}
        this.setState({
          plot: _plot,
          view: tab
        })
      })
    } else {
      this.setState({
@@ -303,7 +308,7 @@
  }
  render() {
    const { visible, plot, colorColumns, view } = this.state
    const { visible, plot, colorColumns, view, baseFormlist } = this.state
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
@@ -317,7 +322,7 @@
    return (
      <div className="line-chart-drawer-form">
        <Icon type="edit" onClick={this.showDrawer} />
        <Icon type="edit" title="编辑" onClick={this.showDrawer} />
        <Modal
          wrapClassName="popview-modal menu-chart-edit-modal"
          title="图表编辑"
@@ -329,7 +334,10 @@
          destroyOnClose
        >
          <Tabs activeKey={view} className="menu-chart-edit-box" onChange={this.changeTab}>
            <TabPane tab="基础设置" key="normal">
            <TabPane tab="组件设置" key="base">
              <NormalForm dict={this.props.dict} formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/>
            </TabPane>
            <TabPane tab="图表设置" key="normal">
              <Form {...formItemLayout}>
                <Row gutter={16}>{this.getFields()}</Row>
              </Form>
@@ -337,7 +345,7 @@
            {plot ? <TabPane tab="颜色设置" key="color">
              <div>
                <Button className="color-add mk-green" onClick={this.addColor}>{this.props.dict['model.add']}</Button>
                <EditTable data={plot.colors || []} columns={colorColumns} onChange={this.changeColor}/>
                <EditTable actions={['edit', 'move', 'del']} data={plot.colors || []} columns={colorColumns} onChange={this.changeColor}/>
              </div>
            </TabPane> : null}
          </Tabs>