king
2021-09-16 d7ec8fbd65cd7225ce8d405a0ee0a1f166f44d7b
src/tabviews/custom/components/share/normalTable/index.jsx
@@ -3,7 +3,7 @@
import md5 from 'md5'
import { connect } from 'react-redux'
import { is, fromJS } from 'immutable'
import { Table, Typography, Icon, Col, Switch } from 'antd'
import { Table, Typography, Icon, Col, Switch, message } from 'antd'
import { modifyTabview } from '@/store/action'
import asyncComponent from '@/utils/asyncComponent'
@@ -51,7 +51,7 @@
          try {
            originVal = parseFloat(originVal)
            contrastVal = parseFloat(contrastVal)
          } catch {
          } catch (e) {
            originVal = NaN
          }
  
@@ -62,7 +62,7 @@
          try {
            originVal = parseFloat(originVal)
            contrastVal = parseFloat(contrastVal)
          } catch {
          } catch (e) {
            originVal = NaN
          }
  
@@ -120,7 +120,7 @@
        try {
          originVal = parseFloat(originVal)
          contrastVal = parseFloat(contrastVal)
        } catch {
        } catch (e) {
          originVal = NaN
        }
@@ -131,7 +131,7 @@
        try {
          originVal = parseFloat(originVal)
          contrastVal = parseFloat(contrastVal)
        } catch {
        } catch (e) {
          originVal = NaN
        }
@@ -191,7 +191,7 @@
          content = `${content.substr(0, 4)}-${content.substr(5, 2)}-${content.substr(8, 2)} ${content.substr(11, 2)}:${content.substr(14, 2)}:${content.substr(17, 2)}`
        }
  
        content = col.prefix + content + col.postfix
        content = (col.prefix || '') + content + (col.postfix || '')
      }
      if (col.marks) {
@@ -223,7 +223,7 @@
        if (isNaN(content)) {
          content = ''
        }
      } catch {
      } catch (e) {
        content = ''
      }
@@ -275,6 +275,7 @@
      let cols = 24 / (col.picSort || 1)
      let paddingTop = '100%'
      let scale = col.scale === 'true'
      if (PicRadio[col.lenWidRadio]) {
        paddingTop = PicRadio[col.lenWidRadio]
@@ -282,9 +283,12 @@
      resProps.children = (
        <div>
          {photos.map((url, i) => (
          {photos && photos.map((url, i) => (
            <Col key={i} span={cols}>
              <div className="ant-mk-picture" style={{paddingTop, backgroundImage: `url('${url}')`}}></div>
              <div className={'ant-mk-picture' + (scale ? ' scale' : '')} onClick={() => {
                if (!scale) return
                MKEmitter.emit('mkImageScale', url, photos)
              }} style={{paddingTop, backgroundImage: `url('${url}')`}}></div>
            </Col>
          ))}
        </div>
@@ -328,7 +332,7 @@
        
        try {
          _param = window.btoa(_quary)
        } catch {
        } catch (e) {
          _param = window.btoa(window.encodeURIComponent(_quary))
        }
        
@@ -350,6 +354,10 @@
      )
    } else if (col.type === 'custom') {
      style.padding = '0px'
      if (col.style) {
        style = {...style, ...col.style}
      }
      resProps.children = (
        <CardCellComponent data={record} cards={config} elements={col.elements}/>
      )
@@ -423,7 +431,10 @@
          if (item.rowspan === 'true') {
            rowspans.push(item.field)
          }
          if (_format && !Math.floor(Math.random() * radio)) {
          if (item.type === 'index') {
            item.field = '$Index'
            item.type = 'text'
          } else if (_format && !Math.floor(Math.random() * radio)) {
            item.blur = true
          }
  
@@ -489,6 +500,8 @@
  }
  componentDidMount () {
    MKEmitter.addListener('mkCheckTopLine', this.mkCheckTopLine)
    MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
    MKEmitter.addListener('resetTable', this.resetTable)
  }
@@ -499,7 +512,54 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('mkCheckTopLine', this.mkCheckTopLine)
    MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
    MKEmitter.removeListener('resetTable', this.resetTable)
  }
  mkCheckTopLine = (menuId) => {
    const { MenuID, data, setting } = this.props
    if (MenuID !== menuId || !data || data.length === 0) return
    this.changedata(0)
    this.setState({ selectedRowKeys: [0], activeIndex: 0 })
    this.props.chgSelectData([data[0]])
    if (setting.$hasSyncModule) {
      MKEmitter.emit('syncBalconyData', MenuID, [data[0]], data.length === 1)
    }
  }
  mkCheckAll = (menuId, checked) => {
    const { MenuID, data } = this.props
    if (MenuID !== menuId) return
    if (checked) {
      this.setState({
        activeIndex: '',
        selectedRowKeys: data.map((item, index) => index)
      })
      this.props.chgSelectData(data)
      MKEmitter.emit('resetSelectLine', MenuID, '', '')
      MKEmitter.emit('syncBalconyData', MenuID, data, data.length > 0)
      if (data.length === 0) {
        message.warning('未获取到数据!')
      }
    } else {
      this.setState({
        activeIndex: '',
        selectedRowKeys: [],
      })
      this.props.chgSelectData([])
      MKEmitter.emit('resetSelectLine', MenuID, '', '')
      MKEmitter.emit('syncBalconyData', MenuID, [], false)
    }
  }
  // 字段透视
@@ -550,7 +610,7 @@
          _param.User_Name = sessionStorage.getItem('User_Name')
          _param.param = __param
          src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
        } catch {
        } catch (e) {
          console.warn('菜单参数解析错误!')
        }
      } else {
@@ -578,7 +638,7 @@
   * 
   */
  onSelectChange = selectedRowKeys => {
    const { setting } = this.props
    const { setting, MenuID, data } = this.props
    let index = ''
    let _activeIndex = null
@@ -597,13 +657,16 @@
    let selects = this.props.data.filter((item, _index) => selectedRowKeys.includes(_index))
    this.props.chgSelectData(selects)
    if (setting.$hasSyncModule) {
      MKEmitter.emit('syncBalconyData', MenuID, selects, data.length === selects.length)
    }
  }
  /**
   * @description 点击整行,触发切换, 判断是否可选,单选或多选,进行对应操作
   */
  changeRow = (record, index) => {
    const { setting } = this.props
    const { setting, MenuID, data } = this.props
    if (!setting.tableType || this.state.pickup) return
    
@@ -633,6 +696,10 @@
    let selects = this.props.data.filter((item, _index) => newkeys.includes(_index))
    
    this.props.chgSelectData(selects)
    if (setting.$hasSyncModule) {
      MKEmitter.emit('syncBalconyData', MenuID, selects, data.length === selects.length)
    }
  }
  changeTable = (pagination, filters, sorter) => {
@@ -802,8 +869,10 @@
      _footer = statFValue.map(f => `${f.label}(合计):${f.value}`).join(';')
    }
    let height = setting.height || false
    return (
      <div className={`normal-custom-table ${setting.tableHeader || ''} ${setting.mode || ''}`} id={tableId}>
      <div className={`normal-custom-table ${setting.tableHeader || ''} ${height ? 'fixed-height' : ''} ${setting.mode || ''}`} id={tableId}>
        {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && data && data.length > 0 ?
          <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null
        }
@@ -816,7 +885,7 @@
          columns={this.state.columns}
          dataSource={_data}
          loading={this.props.loading}
          scroll={{ x: '100%', y: false }}
          scroll={{ x: '100%', y: height }}
          onRow={(record, index) => {
            return {
              lineMarks,