import React from 'react'; import { Button, Icon } from 'antd'; import { WeaTools, WeaLocaleProvider, WeaDialog } from 'ecCom'; const getLabel = WeaLocaleProvider.getLabel; import './style/'; class WeaThemeLayout extends React.Component { state = { visible: false, loading: false, layouts: [], curLayout: {} }; constructor(props) { super(props); this.getButtons = this.getButtons.bind(this); this.onOk = this.onOk.bind(this); this.onCancel = this.onCancel.bind(this); this.onChange = this.onChange.bind(this); } render() { const { visible, loading, layouts = [], curLayout = {} } = this.state; return ( { layouts.map((layout) => { const { key, type, name } = layout; const isSelected = type == curLayout.type; const selectedClassName = isSelected ? 'wea-theme-layout-selected' : ''; return ( this.onChange(layout)}> {name} {isSelected ? : ''} ); }) } ); } getButtons() { let buttons = []; buttons.push({getLabel(0, '关闭')}); return buttons; } onOk() { this.setState({ visible: false }); } onCancel() { this.setState({ visible: false }); } onShow() { this.setState({ visible: true, loading: true }); WeaTools.callApi('/api/portal/themeCenter/getAllLayouts', 'GET', {}).then((result) => { const { data = {} } = result; this.setState({ loading: false, ...data }); }); } onChange(layout) { this.setState({ curLayout: layout }); doThemeAction('onLayoutChange', layout); } } export default WeaThemeLayout;