king
2023-06-16 e4666c46c685ec7eabff25af9890d54c0ff2952b
src/tabviews/custom/components/table/edit-table/index.jsx
@@ -37,7 +37,7 @@
    pageIndex: 1,         // 页码
    pageSize: 10,         // 每页数据条数
    orderBy: '',          // 排序
    search: '',           // 搜索条件数组,使用时需分场景处理
    search: ''            // 搜索条件数组,使用时需分场景处理
  }
  /**
@@ -79,6 +79,7 @@
    let _columns = []
    setting.initId = ''
    let triMap = new Map()
    setting.hasSubmit = false
    let getColumns = (cols) => {
      return cols.filter(item => {
@@ -92,8 +93,9 @@
          if (item.subcols.length === 0) {
            return false
          }
        } else if (item.type === 'action') {
        } else if (item.type === 'custom') {
          item.elements.forEach(btn => {
            if (btn.eleType !== 'button') return
            if (btn.funcType === 'addline') {
              setting.addable = true
            }
@@ -114,6 +116,7 @@
          }
          if (item.editable === 'true') {
            setting.hasSubmit = true
            if (!setting.initId) {
              setting.initId = item.uuid
            }
@@ -330,25 +333,21 @@
        })
      }
      try {
        data = data.map(item => {
          if (item.$$uuid === _data.$$uuid) {
            _data.key = item.key
            _data.$Index = item.$Index
            return _data
          } else {
            return item
          }
        })
        selectedData = selectedData.map(item => {
          if (_data.$$uuid === item.$$uuid) {
            return _data
          }
      data = data.map(item => {
        if (item.$$uuid === _data.$$uuid) {
          _data.key = item.key
          _data.$Index = item.$Index
          return _data
        } else {
          return item
        })
      } catch (e) {
        console.warn('数据查询错误')
      }
        }
      })
      selectedData = selectedData.map(item => {
        if (_data.$$uuid === item.$$uuid) {
          return _data
        }
        return item
      })
      MKEmitter.emit('transferData', config.uuid, _data, 'line')
      MKEmitter.emit('resetSelectLine', config.uuid, _data.$$uuid, _data)
@@ -375,24 +374,12 @@
   * 含有初始不加载的页面,修改设置
   */
  refreshbysearch = (searches) => {
    const { setting } = this.state
    if (setting.onload === 'false') {
      this.setState({
        pageIndex: 1,
        search: searches,
        setting: {...setting, onload: 'true'}
      }, () => {
        this.loadmaindata()
      })
    } else {
      this.setState({
        pageIndex: 1,
        search: searches
      }, () => {
        this.loadmaindata(true, 'true')
      })
    }
    this.setState({
      pageIndex: 1,
      search: searches
    }, () => {
      this.loadmaindata(true, 'true')
    })
  }
  /**
@@ -480,7 +467,9 @@
        BID: id,
        BData: data
      }, () => {
        this.loadmaindata(true, 'true')
        setTimeout(() => {
          this.loadmaindata(true, 'true')
        }, setting.delay || 0)
      })
    }
  }
@@ -513,6 +502,28 @@
    }
  }
  refreshLineData = (menuId, btn, uuid, count) => {
    const { config } = this.state
    if (config.uuid !== menuId) return
    let _data = fromJS(this.state.data).toJS().forEach(item => {
      if (item.$$uuid === uuid) {
        item[btn.field] = count
      }
    })
    let _selectedData = fromJS(this.state.selectedData).toJS().forEach(item => {
      if (item.$$uuid === uuid) {
        item[btn.field] = count
      }
    })
    this.setState({
      data: _data,
      selectedData: _selectedData
    })
  }
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { config } = this.state
@@ -531,6 +542,7 @@
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.addListener('refreshLineData', this.refreshLineData)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
  }
@@ -544,6 +556,7 @@
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshLineData', this.refreshLineData)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
@@ -556,7 +569,7 @@
    }
    return (
      <div className="custom-edit-table" id={'anchor' + config.uuid} style={style}>
      <div className={'custom-edit-table' + (setting.hasSubmit ? '' : ' withnot-submit')} id={'anchor' + config.uuid} style={style}>
        <NormalHeader config={config}/>
        {config.search && config.search.length ?
          <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null