king
2022-03-01 3bb266595fbfa9af6b97405737496ed61c6b7c55
src/templates/zshare/modalform/modaleditable/index.jsx
@@ -115,6 +115,7 @@
class EditTable extends Component {
  static propTpyes = {
    type: PropTypes.string,         // 表单类型
    module: PropTypes.string,       // 元素类型
    linkSubFields: PropTypes.array, // 关联字段
    transfield: PropTypes.object,   // 表单字段名称
    onChange: PropTypes.func        // 数据变化
@@ -383,6 +384,35 @@
    }
  }
  handleEmpty = (e) => {
    e.stopPropagation()
    const { linkSubFields, module } = this.props
    const { dataSource } = this.state
    if (dataSource.filter(item => item.Value === '').length > 0) {
      message.warning('Value为空已存在!')
      return
    }
    const newData = {
      key: Utils.getuuid(),
      Value: '',
      Text: module === 'form' ? '空' : '全部',
      ParentID: ''
    }
    linkSubFields.forEach(m => {
      newData[m] = newData[m] || ''
    })
    let _data = [newData, ...dataSource]
    this.setState({
      dataSource: _data,
    }, () => {
      this.props.onChange(_data)
    })
  }
  resetColumn = (type, linkSubFields) => {
    const { columns, dataSource } = this.getColumns(type, linkSubFields, this.state.dataSource)
@@ -407,6 +437,7 @@
  }
  render() {
    const { module } = this.props
    const { dataSource } = this.state
    const components = {
      body: {
@@ -432,6 +463,7 @@
    })
    return (
      <div className="common-modal-edit-table">
        <span className="add-row add-row-empty" onClick={this.handleEmpty}>{module === 'form' ? '空' : '全部'}</span>
        <PlusOutlined className="add-row" onClick={this.handleAdd} />
        <Table
          components={components}