|
|
@@ -1,11 +1,12 @@
|
|
|
import React from 'react'
|
|
|
import '../../models/dashboardDesigner'
|
|
|
-import { Modal, Radio, Row, Col, Table, message } from 'antd'
|
|
|
+import { Modal, Checkbox, Row, Col, Table, message } from 'antd'
|
|
|
import { connect } from 'dva'
|
|
|
import moment from 'moment'
|
|
|
import 'braft-editor/dist/braft.css'
|
|
|
import ListFilter from '../common/listFilter/index'
|
|
|
import './chooseChartBox.less'
|
|
|
+import CHART_TYPE from '../chartDesigner/sections/chartType'
|
|
|
|
|
|
class ChooseChartBox extends React.Component {
|
|
|
|
|
|
@@ -15,6 +16,7 @@ class ChooseChartBox extends React.Component {
|
|
|
filterLabel: '',
|
|
|
filterItem: { name: 'name', label: '图表名称', type: 'string' },
|
|
|
selectedRecord: -1,
|
|
|
+ selectedRecords: [],
|
|
|
screenWidth: document.documentElement.clientWidth || document.body.clientWidth,
|
|
|
screenHeight: document.documentElement.clientHeight || document.body.clientHeight
|
|
|
};
|
|
|
@@ -38,20 +40,36 @@ class ChooseChartBox extends React.Component {
|
|
|
}
|
|
|
|
|
|
changeSelected = (record) => {
|
|
|
- this.setState({
|
|
|
- selectedRecord: record
|
|
|
- });
|
|
|
+ const { dashboardDesigner } = this.props;
|
|
|
+ const { selectedRecords } = this.state;
|
|
|
+ let idx = selectedRecords.findIndex(s => s.code === record.code);
|
|
|
+ if(dashboardDesigner.items.findIndex(i => i.chartCode===record.code) === -1) {
|
|
|
+ if(idx === -1) {
|
|
|
+ selectedRecords.push(record);
|
|
|
+ }else {
|
|
|
+ selectedRecords.splice(idx, 1);
|
|
|
+ }
|
|
|
+ this.setState({
|
|
|
+ selectedRecords: selectedRecords
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- okHandler = (model) => {
|
|
|
- const { selectedRecord } = this.state;
|
|
|
+ okHandler = () => {
|
|
|
+ // const { selectedRecord } = this.state;
|
|
|
+ // const { dispatch, hideBox } = this.props;
|
|
|
+ // if(selectedRecord) {
|
|
|
+ // dispatch({ type: 'dashboardDesigner/addChart', chart: selectedRecord });
|
|
|
+ // hideBox();
|
|
|
+ // }else {
|
|
|
+ // message.warning('未选中图表');
|
|
|
+ // }
|
|
|
+ const { selectedRecords } = this.state;
|
|
|
const { dispatch, hideBox } = this.props;
|
|
|
- if(selectedRecord) {
|
|
|
- dispatch({ type: 'dashboardDesigner/addChart', chart: selectedRecord });
|
|
|
- hideBox();
|
|
|
- }else {
|
|
|
- message.warning('未选中图表');
|
|
|
+ if(selectedRecords.length > 0) {
|
|
|
+ dispatch({ type: 'dashboardDesigner/addCharts', charts: selectedRecords });
|
|
|
}
|
|
|
+ hideBox();
|
|
|
}
|
|
|
|
|
|
onSearch = (list) => {
|
|
|
@@ -94,7 +112,7 @@ class ChooseChartBox extends React.Component {
|
|
|
|
|
|
render() {
|
|
|
const { visibleBox, hideBox, dashboardDesigner, chart } = this.props;
|
|
|
- const { selectedRecord, screenWidth, screenHeight, filterItem, filterLabel: stateFilterLabel } = this.state;
|
|
|
+ const { selectedRecords, selectedRecord, screenWidth, screenHeight, filterItem, filterLabel: stateFilterLabel } = this.state;
|
|
|
const tableBodyWidth = screenWidth * 0.8 - 10 - 10 - 18;
|
|
|
const tableBodyHeight = screenHeight * 0.8 - 65 - 53 - 38 - 130;
|
|
|
const tableRowHeight = 38;
|
|
|
@@ -106,16 +124,17 @@ class ChooseChartBox extends React.Component {
|
|
|
width: 50,
|
|
|
render: (text, record) => {
|
|
|
// return <Checkbox checked={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1 || selectedRecord.findIndex(s => s.code === record.code) !== -1 } disabled={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1}/>
|
|
|
- return <Radio
|
|
|
- checked={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1 || selectedRecord.code === record.code }
|
|
|
- disabled={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1}
|
|
|
- />
|
|
|
+ return <Checkbox checked={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1 || selectedRecords.findIndex(s => s.code === record.code) !== -1 } disabled={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1}/>
|
|
|
+ // return <Radio
|
|
|
+ // checked={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1 || selectedRecord.code === record.code }
|
|
|
+ // disabled={dashboardDesigner.items.findIndex(i => i.chartCode===record.code)!==-1}
|
|
|
+ // />
|
|
|
}
|
|
|
}, {
|
|
|
title: '名称',
|
|
|
dataIndex: 'name',
|
|
|
key: 'name',
|
|
|
- width: 100,
|
|
|
+ width: 200,
|
|
|
render: (text, record) => {
|
|
|
return <div>
|
|
|
<div>
|
|
|
@@ -134,11 +153,17 @@ class ChooseChartBox extends React.Component {
|
|
|
</div>
|
|
|
</div>
|
|
|
}
|
|
|
+ }, {
|
|
|
+ title: '图形类别',
|
|
|
+ dataIndex: 'type',
|
|
|
+ key: 'type',
|
|
|
+ width: 100,
|
|
|
+ render: text => text ? CHART_TYPE.find(t => t.type === text).label : '无'
|
|
|
}, {
|
|
|
title: '数据源',
|
|
|
dataIndex: 'dataSourceName',
|
|
|
key: 'dataSourceName',
|
|
|
- width: 100,
|
|
|
+ width: 200,
|
|
|
}, {
|
|
|
title: '创建人',
|
|
|
dataIndex: 'creatorName',
|
|
|
@@ -172,7 +197,6 @@ class ChooseChartBox extends React.Component {
|
|
|
title: '说明',
|
|
|
dataIndex: 'description',
|
|
|
key: 'description',
|
|
|
- width: 200,
|
|
|
render: (text, record) => {
|
|
|
return (
|
|
|
<span>
|
|
|
@@ -195,61 +219,52 @@ class ChooseChartBox extends React.Component {
|
|
|
className='choosechart-box'
|
|
|
width='80%'
|
|
|
height='80%'
|
|
|
- title={
|
|
|
- <Row>
|
|
|
- <Row>
|
|
|
- <Col >选择图表</Col>
|
|
|
- </Row>
|
|
|
- <Row type='flex' justify='end'>
|
|
|
- <Col style={{ padding: '0 5px' }}>
|
|
|
- <ListFilter
|
|
|
- modelName={null}
|
|
|
- model={{
|
|
|
- filterItems: chart.filterItems,
|
|
|
- filterItem,
|
|
|
- filterLabel: stateFilterLabel,
|
|
|
- }}
|
|
|
- onChangeFilterItem={(filterItem) => {
|
|
|
- this.setState({
|
|
|
- filterItem
|
|
|
- });
|
|
|
- }}
|
|
|
- onChangeFilterValue={(filterLabel) => {
|
|
|
- this.setState({
|
|
|
- filterLabel
|
|
|
- });
|
|
|
- }}
|
|
|
- />
|
|
|
- </Col>
|
|
|
- </Row>
|
|
|
- </Row>
|
|
|
- }
|
|
|
+ title='选择图表'
|
|
|
visible={visibleBox}
|
|
|
- onOk={() => {this.setState({ filterLabel: '', selectedRecord: -1 });this.okHandler()}}
|
|
|
- onCancel={() => {this.setState({ filterLabel: '', selectedRecord: -1 });hideBox()}}
|
|
|
+ onOk={this.okHandler}
|
|
|
+ onCancel={hideBox}
|
|
|
maskClosable={false}
|
|
|
destroyOnClose={true}
|
|
|
>
|
|
|
- <Table
|
|
|
- className='choosechart-table'
|
|
|
- columns={columns.map(c => ({
|
|
|
- ...c,
|
|
|
- width: 100
|
|
|
- }))}
|
|
|
- dataSource={this.onSort(this.onSearch(chart.list))}
|
|
|
- size='small'
|
|
|
- scroll={{ x: columns ? columns.length * 100 : tableBodyWidth, y: tableBodyHeight }}
|
|
|
- pagination={{ defaultPageSize: Math.floor(tableBodyHeight/tableRowHeight) || 10 }}
|
|
|
- onRow={(record) => {
|
|
|
- return {
|
|
|
- onClick: () => {
|
|
|
- if(dashboardDesigner.items.findIndex(i => i.chartCode===record.code)===-1) {
|
|
|
+ <div>
|
|
|
+ <Row type='flex' justify='end'>
|
|
|
+ <Col style={{ padding: '8px' }}>
|
|
|
+ <ListFilter
|
|
|
+ modelName={null}
|
|
|
+ model={{
|
|
|
+ filterItems: chart.filterItems,
|
|
|
+ filterItem,
|
|
|
+ filterLabel: stateFilterLabel,
|
|
|
+ }}
|
|
|
+ onChangeFilterItem={(filterItem) => {
|
|
|
+ this.setState({
|
|
|
+ filterItem
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ onChangeFilterValue={(filterLabel) => {
|
|
|
+ this.setState({
|
|
|
+ filterLabel
|
|
|
+ });
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ <Table
|
|
|
+ className='choosechart-table'
|
|
|
+ columns={columns}
|
|
|
+ dataSource={this.onSort(this.onSearch(chart.list)).map((d, i) => ({ ...d, key: i }))}
|
|
|
+ size='small'
|
|
|
+ scroll={{ x: columns ? columns.length * 100 : tableBodyWidth, y: tableBodyHeight }}
|
|
|
+ pagination={{ defaultPageSize: Math.floor(tableBodyHeight/tableRowHeight) || 10 }}
|
|
|
+ onRow={(record) => {
|
|
|
+ return {
|
|
|
+ onClick: () => {
|
|
|
this.changeSelected(record);
|
|
|
}
|
|
|
- }
|
|
|
- };
|
|
|
- }}
|
|
|
- />
|
|
|
+ };
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</Modal>
|
|
|
)
|
|
|
}
|