king
2023-10-24 c81296b147b3b6e578a241e21bae7bded4b5f6c6
src/tabviews/custom/components/table/edit-table/normalTable/index.jsx
@@ -1128,6 +1128,8 @@
    loading: PropTypes.bool,         // 表格加载中
    refreshdata: PropTypes.func,     // 表格中排序列、页码的变化时刷新
    chgSelectData: PropTypes.func,
    allSearch: PropTypes.any,
    colsCtrls: PropTypes.any
  }
  state = {
@@ -1144,11 +1146,13 @@
    pageOptions: [],
    deForms: null,
    visible: false,
    midData: null
    midData: null,
    allColumns: null,
    reseting: false
  }
  UNSAFE_componentWillMount () {
    const { setting, fields, columns, BID } = this.props
    const { setting, fields, columns, BID, colsCtrls } = this.props
    let orderfields = {}
    let _columns = []
@@ -1162,7 +1166,7 @@
        let cell = null
  
        if (item.type === 'colspan') {
          cell = { title: item.label, align: item.Align }
          cell = { title: item.label, align: item.Align, $key: item.uuid }
          cell.children = getColumns(item.subcols)
        } else {
          if (item.editable === 'true') {
@@ -1217,7 +1221,8 @@
            title: item.editable === 'true' ? <span>{item.label}<EditOutlined className="system-color mk-edit-sign"/></span> : item.label,
            sorter: (item.field || item.sortField) && item.IsSort === 'true',
            width: item.Width || 120,
            $type: item.type,
            // $type: item.type,
            $key: item.uuid,
            onCell: record => ({
              record,
              col: item,
@@ -1257,9 +1262,16 @@
      pageOptions = pageOptions.sort((a, b) => a - b)
    }
    let allColumns = null
    if (colsCtrls) {
      allColumns = [..._columns]
      _columns = this.getCurColumns(_columns, this.props.allSearch)
    }
    this.setState({
      forms,
      signForms,
      allColumns,
      pageSize: setting.pageSize || 10,
      pageOptions,
      columns: _columns,
@@ -1321,6 +1333,47 @@
    MKEmitter.removeListener('changeRecord', this.changeRecord)
  }
  getCurColumns = (columns, allSearch) => {
    const { colsCtrls } = this.props
    let values = {}
    allSearch.forEach(item => {
      values[item.key] = item.value
    })
    let cols = null
    colsCtrls.some(item => {
      let originVal = item.field.map(f => values[f] || '').join('')
      let contrastVal = item.contrastValue
      let result = false
      if (item.match === '=') {
        result = originVal === contrastVal
      } else if (item.match === '!=') {
        result = originVal !== contrastVal
      } else {
        originVal = isNaN(originVal) ? originVal : +originVal
        contrastVal = isNaN(contrastVal) ? contrastVal : +contrastVal
        if (item.match === '>') {
          result = originVal > contrastVal
        } else if (item.match === '<') {
          result = originVal < contrastVal
        }
      }
      if (!result) return false
      cols = item.cols
      return true
    })
    if (cols) {
      return columns.filter(col => cols.includes(col.$key))
    }
    return columns
  }
  transferData = (menuid, data, type) => {
    const { MenuID, setting } = this.props
    const { edData, signForms } = this.state
@@ -1367,7 +1420,24 @@
  }
  updateMutil = (data) => {
    const { setting } = this.props
    const { setting, colsCtrls, allSearch } = this.props
    const { allColumns } = this.state
    if (colsCtrls) {
      this.setState({
        columns: this.getCurColumns(allColumns, allSearch),
        reseting: true,
        edData: data,
        visible: false,
        midData: null
      }, () => {
        this.setState({
          reseting: false
        })
      })
      return
    }
    if (setting.editType === 'multi' && data.length > 0) {
      this.setState({edData: []}, () => {
@@ -1561,7 +1631,21 @@
      return item
    })
    this.setState({columns: [], edData: []}, () => {
    let _cols = this.state.allColumns
    if (_cols) {
      _cols = _cols.map(item => {
        if (reCols[item.dataIndex]) {
          item.onCell = record => ({
            record,
            col: reCols[item.dataIndex]
          })
        }
        return item
      })
    }
    this.setState({columns: [], edData: [], allColumns: _cols}, () => {
      this.setState({columns: _edColumns, edData: edData})
    })
  }
@@ -2144,7 +2228,9 @@
  render() {
    const { setting, lineMarks, submit } = this.props
    const { tableId, edData, columns, loading, pageOptions, selectedRowKeys, visible, midData } = this.state
    const { tableId, edData, columns, loading, pageOptions, selectedRowKeys, visible, midData, reseting } = this.state
    if (reseting) return null
    const components = {
      body: {