Commit ab61605c by yuananting

fix:未选题校验,接口替换

parent 3c1b158e
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-03 15:13:12
* @LastEditors: yuananting
* @LastEditTime: 2021-04-06 10:44:47
* @LastEditTime: 2021-04-13 13:58:40
* @Description: 助学工具接口
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -80,3 +80,7 @@ export function editPaper(params: object) {
export function batchQueryQuestionDetails(params: object) {
return Service.Hades("public/hades/batchQueryQuestionDetails", params);
}
export function queryQuestionPageListWithContent(params: object) {
return Service.Hades("public/hades/queryQuestionPageListWithContent", params);
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-11 11:34:37
* @LastEditors: yuananting
* @LastEditTime: 2021-04-06 10:44:18
* @LastEditTime: 2021-04-13 13:58:11
* @Description: 助学工具接口
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -25,6 +25,7 @@ import {
viewPaper,
editPaper,
batchQueryQuestionDetails,
queryQuestionPageListWithContent,
} from '@/data-source/aidTool/request-apis';
export default class AidToolService {
// 获取题目分类树
......@@ -116,4 +117,9 @@ export default class AidToolService {
static batchQueryQuestionDetails(params: any) {
return batchQueryQuestionDetails(params);
}
// 操作试卷-选择题目列表带题目详情
static queryQuestionPageListWithContent(params: any) {
return queryQuestionPageListWithContent(params);
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-22 10:59:43
* @LastEditors: yuananting
* @LastEditTime: 2021-04-10 15:36:29
* @LastEditTime: 2021-04-13 13:55:37
* @Description: 助学工具-侧边课程分类树
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -129,7 +129,7 @@ class CourseCategorySiderTree extends Component {
if (this.props.fromModule === "QUESTION_INDEX") {
Bus.trigger("queryQuestionPageList", selectedKeys[0]);
} else if (this.props.fromModule === "QUESTION_MODAL") {
Bus.trigger("queryQuestionModalList", selectedKeys[0]);
Bus.trigger("queryQuestionPageListWithContent", selectedKeys[0]);
} else {
Bus.trigger("queryPaperPageList", selectedKeys[0], 0);
}
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-03-27 16:15:13
* @LastEditors: yuananting
* @LastEditTime: 2021-04-12 20:15:51
* @LastEditTime: 2021-04-13 15:12:49
* @Description: 助学工具-新建/复制/编辑试卷
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -300,6 +300,9 @@ class OperatePaper extends Component {
const { selectQuestionList, formData, currentOperate } = this.state;
const categoryId = getParameterByName("categoryId");
let questionList = [];
if (selectQuestionList.length === 0) {
return message.warning("请选择题目");
}
selectQuestionList.forEach((item, index) => {
questionList.push({
categoryId: item.categoryId,
......@@ -319,7 +322,8 @@ class OperatePaper extends Component {
},
() => {
if (["new", "copy"].includes(currentOperate)) {
AidToolService.createPaper(this.state.formData).then((res) => {
AidToolService.createPaper(this.state.formData)
.then((res) => {
if (res.success) {
message.success(
currentOperate === "new" ? "新建成功" : "复制成功"
......@@ -327,34 +331,53 @@ class OperatePaper extends Component {
window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`,
});
Bus.trigger("queryPaperPageList", categoryId, selectQuestionList.length);
Bus.trigger(
"queryPaperPageList",
categoryId,
selectQuestionList.length
);
Bus.trigger("queryCategoryTree", "remain");
}
}).catch((e)=> {
})
.catch((e) => {
window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`,
});
Bus.trigger("queryPaperPageList", categoryId, selectQuestionList.length);
Bus.trigger(
"queryPaperPageList",
categoryId,
selectQuestionList.length
);
Bus.trigger("queryCategoryTree", "remain");
});
} else if (currentOperate === "edit") {
AidToolService.editPaper({
...this.state.formData,
paperId: getParameterByName("paperId"),
}).then((res) => {
})
.then((res) => {
if (res.success) {
message.success("编辑成功");
window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`,
});
Bus.trigger("queryPaperPageList", categoryId, selectQuestionList.length);
Bus.trigger(
"queryPaperPageList",
categoryId,
selectQuestionList.length
);
Bus.trigger("queryCategoryTree", "remain");
}
}).catch((e)=> {
})
.catch((e) => {
window.RCHistory.push({
pathname: `/paper-manage-index?categoryId=${categoryId}`,
});
Bus.trigger("queryPaperPageList", categoryId, selectQuestionList.length);
Bus.trigger(
"queryPaperPageList",
categoryId,
selectQuestionList.length
);
Bus.trigger("queryCategoryTree", "remain");
});
}
......@@ -368,32 +391,10 @@ class OperatePaper extends Component {
// 预览试卷
previewPaper = () => {
const { selectQuestionList, formData } = this.state;
const questionIdList = selectQuestionList.map((item) => {
return item.questionId;
});
let param = {
questionIdList,
source: 0,
userId: User.getStoreUserId(),
tenantId: User.getStoreId(),
};
AidToolService.batchQueryQuestionDetails(param).then((res) => {
const { result = [] } = res;
result.map((item) => {
selectQuestionList.map((selectItem) => {
if (item.id === selectItem.questionId) {
item.questionId = item.id;
item.questionType = item.questionTypeEnum;
item.score = selectItem.score || 2;
item.portionScore = selectItem.portionScore || 0;
}
});
return item;
});
const m = (
<PaperPreviewModal
previewPage="paper-operate"
paperInfo={{ ...formData, questionList: res.result }}
paperInfo={{ ...formData, questionList: selectQuestionList }}
close={() => {
this.setState({
paperPreviewModal: null,
......@@ -402,7 +403,6 @@ class OperatePaper extends Component {
/>
);
this.setState({ paperPreviewModal: m });
});
};
// 取消/返回
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-25 11:23:47
* @LastEditors: yuananting
* @LastEditTime: 2021-04-12 14:13:39
* @LastEditTime: 2021-04-13 13:56:05
* @Description: 助学工具-新建试卷-选择题目列表
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -78,15 +78,15 @@ class SelectQuestionList extends Component {
}
componentDidMount() {
this.queryQuestionModalList()
Bus.bind('queryQuestionModalList', (selectedCategoryId) => {
this.queryQuestionPageListWithContent()
Bus.bind('queryQuestionPageListWithContent', (selectedCategoryId) => {
selectedCategoryId = selectedCategoryId === "null" ? null : selectedCategoryId;
this.InitSearch(selectedCategoryId)
})
}
componentWillUnmount() {
Bus.unbind('queryQuestionModalList', this.queryQuestionModalList)
Bus.unbind('queryQuestionPageListWithContent', this.queryQuestionPageListWithContent)
}
// 初始化列表查询
......@@ -100,7 +100,7 @@ class SelectQuestionList extends Component {
questionType: null, // 题目类型
};
this.setState({ query: _query }, () => {
this.queryQuestionModalList();
this.queryQuestionPageListWithContent();
});
};
......@@ -117,11 +117,11 @@ class SelectQuestionList extends Component {
const _query = this.state.query;
_query.order = sort;
_query.current = 1;
this.setState({ query: _query }, () => this.queryQuestionModalList());
this.setState({ query: _query }, () => this.queryQuestionPageListWithContent());
};
queryQuestionModalList = () => {
AidToolService.queryQuestionPageList(this.state.query).then((res) => {
queryQuestionPageListWithContent = () => {
AidToolService.queryQuestionPageListWithContent(this.state.query).then((res) => {
const { records = [], total = 0 } = res.result;
this.setState({ dataSource: records, total });
});
......@@ -137,7 +137,7 @@ class SelectQuestionList extends Component {
questionType: null, // 题目类型
};
this.setState({ query: _query }, () => {
this.queryQuestionModalList();
this.queryQuestionPageListWithContent();
});
};
......@@ -211,7 +211,7 @@ class SelectQuestionList extends Component {
}
let _query = this.state.query;
_query.size = size;
this.setState({ query: _query }, () => this.queryQuestionModalList());
this.setState({ query: _query }, () => this.queryQuestionPageListWithContent());
};
// 改变搜索条件
......@@ -226,7 +226,7 @@ class SelectQuestionList extends Component {
},
() => {
if (searchType === "questionName") return;
this.queryQuestionModalList();
this.queryQuestionPageListWithContent();
}
);
};
......@@ -329,7 +329,7 @@ class SelectQuestionList extends Component {
this.handleChangeQuery("questionName", e.target.value);
}}
onSearch={() => {
this.queryQuestionModalList();
this.queryQuestionPageListWithContent();
}}
enterButton={<span className="icon iconfont">&#xe832;</span>}
/>
......@@ -417,7 +417,7 @@ class SelectQuestionList extends Component {
toPage={(page) => {
const _query = { ...query, current: page + 1 };
this.setState({ query: _query }, () =>
this.queryQuestionModalList()
this.queryQuestionPageListWithContent()
);
}}
showSizeChanger={true}
......
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