king
2022-04-26 5046d0d13dc6a8563b8e54e31913bc44cfa1072f
src/templates/zshare/modalform/modaleditable/index.jsx
@@ -67,7 +67,7 @@
    }
    return editing ? (
      <Form.Item style={{ margin: 0 }}>
      <Form.Item style={{ margin: '0 -5px 0 -5px' }}>
        {form.getFieldDecorator(dataIndex, {
          rules: [
            {
@@ -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        // 数据变化
@@ -215,6 +216,20 @@
      _data.splice(index + 1, 0, record)
    }
    this.setState({
      dataSource: _data
    }, () => {
      this.props.onChange(_data)
    })
  }
  handleHide = (record) => {
    let _data = this.state.dataSource.map(item => {
      if (item.key === record.key) {
        item.Hide = !item.Hide
      }
      return item
    })
    this.setState({
      dataSource: _data
    }, () => {
@@ -336,6 +351,7 @@
            <div style={{fontSize: '15px'}}>
              <span className="operation-btn" onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><ArrowUpOutlined /></span>
              <span className="operation-btn" onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><ArrowDownOutlined /></span>
              <span className="operation-btn" title="显示/隐藏" onClick={() => this.handleHide(record)} style={{color: 'rgb(142, 68, 173)'}}><SwapOutlined /></span>
              <Popconfirm
                title="确定删除吗?"
                overlayClassName="popover-confirm"
@@ -368,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)
@@ -392,6 +437,7 @@
  }
  render() {
    const { module } = this.props
    const { dataSource } = this.state
    const components = {
      body: {
@@ -417,10 +463,11 @@
    })
    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}
          rowClassName={() => 'editable-row'}
          rowClassName={(record) => record.Hide ? 'editable-row hide' : 'editable-row'}
          bordered
          dataSource={dataSource}
          columns={columns}