|
@@ -12,11 +12,13 @@ import Select from '../../../components/Select';
|
|
|
import menu from '../index';
|
|
|
import Tabs from '../../../components/Tabs';
|
|
|
import { My } from '../../../stores/my';
|
|
|
-import { QuestionDifficult } from '../../../../Constant';
|
|
|
-import { getMap, formatPercent, formatSeconds } from '../../../../../src/services/Tools';
|
|
|
+import { QuestionDifficult, QuestionType, TimeRange, TextbookMinYear, CourseModule } from '../../../../Constant';
|
|
|
+import { getMap, formatPercent, formatSeconds, timeRange, formatTreeData } from '../../../../../src/services/Tools';
|
|
|
+import { Main } from '../../../stores/main';
|
|
|
|
|
|
const QuestionDifficultMap = getMap(QuestionDifficult, 'value', 'label');
|
|
|
-console.log(QuestionDifficultMap);
|
|
|
+const QuestionTypeMap = getMap(QuestionType, 'value', 'label');
|
|
|
+
|
|
|
const columns = [
|
|
|
{
|
|
|
key: 'title',
|
|
@@ -298,39 +300,195 @@ export default class extends Page {
|
|
|
filterMap: {},
|
|
|
selectList: [],
|
|
|
tab: 'exercise',
|
|
|
+ subject: 'verbal',
|
|
|
questionType: '',
|
|
|
+ timerange: 'today',
|
|
|
info: 'base',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
initData() {
|
|
|
const data = Object.assign(this.state, this.state.search);
|
|
|
+ data.filterMap = this.state;
|
|
|
if (data.order) {
|
|
|
data.sortMap = { [data.order]: data.direction };
|
|
|
}
|
|
|
- data.filterMap = this.state.search;
|
|
|
- const startTime = null;
|
|
|
- const endTime = null;
|
|
|
- switch (data.timerange) {
|
|
|
- case 'all':
|
|
|
- break;
|
|
|
- case 'week':
|
|
|
- break;
|
|
|
- case 'month':
|
|
|
- break;
|
|
|
- case 'month3':
|
|
|
- break;
|
|
|
- case 'today':
|
|
|
+ const [startTime, endTime] = timeRange(data.timerange);
|
|
|
+ this.refreshQuestionType(data.subject, { needSentence: false, allSubject: false })
|
|
|
+ .then(() => {
|
|
|
+ return this.refreshStruct(data.tab, data.one, data.two, { needPreview: false, needTextbook: false });
|
|
|
+ })
|
|
|
+ .then(({ structIds }) => {
|
|
|
+ My.getData(data.tab, data.subject, structIds, startTime, endTime).then(result => {
|
|
|
+ this.data = result;
|
|
|
+ this.setState({
|
|
|
+ list: Object.values(result).map(row => {
|
|
|
+ row.title = QuestionTypeMap[row.questionType];
|
|
|
+ return row;
|
|
|
+ }),
|
|
|
+ });
|
|
|
+ this.onQuestionTypeChange(Object.keys(result)[0]);
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ refreshQuestionType(subject, { needSentence, allSubject }) {
|
|
|
+ return Main.getExercise().then(result => {
|
|
|
+ const list = result.filter(row => (needSentence ? true : row.isExamination)).map(row => {
|
|
|
+ row.title = `${row.titleZh}${row.titleEn}`;
|
|
|
+ row.key = row.extend;
|
|
|
+ return row;
|
|
|
+ });
|
|
|
+ const tree = formatTreeData(list, 'id', 'title', 'parentId');
|
|
|
+ this.questionSubjectMap = getMap(tree, 'key', 'children');
|
|
|
+ this.questionSubjectSelect = tree.filter(row => row.level === 1 && (allSubject ? true : row.children.length > 1));
|
|
|
+ this.setState({
|
|
|
+ questionSubjectSelect: this.questionSubjectSelect,
|
|
|
+ questionSubjectMap: this.questionSubjectMap,
|
|
|
+ });
|
|
|
+ return {
|
|
|
+ questionTypes: subject ? this.questionSubjectMap[subject].map(row => row.key) : null,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ refreshStruct(module, one, two, { needTextbook, needPreview }) {
|
|
|
+ switch (module) {
|
|
|
+ case 'exercise':
|
|
|
+ return Main.getExerciseAll().then(result => {
|
|
|
+ const tmp = result.filter(row => row.level > 2).map(row => {
|
|
|
+ row.title = `${row.titleZh}`;
|
|
|
+ row.key = row.titleEn;
|
|
|
+ return row;
|
|
|
+ });
|
|
|
+ const idsMap = getMap(tmp, 'id', 'key');
|
|
|
+ const map = {};
|
|
|
+ tmp.forEach(row => {
|
|
|
+ if (!map[row.key]) {
|
|
|
+ map[row.key] = {
|
|
|
+ title: row.title,
|
|
|
+ key: row.key,
|
|
|
+ structIds: [],
|
|
|
+ parentId: row.level > 3 ? idsMap[row.parentId] : null,
|
|
|
+ subject: [],
|
|
|
+ questionType: [],
|
|
|
+ };
|
|
|
+ }
|
|
|
+ const item = map[row.key];
|
|
|
+ item.structIds.push(row.id);
|
|
|
+ if (item.subject.indexOf(row.subject) < 0) {
|
|
|
+ item.subject.push(row.subject);
|
|
|
+ }
|
|
|
+ if (item.questionType.indexOf(row.questionType) < 0) {
|
|
|
+ item.questionType.push(row.questionType);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const list = Object.values(map);
|
|
|
+ if (needPreview) {
|
|
|
+ list.push({
|
|
|
+ title: '预习作业',
|
|
|
+ key: 'preview',
|
|
|
+ id: 'preview',
|
|
|
+ });
|
|
|
+ CourseModule.forEach(row => {
|
|
|
+ list.push({
|
|
|
+ title: row.label,
|
|
|
+ key: row.value,
|
|
|
+ parentId: 'preview',
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ let courseModules = null;
|
|
|
+ let structIds = null;
|
|
|
+ if (one === 'preview') {
|
|
|
+ if (!two) {
|
|
|
+ courseModules = CourseModule.map(row => row.value);
|
|
|
+ } else {
|
|
|
+ courseModules = [two];
|
|
|
+ }
|
|
|
+ } else if (one) {
|
|
|
+ const resultMap = getMap(list, 'key', 'structIds');
|
|
|
+ if (!two) {
|
|
|
+ structIds = resultMap[one];
|
|
|
+ } else {
|
|
|
+ structIds = resultMap[two];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const tree = formatTreeData(list, 'key', 'title', 'parentId');
|
|
|
+ const oneSelect = tree;
|
|
|
+ const twoSelectMap = getMap(tree, 'key', 'children');
|
|
|
+ this.setState({ oneSelect, twoSelectMap });
|
|
|
+
|
|
|
+ return {
|
|
|
+ structIds,
|
|
|
+ courseModules,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ case 'examination':
|
|
|
+ return Main.getExamination().then(result => {
|
|
|
+ const list = result.map(row => {
|
|
|
+ row.title = `${row.titleZh}${row.titleEn}`;
|
|
|
+ row.key = `${row.id}`;
|
|
|
+ return row;
|
|
|
+ });
|
|
|
+ if (needTextbook) {
|
|
|
+ list.push({
|
|
|
+ title: '数学机经',
|
|
|
+ key: 'textbook',
|
|
|
+ id: 'textbook',
|
|
|
+ });
|
|
|
+ list.push({
|
|
|
+ title: '最新',
|
|
|
+ key: 'latest',
|
|
|
+ parentId: 'textbook',
|
|
|
+ });
|
|
|
+
|
|
|
+ const nowYear = new Date().getFullYear();
|
|
|
+ for (let i = TextbookMinYear; i <= nowYear; i += 1) {
|
|
|
+ list.push({
|
|
|
+ title: i.toString(),
|
|
|
+ key: i.toString(),
|
|
|
+ parentId: 'textbook',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let latest = null;
|
|
|
+ let year = null;
|
|
|
+ let structIds = null;
|
|
|
+ if (one === 'textbook') {
|
|
|
+ if (!two) {
|
|
|
+ latest = true;
|
|
|
+ } else if (two === 'latest') {
|
|
|
+ latest = true;
|
|
|
+ } else {
|
|
|
+ year = two;
|
|
|
+ }
|
|
|
+ } else if (one) {
|
|
|
+ if (!two) {
|
|
|
+ structIds = [Number(one)];
|
|
|
+ } else {
|
|
|
+ structIds = [Number(two)];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const tree = formatTreeData(list, 'key', 'title', 'parentId');
|
|
|
+ const oneSelect = tree;
|
|
|
+ const twoSelectMap = getMap(tree, 'key', 'children');
|
|
|
+
|
|
|
+ this.setState({ oneSelect, twoSelectMap });
|
|
|
+ return {
|
|
|
+ structIds,
|
|
|
+ latest,
|
|
|
+ year,
|
|
|
+ };
|
|
|
+ });
|
|
|
default:
|
|
|
+ return Promise.resolve({});
|
|
|
}
|
|
|
- My.getData(data.tab, data.subject, '', startTime, endTime).then(result => {
|
|
|
- console.log(result);
|
|
|
- this.data = result;
|
|
|
- this.setState({ list: Object.values(result) });
|
|
|
- this.onQuestionTypeChange();
|
|
|
- });
|
|
|
}
|
|
|
|
|
|
+
|
|
|
onTabChange(tab) {
|
|
|
const data = { tab };
|
|
|
this.refreshQuery(data);
|
|
@@ -361,7 +519,7 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
renderTable() {
|
|
|
- const { tab, questionType, info, questionTypeSelect, filterMap = {}, list = [] } = this.state;
|
|
|
+ const { tab, subject, questionType, info, questionSubjectSelect, questionSubjectMap = {}, oneSelect, twoSelectMap = {}, filterMap = {}, list = [] } = this.state;
|
|
|
return (
|
|
|
<div className="table-layout">
|
|
|
<Tabs
|
|
@@ -376,24 +534,31 @@ export default class extends Page {
|
|
|
onChange={key => this.onTabChange(key)}
|
|
|
/>
|
|
|
<UserAction
|
|
|
- selectList={[{
|
|
|
- children: [
|
|
|
- {
|
|
|
- key: 'one',
|
|
|
- select: [{ title: '123', key: '1' }, { title: '123', key: '2' }, { title: '123', key: '2' }],
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'two',
|
|
|
- be: 'one',
|
|
|
- placeholder: '全部',
|
|
|
- selectMap: [{ title: '123', key: '1' }, { title: '123', key: '2' }, { title: '123', key: '2' }],
|
|
|
- },
|
|
|
- ],
|
|
|
- }, {
|
|
|
- right: true,
|
|
|
- key: 'timerange',
|
|
|
- select: [{ title: '今天', key: 'today' }, { title: '近一周', key: 'week' }, { title: '近一个月', key: 'month' }, { title: '近三个月', key: 'month3' }, { title: '全部', key: 'all' }],
|
|
|
- }]}
|
|
|
+ selectList={[
|
|
|
+ {
|
|
|
+ key: 'subject',
|
|
|
+ select: questionSubjectSelect,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '范围',
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ key: 'one',
|
|
|
+ placeholder: '全部',
|
|
|
+ select: oneSelect,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'two',
|
|
|
+ be: 'one',
|
|
|
+ placeholder: '全部',
|
|
|
+ selectMap: twoSelectMap,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ }, {
|
|
|
+ right: true,
|
|
|
+ key: 'timerange',
|
|
|
+ select: TimeRange,
|
|
|
+ }]}
|
|
|
filterMap={filterMap}
|
|
|
onFilter={value => this.onFilter(value)}
|
|
|
/>
|
|
@@ -405,7 +570,7 @@ export default class extends Page {
|
|
|
size="small"
|
|
|
theme="default"
|
|
|
value={questionType}
|
|
|
- list={questionTypeSelect}
|
|
|
+ list={questionSubjectMap[subject]}
|
|
|
onChange={({ key }) => this.onQuestionTypeChange(key)}
|
|
|
/>
|
|
|
</div>
|
|
@@ -473,22 +638,31 @@ export default class extends Page {
|
|
|
<div className="tab-2-layout">
|
|
|
<BarChart
|
|
|
height={350}
|
|
|
- option={barOption2(`平均正确率${formatPercent(data.userCorrect, data.userNumber, false)}`, '正确率', [['easy', 10], ['Medium', 30], ['Hard', 40]])}
|
|
|
+ option={barOption2(`平均正确率${formatPercent(data.userCorrect, data.userNumber, false)}`, '正确率', data.difficult.map(row => {
|
|
|
+ return [QuestionDifficultMap[row.key], formatPercent(row.userCorrect, row.userNumber)];
|
|
|
+ }))}
|
|
|
/>
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
renderTabplace() {
|
|
|
+ const { data = {} } = this.state;
|
|
|
return (
|
|
|
<div className="tab-3-layout">
|
|
|
<BarChart
|
|
|
height={350}
|
|
|
option={barOption3(
|
|
|
['知识点', '正确率分析', '用时分析'],
|
|
|
- ['Idiom', 'Comparison', 'Verb', 'Pronoun', 'Modifier', 'Parallelism'],
|
|
|
- [10, 12, 12, 13, 14, 15],
|
|
|
- [10, 12, 12, 13, 14, 15],
|
|
|
+ data.place.map(row => {
|
|
|
+ return row.key;
|
|
|
+ }),
|
|
|
+ data.place.map(row => {
|
|
|
+ return formatPercent(row.userCorrect, row.userNumber);
|
|
|
+ }),
|
|
|
+ data.place.map(row => {
|
|
|
+ return row.userTime / row.userNumber;
|
|
|
+ }),
|
|
|
['#92AFD2', '#BFD4EE'],
|
|
|
['#989FC1', '#CCCCDC'],
|
|
|
)}
|