import React, { Component } from 'react'; import { Link } from 'react-router-dom'; import './index.less'; import { Icon } from 'antd'; import Page from '@src/containers/Page'; import { formatDate, getMap } from '@src/services/Tools'; import Modal from '../../../components/Modal'; import UserAction from '../../../components/UserAction'; import UserPagination from '../../../components/UserPagination'; import { RealAuth } from '../../../components/OtherModal'; import Examination from '../../../components/Examination'; import VipRenew from '../../../components/VipRenew'; import CheckboxItem from '../../../components/CheckboxItem'; import { Course } from '../../../stores/course'; import { My } from '../../../stores/my'; export default class extends Page { initState() { return { filterMap: {}, sortMap: {}, // list: [ // { // title: '比较对象对等问题', // content: // '从比较对象和句子结构我们能把DE排除掉,D选项中dffat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题?从比较对象和句子结构我们能把DE排除掉,D选项中fat和livest。ock不是比较对象,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不是比较对象.', // }, // { // title: '比较对象对等问题', // content: // '从比较对象和句子结构我们能把DE排除掉,D选项中dffat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题?从比较对象和句子结构我们能把DE排除掉,D选项中fat和livest。ock不是比较对象,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不是比较对象.', // }, // { // title: '比较对象对等问题', // content: // '从比较对象和句子结构我们能把DE排除掉,D选项中dffat和livestock不是比较对象,E选项中and 后面的句子太凌乱is of a kind ….is…结构出现了重大问题?从比较对象和句子结构我们能把DE排除掉,D选项中fat和livest。ock不是比较对象,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不是比较对象.', // }, // ], selectList: [], allChecked: false, showDetail: false, }; } init() { const { id } = this.params; Course.get(id) .then(result => { const courseNoMap = getMap(result.courseNos, 'id'); this.setState({ course: result, courseNoMap }); }); } initData() { const { id } = this.params; 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); My.listCourseNote(Object.assign({ courseId: id }, this.state.search)) .then(result => { result.list = result.list.map(row => { row.key = row.courseNoId; return row; }); this.setState({ list: result.list, total: result.total }); }); } onFilter(value) { this.search(value, false); this.initData(); } onSearch(value) { this.search({ page: 1, keyword: value }, false); this.initData(); } 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 && value[keys[index]] ? keys[index] : null, direction: keys.length ? value[keys[index]] : null }, false); } onChangePage(page) { this.search({ page }, false); this.initData(); } onAll(checked) { const { selectList } = this.state; const { list = [] } = this.state; if (checked) { list.forEach(item => { if (selectList.indexOf(item.key) >= 0) return; selectList.push(item.key); }); } else { list.forEach(item => { const index = selectList.indexOf(item.key); if (index < 0) return; selectList.splice(index, 1); }); } this.setState({ selectList, allChecked: checked }); } onSelect(selectList) { this.setState({ selectList, allCheckbox: false }); } onAction(key) { const { info } = this.props.user; const { selectList } = this.state; switch (key) { case 'help': this.setState({ showTips: true }); return; case 'clear': if (selectList.length === 0) { this.setState({ showWarn: true, warn: { title: '移除', content: '不可少于1篇,请重新选择' } }); return; } this.setState({ showClearConfirm: true, clearInfo: { courseNoIds: selectList } }); break; case 'export': if (!info.vip) { this.setState({ showVip: true }); return; } if (selectList.length < 1) { this.setState({ showWarn: true, warn: { title: '导出', content: '不可小于1篇,请重新选择' } }); return; } this.setState({ showExportConfirm: true, exportInfo: { courseNoIds: selectList } }); break; default: } } clearNote() { const { exportInfo } = this.state; My.clearCourseNote(exportInfo.courseNoIds) .then(() => { this.refresh(); }) .then(e => { this.setState({ warn: { title: '移除', content: e.message }, showClearConfirm: false }); }); } export() { const { exportInfo } = this.state; this.setState({ showExportWait: true, showExportConfirm: false, showExportAuthConfirm: false }); My.exportNoteCourse(exportInfo) .then((result) => { openLink(`/export/${result}`); this.setState({ showExportWait: false }); }) .catch(e => { this.setState({ warn: { title: '导出', content: e.message }, showExportWait: false }); }); } prevArticle() { const { article, list } = this.state; let index = 0; list.forEach((row, i) => { if (article.key === row.key) index = i; }); index -= 1; if (index < 0) { index = list.length + index; } this.setState({ article: list[index] }); } nextArticle() { const { article, list } = this.state; let index = 0; list.forEach((row, i) => { if (article.key === row.key) index = i; }); index += 1; if (index >= list.length) { index -= list.length; } this.setState({ article: list[index] }); } renderView() { const { course = {}, courseNoMap = {}, list = [], selectList = [], sortMap, filterMap, allChecked, total, page } = this.state; const { user: { info }, } = this.props; return (