|
@@ -1,6 +1,6 @@
|
|
|
import React from 'react';
|
|
|
-import { Link } from 'react-router-dom';
|
|
|
-import { Icon } from 'antd';
|
|
|
+// import { Link } from 'react-router-dom';
|
|
|
+import { Icon, Checkbox } from 'antd';
|
|
|
import './index.less';
|
|
|
import Page from '@src/containers/Page';
|
|
|
import { timeRange, getMap, formatDate } from '@src/services/Tools';
|
|
@@ -21,13 +21,22 @@ import { OpenText } from '../../../components/Open';
|
|
|
const QuestionTypeMap = getMap(QuestionType, 'value', 'label');
|
|
|
const AskTargetMap = getMap(AskTarget, 'value', 'label');
|
|
|
|
|
|
+const exportType = [
|
|
|
+ { key: 'question', title: '题目' },
|
|
|
+ { key: 'official', title: '官方解析' },
|
|
|
+ { key: 'note', title: '我的笔记' },
|
|
|
+ // { key: 'qx', title: '千行解析', auth: true },
|
|
|
+ // { key: 'association', title: '题源联想', auth: true },
|
|
|
+ // { key: 'qa', title: '相关问答', auth: true },
|
|
|
+];
|
|
|
+
|
|
|
const questionColumns = [
|
|
|
{
|
|
|
key: 'questionType',
|
|
|
width: 140,
|
|
|
render(text, row) {
|
|
|
return <div className="group">
|
|
|
- <Link to={row.userQuestionId ? `/paper/question/${row.userQuestionId}` : `/question/detail/${row.questionNoId}`}>{QuestionTypeMap[text]}</Link>
|
|
|
+ <a href={row.userQuestionId ? `/paper/question/${row.userQuestionId}` : `/question/detail/${row.questionNoId}`} target="_blank">{QuestionTypeMap[text]}</a>
|
|
|
</div>;
|
|
|
},
|
|
|
},
|
|
@@ -36,15 +45,15 @@ const questionColumns = [
|
|
|
width: 100,
|
|
|
render(text, row) {
|
|
|
return <div className="group">
|
|
|
- <Link to={row.userQuestionId ? `/paper/question/${row.userQuestionId}` : `/question/detail/${row.questionNoId}`}>{text}</Link>
|
|
|
+ <a href={row.userQuestionId ? `/paper/question/${row.userQuestionId}` : `/question/detail/${row.questionNoId}`} target="_blank">{text}</a>
|
|
|
</div>;
|
|
|
},
|
|
|
},
|
|
|
{
|
|
|
key: 'content',
|
|
|
width: 540,
|
|
|
- render(text, row) {
|
|
|
- return <div className="group text-hidden"><Link to={row.userQuestionId ? `/paper/question/${row.userQuestionId}` : `/question/detail/${row.questionNoId}`}>{text}</Link></div>;
|
|
|
+ render(text) {
|
|
|
+ return <div className="group text-hidden t-16" style={{ width: '540px' }}>{text}</div>;
|
|
|
},
|
|
|
},
|
|
|
];
|
|
@@ -53,7 +62,7 @@ const contentColumns = [
|
|
|
{
|
|
|
key: 'title',
|
|
|
title: '笔记对象',
|
|
|
- width: 140,
|
|
|
+ width: 120,
|
|
|
render(text) {
|
|
|
return <div className="sub">{AskTargetMap[text]}</div>;
|
|
|
},
|
|
@@ -61,7 +70,7 @@ const contentColumns = [
|
|
|
{
|
|
|
key: 'updateTime',
|
|
|
title: '更新时间',
|
|
|
- width: 100,
|
|
|
+ width: 105,
|
|
|
render(text) {
|
|
|
return <div className="sub">
|
|
|
<div className="t-2 t-s-12">{text.split(' ')[0]}</div>
|
|
@@ -138,7 +147,7 @@ export default class extends Page {
|
|
|
row.title = row.questionNo.title;
|
|
|
row.content = row.question.description;
|
|
|
row.list = [];
|
|
|
- AskTarget.forEach((r) => {
|
|
|
+ [{ label: '题目', value: 'question', title: '题目', key: 'question' }].forEach((r) => {
|
|
|
if (!row[`${r.value}Content`]) return;
|
|
|
row.list.push({
|
|
|
title: r.value,
|
|
@@ -149,12 +158,28 @@ export default class extends Page {
|
|
|
});
|
|
|
return row;
|
|
|
});
|
|
|
- this.setState({ list: result.list, total: result.total, page: data.page });
|
|
|
+ const { selectList, allChecked, selectPage } = this.updateSelectInfo(data.page, result.list);
|
|
|
+ this.setState({ list: result.list, total: result.total, selectList, allChecked, selectPage });
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ updateSelectInfo(page, list, selectList = null) {
|
|
|
+ const { selectPage = {} } = this.state;
|
|
|
+ let allChecked = false;
|
|
|
+ if (selectList == null) {
|
|
|
+ selectList = [];
|
|
|
+ if (selectPage[Number(page)]) {
|
|
|
+ selectList = selectPage[Number(page)];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ selectPage[Number(page)] = selectList;
|
|
|
+ }
|
|
|
+ allChecked = list.filter(row => selectList.indexOf(row.key) >= 0).length === list.length && list.length > 0;
|
|
|
+ return { selectList, allChecked, selectPage };
|
|
|
+ }
|
|
|
+
|
|
|
onTabChange(tab) {
|
|
|
const data = { tab };
|
|
|
this.refreshQuery(data);
|
|
@@ -176,6 +201,7 @@ export default class extends Page {
|
|
|
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);
|
|
|
+ this.initData();
|
|
|
}
|
|
|
|
|
|
onChangePage(page) {
|
|
@@ -184,67 +210,85 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
onAll(checked) {
|
|
|
- const { selectList, contentSelectList } = this.state;
|
|
|
+ const { selectPage = {}, search = {} } = this.state;
|
|
|
+ let { selectList } = this.state;
|
|
|
+ const { page } = search;
|
|
|
const { list = [] } = this.state;
|
|
|
if (checked) {
|
|
|
list.forEach(item => {
|
|
|
- if (selectList.indexOf(item.key) < 0) {
|
|
|
- selectList.push(item.key);
|
|
|
- }
|
|
|
-
|
|
|
- AskTarget.forEach((r) => {
|
|
|
- if (!item[`${r.value}Content`]) return;
|
|
|
- if (contentSelectList.indexOf(`${item.key}|${r.value}`) < 0) {
|
|
|
- contentSelectList.push(`${item.key}|${r.value}`);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (selectList.indexOf(item.key) >= 0) return;
|
|
|
+ selectList.push(item.key);
|
|
|
});
|
|
|
+ selectPage[Number(page)] = selectList;
|
|
|
} else {
|
|
|
- list.forEach(item => {
|
|
|
- const index = selectList.indexOf(item.key);
|
|
|
- if (index >= 0) {
|
|
|
- selectList.splice(index, 1);
|
|
|
- }
|
|
|
-
|
|
|
- AskTarget.forEach((r) => {
|
|
|
- if (!item[`${r.value}Content`]) return;
|
|
|
- const i = contentSelectList.indexOf(`${item.key}|${r.value}`);
|
|
|
- if (i >= 0) {
|
|
|
- contentSelectList.splice(i, 1);
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+ selectList = [];
|
|
|
+ delete selectPage[Number(page)];
|
|
|
}
|
|
|
- this.setState({ selectList, contentSelectList, allChecked: checked });
|
|
|
+ this.setState({ selectList, selectPage, allChecked: checked });
|
|
|
+ // const { selectList, contentSelectList } = this.state;
|
|
|
+ // const { list = [] } = this.state;
|
|
|
+ // if (checked) {
|
|
|
+ // list.forEach(item => {
|
|
|
+ // if (selectList.indexOf(item.key) < 0) {
|
|
|
+ // selectList.push(item.key);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // AskTarget.forEach((r) => {
|
|
|
+ // if (!item[`${r.value}Content`]) return;
|
|
|
+ // if (contentSelectList.indexOf(`${item.key}|${r.value}`) < 0) {
|
|
|
+ // contentSelectList.push(`${item.key}|${r.value}`);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // list.forEach(item => {
|
|
|
+ // const index = selectList.indexOf(item.key);
|
|
|
+ // if (index >= 0) {
|
|
|
+ // selectList.splice(index, 1);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // AskTarget.forEach((r) => {
|
|
|
+ // if (!item[`${r.value}Content`]) return;
|
|
|
+ // const i = contentSelectList.indexOf(`${item.key}|${r.value}`);
|
|
|
+ // if (i >= 0) {
|
|
|
+ // contentSelectList.splice(i, 1);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // this.setState({ selectList, contentSelectList, allChecked: checked });
|
|
|
}
|
|
|
|
|
|
- onSelect(selectList, key, checked) {
|
|
|
- const { contentSelectList, list = [] } = this.state;
|
|
|
- if (checked) {
|
|
|
- const [item] = list.filter(row => row.key === key);
|
|
|
- if (item) {
|
|
|
- // 选中下面所有
|
|
|
- AskTarget.forEach((r) => {
|
|
|
- if (!item[`${r.value}Content`]) return;
|
|
|
- if (contentSelectList.indexOf(`${item.key}|${r.value}`) < 0) {
|
|
|
- contentSelectList.push(`${item.key}|${r.value}`);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- const [item] = list.filter(row => row.key === key);
|
|
|
- if (item) {
|
|
|
- // 取消下面所有
|
|
|
- AskTarget.forEach((r) => {
|
|
|
- if (!item[`${r.value}Content`]) return;
|
|
|
- const index = contentSelectList.indexOf(`${item.key}|${r.value}`);
|
|
|
- if (index >= 0) {
|
|
|
- contentSelectList.splice(index, 1);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- this.setState({ selectList, contentSelectList, allCheckbox: false });
|
|
|
+ onSelect(slist) {
|
|
|
+ const { search = {}, list } = this.state;
|
|
|
+ const { selectList, allChecked, selectPage } = this.updateSelectInfo(search.page, list, slist);
|
|
|
+ this.setState({ selectList, allChecked, selectPage });
|
|
|
+ // const { contentSelectList, list = [] } = this.state;
|
|
|
+ // if (checked) {
|
|
|
+ // const [item] = list.filter(row => row.key === key);
|
|
|
+ // if (item) {
|
|
|
+ // // 选中下面所有
|
|
|
+ // AskTarget.forEach((r) => {
|
|
|
+ // if (!item[`${r.value}Content`]) return;
|
|
|
+ // if (contentSelectList.indexOf(`${item.key}|${r.value}`) < 0) {
|
|
|
+ // contentSelectList.push(`${item.key}|${r.value}`);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // const [item] = list.filter(row => row.key === key);
|
|
|
+ // if (item) {
|
|
|
+ // // 取消下面所有
|
|
|
+ // AskTarget.forEach((r) => {
|
|
|
+ // if (!item[`${r.value}Content`]) return;
|
|
|
+ // const index = contentSelectList.indexOf(`${item.key}|${r.value}`);
|
|
|
+ // if (index >= 0) {
|
|
|
+ // contentSelectList.splice(index, 1);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // this.setState({ selectList, contentSelectList, allCheckbox: false });
|
|
|
}
|
|
|
|
|
|
onSelectContent(contentSelectList, key, checked) {
|
|
@@ -267,7 +311,7 @@ export default class extends Page {
|
|
|
const { info } = this.props.user;
|
|
|
const { selectList, contentSelectList } = this.state;
|
|
|
const questionNoMap = {};
|
|
|
- let questionNoIds;
|
|
|
+ // let questionNoIds;
|
|
|
switch (key) {
|
|
|
case 'help':
|
|
|
this.setState({ showTips: true });
|
|
@@ -286,20 +330,7 @@ export default class extends Page {
|
|
|
questionNoMap[questionNoId][target] = '';
|
|
|
questionNoMap[questionNoId].fields += 1;
|
|
|
});
|
|
|
- questionNoIds = Object.keys(questionNoMap).filter(row => questionNoMap[row].fields < AskTarget.length);
|
|
|
- if (questionNoIds.length > 0) {
|
|
|
- Promise.all(questionNoIds.map(row => {
|
|
|
- return My.updateQuestionNote(row, questionNoMap);
|
|
|
- }))
|
|
|
- .then(() => {
|
|
|
- const clearList = Object.keys(questionNoMap).filter(row => questionNoMap[row].fields === AskTarget.length);
|
|
|
- if (clearList.length > 0) {
|
|
|
- this.clearNote(clearList);
|
|
|
- } else {
|
|
|
- this.refresh();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ this.clearNote(Object.keys(questionNoMap));
|
|
|
// this.setState({ showClearConfirm: true, clearInfo: { questionNoIds: selectList } });
|
|
|
break;
|
|
|
case 'export':
|
|
@@ -315,17 +346,23 @@ export default class extends Page {
|
|
|
this.setState({ showWarn: true, warn: { title: '导出', content: '不可多余100题,请重新选择' } });
|
|
|
return;
|
|
|
}
|
|
|
- contentSelectList.forEach(row => {
|
|
|
- const [questionNoIdStr, target] = row.split('|');
|
|
|
- const questionNoId = Number(questionNoIdStr);
|
|
|
- if (!questionNoMap[questionNoId]) {
|
|
|
- questionNoMap[questionNoId] = { fields: 0 };
|
|
|
- }
|
|
|
- questionNoMap[questionNoId][target] = '';
|
|
|
- questionNoMap[questionNoId].fields += 1;
|
|
|
- });
|
|
|
- questionNoIds = Object.keys(questionNoMap);
|
|
|
- this.setState({ showExportConfirm: true, exportInfo: { questionNoIds, questionNoMap } });
|
|
|
+ // if (info.bindReal) {
|
|
|
+ this.setState({ showExportConfirm: true, exportInfo: { include: exportType.map(row => row.key), questionNoIds: selectList, answer: true } });
|
|
|
+ // } else {
|
|
|
+ // this.setState({ showExportAuthConfirm: true, exportInfo: { include: exportType.filter(row => !row.auth).map(row => row.key), questionNoIds: selectList, answer: true } });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // contentSelectList.forEach(row => {
|
|
|
+ // const [questionNoIdStr, target] = row.split('|');
|
|
|
+ // const questionNoId = Number(questionNoIdStr);
|
|
|
+ // if (!questionNoMap[questionNoId]) {
|
|
|
+ // questionNoMap[questionNoId] = { fields: 0 };
|
|
|
+ // }
|
|
|
+ // questionNoMap[questionNoId][target] = '';
|
|
|
+ // questionNoMap[questionNoId].fields += 1;
|
|
|
+ // });
|
|
|
+ // questionNoIds = Object.keys(questionNoMap);
|
|
|
+ // this.setState({ showExportConfirm: true, exportInfo: { questionNoIds, questionNoMap } });
|
|
|
break;
|
|
|
default:
|
|
|
}
|
|
@@ -461,7 +498,7 @@ export default class extends Page {
|
|
|
<UserTable
|
|
|
border={false}
|
|
|
size="small"
|
|
|
- select
|
|
|
+ // select
|
|
|
even="default"
|
|
|
selectList={contentSelectList}
|
|
|
columns={contentColumns}
|
|
@@ -481,17 +518,12 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
renderModal() {
|
|
|
- const { showTips, showWarn, warn = {}, showClearConfirm, clearInfo = {}, showVip, showExamination, showReal, showExportWait, showExportConfirm, exportInfo = {} } = this.state;
|
|
|
+ const { showTips, showWarn, warn = {}, showClearConfirm, clearInfo = {}, showVip, showExamination, showReal, showExportWait, showExportConfirm, showExportAuthConfirm, exportInfo = {} } = this.state;
|
|
|
const { info } = this.props.user;
|
|
|
return [
|
|
|
<Modal show={showTips} title="操作提示" confirmText="好的,知道了" btnAlign="center" onConfirm={() => this.setState({ showTips: false })}>
|
|
|
<div className="flex-layout m-b-2">
|
|
|
<div className="flex-block">
|
|
|
- <div className="t-1 t-s-18">组卷功能</div>
|
|
|
- <div className="t-2">操作数量:10-50;</div>
|
|
|
- <div className="t-2">注意事项:可跨题型、不可跨学科。</div>
|
|
|
- </div>
|
|
|
- <div className="flex-block">
|
|
|
<div className="t-1 t-s-18">导出功能</div>
|
|
|
<div className="t-2">操作数量:1-100;</div>
|
|
|
<div className="t-2">注意事项:“综合推理IR”暂时无法导出。</div>
|
|
@@ -514,7 +546,56 @@ export default class extends Page {
|
|
|
</Modal>,
|
|
|
<Modal show={showExportConfirm} title="导出" confirmText="导出" onConfirm={() => this.export()} onCancel={() => this.setState({ showExportConfirm: false })}>
|
|
|
<div className="t-2 t-s-18 m-b-5">
|
|
|
- 当前共选中 <span className="t-4">{exportInfo.questionNoIds ? exportInfo.questionNoIds.length : 0}</span> 道题笔记,是否开始导出:
|
|
|
+ 当前共选中 <span className="t-4">{exportInfo.questionNoIds ? exportInfo.questionNoIds.length : 0}</span> 道题,请确认需要导出的内容:
|
|
|
+ </div>
|
|
|
+ <div className="t-2 t-s-16">
|
|
|
+ {exportType.map(item => {
|
|
|
+ return (
|
|
|
+ <div className="d-i-b m-b-5" style={{ width: 135 }}>
|
|
|
+ <Checkbox checked={exportInfo.include ? exportInfo.include.indexOf(item.key) >= 0 : false} className="m-r-5" onChange={() => {
|
|
|
+ exportInfo.include.push(item.key);
|
|
|
+ this.setState({ exportInfo });
|
|
|
+ }} />
|
|
|
+ {item.title}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ </Modal>,
|
|
|
+ <Modal show={showExportAuthConfirm} title="导出" confirmText="导出" onConfirm={() => this.export()} onCancel={() => this.setState({ showExportAuthConfirm: false })}>
|
|
|
+ <div className="t-2 t-s-18 m-b-5">
|
|
|
+ 当前共选中 <span className="t-4">{exportInfo.questionNoIds ? exportInfo.questionNoIds.length : 0}</span> 道题,请确认需要导出的内容:
|
|
|
+ </div>
|
|
|
+ <div className="t-2 t-s-16 m-b-2">
|
|
|
+ {exportType
|
|
|
+ .filter(item => !item.auth)
|
|
|
+ .map(item => {
|
|
|
+ return (
|
|
|
+ <div className="d-i-b m-b-2" style={{ width: 135 }}>
|
|
|
+ <Checkbox checked={exportInfo.include ? exportInfo.include.indexOf(item.key) >= 0 : false} className="m-r-5" onChange={() => {
|
|
|
+ exportInfo.include.push(item.key);
|
|
|
+ this.setState({ exportInfo });
|
|
|
+ }} />
|
|
|
+ {item.title}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ <div className="b-b m-b-2 m-t-2" />
|
|
|
+ <div className="t-3 m-b-1">
|
|
|
+ 以下内容需实名认证后才可导出: <a className="f-r" onClick={() => this.setState({ showExportAuthConfirm: false, showReal: true })}>去认证 ></a>
|
|
|
+ </div>
|
|
|
+ <div className="t-2 t-s-16 m-b-2">
|
|
|
+ {exportType
|
|
|
+ .filter(item => item.auth)
|
|
|
+ .map(item => {
|
|
|
+ return (
|
|
|
+ <div className="d-i-b" style={{ width: 135 }}>
|
|
|
+ <Checkbox disabled className="m-r-5" />
|
|
|
+ {item.title}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ })}
|
|
|
</div>
|
|
|
</Modal>,
|
|
|
<Modal show={showExportWait} title="导出" confirmText="好的,知道了" btnAlign="center" onConfirm={() => this.setState({ showExportWait: false })}>
|