king
2023-06-22 79e4981aa6cc9354276fc54cdf6d14eb08ab7fee
src/templates/zshare/modalform/fieldtable/index.jsx
@@ -11,7 +11,6 @@
class EdiFieldsTable extends Component {
  static propTpyes = {
    dict: PropTypes.object,         // 字典项
    onChange: PropTypes.func        // 数据变化
  }
@@ -19,6 +18,7 @@
    let data = this.props['data-__meta'].initialValue || []
    this.setState({
      loading: false,
      data: data.map(item => {
        item.uuid = item.uuid || item.key
        return item
@@ -62,11 +62,20 @@
        editable: true,
        width: '20%',
        options: [
          {value: 'left', text: 'left'},
          {value: 'center', text: 'center'},
          {value: 'right', text: 'right'},
          {value: 'justify', text: 'justify'}
        ]
          {value: 'left', text: '居左'},
          {value: 'center', text: '居中'},
          {value: 'right', text: '居右'},
          // {value: 'justify', text: 'justify'}
        ],
        render: (text, record) => {
          if (text === 'center') {
            return '居中'
          } else if (text === 'right') {
            return '居右'
          } else {
            return '居左'
          }
        }
      }
    ]
  }
@@ -104,21 +113,54 @@
        message: '字段名不可重复!',
        duration: 5
      })
      this.setState({loading: true}, () => {
        this.setState({loading: false})
      })
      return
    } else if (fields.filter(f => f.toLowerCase() === 'value').length > 0) {
      notification.warning({
        top: 92,
        message: '字段名不可使用value!',
        duration: 5
      })
      this.setState({loading: true}, () => {
        this.setState({loading: false})
      })
      return
    } else if (fields.filter(f => f.toLowerCase() === 'parentid').length > 0) {
      notification.warning({
        top: 92,
        message: '字段名不可使用parentid!',
        duration: 5
      })
      this.setState({loading: true}, () => {
        this.setState({loading: false})
      })
      return
    } else if (fields.filter(f => f.toLowerCase() === 'pid').length > 0) {
      notification.warning({
        top: 92,
        message: '字段名不可使用pid!',
        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 ? <PlusOutlined className="add-row" onClick={this.handleAdd} /> : null}
        <EditTable actions={['edit', 'move', 'del']} data={data} columns={columns} onChange={this.changeData}/>
        {data.length < 6 ? <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>
    )
  }