| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { Icon, Tooltip, Modal, notification, Switch, message } from 'antd' |
| | | import { Tooltip, Modal, notification, Switch, message } from 'antd' |
| | | import { QuestionCircleOutlined, CopyOutlined } from '@ant-design/icons' |
| | | |
| | | import zhCN from '@/locales/zh-CN/model.js' |
| | | import enUS from '@/locales/en-US/model.js' |
| | |
| | | import GridBtnForm from './gridbtnform' |
| | | import DragElement from './dragcolumn' |
| | | import MarkColumn from './markcolumn' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import './index.scss' |
| | | |
| | | const { confirm } = Modal |
| | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | columnlist: null, // 显示列 |
| | | showField: false, // 显示列字段 |
| | | showField: true, // 显示列字段 |
| | | modaltype: '', // 模态框控制 |
| | | card: null // 编辑中元素 |
| | | } |
| | |
| | | this.setState({ |
| | | columnlist: fromJS(this.props.config.columns).toJS() |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 监听到显示列复制时,触发显示列编辑 |
| | | */ |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | const { config } = this.props |
| | | const { columnlist } = this.state |
| | | |
| | | if (!is(fromJS(nextProps.config.columns), fromJS(config.columns)) && !is(fromJS(nextProps.config.columns), fromJS(columnlist))) { |
| | | this.setState({columnlist: fromJS(nextProps.config.columns).toJS()}) |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | |
| | | plusColumns = (MenuId, items) => { |
| | | const { config } = this.props |
| | | const { columnlist } = this.state |
| | | |
| | | if (MenuId !== config.uuid) return |
| | | |
| | | let list = [...columnlist, ...items] |
| | | |
| | | if (list[0] && list[0].origin) { |
| | | list = list.filter(col => !col.origin) |
| | | } |
| | | |
| | | this.setState({ |
| | | columnlist: list |
| | | }, () => { |
| | | this.props.updatecolumn({...config, columns: list}) |
| | | }) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState)) |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('plusColumns', this.plusColumns) |
| | | } |
| | | |
| | | /** |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('plusColumns', this.plusColumns) |
| | | } |
| | | |
| | | render() { |
| | |
| | | return ( |
| | | <div className="model-table-column-list"> |
| | | <Tooltip placement="bottomLeft" overlayClassName="middle" title={dict['model.tooltip.column.guide']}> |
| | | <Icon type="question-circle" /> |
| | | <QuestionCircleOutlined style={{color: '#c49f47', position: 'relative', left: '-15px', top: '5px'}} /> |
| | | </Tooltip> |
| | | {columnlist && columnlist.length > 0 ? |
| | | <Icon className="column-copy" title="copy" type="copy" onClick={this.copycolumn} /> : null |
| | | <CopyOutlined className="column-copy" title="copy" onClick={this.copycolumn} /> : null |
| | | } |
| | | <Switch checkedChildren={dict['model.switch.open']} unCheckedChildren={dict['model.switch.close']} defaultChecked={this.state.showField} onChange={this.onFieldChange} /> |
| | | <DragElement |