king
2023-06-25 5025901e459ae49d85210573ad38fb3f3c1d9230
src/tabviews/custom/components/card/data-card/index.jsx
@@ -80,6 +80,9 @@
      }
    }
    _config.$extend = false
    _config.$empty = true
    _config.subcards.forEach(item => {
      if (item.setting.click === 'button' && !item.setting.linkbtn) {
        item.elements.forEach(ele => {
@@ -95,8 +98,14 @@
      if (item.$cardType !== 'extendCard') {
        _card = item
      } else if (!_card) {
        _config.$extend = true
        if (item.setting.width !== 24) {
          _config.$empty = false
        }
        precards.push(item)
      } else {
        _config.$extend = true
        _config.$empty = false
        nextcards.push(item)
      }
    })
@@ -130,7 +139,7 @@
        item.$Index = index + 1 + ''
        if (_config.wrap.controlField) {
          if (_config.wrap.controlVal.includes(item[_config.wrap.controlField])) {
          if (_config.wrap.controlVal.includes(item[_config.wrap.controlField] + '')) {
            item.$disabled = true
          }
        }
@@ -162,6 +171,10 @@
    this.loaded = _data !== null
    let pageOptions = ['10', '25', '50', '100', '500', '1000']
    if (!_config.setting.laypage) {
      _config.wrap.pagestyle = 'none'
    }
    if (_config.wrap.pagestyle === 'page') {
      let size = (_config.setting.pageSize || 10) + ''
@@ -202,6 +215,7 @@
    MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.addListener('refreshLineData', this.refreshLineData)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
    
    if (config.timer) {
@@ -224,7 +238,7 @@
          item.$Index = index + 1 + ''
          if (config.wrap.controlField) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) {
              item.$disabled = true
            }
          }
@@ -256,7 +270,7 @@
          item.$Index = index + 1 + ''
          if (config.wrap.controlField) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) {
              item.$disabled = true
            }
          }
@@ -292,6 +306,7 @@
    MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshLineData', this.refreshLineData)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
    this.timer && this.timer.stop()
@@ -362,6 +377,23 @@
    if (position === 'popclose') { // 执行启动弹窗的按钮所选择的刷新项
      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
    }
  }
  refreshLineData = (menuId, btn, uuid, count) => {
    const { config, data } = this.state
    if (config.uuid !== menuId) return
    let _data = fromJS(data).toJS().map(item => {
      if (item.$$uuid === uuid) {
        item[btn.field] = count
      }
      return item
    })
    this.setState({
      data: _data
    })
  }
  checkTopLine = (id) => {
@@ -488,6 +520,7 @@
  checkAll = () => {
    const { config, data, selectedData } = this.state
    if (config.wrap.cardType !== 'checkbox') return
    if (!data || data.length === 0) return
    
    if (selectedData.length === 0 || selectedData.length < data.length) {
@@ -697,7 +730,7 @@
          item.$Index = index + 1 + ''
          if (config.wrap.controlField) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) {
              item.$disabled = true
            }
          }
@@ -712,7 +745,7 @@
          item.$Index = index + start + ''
          if (config.wrap.controlField) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField] + '')) {
              item.$disabled = true
            }
          }
@@ -735,16 +768,31 @@
          this.timer && this.timer.stop()
        }
      }
      if (result.message) {
        if (result.ErrCode === 'Y') {
          Modal.success({
            title: result.message
          })
        } else if (result.ErrCode === 'S') {
          notification.success({
            top: 92,
            message: result.message,
            duration: 2
          })
        }
      }
    } else {
      this.setState({
        loading: false
      })
      this.timer && this.timer.stop()
      if (!result.message) return
      if (result.ErrCode === 'N') {
        Modal.error({
          title: result.message,
        })
      } else {
      } else if (result.ErrCode !== '-2') {
        notification.error({
          top: 92,
          message: result.message,
@@ -945,15 +993,23 @@
    let _total = 0
    let switchable = false
    if (config.wrap.pagestyle === 'switch' && config.pageable && config.setting.laypage && total > pageSize && data) {
    if (config.wrap.pagestyle === 'switch' && total > pageSize && data) {
      _total = pageSize * pageIndex
      switchable = true
    }
    let extendData = {$$BID: BID, $$BData: BData, $$selectedData: selectedData, $$type: 'extendCard'}
    let extendData = null
    if (data && data[0]) {
      extendData = {...extendData, ...data[0]}
    if (config.$extend) {
      extendData = {$$BID: BID, $$BData: BData, $$selectedData: selectedData, $$type: 'extendCard'}
      if (data && data[0]) {
        if (selectedData[0]) {
          extendData = {...extendData, ...selectedData[0]}
        } else {
          extendData = {...extendData, ...data[0]}
        }
      }
    }
    let checkAll = ''
@@ -1028,10 +1084,10 @@
            ))}
          </Row>
          {switchable ? <div className={'prev-page ' + (total <= _total ? 'disabled' : '')} onClick={this.nextPage}><div><div><img src={nextImg} alt=""/></div></div></div> : null}
          {precards.length === 0 && nextcards.length === 0 && (!data || data.length === 0) ? <Empty description={false}/> : null}
        </div>
        {config.wrap.pagestyle === 'page' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={(t, range) => `${range[0]}-${range[1]} 共 ${total} 条`} pageSize={pageSize} showSizeChanger={true} pageSizeOptions={this.state.pageOptions} onChange={this.changePageIndex} onShowSizeChange={this.pageSizeChange} current={pageIndex}/> : null}
        {config.wrap.pagestyle === 'more' && config.setting.laypage && data && data.length > 0 ? <div className={'mk-more' + (pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>查看更多<DownOutlined/></div> : null}
        {config.$empty && (!data || data.length === 0) ? <Empty description={false}/> : null}
        {config.wrap.pagestyle === 'page' && data ? <Pagination size="small" total={total} showTotal={(t, range) => total > 0 ? `${range[0]}-${range[1]} 共 ${total} 条` : `共 ${total} 条`} pageSize={pageSize} showSizeChanger={true} pageSizeOptions={this.state.pageOptions} onChange={this.changePageIndex} onShowSizeChange={this.pageSizeChange} current={pageIndex}/> : null}
        {config.wrap.pagestyle === 'more' && data && data.length > 0 ? <div className={'mk-more' + (pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>查看更多<DownOutlined/></div> : null}
      </div>
    )
  }