|
|
@@ -1,13 +1,14 @@
|
|
|
import React from 'react';
|
|
|
import { connect } from 'dva';
|
|
|
-import { Input, Icon } from 'antd'
|
|
|
+import { Input, Icon, message } from 'antd'
|
|
|
import ChartView from './chartView';
|
|
|
|
|
|
class ViewLayoutItem extends React.Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
this.state = {
|
|
|
- editing: false
|
|
|
+ editing: false,
|
|
|
+ title: props.item.name
|
|
|
};
|
|
|
}
|
|
|
|
|
|
@@ -18,7 +19,7 @@ class ViewLayoutItem extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
const { dispatch, main, dashboardDesigner, item, isPreview, reload } = this.props;
|
|
|
- const { editing } = this.state;
|
|
|
+ const { editing, title } = this.state;
|
|
|
const { currentUser } = main;
|
|
|
const { dashboardDesignerCode, editMode, minLayoutHeight, theme: themeName } = dashboardDesigner;
|
|
|
const { code, name, viewType, layout, chartCode, chartOption } = item;
|
|
|
@@ -29,12 +30,24 @@ class ViewLayoutItem extends React.Component {
|
|
|
<div className='chartview-toolbar mover'>
|
|
|
<div className='chart-title'>
|
|
|
{editing ? <Input width={200} ref={node => this['inputRef-' + code] = node} defaultValue={name}
|
|
|
+ value={title}
|
|
|
style={{ marginTop: '4px' }}
|
|
|
+ onChange={e => {
|
|
|
+ let val = e.target.value + '';
|
|
|
+ if(val.trim().length > 20) {
|
|
|
+ message.warning('名称长度不能大于20');
|
|
|
+ }else {
|
|
|
+ this.setState({
|
|
|
+ title: val
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }}
|
|
|
onMouseDown={e => {
|
|
|
e.stopPropagation()
|
|
|
}}
|
|
|
onBlur={(e) => {
|
|
|
- let value = e.target.value
|
|
|
+ let value = e.target.value;
|
|
|
+ console.log(value);
|
|
|
this.setState({
|
|
|
editing: false,
|
|
|
}, () => {
|
|
|
@@ -42,7 +55,8 @@ class ViewLayoutItem extends React.Component {
|
|
|
});
|
|
|
}}
|
|
|
onPressEnter={(e) => {
|
|
|
- let value = e.target.value
|
|
|
+ let value = e.target.value;
|
|
|
+ console.log(value);
|
|
|
this.setState({
|
|
|
editing: false,
|
|
|
}, () => {
|