| | |
| | | import React, { Component } from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { Icon, notification } from 'antd' |
| | | import { notification } from 'antd' |
| | | import { PlusOutlined } from '@ant-design/icons' |
| | | |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | let data = this.props['data-__meta'].initialValue || [] |
| | | |
| | | this.setState({ |
| | | loading: false, |
| | | data: data.map(item => { |
| | | item.uuid = item.uuid || item.key |
| | | return item |
| | |
| | | message: '字段名不可重复!', |
| | | duration: 5 |
| | | }) |
| | | this.setState({loading: true}, () => { |
| | | this.setState({loading: false}) |
| | | }) |
| | | return |
| | | } |
| | | Array.from(new Set(fields)) |
| | | |
| | | this.setState({ data }, () => { |
| | | this.props.onChange(data) |
| | | }) |
| | | } |
| | | |
| | | render() { |
| | | const { data, columns } = this.state |
| | | const { data, columns, loading } = this.state |
| | | |
| | | return ( |
| | | <div className="modal-card-field-table"> |
| | | {data.length < 3 ? <Icon className="add-row" type="plus" onClick={this.handleAdd} /> : null} |
| | | <EditTable actions={['edit', 'move', 'del']} data={data} columns={columns} onChange={this.changeData}/> |
| | | {data.length < 3 ? <PlusOutlined className="add-row" onClick={this.handleAdd} /> : null} |
| | | {!loading ? <EditTable indexShow={false} actions={['edit', 'move', 'del']} data={data} columns={columns} onChange={this.changeData}/> : null} |
| | | </div> |
| | | ) |
| | | } |