king
2022-08-02 8d66ff34fae5b048a6b7923cc75d34f13a08be9d
src/tabviews/custom/components/timeline/normal-timeline/index.jsx
@@ -19,7 +19,6 @@
    data: PropTypes.array,           // 统一查询数据
    config: PropTypes.object,        // 组件配置信息
    mainSearch: PropTypes.any,       // 外层搜索条件
    menuType: PropTypes.any,         // 菜单类型
  }
  state = {
@@ -158,20 +157,10 @@
    if (config.uuid !== menuId) return
    let supModule = config.setting.supModule
    btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
    if (!btn.syncComponentId || btn.syncComponentId !== supModule) {
      if (position === 'mainline' || position === 'popclose') { // 刷新源组件时,附带刷新上级行与当前组件
        if (supModule && BID) {
          MKEmitter.emit('reloadData', supModule, BID)
        } else {
          this.loadData()
        }
      } else {
        this.loadData()
      }
    if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 刷新源组件时,附带刷新上级行与当前组件
      MKEmitter.emit('reloadData', config.setting.supModule, BID)
    } else {
      this.loadData()
    }
    if (position === 'popclose') { // 执行启动弹窗的按钮所选择的刷新项
@@ -226,7 +215,7 @@
  }
  async loadData () {
    const { mainSearch, menuType } = this.props
    const { mainSearch } = this.props
    const { config, arr_field, BID, BData } = this.state
    if (config.setting.supModule && !BID) { // BID 不存在时,不做查询
@@ -256,7 +245,7 @@
    })
    let _orderBy = config.setting.order || ''
    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, config.setting.pageSize, BID, menuType)
    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, config.setting.pageSize, BID)
    let result = await Api.genericInterface(param)
    if (result.status) {
@@ -314,6 +303,62 @@
    </Timeline.Item>)
  }
  getMknodes = (data) => {
    const { config, card } = this.state
    let color = config.wrap.color
    let dot = ''
    let linebg = {}
    if (config.wrap.node && card.nodes && card.nodes.length > 0) {
      let sign = data[config.wrap.node]
      card.nodes.some(item => {
        if (sign === item.sign) {
          color = item.color
          if (item.icon) {
            dot = <MkIcon type={item.icon}/>
          }
          if (item.linecolor) {
            linebg = {borderColor: item.linecolor}
          }
          return true
        }
        return false
      })
    }
    if (config.wrap.mode === 'down') {
      return (<div className="mk-time-line-item" key={data.$Index}>
        <div className="mk-timeline-item-content">
          <div className="card-item-box" style={card.style}>
            <CardCellComponent data={data} cards={config} cardCell={card} elements={card.elements}/>
          </div>
        </div>
        <div className="mk-timeline-item-head">
          <div className="mk-timeline-item-tail" style={linebg}></div>
          <div className={'mk-dot ' + (dot ? 'mk-dot-icon' : '')} style={{background: color}}>
            {dot}
          </div>
        </div>
      </div>)
    } else {
      return (<div className="mk-time-line-item" key={data.$Index}>
        <div className="mk-timeline-item-head">
          <div className="mk-timeline-item-tail" style={linebg}></div>
          <div className={'mk-dot ' + (dot ? 'mk-dot-icon' : '')} style={{background: color}}>
            {dot}
          </div>
        </div>
        <div className="mk-timeline-item-content">
          <div className="card-item-box" style={card.style}>
            <CardCellComponent data={data} cards={config} cardCell={card} elements={card.elements}/>
          </div>
        </div>
      </div>)
    }
  }
  render() {
    const { config, loading, data } = this.state
@@ -326,9 +371,12 @@
          </div> : null
        }
        <NormalHeader config={config} />
        {data && data.length > 0 ? <Timeline mode={config.wrap.mode} reverse={config.wrap.reverse === 'true'} className={'card-row-list ' + (config.wrap.line || '')} style={{height: config.wrap.contentHeight}}>
        {config.wrap.direction !== 'horizontal' && data && data.length > 0 ? <Timeline mode={config.wrap.mode} className={'card-row-list ' + (config.wrap.line || '')} style={{height: config.wrap.contentHeight}}>
          {data.map(item => this.getnodes(item))}
        </Timeline> : null}
        {config.wrap.direction === 'horizontal' && data && data.length > 0 ? <div className={'mk-time-line-wrap card-row-list ' + (config.wrap.line || '')} style={{height: config.wrap.contentHeight}}>
          {data.map(item => this.getMknodes(item))}
        </div> : null}
        {data && data.length === 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}>
          <Empty description={false}/>
        </div> : null}