king
2020-04-29 9b6ce1a5778c6e1a813237e87588c0052aae1bbb
src/tabviews/subtable/index.jsx
@@ -10,6 +10,7 @@
import enUS from '@/locales/en-US/main.js'
import Utils from '@/utils/utils.js'
import options from '@/store/options.js'
import { modifyTabview } from '@/store/action'
import SubTable from '@/tabviews/zshare/normalTable'
import SubSearch from '@/tabviews/zshare/topSearch'
@@ -30,6 +31,7 @@
    BData: PropTypes.any,            // 上级数据
    MenuID: PropTypes.string,        // 菜单Id
    SupMenuID: PropTypes.string,     // 上级菜单Id
    mainSearch: PropTypes.any,       // 主表搜索条件
    ContainerId: PropTypes.any,      // 三级菜单Container(html) ID
    handleTableId: PropTypes.func,   // 控制表格数据切换时,更新在主表中的id
    handleMainTable: PropTypes.func, // 刷新主表
@@ -73,9 +75,17 @@
      this.loadmaindata(nextProps.BID, 'refresh')
    } else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) {
      this.reloadtable()
    } else if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.parentId === this.props.MenuID) {
    } else if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.parentId === this.props.Tab.uuid) {
      let trigger = nextProps.triggerBtn
      trigger.parentId = this.props.MenuID
      this.setState({
        triggerBtn: nextProps.triggerBtn
        triggerBtn: trigger
      })
    } else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      this.setState({}, () => {
        this.loadmaindata()
      })
    }
  }
@@ -84,7 +94,7 @@
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { permAction, Tab, BID, userConfig } = this.props
    const { permAction, permMenus, Tab, BID, userConfig } = this.props
    let param = {
      func: 'sPC_Get_LongParam',
@@ -165,6 +175,7 @@
        config.action = config.action.map(item => {
          if (userConfig.action[item.uuid]) {
            delete userConfig.action[item.uuid].label
            item = {...item, ...userConfig.action[item.uuid]}
          }
@@ -203,8 +214,14 @@
      })
      // 生成显示列,处理合并列中的字段
      config.columns.forEach(col => {
      config.columns.forEach((col, index) => {
        if (_hideCol.includes(col.uuid)) return
        if (col.linkThdMenu && !permMenus[col.linkThdMenu.MenuID]) {
          col.linkThdMenu = ''
        }
        col.sort = index
        if (col.type === 'colspan' && col.sublist) {
          let _col = JSON.parse(JSON.stringify(col))
@@ -254,6 +271,7 @@
      if (userConfig) {
        _columns = _columns.map(item => {
          if (userConfig.columns[item.uuid]) {
            delete userConfig.columns[item.uuid].label
            item = {...item, ...userConfig.columns[item.uuid]}
          }
@@ -287,10 +305,12 @@
        loadingview: false,
        viewlost: true
      })
      let prex = Tab && Tab.label ? Tab.label + ': ' : ''
      notification.warning({
        top: 92,
        message: result.message,
        duration: 10
        message: prex + result.message,
        duration: 5
      })
    }
  }
@@ -338,10 +358,12 @@
        })
        deffers.push(defer)
      } else if (item.resourceType === '1' && !item.dataSource) {
        let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : ''
        notification.warning({
          top: 92,
          message: item.label + ': ' + this.state.dict['main.datasource.settingerror'],
          duration: 10
          message: prex + item.label + ': ' + this.state.dict['main.datasource.settingerror'],
          duration: 5
        })
      }
    })
@@ -373,10 +395,12 @@
            return item
          })
        } else {
          let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : ''
          notification.warning({
            top: 92,
            message: res.search.label + ':' + res.message,
            duration: 10
            message: prex + res.search.label + ':' + res.message,
            duration: 5
          })
        }
      })
@@ -443,10 +467,12 @@
      this.setState({
        loading: false
      })
      let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + ': ' : ''
      notification.error({
        top: 92,
        message: result.message,
        duration: 15
        message: prex + result.message,
        duration: 10
      })
    }
  }
