Commit da03cc27 by yuananting

fix:loading

parent 0c8b67b7
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-22 10:59:43
* @LastEditors: yuananting
* @LastEditTime: 2021-04-07 12:19:27
* @LastEditTime: 2021-04-10 10:59:32
* @Description: 助学工具-侧边课程分类树
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -131,7 +131,7 @@ class CourseCategorySiderTree extends Component {
} else if (this.props.fromModule === "QUESTION_MODAL") {
Bus.trigger("queryQuestionModalList", selectedKeys[0]);
} else {
Bus.trigger("queryPaperPageList", selectedKeys[0]);
Bus.trigger("queryPaperPageList", selectedKeys[0], false);
}
});
};
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-25 11:23:47
* @LastEditors: yuananting
* @LastEditTime: 2021-04-08 10:03:45
* @LastEditTime: 2021-04-10 11:03:26
* @Description: 助学工具-题库-试卷列表数据
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -22,7 +22,7 @@ import {
} from "antd";
import { PageControl } from "@/components";
import "./PaperList.less";
import { Route, withRouter } from 'react-router-dom';
import { Route, withRouter } from "react-router-dom";
import OperatePaper from "@/modules/teach-tool/paper-manage/OperatePaper";
import User from "@/common/js/user";
import AidToolService from "@/domains/aid-tool-domain/AidToolService";
......@@ -48,23 +48,32 @@ class PaperList extends Component {
selectedRowKeys: [this.props.paperId],
dataSource: [],
paperPreviewModal: null, // 试卷预览模态框
loading: false,
};
}
componentDidMount() {
this.queryPaperPageList();
Bus.bind('queryPaperPageList', (selectedCategoryId) => {
selectedCategoryId = selectedCategoryId === "null" ? null : selectedCategoryId;
this.InitSearch(selectedCategoryId)
})
Bus.bind("queryPaperPageList", (selectedCategoryId, delay) => {
selectedCategoryId =
selectedCategoryId === "null" ? null : selectedCategoryId;
this.setState({ loading: true });
if (delay) {
setTimeout(() => {
this.InitSearch(selectedCategoryId);
}, 5000);
} else {
this.InitSearch(selectedCategoryId);
}
});
}
componentWillUnmount() {
Bus.unbind('queryPaperPageList', this.queryPaperPageList)
Bus.unbind("queryPaperPageList", this.queryPaperPageList);
}
// 初始化列表查询
InitSearch = (categoryId) => {
InitSearch = (categoryId, delay) => {
const _query = {
...this.state.query,
categoryId,
......@@ -77,11 +86,10 @@ class PaperList extends Component {
};
// 查询试卷列表
queryPaperPageList = () => {
AidToolService.queryPaperPageList(this.state.query).then((res) => {
const { records = [], total = 0 } = res.result;
this.setState({ dataSource: records, total });
});
queryPaperPageList = async () => {
const res = await AidToolService.queryPaperPageList(this.state.query);
const { records = [], total = 0 } = res.result;
this.setState({ dataSource: records, total, loading: false });
};
// 预览试卷
......@@ -112,8 +120,6 @@ class PaperList extends Component {
// 编辑试卷
editPaper = (record) => {
const { match } = this.props;
if (record.relatedExam === 0) {
const { categoryId } = this.state.query;
const { match } = this.props;
......@@ -158,7 +164,7 @@ class PaperList extends Component {
});
}
});
}
};
// 删除试卷确认
confirmDeletePaper = (record) => {
......@@ -249,45 +255,49 @@ class PaperList extends Component {
width: this.props.type !== "modal-select" ? "12%" : "20%",
align: "right",
render: (val, record) => {
return (
this.props.type !== "modal-select" ?
<span>
{record.questionCnt}
</span> :
<Tooltip
overlayClassName="tool-list"
title={
<div>
<div className="item">单选题:{record.singleChoiceCnt || 0}</div>
<div className="item">多选题:{record.multiChoiceCnt || 0}</div>
<div className="item">判断题:{record.judgeCnt || 0}</div>
<div className="item">填空题:{record.gapFillingCnt || 0}</div>
<div className="item">不定项选择题:{record.indefiniteChoiceCnt || 0}</div>
return this.props.type !== "modal-select" ? (
<span>{record.questionCnt}</span>
) : (
<Tooltip
overlayClassName="tool-list"
title={
<div>
<div className="item">
单选题:{record.singleChoiceCnt || 0}
</div>
}
placement="top"
overlayStyle={{ maxWidth: 700 }}
>
<span>
{record.questionCnt}
</span>
</Tooltip>
<div className="item">
多选题:{record.multiChoiceCnt || 0}
</div>
<div className="item">判断题:{record.judgeCnt || 0}</div>
<div className="item">
填空题:{record.gapFillingCnt || 0}
</div>
<div className="item">
不定项选择题:{record.indefiniteChoiceCnt || 0}
</div>
</div>
}
placement="top"
overlayStyle={{ maxWidth: 700 }}
>
<span>{record.questionCnt}</span>
</Tooltip>
);
},
},
];
if (this.props.type !== "modal-select") {
const isPermiss = ["CloudManager", "StoreManager"].includes(User.getUserRole());
const isPermiss = ["CloudManager", "StoreManager"].includes(
User.getUserRole()
);
columns.push({
title: "关联考试数",
key: "relatedExam",
dataIndex: "relatedExam",
width: this.props.type !== "modal-select" ? "16%" : "24%",
align: "right",
})
});
columns.push({
title: "操作",
key: "operate",
......@@ -302,17 +312,25 @@ class PaperList extends Component {
>
预览
</div>
{isPermiss && <span className="record-operate__item split"> | </span>}
{isPermiss && <div
className="record-operate__item"
onClick={() => this.copyPaper(record)}
>
复制
</div>}
{isPermiss && <span className="record-operate__item split"> | </span>}
{isPermiss && <Dropdown overlay={this.initDropMenu(record)}>
<div className="record-operate__item">更多</div>
</Dropdown>}
{isPermiss && (
<span className="record-operate__item split"> | </span>
)}
{isPermiss && (
<div
className="record-operate__item"
onClick={() => this.copyPaper(record)}
>
复制
</div>
)}
{isPermiss && (
<span className="record-operate__item split"> | </span>
)}
{isPermiss && (
<Dropdown overlay={this.initDropMenu(record)}>
<div className="record-operate__item">更多</div>
</Dropdown>
)}
</div>
);
},
......@@ -359,6 +377,7 @@ class PaperList extends Component {
query,
paperPreviewModal,
selectedRowKeys,
loading,
} = this.state;
const { current, size, categoryId, paperName } = query;
const rowSelection = {
......@@ -366,7 +385,9 @@ class PaperList extends Component {
selectedRowKeys,
onChange: this.onSelectChange,
};
const isPermiss = ["CloudManager", "StoreManager"].includes(User.getUserRole())
const isPermiss = ["CloudManager", "StoreManager"].includes(
User.getUserRole()
);
const { match } = this.props;
return (
<div className={"paper-list " + this.props.type}>
......@@ -397,19 +418,18 @@ class PaperList extends Component {
</div>
</Row>
</div>
{this.props.type !== "modal-select" && isPermiss &&
categoryId && (
<Button
type="primary"
onClick={() => {
window.RCHistory.push({
pathname: `${match.url}/paper-operate-page?type=new&categoryId=${categoryId}`,
});
}}
>
新建试卷
</Button>
)}
{this.props.type !== "modal-select" && isPermiss && categoryId && (
<Button
type="primary"
onClick={() => {
window.RCHistory.push({
pathname: `${match.url}/paper-operate-page?type=new&categoryId=${categoryId}`,
});
}}
>
新建试卷
</Button>
)}
<div className="paper-list-content">
<ConfigProvider renderEmpty={this.customizeRenderEmpty}>
......@@ -420,6 +440,7 @@ class PaperList extends Component {
columns={this.parseColumns()}
pagination={false}
bordered
loading={loading}
onChange={this.handleChangeTable}
/>
) : (
......@@ -457,7 +478,10 @@ class PaperList extends Component {
)}
{paperPreviewModal}
</div>
<Route path={`${match.url}/paper-operate-page`} component={OperatePaper} />
<Route
path={`${match.url}/paper-operate-page`}
component={OperatePaper}
/>
</div>
);
}
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-25 11:23:47
* @LastEditors: yuananting
* @LastEditTime: 2021-04-09 17:21:36
* @LastEditTime: 2021-04-10 09:34:35
* @Description: 助学工具-新建试卷-选择题目列表
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -64,7 +64,7 @@ class SelectQuestionList extends Component {
query: {
current: 1,
size: 10,
order: "ACCURACY_DESC",
order: "UPDATED_DESC",
categoryId: null, // 当前题库分类Id
questionName: null, // 题目名称
questionType: null, // 题目类型
......@@ -95,7 +95,7 @@ class SelectQuestionList extends Component {
...this.state.query,
categoryId,
current: 1,
order: "ACCURACY_DESC", // 排序规则
order: "UPDATED_DESC", // 排序规则
questionName: null, // 题目名称
questionType: null, // 题目类型
};
......@@ -107,7 +107,7 @@ class SelectQuestionList extends Component {
// 排序
handleChangeTable = (pagination, filters, sorter) => {
const { columnKey, order } = sorter;
let sort = null;
let sort = "UPDATED_DESC";
if (order === "ascend") {
sort = "ACCURACY_ASC";
}
......@@ -115,7 +115,7 @@ class SelectQuestionList extends Component {
sort = "ACCURACY_DESC";
}
const _query = this.state.query;
_query.order = sort || "ACCURACY_DESC";
_query.order = sort;
_query.current = 1;
this.setState({ query: _query }, () => this.queryQuestionModalList());
};
......@@ -132,7 +132,7 @@ class SelectQuestionList extends Component {
const _query = {
...this.state.query,
current: 1,
order: "ACCURACY_DESC", // 排序规则
order: "UPDATED_DESC", // 排序规则
questionName: null, // 题目名称
questionType: null, // 题目类型
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment