import React, { Component } from 'react'; import './index.less'; import Page from '@src/containers/Page'; import { formatDate, formatMonth, getMap, formatPercent } from '@src/services/Tools'; import Ratio from '../../../components/Ratio'; import UserAction from '../../../components/UserAction'; import UserPagination from '../../../components/UserPagination'; import { ExperienceScore, ExperienceDay, PrepareStatus, ExperiencePercent } from '../../../../Constant'; import { Main } from '../../../stores/main'; import { My } from '../../../stores/my'; import { Course } from '../../../stores/course'; const PrepareStatusMap = getMap(PrepareStatus, 'value', 'label'); const ExperiencePercentMap = getMap(ExperiencePercent, 'value', 'label'); const colorList = ['#2754E0', '#3F86EA', '#41A6F3', '#9BD4FF']; export default class extends Page { initState() { const prepareStatusSelect = PrepareStatus.map(row => { return { title: row.label, key: row.value, }; }); prepareStatusSelect.unshift({ title: '全部', key: '', }); const experienceDaySelect = ExperienceDay.map(row => { return { title: row.label, key: row.value, }; }); experienceDaySelect.unshift({ title: '全部', key: '', }); const experienceScoreSelect = ExperienceScore.map(row => { return { title: row.label, key: row.value, }; }); experienceScoreSelect.unshift({ title: '全部', key: '', }); const experiencePercentSelect = ExperiencePercent.map(row => { return { title: row.label, key: row.value, }; }); experiencePercentSelect.unshift({ title: '全部', key: '', }); return { prepareStatusSelect, experienceDaySelect, experienceScoreSelect, experiencePercentSelect, }; } init() { Main.getExperience() .then(result => { const totalScoreNumber = result.score.reduce((x, y) => x + y, 0); const totalPercentNumber = result.percent.reduce((x, y) => x + y, 0); const scoreList = ExperienceScore.map((row, index) => { const percent = formatPercent(result.score[index] || 0, totalScoreNumber); return { color: colorList[index], label: `${row.label} ${percent} ${result.score[index] || 0}人`, value: percent, }; }); const percentList = ExperiencePercent.map((row, index) => { const percent = formatPercent(result.percent[index] || 0, totalPercentNumber); return { color: colorList[index], label: `${row.label} ${percent} ${result.percent[index] || 0}人`, value: percent, }; }); this.setState({ data: result, scoreList, percentList }); }); } initData() { const data = Object.assign(this.state, this.state.search); if (data.order) { data.sortMap = { [data.order]: data.direction }; } data.filterMap = this.state.search; this.setState(data); Course.listExperience(Object.assign({}, this.state.search)) .then(result => { this.setState({ list: result.list, total: result.total }); }); } onFilter(value) { this.search(value, false); this.initData(); } onChangePage(page) { this.search({ page }, false); this.initData(); } renderView() { return (