import React, { Component } from 'react'; import { connect } from 'react-redux'; import router from 'umi/router'; import DocumentTitle from 'react-document-title'; import styles from './index.less'; @connect(({ dogGroup, fciSection }) => ({ dogGroup, fciSection })) class index extends Component { state = {}; componentWillMount = () => { const { list } = this.props.dogGroup; if (list.length === 0) { router.goBack(); return; } const { index } = this.props.location.query; if (index) { this.props.dispatch({ type: 'fciSection/updateState', payload: { index, item: list[index], }, }); this.props.dispatch({ type: 'fciSection/getFciSectionByGroupId', payload: { groupNo: list[index].group_no, }, }); } }; componentDidMount = () => {}; componentWillUnmount = () => { this.props.dispatch({ type: 'fciSection/clearState', payload: {}, }); }; goOpen = (data, index) => { const { listI } = this.props.fciSection; if (index === listI) { this.props.dispatch({ type: 'fciSection/updateState', payload: { listI: null, }, }); return; } this.props.dispatch({ type: 'fciSection/updateState', payload: { listI: index, }, }); this.props.dispatch({ type: 'fciSection/getFciDogBySectionId', payload: { gsNo: data.gs_no, }, }); }; goDetail = typeNo => { router.push(`/breed/detail?typeNo=${typeNo}`); }; render() { const { item, list, listI } = this.props.fciSection; return (
{item.chinese_group_name}

{item.introduction}

{list ? list.map((data, index) => { return (
{ this.goOpen(data, index); }} className={`${styles.g_b_i} ${index === listI ? styles.g_b_i_a : ''}`} > {data.chinese_section_name}
{data.children ? data.children.map((cData, cIndex) => { return (
{ this.goDetail(cData.type_no); }} className={styles.g_b_c_i} > {cData.chinese_breed_name} {cData.english_breed_name}
); }) : null}
); }) : null}
); } } export default index;