import React, { useContext } from 'react'; import { connect, mapProps, observer, useField, useFieldSchema, mapReadPretty, } from '@formily/react'; import { Button, Dropdown, Input as AntdInput, Menu, Space } from 'antd'; import { LoadingOutlined, MenuOutlined, DragOutlined } from '@ant-design/icons'; import { useDesignable } from '../../components/schema-renderer'; import { useState } from 'react'; import AddNew from '../add-new'; import cls from 'classnames'; import { DraggableBlockContext } from '../../components/drag-and-drop'; import { uid } from '@formily/shared'; import { removeSchema, updateSchema } from '..'; import { isGridRowOrCol } from '../grid'; import G2Plot from './G2Plot'; import { Column, Line, Pie, Bar } from '@antv/g2plot'; import { DragHandle } from '../../components/Sortable'; export const Chart: any = {}; Chart.Column = observer((props: any) => { return ; }); Chart.Line = observer((props: any) => { return ; }); Chart.Pie = observer((props: any) => { return ; }); Chart.Bar = observer((props: any) => { return ; }); Chart.DesignableBar = observer((props) => { const field = useField(); const { designable, schema, refresh, deepRemove } = useDesignable(); const [visible, setVisible] = useState(false); const { dragRef } = useContext(DraggableBlockContext); if (!designable) { return null; } return (
{ e.stopPropagation(); }} className={cls('designable-bar-actions', { active: visible })} > { setVisible(visible); }} overlay={ { field.readPretty = false; setVisible(false); }} > 修改内容 { const removed = deepRemove(); // console.log({ removed }) const last = removed.pop(); if (isGridRowOrCol(last)) { await removeSchema(last); } }} > 移除 } >
); });