@@ -455,9 +481,15 @@
   * @description 获取用户自定义存储过程传参
   */
  getCustomParam = (BID) => {
    const { mainSearch } = this.props
    const { pageIndex, pageSize, orderBy, search, setting } = this.state
    let _search = Utils.formatCustomMainSearch(search)
    let searches = search
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...search]
    }
    let _search = Utils.formatCustomMainSearch(searches)
    let param = {
      PageIndex: pageIndex,
@@ -477,14 +509,12 @@
          param.rduri = setting.interface
        }
      } else {
        if (setting.sysInterface === 'true') {
          param.rduri = window.GLOB.mainSystemApi || window.GLOB.subSystemApi
        } else {
        if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) {
          param.rduri = window.GLOB.mainSystemApi
        } else if (setting.sysInterface !== 'true') {
          param.rduri = setting.interface
        }
      }
      param.appkey = window.GLOB.appkey || '' // 调用外部接口增加appkey
      if (setting.outerFunc) {
        param.func = setting.outerFunc
@@ -498,17 +528,22 @@
   * @description 获取系统存储过程 sPC_Get_TableData 的参数
   */
  getDefaultParam = (BID) => {
    const { mainSearch } = this.props
    const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state
    let _search = Utils.joinMainSearchkey(search)
    let searches = search
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...search]
    }
    let _search = Utils.joinMainSearchkey(searches)
    _search = _search ? 'where ' + _search : ''
    let param = {
      func: 'sPC_Get_TableData',
      obj_name: 'data',
      arr_field: arr_field,
      BID: BID,
      appkey: window.GLOB.appkey || ''
      BID: BID
    }
    let _orderBy = orderBy || setting.order
@@ -530,12 +565,12 @@
        fieldmap.set(item.key, true)
        return {
          reg: new RegExp('@' + _field, 'ig'),
          reg: new RegExp('@' + _field + '@', 'ig'),
          value: item.value
        }
      })
      options.reverse()
      // options.reverse()
      options.forEach(item => {
        _dataresource = _dataresource.replace(item.reg, `'${item.value}'`)
@@ -663,13 +698,18 @@
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  getexceloutparam = () => {
    const { Tab } = this.props
    const { Tab, mainSearch } = this.props
    const { arr_field, orderBy, search, setting} = this.state
    let searches = search
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...search]
    }
    return {
      arr_field: arr_field,
      orderBy: orderBy || setting.order,
      search: search,
      search: searches,
      menuName: Tab.label
    }
  }
@@ -697,7 +737,6 @@
        data: record
      }
    })
    // this.refs.subButton.actionTrigger(btn, record)
  }
  /**
@@ -727,6 +766,34 @@
    this.setState({
      pickup: !pickup
    })
  }
  linkTrigger = (menu) => {
    const { tabviews, SupMenuID } = this.props
    menu.selected = true
    let index = 0
    let isexit = false
    let tabs = tabviews.map((tab, i) => {
      tab.selected = false
      if (tab.MenuID === SupMenuID) {
        index = i
      } else if (tab.MenuID === menu.MenuID) {
        tab.param = menu.param
        tab.selected = true
        isexit = true
      }
      return tab
    })
    if (!isexit) {
      tabs.splice(index + 1, 0, menu)
    }
    this.props.modifyTabview(tabs)
  }
  popclose = () => {
@@ -797,6 +864,7 @@
            }
            <SubTable
              ref="subTable"
              menuType={this.props.menuType}
              tableId={this.props.Tab.uuid}
              pickup={pickup}
              setting={setting}
@@ -808,6 +876,7 @@
              loading={this.state.loading}
              refreshdata={this.refreshbytable}
              buttonTrigger={this.buttonTrigger}
              linkTrigger={this.linkTrigger}
              handleTableId={this.handleTableId}
            />
          </div> : null
@@ -843,13 +912,17 @@
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    permAction: state.permAction,
    permRoles: state.permRoles
    permRoles: state.permRoles,
    permMenus: state.permMenus
  }
}
const mapDispatchToProps = () => {
  return {}
const mapDispatchToProps = (dispatch) => {
  return {
    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(SubTabViewTable)