king
2020-06-12 89e7167a83e0d8409ca87698e4c08651a37cc26e
src/tabviews/commontable/secretKeyTable/index.jsx
File was renamed from src/tabviews/managetable/secretKeyTable/index.jsx
@@ -9,10 +9,12 @@
import options from '@/store/options.js'
import { buttonConfig, tabConfig, refCodes } from './config'
import SubTable from '@/tabviews/zshare/normalTable'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import SubAction from './actionList'
import './index.scss'
const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
class VerupSubTabViewTable extends Component {
  static propTpyes = {
@@ -23,7 +25,6 @@
    MenuID: PropTypes.string,        // 菜单Id
    SupMenuID: PropTypes.string,     // 上级菜单Id
    ContainerId: PropTypes.any,      // 三级菜单Container(html) ID
    handleTableId: PropTypes.func,   // 控制表格数据切换时,更新在主表中的id
    handleMainTable: PropTypes.func, // 刷新主表
    refreshtabs:PropTypes.any
  }
@@ -35,6 +36,8 @@
    columns: null,        // 显示列
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: null,           // 列表数据集
    selectedData: [],     // 已选表格数据
    resetTable: false,    // 表格重置,值在true与false之间切换,切换时表格重置
    loading: false,       // 列表数据加载中
    visible: false,       // 弹框显示隐藏控制
    pickup: false,        // 子表数据隐藏显示切换
@@ -45,8 +48,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.loadmaindata(nextProps.BID, 'refresh')
      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()
@@ -99,6 +107,8 @@
      }
    })
    config.setting.tabType = 'sub'
    this.setState({
      config: config,
      setting: config.setting,
@@ -123,8 +133,6 @@
   * @description 子表数据加载
   */
  async loadmaindata (bid, type) {
    const { setting } = this.state
    let param = ''
    let _BID = this.props.BID
    
    if (type === 'refresh') {
@@ -134,19 +142,11 @@
          data: [],
          loading: false
        })
        return
      }
    }
    if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) {
      param = this.getCustomParam(_BID)
    } else {
      param = this.getDefaultParam(_BID)
    }
    this.handleTableId()
    let param = this.getCustomParam(_BID)
    let result = await Api.getLocalConfig(param)
    if (result.status) {
@@ -246,16 +246,17 @@
      })
    }
    this.setState({data})
    this.setState({data: data, selectedData: []})
  }
  /**
   * @description 表格刷新
   */
  reloadtable = () => {
    this.refs.subTable.resetTable()
    this.setState({
      loading: true,
      selectedData: [],
      resetTable: !this.state.resetTable
    }, () => {
      this.loadmaindata()
    })
@@ -266,12 +267,7 @@
   */
  reloadview = () => {
    this.setState({
      config: null,
      actions: null,
      columns: null,
      setting: null,
      data: null,
      loading: false,
      config: null, actions: null, columns: null, setting: null, data: null, loading: false, selectedData: []
    }, () => {
      this.loadconfig()
    })
@@ -280,34 +276,19 @@
  /**
   * @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.reloadtable()
    } else if (btn.execSuccess === 'view' && type === 'success') {
      this.reloadview()
    } else if (btn.execError === 'view' && type === 'error') {
    } else if (position === 'view') {
      this.reloadview()
    }
  }
  /**
   * @description 获取表格选择项
   * @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 = '') => {
    this.props.handleTableId(type, id, data)
  changeSelectedData = (selectedData) => {
    this.setState({selectedData})
  }
  /**
@@ -327,7 +308,7 @@
  }
  shouldComponentUpdate (nextProps, nextState) { // handleMainTable 函数判断时不相等
    return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState))
    return !is(fromJS({...this.props, handleMainTable: ''}), fromJS({...nextProps, handleMainTable: ''})) || !is(fromJS(this.state), fromJS(nextState))
  }
  /**
@@ -340,26 +321,22 @@
  }
  render() {
    const { setting, actions, columns, pickup, config } = this.state
    const { setting, actions, columns, pickup, config, selectedData } = this.state
    return (
      <div className="subtable" id={'subtable' + this.props.MenuID}>
        <div className="sub-action">
          <SubAction
            ref="subButton"
            type="sub"
            setting={setting}
            actions={actions}
            Tab={this.props.Tab}
            BID={this.props.BID}
            datalist={this.state.data}
            dict={this.state.dict}
            selectedData={selectedData}
            MenuID={this.props.SupMenuID}
            logcolumns={[]}
            refreshdata={this.refreshbyaction}
            ContainerId={this.props.ContainerId}
            getexceloutparam={this.getexceloutparam}
            gettableselected={this.gettableselected}
          />
        </div>
        <div className="subtable-box">
@@ -367,21 +344,19 @@
            <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}
            setting={setting}
            columns={columns}
            pagination={false}
            dict={this.state.dict}
            data={this.state.data}
            MenuID={this.props.MenuID}
            loading={this.state.loading}
            refreshdata={this.refreshbytable}
            buttonTrigger={() => {}}
            handleTableId={this.handleTableId}
            handleTableId={() => {}}
            chgSelectData={this.changeSelectedData}
          />
        </div>
      </div>