king
3 小时以前 80deba0c2dcffd9e6b6f07815c7c52199309ce42
src/views/interface/workspace/editTable/index.jsx
@@ -1,6 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { Table, Input, Form, Icon } from 'antd'
import { Table, Input, Form } from 'antd'
import { CloseOutlined } from '@ant-design/icons'
import Utils from '@/utils/utils.js'
import './index.scss'
@@ -104,7 +105,7 @@
      title: '',
      width: '20px',
      render: (text, record) => {
        return (<Icon type="close" onClick={() => this.delete(record)}/>)
        return (<CloseOutlined onClick={() => this.delete(record)}/>)
      }
    }]
  }
@@ -173,34 +174,29 @@
    })
  }
  handleAdd = (e) => {
    e.stopPropagation()
    const { dataSource, selectedRowKeys } = this.state
    const item = {
      uuid: Utils.getuuid(),
      key: '',
      value: '',
      description: '',
      selected: true
    }
    let _data = [...dataSource, item]
    this.setState({
      dataSource: _data,
      selectedRowKeys: [...selectedRowKeys, item.uuid]
    }, () => {
      this.props.onChange(_data)
    })
  }
  handleSave = row => {
    const newData = this.state.dataSource.map(item => {
    let newData = this.state.dataSource.map(item => {
      if (row.uuid === item.uuid) return row
      return item
    })
    this.setState({ dataSource: newData }, () => {
    let selectedRowKeys = this.state.selectedRowKeys
    let last = newData[newData.length - 1]
    if (last.key || last.value || last.description) {
      const item = {
        uuid: Utils.getuuid(),
        key: '',
        value: '',
        description: '',
        selected: true
      }
      newData = [...newData, item]
      selectedRowKeys = [...selectedRowKeys, item.uuid]
    }
    this.setState({ dataSource: newData, selectedRowKeys }, () => {
      this.props.onChange(newData)
    })
  }
@@ -237,7 +233,6 @@
    })
    return (
      <div className="params-edit-table">
        <Icon className="add-row" type="plus" onClick={this.handleAdd} />
        <Table
          rowKey="uuid"
          components={components}