king
2021-05-08 9d65dcb2e35f8091f71110c4de7a04215b63b81e
src/tabviews/custom/index.jsx
@@ -190,7 +190,9 @@
        })
      }
      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs)
      let isEmpty = mainSearch.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0
      config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, isEmpty)
      this.setState({
        BID: BID,
@@ -719,7 +721,7 @@
  }
  // 格式化默认设置
  formatSetting = (components, params, mainSearch, inherit, regs) => {
  formatSetting = (components, params, mainSearch, inherit, regs, isEmpty) => {
    return components.map(component => {
      if (component.type === 'tabs') {
        component.subtabs = component.subtabs.map(tab => {
@@ -787,8 +789,32 @@
      // dataName 系统生成的数据源名称
      // pageable 是否分页,组件属性,不分页的组件才可以统一查询
      if (component.floor === 1 && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') {
        let param = this.getDefaultParam(component, mainSearch)
        params.push(param)
        if (isEmpty && component.setting.useMSearch === 'true') {
          component.setting.sync = 'false'
          component.setting.onload = 'false'
        } else {
          let searchlist = []
          if (component.search && component.search.length > 0) {
            searchlist = Utils.initMainSearch(component.search)
          }
          let _empty = searchlist.filter(item => item.required && (!item.value || item.value.length === 0)).length > 0
          if (_empty) {
            component.setting.sync = 'false'
            component.setting.onload = 'false'
          } else {
            if (component.setting.useMSearch === 'true') {
              let keys = searchlist.map(item => item.key)
              mainSearch.forEach(item => {
                if (!keys.includes(item.key)) {
                  searchlist.push(item)
                }
              })
            }
            params.push(this.getDefaultParam(component, searchlist))
          }
        }
      } else if (component.floor === 1) {
        component.setting.sync = 'false'
      }
@@ -800,22 +826,8 @@
  /**
   * @description 获取系统存储过程 sPC_Get_TableData 的参数
   */
  getDefaultParam = (component, mainSearch) => {
    const { columns, search, setting, dataName, format } = component
    let searchlist = []
    if (search && search.length > 0) {
      searchlist = Utils.initMainSearch(search)
    }
    if (setting.useMSearch === 'true') {
      let keys = searchlist.map(item => item.key)
      mainSearch.forEach(item => {
        if (!keys.includes(item.key)) {
          searchlist.push(item)
        }
      })
    }
  getDefaultParam = (component, searchlist) => {
    const { columns, setting, dataName, format } = component
    let arr_field = columns.map(col => col.field)
    let _dataresource = setting.dataresource