king
2019-12-31 f9697383bc9097be8a444558e09ae21b27f1e831
src/tabviews/subtabtable/index.jsx
@@ -15,10 +15,9 @@
export default class NormalTable extends Component {
  static propTpyes = {
    Tab: PropTypes.object,       // 标签信息
    BID: PropTypes.string,       // 上级数据ID
    MenuID: PropTypes.string,    // 菜单Id
    SupMenuID: PropTypes.string  // 上级菜单Id
    BID: PropTypes.string,         // 上级数据ID
    MenuID: PropTypes.string,      // 菜单Id
    SupMenuID: PropTypes.string   // 上级菜单Id
  }
  state = {
@@ -26,27 +25,21 @@
    loadingview: true,    // 页面加载中
    viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
    lostmsg: '',          // 页面丢失时的提示信息
    config: {},
    searchlist: null,
    actions: null,
    columns: null,
    arr_field: '',
    setting: null,
    data: [],
    total: 0,
    loading: false,
    pageIndex: 1,
    pageSize: 10,
    orderColumn: '',
    orderType: 'asc',
    search: '',
    configMap: {}
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    if (this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) {
      this.loadmaindata()
    }
    config: {},           // 页面配置信息,包括按钮、搜索、显示列、标签等
    searchlist: null,     // 搜索条件
    actions: null,        // 按钮集
    columns: null,        // 显示列
    arr_field: '',        // 使用 sPC_Get_TableData 时的查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: null,           // 列表数据集
    total: 0,             // 总数
    loading: false,       // 列表数据加载中
    pageIndex: 1,         // 页码
    pageSize: 10,         // 每页数据条数
    orderColumn: '',      // 排序字段
    orderType: 'asc',     // 排序方式
    search: '',           // 搜索条件数组,使用时需分场景处理
    configMap: {}         // 页面配置信息:下拉、按钮等
  }
  /**
@@ -162,6 +155,9 @@
    }
  }
  /**
   * @description 搜索条件下拉选项预加载
   */
  improveSearch = () => {
    let searchlist = JSON.parse(JSON.stringify(this.state.searchlist))
    let deffers = []
@@ -237,7 +233,9 @@
    })
  }
  /**
   * @description 子表数据加载
   */
  async loadmaindata () {
    const { setting } = this.state
    let param = ''
@@ -270,6 +268,9 @@
    }
  }
  /**
   * @description 获取用户自定义存储过程传参
   */
  getCustomParam = () => {
    const { pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state
@@ -295,6 +296,9 @@
    return param
  }
  /**
   * @description 获取系统存储过程 sPC_Get_TableData 的参数
   */
  getDefaultParam = () => {
    const { arr_field, pageIndex, pageSize, orderColumn, orderType, search, setting } = this.state
@@ -326,8 +330,11 @@
    return param
  }
  /**
   * @description 搜索条件改变时,重置表格数据
   * 含有初始不加载的页面,修改设置
   */
  refreshbysearch = (searches) => {
    // 搜索条件变化
    this.refs.subTable.resetTable()
    this.setState({
@@ -339,8 +346,10 @@
    })
  }
  /**
   * @description 表格条件改变时重置数据(分页或排序)
   */
  refreshbytable = (pagination, filters, sorter) => {
    // 表格查询条件修改
    if (sorter.order) {
      let _chg = {
        ascend: 'asc',
@@ -360,6 +369,9 @@
    })
  }
  /**
   * @description 表格刷新
   */
  reloadtable = () => {
    this.refs.subTable.resetTable()
    this.setState({
@@ -370,11 +382,14 @@
    })
  }
  /**
   * @description 页面刷新,重新获取配置
   */
  reloadview = () => {
    this.setState({
      loadingview: true,    // 页面加载中
      viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
      lostmsg: '',          // 页面丢失时的提示信息
      loadingview: true,
      viewlost: false,
      lostmsg: '',
      config: {},
      searchlist: null,
      actions: null,
@@ -395,8 +410,10 @@
    })
  }
  /**
   * @description 按钮操作完成后(成功或失败),页面刷新,重置页码及选择项
   */
  refreshbyaction = (btn, type) => {
    // 按钮操作后刷新表格,重置页码及选择项
    if (btn.execSuccess === 'grid' && type === 'success') {
      this.reloadtable()
    } else if (btn.execError === 'grid' && type === 'error') {
@@ -410,6 +427,9 @@
    }
  }
  /**
   * @description 使用默认存储过程 sPC_Get_TableData 导出excel表格
   */
  handleDefaultExcelout = (btn) => {
    const { MenuName } = this.props
    const { arr_field, orderColumn, orderType, search, setting, config } = this.state
@@ -454,15 +474,17 @@
    Api.getExcelOut(param, name).then(res => {
      if (res && res.status === false) {
        this.refs.subButton.execError(res, btn)
        this.refs.subtabButton.execError(res, btn)
      } else {
        this.refs.subButton.execSuccess(btn)
        this.refs.subtabButton.execSuccess(btn)
      }
    })
  }
  /**
   * @description 获取表格选择项
   */
  gettableselected = () => {
    // 获取表格选择项
    let data = []
    this.refs.subTable.state.selectedRowKeys.forEach(item => {
      data.push(this.refs.subTable.props.data[item])
@@ -470,9 +492,17 @@
    return data
  }
  /**
   * @description 表格中,按钮触发事件传递
   */
  buttonTrigger = (btn, record) => {
    this.refs.subButton.actionTrigger(btn, record)
    this.refs.subtabButton.actionTrigger(btn, record)
  }
  /**
   * @description 表格Id变化
   */
  handleTableId = () => {}
  UNSAFE_componentWillMount () {
    // 组件加载时,获取菜单数据
@@ -487,7 +517,7 @@
   * @description 组件销毁,清除state更新
   */
  componentWillUnmount () {
    this.setState = (state, callback) => {
    this.setState = () => {
      return
    }
  }
@@ -496,7 +526,7 @@
    const { setting, searchlist, actions, columns, loadingview, viewlost } = this.state
    return (
      <div className="subtable" id={'subtable' + this.props.MenuID}>
      <div className="subtabtable" id={'subtabtable' + this.props.MenuID}>
        {loadingview && <Spin size="large" />}
        {searchlist && searchlist.length > 0 ?
          <SubSearch
@@ -507,8 +537,8 @@
        }
        {actions &&
          <SubAction
            ref="subButton"
            type="sub"
            ref="subtabButton"
            type="subtab"
            setting={setting}
            actions={actions}
            BID={this.props.BID}
@@ -530,6 +560,7 @@
            loading={this.state.loading}
            refreshdata={this.refreshbytable}
            buttonTrigger={this.buttonTrigger}
            handleTableId={this.handleTableId}
          />
        }
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}