king
2022-04-25 9e716f3bd30820a08757845b592db73363faa48c
src/tabviews/custom/components/card/data-card/index.jsx
@@ -115,6 +115,8 @@
    let selected = 'false'
    if (_config.wrap.selected === 'always' || _config.wrap.selected === 'init') {
      selected = _config.wrap.selected
    } else {
      _config.wrap.selected = 'false'
    }
    if (_data) {
@@ -264,7 +266,7 @@
   * @param {*} position   // 刷新位置
   * @param {*} btn        // 执行的按钮
   */
  refreshByButtonResult = (menuId, position, btn, id, lines) => {
  refreshByButtonResult = (menuId, position, btn, id = '', lines) => {
    const { config, BID, supComs, supNodes } = this.state
    if (config.uuid !== menuId) return
@@ -290,16 +292,16 @@
          if (lines && lines.length === 1) {
            this.loadLinedata(lines[0].$$uuid)
          } else {
            this.loadData()
            this.loadData(id)
          }
        } else if (!btn || btn.resetPageIndex !== 'false') {
          this.setState({
            pageIndex: 1
          }, () => {
            this.loadData()
            this.loadData(id)
          })
        } else {
          this.loadData()
          this.loadData(id)
        }
      }
    } else {
@@ -312,22 +314,22 @@
          if (lines && lines.length === 1) {
            this.loadLinedata(lines[0].$$uuid)
          } else {
            this.loadData()
            this.loadData(id)
          }
        } else if (position === 'mainline' || position === 'popclose') { // 刷新源组件时,附带刷新上级行与当前组件
          if (supModule && BID) {
            MKEmitter.emit('reloadData', supModule, BID)
          } else {
            this.loadData()
            this.loadData(id)
          }
        } else if (!btn || btn.resetPageIndex !== 'false') {
          this.setState({
            pageIndex: 1
          }, () => {
            this.loadData()
            this.loadData(id)
          })
        } else {
          this.loadData()
          this.loadData(id)
        }
      }
    }
@@ -337,7 +339,7 @@
    }
  }
  checkTopLine = () => {
  checkTopLine = (id) => {
    const { config, data } = this.state
    if (!data || data.length === 0 || data[0].$disabled) {
@@ -354,15 +356,23 @@
      return
    }
    let index = 0
    if (id) {
      index = data.findIndex(item => item.$$uuid === id)
      if (index === -1) {
        index = 0
      }
    }
    this.setState({
      activeKey: 0,
      selectKeys: [0],
      selectedData: [data[0]]
      activeKey: index,
      selectKeys: [index],
      selectedData: [data[index]]
    })
    MKEmitter.emit('resetSelectLine', config.uuid, data[0].$$uuid, data[0])
    MKEmitter.emit('resetSelectLine', config.uuid, data[index].$$uuid, data[index])
    if (config.setting.$hasSyncModule) {
      MKEmitter.emit('syncBalconyData', config.uuid, [data[0]], data.length === 1)
      MKEmitter.emit('syncBalconyData', config.uuid, [data[index]], data.length === 1)
    }
  }
@@ -468,7 +478,7 @@
    })
  }
  async loadData () {
  async loadData (id) {
    const { mainSearch, menuType } = this.props
    const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state
@@ -483,9 +493,9 @@
        loading: false
      })
      
      if (selected !== 'false') {
      if (selected !== 'false' || (id && config.wrap.selected !== 'false')) {
        setTimeout(() => {
          this.checkTopLine()
          this.checkTopLine(id)
        }, 200)
        if (selected === 'init') {
          this.setState({selected: 'false'})
@@ -528,9 +538,9 @@
        start = config.setting.pageSize * (pageIndex - 1) + 1
      }
      if (selected !== 'false') {
      if (selected !== 'false' || (id && config.wrap.selected !== 'false')) {
        setTimeout(() => {
          this.checkTopLine()
          this.checkTopLine(id)
        }, 200)
        if (selected === 'init') {
          this.setState({selected: 'false'})