king
2020-06-12 89e7167a83e0d8409ca87698e4c08651a37cc26e
src/tabviews/verupmanage/subtabtable/index.jsx
@@ -11,11 +11,13 @@
import options from '@/store/options.js'
import { buttonConfig, tabConfig } from '../config'
import SubTable from '@/tabviews/zshare/normalTable'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import SubAction from '../actionList'
import SubSearch from '../topSearch'
import './index.scss'
const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
class VerupSubTabViewTable extends Component {
  static propTpyes = {
@@ -41,6 +43,8 @@
    arr_field: '',        // 使用 sPC_Get_TableData 时的查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: null,           // 列表数据集
    selectedData: [],     // 已选表格数据
    resetTable: false,    // 表格重置,值在true与false之间切换,切换时表格重置
    total: 0,             // 总数
    loading: false,       // 列表数据加载中
    pageIndex: 1,         // 页码
@@ -58,8 +62,13 @@
   */
  UNSAFE_componentWillReceiveProps(nextProps) {
    if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) {
      this.refs.subTable.resetTable()
      this.setState({
        pageIndex: 1,
        selectedData: [],
        resetTable: !this.state.resetTable,
      }, () => {
      this.loadmaindata(nextProps.BID, 'refresh')
      })
    } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) {
      this.reloadtable()
@@ -288,12 +297,12 @@
   * 含有初始不加载的页面,修改设置
   */
  refreshbysearch = (searches) => {
    this.refs.subTable.resetTable()
    this.setState({
      loading: true,
      pageIndex: 1,
      search: searches
      selectedData: [],
      search: searches,
      resetTable: !this.state.resetTable
    }, () => {
      this.loadmaindata()
    })
@@ -313,6 +322,7 @@
    this.setState({
      loading: true,
      selectedData: [],
      pageIndex: pagination.current,
      pageSize: pagination.pageSize,
      orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
@@ -325,13 +335,21 @@
   * @description 表格刷新
   */
  reloadtable = () => {
    this.refs.subTable.resetTable()
    this.setState({
      loading: true,
      pageIndex: 1
      pageIndex: 1,
      selectedData: [],
      resetTable: !this.state.resetTable
    }, () => {
      this.loadmaindata()
    })
  }
  /**
   * @description 表格选择项切换
   */
  changeSelectedData = (selectedData) => {
    this.setState({selectedData})
  }
  /**
@@ -379,17 +397,6 @@
  }
  /**
   * @description 获取表格选择项
   */
  gettableselected = () => {
    let data = []
    this.refs.subTable.state.selectedRowKeys.forEach(item => {
      data.push(this.refs.subTable.props.data[item])
    })
    return data
  }
  /**
   * @description 表格Id变化
   */
  handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => {
@@ -426,7 +433,7 @@
  }
  render() {
    const { config, setting, searchlist, actions, columns, pickup } = this.state
    const { config, setting, searchlist, actions, columns, pickup, selectedData } = this.state
    return (
      <div className="subtable" id={'subtable' + this.props.MenuID}>
@@ -440,7 +447,6 @@
        {actions ?
          <div className="sub-action">
            <SubAction
              ref="subButton"
              type="sub"
              setting={setting}
              actions={actions}
@@ -448,12 +454,12 @@
              BID={this.props.BID}
              BData={this.props.BData}
              dict={this.state.dict}
              selectedData={selectedData}
              MenuID={this.props.SupMenuID}
              logcolumns={this.state.logcolumns}
              refreshdata={this.refreshbyaction}
              ContainerId={this.props.ContainerId}
              getexceloutparam={this.getexceloutparam}
              gettableselected={this.gettableselected}
            />
          </div> : null
        }
@@ -463,8 +469,6 @@
              <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
            }
            <SubTable
              ref="subTable"
              menuType="HS"
              tableId={this.props.Tab.uuid}
              pickup={pickup}
              config={config}
@@ -478,6 +482,8 @@
              refreshdata={this.refreshbytable}
              buttonTrigger={() => {}}
              handleTableId={this.handleTableId}
              resetTable={this.state.resetTable}
              chgSelectData={this.changeSelectedData}
            />
          </div> : null
        }