|
@@ -10,6 +10,7 @@ import TotalSort from '../TotalSort';
|
|
|
import Date from '../Date';
|
|
|
import Ratio from '../Ratio';
|
|
|
import { My } from '../../stores/my';
|
|
|
+import { Main } from '../../stores/main';
|
|
|
import { PrepareStatus, PrepareExaminationTime, PrepareScoreTime } from '../../../Constant';
|
|
|
|
|
|
const PrepareStatusMap = getMap(PrepareStatus, 'value', 'short');
|
|
@@ -49,48 +50,44 @@ export default class extends Component {
|
|
|
},
|
|
|
};
|
|
|
this.state = { step: 0, data: { prepareGoal: 650 } };
|
|
|
- My.getPrepare().then(result => {
|
|
|
- const statusTotal = result.stat.status.reduce((p, n) => {
|
|
|
- return p + n.value;
|
|
|
- }, 0);
|
|
|
- const goalTotal = result.stat.goal.reduce((p, n) => {
|
|
|
- return p + n.value;
|
|
|
- }, 0);
|
|
|
- const examinationTimeTotal = result.stat.examinationTime.reduce((p, n) => {
|
|
|
- return p + n.value;
|
|
|
- }, 0);
|
|
|
- const scoreTimeTotal = result.stat.scoreTime.reduce((p, n) => {
|
|
|
- return p + n.value;
|
|
|
- }, 0);
|
|
|
- const stat = {
|
|
|
- status: result.stat.status.map((row, index) => {
|
|
|
- row.value = formatPercent(row.value, statusTotal);
|
|
|
- row.label = `${PrepareStatusMap[row.key]}; ${row.value}%`;
|
|
|
- row.color = this.statusColors[index];
|
|
|
- return row;
|
|
|
- }),
|
|
|
- goal: result.stat.goal.map((row, index) => {
|
|
|
- row.value = formatPercent(row.value, goalTotal);
|
|
|
- row.label = `${row.key}+; ${row.value}%`;
|
|
|
- row.color = this.goalColors[index];
|
|
|
- return row;
|
|
|
- }),
|
|
|
- examinationTime: result.stat.status.map((row, index) => {
|
|
|
- row.value = formatPercent(row.value, examinationTimeTotal);
|
|
|
- row.label = `${PrepareExaminationTimeMap[row.key]}; ${row.value}%`;
|
|
|
- row.color = this.examinationTimeColors[index];
|
|
|
- return row;
|
|
|
- }),
|
|
|
- scoreTime: result.stat.scoreTime.map((row, index) => {
|
|
|
- row.value = formatPercent(row.value, scoreTimeTotal);
|
|
|
- row.label = `${PrepareScoreTimeMap[row.key]}; ${row.value}%`;
|
|
|
- row.color = this.scoreTimeColors[index];
|
|
|
- return row;
|
|
|
- }),
|
|
|
- };
|
|
|
- result.prepareGoal = result.prepareGoal || 650;
|
|
|
- result.prepareScoreTime = result.prepareScoreTime ? moment(result.prepareScoreTime) : null;
|
|
|
- this.setState({ data: result, stat, first: !result.prepareStatus, step: !result.prepareStatus ? 0 : 4 });
|
|
|
+ My.getPrepare()
|
|
|
+ .then(result => {
|
|
|
+ const statusTotal = result.stat.status.reduce((p, n) => { return p + n.value; }, 0);
|
|
|
+ const goalTotal = result.stat.goal.reduce((p, n) => { return p + n.value; }, 0);
|
|
|
+ const examinationTimeTotal = result.stat.examinationTime.reduce((p, n) => { return p + n.value; }, 0);
|
|
|
+ const scoreTimeTotal = result.stat.scoreTime.reduce((p, n) => { return p + n.value; }, 0);
|
|
|
+ const stat = {
|
|
|
+ status: result.stat.status.map((row, index) => {
|
|
|
+ row.value = formatPercent(row.value, statusTotal);
|
|
|
+ row.label = `${PrepareStatusMap[row.key]}; ${row.value}%`;
|
|
|
+ row.color = this.statusColors[index];
|
|
|
+ return row;
|
|
|
+ }),
|
|
|
+ goal: result.stat.goal.map((row, index) => {
|
|
|
+ row.value = formatPercent(row.value, goalTotal);
|
|
|
+ row.label = `${row.key}+; ${row.value}%`;
|
|
|
+ row.color = this.goalColors[index];
|
|
|
+ return row;
|
|
|
+ }),
|
|
|
+ examinationTime: result.stat.status.map((row, index) => {
|
|
|
+ row.value = formatPercent(row.value, examinationTimeTotal);
|
|
|
+ row.label = `${PrepareExaminationTimeMap[row.key]}; ${row.value}%`;
|
|
|
+ row.color = this.examinationTimeColors[index];
|
|
|
+ return row;
|
|
|
+ }),
|
|
|
+ scoreTime: result.stat.scoreTime.map((row, index) => {
|
|
|
+ row.value = formatPercent(row.value, scoreTimeTotal);
|
|
|
+ row.label = `${PrepareScoreTimeMap[row.key]}; ${row.value}%`;
|
|
|
+ row.color = this.scoreTimeColors[index];
|
|
|
+ return row;
|
|
|
+ }),
|
|
|
+ };
|
|
|
+ result.prepareGoal = result.prepareGoal || 650;
|
|
|
+ result.prepareScoreTime = result.prepareScoreTime ? moment(result.prepareScoreTime) : null;
|
|
|
+ this.setState({ data: result, stat, first: !result.prepareStatus, step: !result.prepareStatus ? 0 : 4 });
|
|
|
+ });
|
|
|
+ Main.getContract('register').then(() => {
|
|
|
+ this.setState({ link: { url: 'www', title: '了解出分时间信息>' } });
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -118,16 +115,22 @@ export default class extends Component {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ onClose() {
|
|
|
+ const { onClose } = this.props;
|
|
|
+ if (onClose) onClose();
|
|
|
+ this.setState({ step: 0 });
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
const { step } = this.state;
|
|
|
- const { show, onClose } = this.props;
|
|
|
+ const { show } = this.props;
|
|
|
return (
|
|
|
<Modal
|
|
|
className="examination-modal"
|
|
|
show={show}
|
|
|
width={460}
|
|
|
{...this.stepProp[step]}
|
|
|
- onClose={() => onClose && onClose()}
|
|
|
+ onClose={() => this.onClose()}
|
|
|
>
|
|
|
<div className="examination-modal-wrapper">{this[`renderStep${step}`]()}</div>
|
|
|
</Modal>
|
|
@@ -208,11 +211,13 @@ export default class extends Component {
|
|
|
}
|
|
|
|
|
|
renderStep3() {
|
|
|
- const { data } = this.state;
|
|
|
+ const { data, link, step } = this.state;
|
|
|
const { prepareScoreTime } = data;
|
|
|
return (
|
|
|
<div className="step-3-layout">
|
|
|
+ {link && <a href={link.url} className="a-l" target='_blank'>{link.title}</a>}
|
|
|
<Date
|
|
|
+ show={step === 3}
|
|
|
theme="filled"
|
|
|
value={prepareScoreTime}
|
|
|
onChange={date => {
|