king
2023-04-25 9ecbd8f279f6e0a1037e282418e8f9bfc0250769
src/tabviews/custom/components/table/edit-table/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { notification } from 'antd'
import { notification, Modal } from 'antd'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -48,7 +48,6 @@
   */
  UNSAFE_componentWillMount () {
    let _config = fromJS(this.props.config).toJS()
    let _cols = new Map()
    let setting = {..._config.setting, ..._config.wrap}
    setting.tableId = Utils.getuuid()
@@ -82,11 +81,6 @@
      setting.operType = 'btnMode'
    }
    _config.columns.forEach(item => {
      if (item.type !== 'number') return
      _cols.set(item.field, item)
    })
    let _columns = []
    let signAdd = false
    _config.cols.forEach(column => {
@@ -115,17 +109,6 @@
  
          return !cell.Hide
        })
      }
      if (column.type === 'custom') {
        column.elements = column.elements.map(item => {
          if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') {
            item.decimal = _cols.get(item.field).decimal || 0
          }
          return item
        })
      } else if (column.type === 'action') {
        column.operations = column.elements
      }
      _columns.push(column)
@@ -186,7 +169,7 @@
        selectedData: [],
        total: 0
      })
      reset && MKEmitter.emit('resetTable', config.uuid, repage) // 列表重置
      reset && MKEmitter.emit('resetTable', config.uuid, 'true') // 列表重置
      return
    }
@@ -252,11 +235,18 @@
      this.setState({
        loading: false
      })
      notification.error({
        top: 92,
        message: result.message,
        duration: 10
      })
      if (result.ErrCode === 'N') {
        Modal.error({
          title: result.message,
        })
      } else {
        notification.error({
          top: 92,
          message: result.message,
          duration: 10
        })
      }
    }
  }
@@ -567,7 +557,7 @@
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { config } = this.state
    if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
    if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      this.setState({pageIndex: 1}, () => {
        this.reloadtable()
      })
@@ -599,10 +589,15 @@
  }
  render() {
    const { BID, setting, actions, config, columns, BData, selectedData, lock } = this.state
    const { BID, setting, actions, config, columns, BData, data, selectedData, lock } = this.state
    let style = {...config.style}
    if (config.wrap.empty === 'hidden' && data.length === 0) {
      style.display = 'none'
    }
    return (
      <div className="custom-edit-table" id={'anchor' + config.uuid} style={config.style}>
      <div className="custom-edit-table" id={'anchor' + config.uuid} style={style}>
        <NormalHeader config={config}/>
        {config.search && config.search.length ?
          <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null