|
@@ -2,22 +2,25 @@ import React, { Component } from 'react';
|
|
|
import './index.less';
|
|
|
import { Icon, Checkbox } from 'antd';
|
|
|
import Page from '@src/containers/Page';
|
|
|
+import { timeRange } from '@src/services/Tools';
|
|
|
import UserLayout from '../../../layouts/User';
|
|
|
import UserTable from '../../../components/UserTable';
|
|
|
import UserAction from '../../../components/UserAction';
|
|
|
-import menu from '../index';
|
|
|
+import menu, { refreshQuestionType, refreshStruct } from '../index';
|
|
|
import Tabs from '../../../components/Tabs';
|
|
|
import Modal from '../../../components/Modal';
|
|
|
import Select from '../../../components/Select';
|
|
|
import GIcon from '../../../components/Icon';
|
|
|
+import { TimeRange } from '../../../../Constant';
|
|
|
+import { My } from '../../../stores/my';
|
|
|
|
|
|
const columns = [
|
|
|
- { key: '', title: '题型', fixSort: true },
|
|
|
- { key: '', title: '题目ID', fixSort: true },
|
|
|
- { key: '', title: '内容' },
|
|
|
- { key: '', title: '耗时', sort: true },
|
|
|
- { key: '', title: '错误率', sort: true },
|
|
|
- { key: '', title: '最近做题' },
|
|
|
+ { key: 'question_type', title: '题型', fixSort: true },
|
|
|
+ { key: 'title', title: '题目ID', fixSort: true },
|
|
|
+ { key: 'description', title: '内容' },
|
|
|
+ { key: 'time', title: '耗时', sort: true },
|
|
|
+ { key: 'correct', title: '错误率', sort: true },
|
|
|
+ { key: 'latest_time', title: '最近做题' },
|
|
|
{
|
|
|
key: '',
|
|
|
title: '',
|
|
@@ -37,34 +40,89 @@ const exportType = [
|
|
|
];
|
|
|
|
|
|
export default class extends Page {
|
|
|
+ constructor(props) {
|
|
|
+ props.size = 10;
|
|
|
+ super(props);
|
|
|
+ }
|
|
|
+
|
|
|
initState() {
|
|
|
return {
|
|
|
- tab: '1',
|
|
|
+ tab: 'question',
|
|
|
+ timerange: 'today',
|
|
|
filterMap: {},
|
|
|
sortMap: {},
|
|
|
data: [{}, {}],
|
|
|
selectList: [],
|
|
|
allChecked: false,
|
|
|
- page: 1,
|
|
|
- total: 1,
|
|
|
showDetail: false,
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- onChangeTab(tab) {
|
|
|
- this.setState({ tab });
|
|
|
+ initData() {
|
|
|
+ const data = Object.assign(this.state, this.state.search);
|
|
|
+ data.filterMap = this.state.search;
|
|
|
+ if (data.order) {
|
|
|
+ data.sortMap = { [data.order]: data.direction };
|
|
|
+ }
|
|
|
+ if (data.timerange) {
|
|
|
+ data.filterMap.timerange = data.timerange;
|
|
|
+ }
|
|
|
+ switch (data.tab) {
|
|
|
+ case 'question':
|
|
|
+ return this.refreshQuestion(data);
|
|
|
+ case 'article':
|
|
|
+ return this.refreshArticle(data);
|
|
|
+ default:
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ refreshQuestion(data) {
|
|
|
+ const [startTime, endTime] = timeRange(data.timerange);
|
|
|
+ refreshQuestionType(this, data.subject, data.questionType, { all: true, needSentence: true, allSubject: true })
|
|
|
+ .then(({ questionTypes }) => {
|
|
|
+ return refreshStruct(this, data.tab, data.one, data.two, {
|
|
|
+ all: true, needPreview: false, needTextbook: true,
|
|
|
+ })
|
|
|
+ .then(({ structIds, latest, year }) => {
|
|
|
+ My.listQuestionCollect(Object.assign({ module: data.tab, questionTypes, structIds, latest, year, startTime, endTime }, this.state.search, {
|
|
|
+ order: Object.keys(data.sortMap).map(key => {
|
|
|
+ if (key === 'title') return 'pid desc, no desc';
|
|
|
+ return `${key} ${data.sortMap[key]}`;
|
|
|
+ }).join(','),
|
|
|
+ })).then(result => {
|
|
|
+ this.setState({ list: result.list, total: result.total });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ refreshArticle(data) {
|
|
|
+ const [startTime, endTime] = timeRange(data.timerange);
|
|
|
+ My.listExperienceCollect(Object.assign({ startTime, endTime }, this.state.search)).then(result => {
|
|
|
+ this.setState({ list: result.list, total: result.total });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ onTabChange(tab) {
|
|
|
+ const data = { tab };
|
|
|
+ this.refreshQuery(data);
|
|
|
}
|
|
|
|
|
|
onFilter(value) {
|
|
|
- this.setState({ filterMap: value });
|
|
|
+ this.search(value);
|
|
|
}
|
|
|
|
|
|
onSort(value) {
|
|
|
- this.setState({ sortMap: value });
|
|
|
+ const keys = Object.keys(value);
|
|
|
+ // this.search({ order: keys.length ? keys.join('|') : null, direction: keys.length ? Object.values(value).join('|') : null });
|
|
|
+ const { sortMap } = this.state;
|
|
|
+ const index = keys.length > 1 && sortMap[keys[0]] ? 1 : 0;
|
|
|
+ this.search({ order: keys.length ? keys[index] : null, direction: keys.length ? value[keys[index]] : null });
|
|
|
}
|
|
|
|
|
|
- onDataChange(page) {
|
|
|
- this.setState({ page, allChecked: false, selectList: [] });
|
|
|
+ onChangePage(page) {
|
|
|
+ this.search({ page });
|
|
|
}
|
|
|
|
|
|
onAll(checked) {
|
|
@@ -80,7 +138,7 @@ export default class extends Page {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- onAction() {}
|
|
|
+ onAction() { }
|
|
|
|
|
|
onSelect(selectList) {
|
|
|
this.setState({ selectList });
|
|
@@ -103,7 +161,7 @@ export default class extends Page {
|
|
|
space={2.5}
|
|
|
width={100}
|
|
|
active={tab}
|
|
|
- tabs={[{ key: '1', title: '题目' }, { key: '2', title: '文章' }]}
|
|
|
+ tabs={[{ key: 'question', title: '题目' }, { key: 'article', title: '文章' }]}
|
|
|
onChange={key => this.onChangeTab(key)}
|
|
|
/>
|
|
|
{this[`renderTab${tab}`]()}
|
|
@@ -112,40 +170,41 @@ export default class extends Page {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- renderTab1() {
|
|
|
- const { filterMap = {}, sortMap = {}, selectList = [], data = [], allChecked, page, total } = this.state;
|
|
|
+ renderTabquestion() {
|
|
|
+ const { questionSubjectSelect, questionSubjectMap = {}, oneSelect, twoSelectMap = {}, filterMap = {}, sortMap = {}, list = [] } = this.state;
|
|
|
+ const { selectList = [], allChecked, page, total } = this.state;
|
|
|
return (
|
|
|
<div className="tab-1-layout">
|
|
|
<UserAction
|
|
|
- selectList={[
|
|
|
- {
|
|
|
- children: [
|
|
|
- {
|
|
|
- key: '3',
|
|
|
- default: '1',
|
|
|
- select: [{ title: '123', key: '1' }, { title: '123', key: '2' }, { title: '123', key: '2' }],
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'two',
|
|
|
- be: 'one',
|
|
|
- placeholder: '全部',
|
|
|
- selectMap: {
|
|
|
- 1: [{ title: '123', key: '1' }, { title: '123', key: '2' }, { title: '123', key: '2' }],
|
|
|
- },
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- label: '123',
|
|
|
+ search
|
|
|
+ selectList={[{
|
|
|
+ children: [{
|
|
|
+ key: 'subject',
|
|
|
+ placeholder: '学科',
|
|
|
+ select: questionSubjectSelect,
|
|
|
+ }, {
|
|
|
+ placeholder: '题型',
|
|
|
+ key: 'questionType',
|
|
|
+ be: 'subject',
|
|
|
+ selectMap: questionSubjectMap,
|
|
|
+ }],
|
|
|
+ }, {
|
|
|
+ label: '范围',
|
|
|
+ children: [{
|
|
|
key: 'one',
|
|
|
- select: [{ title: '123', key: '1' }, { title: '123', key: '2' }, { title: '123', key: '2' }],
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'th',
|
|
|
- right: true,
|
|
|
- select: [{ title: '123', key: '1' }, { title: '123', key: '2' }, { title: '123', key: '2' }],
|
|
|
- },
|
|
|
- ]}
|
|
|
+ placeholder: '全部',
|
|
|
+ select: oneSelect,
|
|
|
+ }, {
|
|
|
+ key: 'two',
|
|
|
+ be: 'one',
|
|
|
+ placeholder: '全部',
|
|
|
+ selectMap: twoSelectMap,
|
|
|
+ }],
|
|
|
+ }, {
|
|
|
+ right: true,
|
|
|
+ key: 'timerange',
|
|
|
+ select: TimeRange,
|
|
|
+ }]}
|
|
|
filterMap={filterMap}
|
|
|
onFilter={value => this.onFilter(value)}
|
|
|
/>
|
|
@@ -170,19 +229,19 @@ export default class extends Page {
|
|
|
select
|
|
|
columns={columns}
|
|
|
sortMap={sortMap}
|
|
|
- data={data}
|
|
|
+ data={list}
|
|
|
current={page}
|
|
|
total={total}
|
|
|
selectList={selectList}
|
|
|
onSelect={l => this.onSelect(l)}
|
|
|
onSort={v => this.onSort(v)}
|
|
|
- onChange={p => this.onDataChange(p)}
|
|
|
+ onChange={p => this.onChangePage(p)}
|
|
|
/>
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- renderTab2() {
|
|
|
+ renderTabarticle() {
|
|
|
const { filterMap = {}, sortMap = {} } = this.state;
|
|
|
return (
|
|
|
<div className="tab-1-layout">
|
|
@@ -219,7 +278,7 @@ export default class extends Page {
|
|
|
renderModal() {
|
|
|
return [
|
|
|
<ArticleDetail show={this.state.showDetail} onClose={() => this.setState({ showDetail: false })} />,
|
|
|
- <Modal title="操作提示" confirmText="好的,知道了" btnAlign="center" onConfirm={() => {}}>
|
|
|
+ <Modal title="操作提示" confirmText="好的,知道了" btnAlign="center" onConfirm={() => { }}>
|
|
|
<div className="flex-layout m-b-2">
|
|
|
<div className="flex-block">
|
|
|
<div className="t-1 t-s-18">组卷功能</div>
|
|
@@ -239,10 +298,10 @@ export default class extends Page {
|
|
|
查阅以上信息。
|
|
|
</div>
|
|
|
</Modal>,
|
|
|
- <Modal title="组卷练习" confirmText="好的,知道了" btnAlign="center" onConfirm={() => {}}>
|
|
|
+ <Modal title="组卷练习" confirmText="好的,知道了" btnAlign="center" onConfirm={() => { }}>
|
|
|
<div className="t-2 t-s-18">不可同时选中语文题和数学题,请重新选择。</div>
|
|
|
</Modal>,
|
|
|
- <Modal title="组卷练习" confirmText="开始练习" onConfirm={() => {}} onCancel={() => {}}>
|
|
|
+ <Modal title="组卷练习" confirmText="开始练习" onConfirm={() => { }} onCancel={() => { }}>
|
|
|
<div className="t-2 t-s-18">
|
|
|
您共选择了 <span className="t-4">50</span> 道题目,是否开始练习?
|
|
|
</div>
|
|
@@ -256,15 +315,15 @@ export default class extends Page {
|
|
|
次以上的错题
|
|
|
</div>
|
|
|
</Modal>,
|
|
|
- <Modal title="移出" onConfirm={() => {}} onCancel={() => {}}>
|
|
|
+ <Modal title="移出" onConfirm={() => { }} onCancel={() => { }}>
|
|
|
<div className="t-2 t-s-18">
|
|
|
当前选中的 <span className="t-4">50</span> 道题即将被移出错题本,移出后无法恢复,是否继续?
|
|
|
</div>
|
|
|
</Modal>,
|
|
|
- <Modal title="导出" confirmText="好的,知道了" btnAlign="center" onConfirm={() => {}}>
|
|
|
+ <Modal title="导出" confirmText="好的,知道了" btnAlign="center" onConfirm={() => { }}>
|
|
|
<div className="t-2 t-s-18">正在下载中,请不要关闭当前页面!</div>
|
|
|
</Modal>,
|
|
|
- <Modal title="导出" confirmText="导出" onConfirm={() => {}} onCancel={() => {}}>
|
|
|
+ <Modal title="导出" confirmText="导出" onConfirm={() => { }} onCancel={() => { }}>
|
|
|
<div className="t-2 t-s-18 m-b-5">
|
|
|
当前共选中 <span className="t-4">50</span> 道题,请确认需要导出的内容:
|
|
|
</div>
|
|
@@ -279,7 +338,7 @@ export default class extends Page {
|
|
|
})}
|
|
|
</div>
|
|
|
</Modal>,
|
|
|
- <Modal title="导出" confirmText="导出" onConfirm={() => {}} onCancel={() => {}}>
|
|
|
+ <Modal title="导出" confirmText="导出" onConfirm={() => { }} onCancel={() => { }}>
|
|
|
<div className="t-2 t-s-18 m-b-5">
|
|
|
当前共选中 <span className="t-4">50</span> 道题,请确认需要导出的内容:
|
|
|
</div>
|