king
2022-03-21 fc241324087e605b145e8bbcc4ee3aece61dbf14
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -873,7 +873,6 @@
    lineMarks: PropTypes.any,        // 行标记
    fields: PropTypes.array,         // 组件字段集
    BID: PropTypes.any,              // 主表ID
    data: PropTypes.any,             // 表格数据
    total: PropTypes.any,            // 总数
    loading: PropTypes.bool,         // 表格加载中
    refreshdata: PropTypes.func,     // 表格中排序列、页码的变化时刷新
@@ -1038,7 +1037,6 @@
      this.setState({data: data || []})
      if (this.state.editable && !this.state.pickup) {
        this.setState({editable: false})
        setTimeout(() => {
          this.pickupChange()
        }, 200)
@@ -1061,6 +1059,7 @@
      this.setState({edData: _edData, data: _data})
    }
    this.setState({editable: false})
  }
  improveActionForm = (deForms) => {
@@ -1831,7 +1830,7 @@
  }
  pickupChange = () => {
    const { submit, MenuID } = this.props
    const { submit, MenuID, setting } = this.props
    const { data } = this.state
    let pickup = !this.state.pickup
@@ -1845,7 +1844,7 @@
      return
    }
    if (!pickup && !is(fromJS(data), fromJS(this.state.edData))) {
    if (!pickup && this.state.edData.filter(item => !item.$origin).length > 0) {
      const _this = this
      confirm({
        title: '数据已修改,确定放弃保存吗?',
@@ -1866,18 +1865,28 @@
    } else {
      pickup && MKEmitter.emit('resetSelectLine', MenuID, '', '')
      pickup && this.props.chgSelectData([])
      let keys = this.state.selectedRowKeys
      this.setState({
        data: [],
        edData: [],
        selectedRowKeys: [],
        pickup,
        loading: false,
        editable: 'false'
        editable: false
      }, () => {
        this.setState({
          data: data,
          edData: pickup ? fromJS(data).toJS() : []
        })
        if (pickup && setting.tableType === 'checkbox' && keys.length > 0) {
          this.setState({
            data: data,
            edData: fromJS(data).toJS().filter(item => keys.includes(item.$$uuid))
          })
        } else {
          this.setState({
            data: data,
            edData: pickup ? fromJS(data).toJS() : []
          })
        }
      })
    }
    this.props.changeLock(pickup)
  }
@@ -1934,33 +1943,38 @@
    let height = setting.height || false
    return (
      <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}>
        <Switch title="编辑" className="main-pickup" checkedChildren="开" unCheckedChildren="关" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} />
        {pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">提交</Button> : null}
        <Table
          rowKey="$$uuid"
          components={components}
          style={setting.style}
          size={setting.size || 'middle'}
          bordered={setting.bordered !== 'false'}
          rowSelection={rowSelection}
          columns={_columns}
          dataSource={_data}
          loading={this.props.loading}
          scroll={{ x: '100%', y: height }}
          onRow={(record, index) => {
            return {
              lineMarks,
              data: record,
              onClick: () => {this.changeRow(record.$$uuid)},
            }
          }}
          onChange={this.changeTable}
          pagination={_pagination}
        />
        {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null}
        {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null}
      </div>
      <>
        <div className="edit-custom-table-btn-wrap" style={submit.wrapStyle}>
          {pickup ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-table" type="link">提交</Button> : null}
          <Switch title="编辑" className="main-pickup" checkedChildren="开" unCheckedChildren="关" disabled={loading || this.props.loading} checked={pickup} onChange={this.pickupChange} />
        </div>
        <div className={`edit-custom-table ${pickup ? 'editable' : ''} ${setting.tableHeader || ''} ${setting.operType || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}>
          <Table
            rowKey="$$uuid"
            components={components}
            style={setting.style}
            size={setting.size || 'middle'}
            bordered={setting.bordered !== 'false'}
            rowSelection={rowSelection}
            columns={_columns}
            dataSource={_data}
            loading={this.props.loading}
            scroll={{ x: '100%', y: height }}
            onRow={(record, index) => {
              return {
                lineMarks,
                data: record,
                onClick: () => {this.changeRow(record.$$uuid)},
              }
            }}
            onChange={this.changeTable}
            pagination={_pagination}
          />
          {_footer ? <div className={'normal-table-footer ' + (_pagination ? 'pagination' : '')}>{_footer}</div> : null}
          {pickup && setting.addable === 'true' ? <Button className="mk-add-line" onClick={() => this.addLine()} disabled={this.props.loading} type="link"><PlusOutlined /></Button> : null}
          {pickup && _data.length > 10 ? <Button style={submit.style} onClick={() => setTimeout(() => {this.checkData()}, 10)} loading={loading} className="submit-footer-table" type="link">提交</Button> : null}
        </div>
      </>
    )
  }
}