|
|
@@ -1,6 +1,7 @@
|
|
|
import React from 'react'
|
|
|
import { Input, Icon, Button, Popconfirm, Tooltip, Modal } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
+import DeleteBox from '../common/deleteBox/deleteBox'
|
|
|
import './header.less'
|
|
|
|
|
|
class Header extends React.Component {
|
|
|
@@ -9,6 +10,7 @@ class Header extends React.Component {
|
|
|
this.state = {
|
|
|
visibleConfirm: false,
|
|
|
visibleCopyBox: false,
|
|
|
+ visibleDeleteBox: false,
|
|
|
newHeaderLabel: ''
|
|
|
}
|
|
|
}
|
|
|
@@ -35,7 +37,7 @@ class Header extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
const { chartDesigner, dispatch } = this.props;
|
|
|
- const { visibleCopyBox, newHeaderLabel } = this.state;
|
|
|
+ const { visibleCopyBox, newHeaderLabel, visibleDeleteBox } = this.state;
|
|
|
return (
|
|
|
<div className='header'>
|
|
|
<div className='header-item toolbar-back'>
|
|
|
@@ -73,14 +75,6 @@ class Header extends React.Component {
|
|
|
}}>
|
|
|
<Icon type='left' />返回
|
|
|
</Button>}
|
|
|
- {this.isOwner() && <Button className='button-uodo' onClick={() => {
|
|
|
- if(chartDesigner.code && chartDesigner.code !== -1) {
|
|
|
- dispatch({ type: 'chart/remoteModify' });
|
|
|
- }else {
|
|
|
- dispatch({ type: 'chart/remoteAdd' });
|
|
|
- }
|
|
|
- dispatch({ type: 'chartDesigner/setDirty', dirty: false });
|
|
|
- }}><Icon type='save' />保存</Button>}
|
|
|
</div>
|
|
|
<div className='header-item toolbar-title'>
|
|
|
<Input
|
|
|
@@ -99,41 +93,55 @@ class Header extends React.Component {
|
|
|
/>
|
|
|
</div>
|
|
|
<div className='header-item toolbar-buttons'>
|
|
|
- <div>
|
|
|
- {this.isOwner() && <Tooltip title='复制新增'>
|
|
|
- <Button className='tools-btn' icon='copy' onClick={() => {
|
|
|
- this.setState({
|
|
|
- visibleCopyBox: true,
|
|
|
- newHeaderLabel: chartDesigner.header.label + '_副本'
|
|
|
- })
|
|
|
- }}>
|
|
|
- </Button>
|
|
|
- </Tooltip>}
|
|
|
- {this.isOwner() && visibleCopyBox && <Modal
|
|
|
- title="复制新增"
|
|
|
- visible={visibleCopyBox}
|
|
|
- okText='创建'
|
|
|
- onOk={this.copyHandler}
|
|
|
- onCancel={() => {this.setState({visibleCopyBox:false})}}
|
|
|
- >
|
|
|
- <p>当前的图表会被保存,您将从新的图表副本继续设计。</p>
|
|
|
- 副本名称:<Input value={newHeaderLabel} placeholder={chartDesigner.header.label+'_副本'} onChange={(e) => {
|
|
|
- this.setState({
|
|
|
- newHeaderLabel: e.target.value
|
|
|
- });
|
|
|
- }} />
|
|
|
- </Modal>}
|
|
|
- {/* <Tooltip title='撤销'>
|
|
|
- <Button className='tools-btn' icon='undo' disabled={past.length === 0} onClick={() => {
|
|
|
- dispatch(ActionCreators.undo());
|
|
|
- }}></Button>
|
|
|
- </Tooltip>
|
|
|
- <Tooltip title='重做'>
|
|
|
- <Button className='tools-btn' icon='redo' disabled={future.length === 0} onClick={() => {
|
|
|
- dispatch(ActionCreators.redo());
|
|
|
- }}></Button>
|
|
|
- </Tooltip> */}
|
|
|
- </div>
|
|
|
+ {this.isOwner() && <Tooltip title='复制新增'>
|
|
|
+ <Button className='tools-btn' icon='copy' onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleCopyBox: true,
|
|
|
+ newHeaderLabel: chartDesigner.header.label + '_副本'
|
|
|
+ })
|
|
|
+ }}>
|
|
|
+ 复制
|
|
|
+ </Button>
|
|
|
+ </Tooltip>}
|
|
|
+ {this.isOwner() && visibleCopyBox && <Modal
|
|
|
+ title="复制新增"
|
|
|
+ visible={visibleCopyBox}
|
|
|
+ okText='创建'
|
|
|
+ onOk={this.copyHandler}
|
|
|
+ onCancel={() => {this.setState({visibleCopyBox:false})}}
|
|
|
+ >
|
|
|
+ <p>当前的图表会被保存,您将从新的图表副本继续设计。</p>
|
|
|
+ 副本名称:<Input value={newHeaderLabel} placeholder={chartDesigner.header.label+'_副本'} onChange={(e) => {
|
|
|
+ this.setState({
|
|
|
+ newHeaderLabel: e.target.value
|
|
|
+ });
|
|
|
+ }} />
|
|
|
+ </Modal>}
|
|
|
+ {this.isOwner() && <Button onClick={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleDeleteBox: true
|
|
|
+ });
|
|
|
+ }}><Icon type='delete' />删除</Button>}
|
|
|
+ {visibleDeleteBox && <DeleteBox
|
|
|
+ visibleBox={visibleDeleteBox}
|
|
|
+ text={<div><span>确定要删除图表【{chartDesigner.header.label}】吗?</span></div>}
|
|
|
+ hideBox={() => {
|
|
|
+ this.setState({
|
|
|
+ visibleDeleteBox: false
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ okHandler={() => {
|
|
|
+ dispatch({ type: 'chart/remoteDelete', code: chartDesigner.code });
|
|
|
+ dispatch({ type: 'main/goBack', path: '/workshop/chart' });
|
|
|
+ }} />}
|
|
|
+ {this.isOwner() && <Button onClick={() => {
|
|
|
+ if(chartDesigner.code && chartDesigner.code !== -1) {
|
|
|
+ dispatch({ type: 'chart/remoteModify' });
|
|
|
+ }else {
|
|
|
+ dispatch({ type: 'chart/remoteAdd' });
|
|
|
+ }
|
|
|
+ dispatch({ type: 'chartDesigner/setDirty', dirty: false });
|
|
|
+ }}><Icon type='save' />保存</Button>}
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|