king
2022-01-21 46f79b491173d284a4900d19e7aecf7509481438
src/templates/zshare/modalform/fieldtable/index.jsx
@@ -1,6 +1,7 @@
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'
@@ -18,6 +19,7 @@
    let data = this.props['data-__meta'].initialValue || []
    this.setState({
      loading: false,
      data: data.map(item => {
        item.uuid = item.uuid || item.key
        return item
@@ -103,21 +105,24 @@
        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>
    )
  }