import React from 'react'
import { connect } from 'dva'
import { Collapse, Menu, Form, Checkbox, Row, Col, Select, Radio, Input, InputNumber } from 'antd'
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;
// const TableStyle = ({ chartDesigner, formItemLayout, dispatch }) => {
class TableStyle extends React.Component {
constructor(props) {
super(props);
this.state = {
layoutColumn: null,
formatColumn: null,
colorColumn: null,
}
}
changeAligns = (value) => {
const { chartDesigner, dispatch } = this.props;
const { layoutColumn } = this.state;
const { styleConfig } = chartDesigner;
const { table } = (styleConfig || { aligns: {} });
let aligns = table ? (table.aligns || {}) : {};
if(!layoutColumn) {
return;
}else if(layoutColumn.name === 'all') {
chartDesigner.dataViewConfig.viewColumns.map(c => {
aligns[c.name] = value
});
}else {
aligns[layoutColumn.name] = value
}
dispatch({ type: 'chartDesigner/setField', name: 'styleConfig', value: { ...styleConfig, table: { ...table, aligns }} });
}
changeWidths = (e) => {
const { chartDesigner, dispatch } = this.props;
const { layoutColumn } = this.state;
const { styleConfig } = chartDesigner;
const { table} = styleConfig;
let widths = table ? (table.widths || {}) : {};
if(!layoutColumn) {
return;
}else if(layoutColumn.name === 'all') {
chartDesigner.dataViewConfig.viewColumns.map(c => {
widths[c.name] = e.target.value
});
}else {
widths[layoutColumn.name] = e.target.value
}
dispatch({ type: 'chartDesigner/setField', name: 'styleConfig', value: { ...styleConfig, table: { ...table, widths }} });
}
changeThousandsSeparator = (e) => {
const { chartDesigner, dispatch } = this.props;
const { formatColumn } = this.state;
const { styleConfig } = chartDesigner;
const { table} = styleConfig;
const checked = e.target.checked;
let thousandsSeparatorColumns = table ? (table.thousandsSeparatorColumns || []) : [];
if(!formatColumn) {
return;
}else {
let idx = thousandsSeparatorColumns.findIndex(s => s === formatColumn.name);
console.log(idx);
checked ? (idx !== -1 ? (void 0) : thousandsSeparatorColumns.push(formatColumn.name)) : thousandsSeparatorColumns.splice(idx, 1);
}
dispatch({ type: 'chartDesigner/setField', name: 'styleConfig', value: { ...styleConfig, table: { ...table, thousandsSeparatorColumns }} });
}
createColumnSelector = (type, all) => {
const { chartDesigner } = this.props;
let columns = all ? [{
name: 'all',
label: '全部'
}].concat(chartDesigner.dataViewConfig.viewColumns) : chartDesigner.dataViewConfig.viewColumns;
return
}
render() {
const { chartDesigner, formItemLayout, dispatch } = this.props;
const { layoutColumn, formatColumn, colorColumn } = this.state;
const { styleConfig } = chartDesigner;
console.log(styleConfig);
const { table } = (styleConfig || { aligns: {} });
return (
{
const checked = e.target.checked;
dispatch({ type: 'chartDesigner/setField', name: 'styleConfig', value: { ...styleConfig, table: { ...table, visibleIndex: checked }} });
}}/>
{
const checked = e.target.checked;
dispatch({ type: 'chartDesigner/setField', name: 'styleConfig', value: { ...styleConfig, table: { ...table, bordered: checked }} });
}}/>
{this.createColumnSelector('layoutColumn', true)}
{layoutColumn &&
}
{layoutColumn &&
}
{this.createColumnSelector('formatColumn', false)}
{formatColumn && formatColumn.type === 'scale' &&
}
{formatColumn && formatColumn.type === 'scale' &&
}
{formatColumn &&
}
行交替
列交替
)
}
}
export default connect(({ present: { chartDesigner } }) => ({ chartDesigner }))(TableStyle);