Modal in use and react multiple times with different parameters to achieve

A Example: For echatrs columns are needed pop pop band parametric trigger event occurs showModalhref
 1   myChart.on('click', (params) => {
 2         switch (params.seriesIndex) {
 3           // echarts 双柱1
 4           case 0: this.showModalhref('kjxy', industryBar_list.list, params);
 5             break;
 6           // echarts 双柱2
 7           case 1: this.showModalhref('cpxy', industryBar_list.list, params);
 8             break;
 9           default: break;
10         }
11       });

 

Two, modal  

   state = {
      modalShowHref: {
             visibleHref: false,
             type: '',
             data1: [],
             data2: {},
         },
     }    
    

      <Modal
          visible={this.state.modalShowHref.visibleHref}
          onOk={this.okModalhref}
          onCancel={this.hideModalhref}
          okText="确认"
          cancelText="取消"
          width={278}
          className={styles.hrefModal}
        >
          <p> The jump it? </ the p-> 
        </ Modal>

 

  Third, when you click onOk

okModalhref = () => {
    const { modalShowHref } = this.state;
    const { type } = modalShowHref;
    const { data1 } = modalShowHref;
    const { data2 } = modalShowHref;
    if (type === 'kjxy') { // 框架协议 (arr, params)
      const obj = data1.find(t => t.name === data2.name);
      const { corpCstTps } = obj;
      this.props.dispatch(routerRedux.push({
        pathname: '/QYGL/kjxy/query',
        state: {
          corpCstTps,
        },
      }));
    } else if (type === 'cpxy') { // 产品协议 (arr, params)
      const obj = data1.find(t => t.name === data2.name);
      const { corpCstTps } = obj;
      this.props.dispatch(routerRedux.push({
        pathname: '/QYGL/cpxy/searchList',
        state: {
          corpCstTps,
        },
      }));
    }
  };

Fourth, click onCancel

/////弹窗中 取消事件
  hideModalhref = () => {
    this.setState({
      modalShowHref: {
        visibleHref: false,
        type: '',
        data1: [],
        data2: {},
      },
    });
  };

 

Guess you like

Origin www.cnblogs.com/roxanneQQyxm/p/11531999.html