king
2020-06-12 89e7167a83e0d8409ca87698e4c08651a37cc26e
src/tabviews/subtabtable/index.jsx
@@ -13,7 +13,6 @@
import asyncComponent from '@/utils/asyncComponent'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import SubTable from '@/tabviews/zshare/normalTable'
import SubSearch from '@/tabviews/zshare/topSearch'
import NotFount from '@/components/404'
@@ -21,17 +20,16 @@
const { TabPane } = Tabs
const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
const CardComponent = asyncComponent(() => import('@/tabviews/zshare/cardcomponent'))
const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent'))
const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent'))
class SubTabModalTable extends Component {
  static propTpyes = {
    menuType: PropTypes.any,         // 菜单类型,普通菜单或HS
    BID: PropTypes.string,           // 上级数据ID
    BData: PropTypes.any,            // 上级数据
    MenuID: PropTypes.string,        // 菜单Id
    SupMenuID: PropTypes.string,     // 上级菜单Id
    ContainerId: PropTypes.any,      // 三级菜单Container(html) ID
    refreshSupView: PropTypes.any    // 刷新上级菜单
  }
@@ -48,6 +46,8 @@
    arr_field: '',        // 使用 sPC_Get_TableData 时的查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: null,           // 列表数据集
    selectedData: [],     // 已选表格数据
    resetTable: false,    // 表格重置,值在true与false之间切换,切换时表格重置
    total: 0,             // 总数
    loading: false,       // 列表数据加载中
    pageIndex: 1,         // 页码
@@ -236,10 +236,8 @@
      })
      if (config.gridBtn && config.gridBtn.display && _operations.length > 0) {
        _columns.push({
          ...config.gridBtn,
          operations: _operations
        })
        config.gridBtn.operations = _operations
        _columns.push(config.gridBtn)
      }
      let valid = true // 搜索条件必填验证
@@ -248,6 +246,8 @@
          valid = false
        }
      })
      config.setting.tabType = 'subtab'
      this.setState({
        loadingview: false,
@@ -580,11 +580,11 @@
   * 含有初始不加载的页面,修改设置
   */
  refreshbysearch = (searches) => {
    this.refs.subTable && this.refs.subTable.resetTable()
    this.setState({
      pageIndex: 1,
      search: searches
      search: searches,
      selectedData: [],
      resetTable: !this.state.resetTable
    }, () => {
      this.loadmaindata()
    })
@@ -603,6 +603,7 @@
    }
    this.setState({
      selectedData: [],
      pageIndex: pagination.current,
      pageSize: pagination.pageSize,
      orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
@@ -615,35 +616,28 @@
   * @description 表格刷新
   */
  reloadtable = () => {
    this.refs.subTable && this.refs.subTable.resetTable()
    this.setState({
      pageIndex: 1
      pageIndex: 1,
      selectedData: [],
      resetTable: !this.state.resetTable
    }, () => {
      this.loadmaindata()
    })
  }
  /**
   * @description 表格选择项切换
   */
  changeSelectedData = (selectedData) => {
    this.setState({selectedData})
  }
  /**
   * @description 页面刷新,重新获取配置
   */
  reloadview = () => {
    this.setState({
      loadingview: true,
      viewlost: false,
      lostmsg: '',
      config: null,
      searchlist: null,
      actions: null,
      columns: null,
      arr_field: '',
      setting: null,
      data: null,
      total: 0,
      loading: false,
      pageIndex: 1,
      pageSize: 10,
      orderBy: '',
      search: '',
    this.setState({ loadingview: true, viewlost: false, lostmsg: '', config: null, searchlist: null, actions: null, columns: null,
      arr_field: '', setting: null, data: null, total: 0, loading: false, pageIndex: 1, pageSize: 10, orderBy: '', search: '',
      triggerBtn: null
    }, () => {
      this.loadconfig()
@@ -653,30 +647,14 @@
  /**
   * @description 按钮操作完成后(成功或失败),页面刷新,重置页码及选择项
   */
  refreshbyaction = (btn, type) => {
    if (btn.execSuccess === 'grid' && type === 'success') {
  refreshbyaction = (position) => {
    if (position === 'grid') {
      this.reloadtable()
    } else if (btn.execError === 'grid' && type === 'error') {
      this.props.refreshSupView()
    } else if (position === 'view') {
      this.reloadview()
    } else if (btn.execSuccess === 'view' && type === 'success') {
      this.reloadtable()
    } else if (btn.execError === 'view' && type === 'error') {
      this.reloadview()
    }
    if (type === 'success') {
      this.props.refreshSupView()
    }
  }
  /**
   * @description 获取表格选择项
   */
  gettableselected = () => {
    let data = []
    this.refs.subTable && this.refs.subTable.state.selectedRowKeys.forEach(item => {
      data.push(this.refs.subTable.props.data[item])
    })
    return data
  }
  /**
@@ -719,7 +697,7 @@
  }
  render() {
    const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, triggerBtn, chartId } = this.state
    const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, triggerBtn, chartId, selectedData } = this.state
    return (
      <div className="subtabtable" id={'subtabtable' + this.props.MenuID}>
@@ -747,38 +725,34 @@
                  {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null}
                  <div style={{minHeight: '25px'}}>
                    <SubAction
                      type="subtab"
                      triggerBtn={triggerBtn}
                      menuType={this.props.menuType}
                      setting={setting}
                      actions={actions}
                      BID={this.props.BID}
                      dict={this.state.dict}
                      BData={this.props.BData}
                      selectedData={selectedData}
                      MenuID={this.props.SupMenuID}
                      logcolumns={this.state.logcolumns}
                      operations={config.gridBtn.operations || []}
                      refreshdata={this.refreshbyaction}
                      ContainerId={this.props.ContainerId}
                      gettableselected={this.gettableselected}
                    />
                  </div>
                  <SubTable
                    ref="subTable"
                    menuType={this.props.menuType}
                    tableId=""
                    dict={this.state.dict}
                    MenuID={this.props.MenuID}
                    config={config}
                    setting={setting}
                    columns={columns}
                    pageSize={pageSize}
                    data={this.state.data}
                    dict={this.state.dict}
                    total={this.state.total}
                    memberLevel={this.props.memberLevel}
                    MenuID={this.props.MenuID}
                    loading={this.state.loading}
                    pagination={setting.laypage !== 'false'}
                    refreshdata={this.refreshbytable}
                    buttonTrigger={this.buttonTrigger}
                    resetTable={this.state.resetTable}
                    chgSelectData={this.changeSelectedData}
                    handleTableId={() => {}}
                  />
                </Col>
@@ -795,25 +769,6 @@
                    buttonTrigger={this.buttonTrigger}
                    handleTableId={() => {}}
                  />
                  <div style={{display: 'none'}}>
                    <SubAction
                      type="subtab"
                      triggerBtn={triggerBtn}
                      menuType={this.props.menuType}
                      setting={setting}
                      actions={actions}
                      BID={this.props.BID}
                      dict={this.state.dict}
                      BData={this.props.BData}
                      MenuID={this.props.SupMenuID}
                      permRoles={this.props.permRoles}
                      dataManager={this.props.dataManager}
                      logcolumns={this.state.logcolumns}
                      refreshdata={this.refreshbyaction}
                      ContainerId={this.props.ContainerId}
                      gettableselected={() => {}}
                    />
                  </div>
                </Col>
              )
            } else {
@@ -838,6 +793,7 @@
const mapStateToProps = (state) => {
  return {
    menuType: state.editLevel,
    permAction: state.permAction,
    permRoles: state.permRoles,
    dataManager: state.dataManager,