king
2021-09-24 95ccc1acc6d8ede1c839493e7aecc9c97fd34c8c
src/tabviews/zshare/normalTable/index.jsx
@@ -17,6 +17,16 @@
const TabButton = asyncComponent(() => import('@/tabviews/zshare/actionList/tabbutton'))
const NewPageButton = asyncComponent(() => import('@/tabviews/zshare/actionList/newpagebutton'))
class BodyRow extends React.Component {
  shouldComponentUpdate (nextProps) {
    return this.props.className !== nextProps.className
  }
  render() {
    return <tr {...this.props}/>
  }
}
class NormalTable extends Component {
  static propTpyes = {
    tableId: PropTypes.string,       // 列表Id
@@ -49,7 +59,7 @@
  }
  UNSAFE_componentWillMount () {
    const { menuType, memberLevel, pageSize } = this.props
    const { menuType, memberLevel, pageSize, setting } = this.props
    let columns = fromJS(this.props.columns).toJS()
    let lineMarks = []
    let _columns = []
@@ -57,122 +67,159 @@
    let _format = false    // 是否虚化处理
    let rowspans = []
    if (window.GLOB.dataFormat && menuType !== 'HS' && memberLevel) {
      _format = true
      if (memberLevel >= 30) {
        radio = 20
      } else if (memberLevel >= 20) {
        radio = 10
      }
    }
    columns.forEach((item, index) => {
      if (item.hidden === true || item.Hide === 'true') return
      let cell = null
      if (item.type === 'colspan') {
        cell = {title: item.label, children: []}
        item.subcols.forEach(col => {
          if (col.rowspan === 'true') {
            rowspans.push(col.field)
          }
          if (_format && !Math.floor(Math.random() * radio)) {
            col.blur = true
          }
          if (col.marks) { // 过滤行和卡片标记
            col.marks = col.marks.filter(mark => {
              if (mark.signType === 'line') {
                lineMarks.push(mark)
              }
              return mark.signType !== 'line' && mark.signType !== 'card'
    if (setting.tableMode === 'fast') {
      rowspans = null
      columns.forEach(item => {
        if (item.hidden === true || item.Hide === 'true') return
        let cell = null
        if (item.type === 'colspan' || item.type === 'old_colspan') {
          cell = {title: item.label, children: []}
          item.subcols.forEach(col => {
            cell.children.push({
              align: col.Align,
              title: col.label,
              dataIndex: col.field || col.uuid,
              key: col.uuid,
              width: col.Width || 120
            })
            if (col.marks.length === 0) {
              col.marks = ''
            }
          }
          cell.children.push({
            align: col.Align,
            title: col.label,
            dataIndex: col.field || col.uuid,
            key: col.uuid,
            width: col.Width || 120,
            render: (text, record) => {
              return this.getContent(col, record)
            }
          })
        })
      } else if (item.type === 'old_colspan') {
        item.subcols.forEach(col => {
          if (col.marks) { // 过滤行和卡片标记
            col.marks = col.marks.filter(mark => {
              if (mark.signType === 'line') {
                lineMarks.push(mark)
        } else {
          if (item.type === 'index') {
            item.field = '$Index'
            item.type = 'text'
          }
          cell = {
            align: item.Align,
            dataIndex: item.field || item.uuid,
            title: item.label,
            sorter: item.field && item.IsSort === 'true',
            width: item.Width || 120
          }
        }
        _columns.push(cell)
      })
    } else {
      if (window.GLOB.dataFormat && menuType !== 'HS' && memberLevel) {
        _format = true
        if (memberLevel >= 30) {
          radio = 20
        } else if (memberLevel >= 20) {
          radio = 10
        }
      }
      columns.forEach((item, index) => {
        if (item.hidden === true || item.Hide === 'true') return
        let cell = null
        if (item.type === 'colspan') {
          cell = {title: item.label, children: []}
          item.subcols.forEach(col => {
            if (col.rowspan === 'true') {
              rowspans.push(col.field)
            }
            if (_format && !Math.floor(Math.random() * radio)) {
              col.blur = true
            }
            if (col.marks) { // 过滤行和卡片标记
              col.marks = col.marks.filter(mark => {
                if (mark.signType === 'line') {
                  lineMarks.push(mark)
                }
                return mark.signType !== 'line' && mark.signType !== 'card'
              })
              if (col.marks.length === 0) {
                col.marks = ''
              }
              return mark.signType !== 'line' && mark.signType !== 'card'
            }
            cell.children.push({
              align: col.Align,
              title: col.label,
              dataIndex: col.field || col.uuid,
              key: col.uuid,
              width: col.Width || 120,
              render: (text, record) => {
                return this.getContent(col, record)
              }
            })
            if (col.marks.length === 0) {
              col.marks = ''
          })
        } else if (item.type === 'old_colspan') {
          item.subcols.forEach(col => {
            if (col.marks) { // 过滤行和卡片标记
              col.marks = col.marks.filter(mark => {
                if (mark.signType === 'line') {
                  lineMarks.push(mark)
                }
                return mark.signType !== 'line' && mark.signType !== 'card'
              })
              if (col.marks.length === 0) {
                col.marks = ''
              }
            }
          }
        })
        cell = {
          align: item.Align,
          dataIndex: item.field || item.uuid,
          title: item.label,
          sorter: item.field && item.IsSort === 'true',
          width: item.Width || 120,
          render: (text, record) => {
            return this.getContent(item, record)
          }
        }
      } else {
        if (item.rowspan === 'true') {
          rowspans.push(item.field)
        }
        if (item.type === 'index') {
          item.field = '$Index'
          item.type = 'text'
        } else if (_format && !Math.floor(Math.random() * radio)) {
          item.blur = true
        }
        if (item.marks) { // 过滤行和卡片标记
          item.marks = item.marks.filter(mark => {
            if (mark.signType === 'line') {
              lineMarks.push(mark)
            }
            return mark.signType !== 'line' && mark.signType !== 'card'
          })
  
          if (item.marks.length === 0) {
            item.marks = ''
          cell = {
            align: item.Align,
            dataIndex: item.field || item.uuid,
            title: item.label,
            sorter: item.field && item.IsSort === 'true',
            width: item.Width || 120,
            render: (text, record) => {
              return this.getContent(item, record)
            }
          }
        } else {
          if (item.rowspan === 'true') {
            rowspans.push(item.field)
          }
          if (item.type === 'index') {
            item.field = '$Index'
            item.type = 'text'
          } else if (_format && !Math.floor(Math.random() * radio)) {
            item.blur = true
          }
          if (item.marks) { // 过滤行和卡片标记
            item.marks = item.marks.filter(mark => {
              if (mark.signType === 'line') {
                lineMarks.push(mark)
              }
              return mark.signType !== 'line' && mark.signType !== 'card'
            })
            if (item.marks.length === 0) {
              item.marks = ''
            }
          }
          cell = {
            align: item.Align,
            dataIndex: item.field || item.uuid,
            title: item.label,
            sorter: item.field && item.IsSort === 'true',
            width: item.Width || 120,
            render: (text, record) => {
              return this.getContent(item, record)
            }
          }
        }
        cell = {
          align: item.Align,
          dataIndex: item.field || item.uuid,
          title: item.label,
          sorter: item.field && item.IsSort === 'true',
          width: item.Width || 120,
          render: (text, record) => {
            return this.getContent(item, record)
          }
        }
        _columns.push(cell)
      })
      if (rowspans.length === 0) {
        rowspans = null
      }
      _columns.push(cell)
    })
    if (rowspans.length === 0) {
      rowspans = null
    }
    
    this.setState({
@@ -1056,6 +1103,14 @@
    const { setting, pickup, statFValue } = this.props
    const { selectedRowKeys, lineMarks, activeIndex } = this.state
    let components = {
      body: {}
    }
    if (setting.tableMode === 'fast') {
      components.body.row = BodyRow
    }
    // 设置表格选择属性:单选、多选、不可选
    let rowSelection = null
    if (setting.tableType) {
@@ -1136,6 +1191,7 @@
          />
        </Affix>}
        <Table
          components={components}
          size={setting.size || 'middle'}
          style={style}
          bordered={setting.bordered !== 'false'}