import React from 'react';
import { Link } from 'react-router-dom';
import './index.less';
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 UserPagination from '../../../components/UserPagination';
import menu, { refreshQuestionType, refreshStruct } from '../index';
import Tabs from '../../../components/Tabs';
import { TimeRange } from '../../../../Constant';
import { My } from '../../../stores/my';
const columns = [
{
key: 'title',
title: '笔记对象',
width: 140,
render(text, row) {
return row.group ? (
{text}
) : (
{text}
);
},
},
{
key: 'date',
title: '更新时间',
width: 100,
render(text, row) {
return row.group ? (
{text}
) : (
{text.split(' ')[0]}
{text.split(' ')[1]}
);
},
},
{
key: 'content',
title: '内容',
width: 540,
render(text, row) {
return row.group ? (
{text}
) : (
{text}
);
},
},
];
export default class extends Page {
constructor(props) {
props.size = 10;
super(props);
}
initState() {
return {
filterMap: {},
sortMap: {},
data: [
{
group: true,
title: '语法',
date: ' OG18 #678',
content: '「图形」None of the attempts to specify the causes of crime explains why most of the p',
list: [
{
title: '题目',
date: '2019-07-23 15:20:21',
content:
'从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,',
},
{
title: '官方解析',
date: '2019-07-23 15:20:21',
content:
'从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,',
},
],
},
{
group: true,
title: '语法',
date: ' OG18 #678',
content: '「图形」None of the attempts to specify the causes of crime explains why most of the p',
list: [
{
title: '题目',
date: '2019-07-23 15:20:21',
content:
'从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,',
},
{
title: '官方解析',
date: '2019-07-23 15:20:21',
content:
'从比较对象和句子结构我们能把DE排除掉,D选项中fat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题,',
},
],
},
],
selectList: [],
allChecked: false,
tab: 'exercise',
timerange: 'today',
};
}
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;
}
const [startTime, endTime] = timeRange(data.timerange);
refreshQuestionType(this, data.subject, data.questionType, { all: true, needSentence: false, allSubject: true })
.then(({ questionTypes }) => {
return refreshStruct(this, data.tab, data.one, data.two, {
all: true, needPreview: false, needTextbook: false,
})
.then(({ structIds, latest, year }) => {
My.listQuestionNote(Object.assign({ module: data.tab, questionTypes, structIds, latest, year, startTime, endTime }, this.state.search, {
order: Object.keys(data.sortMap).map(key => {
return `${key} ${data.sortMap[key]}`;
}).join(','),
})).then(result => {
this.setState({ list: result.list, total: result.total, page: data.page });
});
});
});
}
onTabChange(tab) {
const data = { tab };
this.refreshQuery(data);
}
onFilter(value) {
this.search(value);
}
onSort(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 });
}
onChangePage(page) {
this.search({ page });
}
onAll(checked) {
if (checked) {
const { data = [] } = this.state;
const list = [];
data.forEach(item => {
list.push(item.key);
});
this.setState({ selectList: list, allChecked: true });
} else {
this.setState({ selectList: [], allChecked: false });
}
}
onAction() { }
onSelect(selectList) {
this.setState({ selectList });
}
renderView() {
const { config } = this.props;
return ;
}
renderTable() {
const { tab, questionSubjectSelect, questionSubjectMap = {}, oneSelect, twoSelectMap = {}, filterMap = {}, sortMap = {}, list = [] } = this.state;
const { selectList = [], allChecked, page, total } = this.state;
return (
this.onTabChange(key)}
/>
this.onFilter(value)}
/>
this.onSort(value)}
onAll={checked => this.onAll(checked)}
onAction={key => this.onAction(key)}
/>
{list.map((item, index) => {
return (
);
})}
{total && list.length > 0 && this.onChangePage(p)} />}
);
}
}