king
2021-01-25 d33d00cafeea2c4f980ea3af268d9260269edcc1
src/tabviews/subtable/index.jsx
@@ -74,14 +74,12 @@
      }, () => {
        if (this.state.setting) {
          this.loadmaindata(nextProps.BID, 'refresh')
          this.getStatFieldsValue(nextProps.BID, 'refresh')
        }
      })
    } else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      if (this.state.setting) {
        this.setState({}, () => {
          this.loadmaindata()
          this.getStatFieldsValue()
        })
      }
    }
@@ -103,6 +101,7 @@
      try { // 配置信息解析
        config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
        config.setting.MenuName = Tab.label
      } catch (e) {
        console.warn('Parse Failure')
        config = ''
@@ -274,7 +273,7 @@
      config.setting.execute = config.setting.default !== 'false'     // 默认sql是否执行,转为boolean 统一格式
      config.setting.customScript = ''                                // 自定义脚本
      if (config.setting.interType === 'system') {
      if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) {
        if (config.setting.scripts && config.setting.scripts.length > 0) {
          let _customScript = ''
          config.setting.scripts.forEach(item => {
@@ -321,7 +320,6 @@
      }, () => {
        if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode) && valid) { // 初始化可加载
          this.loadmaindata()
          this.getStatFieldsValue()
        }
      })
    } else {
@@ -371,6 +369,7 @@
      if (!bid) { // 主表ID不存在时,不查询子表
        this.setState({
          data: [],
          statFValue: [],
          total: 0
        })
        return
@@ -378,6 +377,7 @@
        _BID = bid
      }
    }
    this.setState({
      selectedData: [],
      loading: true
@@ -393,6 +393,9 @@
    }
    let result = await Api.genericInterface(param)
    this.getStatFieldsValue(_BID, searches)
    if (result.status) {
      this.setState({
        data: result.data.map((item, index) => {
@@ -501,36 +504,13 @@
  /**
   * @description 获取合计字段值
   */
  getStatFieldsValue = (bid, type) => {
    const { mainSearch } = this.props
    const { setting, search, orderBy, statFields } = this.state
  getStatFieldsValue = (bid, searches) => {
    const { setting, orderBy, statFields } = this.state
    let _BID = this.props.BID
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...searches]
    }
    if (statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return
    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
    if (requireFields.length > 0) {
      return
    }
    if (type === 'refresh') {
      if (!bid) { // 主表ID不存在时,不查询子表合计值
        this.setState({
          statFValue: []
        })
        return
      } else {
        _BID = bid
      }
    }
    if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, _BID, this.props.menuType)
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, bid, this.props.menuType)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = this.props.Tab.label || ''
@@ -580,7 +560,6 @@
      search: searches,
    }, () => {
      this.loadmaindata()
      this.getStatFieldsValue()
    })
  }
@@ -615,12 +594,10 @@
        pageIndex: 1
      }, () => {
        this.loadmaindata()
        this.getStatFieldsValue()
      })
    } else {
      MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置
      this.loadmaindata()
      this.getStatFieldsValue()
    }
  }