Commit 96b7a4c4 by yuananting

feat:题目模块联调

parent 69411c9a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-03-03 15:13:12 * @Date: 2021-03-03 15:13:12
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 20:46:54 * @LastEditTime: 2021-03-15 19:44:31
* @Description: 助学工具接口 * @Description: 助学工具接口
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -43,4 +43,12 @@ export function addQuestion(params: object) { ...@@ -43,4 +43,12 @@ export function addQuestion(params: object) {
export function deleteQuestion(params: object) { export function deleteQuestion(params: object) {
return Service.Hades("anon/hades/question/deleteQuestion", params); return Service.Hades("anon/hades/question/deleteQuestion", params);
}
export function queryQuestionDetails(params: object) {
return Service.Hades("anon/hades/question/queryQuestionDetails", params);
}
export function editQuestion(params: object) {
return Service.Hades("anon/hades/question/editQuestion", params);
} }
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-03-11 11:34:37 * @Date: 2021-03-11 11:34:37
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 20:46:28 * @LastEditTime: 2021-03-15 19:45:10
* @Description: 描述一下咯 * @Description: 描述一下咯
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import { queryCategoryTree, addCategory, delCategory, editCategory, editCategoryTree, queryQuestionCategoryTree, addQuestion, queryQuestionPageList, deleteQuestion } from '@/data-source/questionBank/request-apis'; import { queryCategoryTree, addCategory, delCategory, editCategory, editCategoryTree, queryQuestionCategoryTree, addQuestion, queryQuestionPageList, deleteQuestion, queryQuestionDetails, editQuestion } from '@/data-source/questionBank/request-apis';
export default class QuestionBankService { export default class QuestionBankService {
// 获取题目分类树 // 获取题目分类树
static queryCategoryTree(params: any) { static queryCategoryTree(params: any) {
...@@ -52,4 +52,14 @@ export default class QuestionBankService { ...@@ -52,4 +52,14 @@ export default class QuestionBankService {
static deleteQuestion(params: any) { static deleteQuestion(params: any) {
return deleteQuestion(params); return deleteQuestion(params);
} }
// 预览题目
static queryQuestionDetails(params: any) {
return queryQuestionDetails(params);
}
// 编辑题目
static editQuestion(params: any) {
return editQuestion(params);
}
} }
\ No newline at end of file
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-25 13:46:35 * @Date: 2021-02-25 13:46:35
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 20:12:14 * @LastEditTime: 2021-03-15 21:14:47
* @Description: 助学工具-题库-题目管理-新增题目 * @Description: 助学工具-题库-题目管理-新增题目
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React, { Component } from "react"; import React, { Component } from "react";
import { Tabs, Button, Tooltip } from "antd"; import { Tabs, Button, Tooltip, message } from "antd";
import Breadcrumbs from "@/components/Breadcrumbs"; import Breadcrumbs from "@/components/Breadcrumbs";
import ShowTips from "@/components/ShowTips"; import ShowTips from "@/components/ShowTips";
import "./AddNewQuestion.less"; import "./AddNewQuestion.less";
...@@ -21,7 +21,7 @@ class AddNewQuestion extends Component { ...@@ -21,7 +21,7 @@ class AddNewQuestion extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
activeKey: "SINGLE_CHOICE", activeKey: getParameterByName("type") || "SINGLE_CHOICE",
// 构建题目基本结构 // 构建题目基本结构
singleChoiceContent: defineQuestionInfo("SINGLE_CHOICE"), // 单选题 singleChoiceContent: defineQuestionInfo("SINGLE_CHOICE"), // 单选题
multiChoiceContent: defineQuestionInfo("MULTI_CHOICE"), // 多选题 multiChoiceContent: defineQuestionInfo("MULTI_CHOICE"), // 多选题
...@@ -31,34 +31,97 @@ class AddNewQuestion extends Component { ...@@ -31,34 +31,97 @@ class AddNewQuestion extends Component {
}; };
} }
componentDidMount() {} componentDidMount() {
if (getParameterByName("id")) {
// 编辑
this.queryQuestionDetails();
}
}
queryQuestionDetails = () => {
let query = {
id: getParameterByName("id"),
source: 0,
userId: User.getStoreUserId(),
tenantId: User.getStoreId(),
};
QuestionBankService.queryQuestionDetails(query).then((res) => {
const { result = [] } = res;
const { questionTypeEnum } = result;
switch (questionTypeEnum) {
case "SINGLE_CHOICE":
this.setState({ singleChoiceContent: result });
break;
case "MULTI_CHOICE":
this.setState({ multiChoiceContent: result });
break;
case "JUDGE":
this.setState({ judgeContent: result });
break;
case "GAP_FILLING":
this.setState({ gapFillingContent: result });
break;
case "INDEFINITE_CHOICE":
this.setState({ indefiniteChoiceContent: result });
break;
}
});
};
saveCurrentQuestion = (content) => { saveCurrentQuestion = (content) => {
content.questionStemList.map((item, index)=> { content.questionStemList.map((item, index) => {
item.sort = index; item.sort = index;
return item; return item;
}) });
content.optionList.map((item)=> { content.optionList.map((item) => {
item.questionOptionContentList.map((childItem, childIndex) => { item.questionOptionContentList.map((childItem, childIndex) => {
childItem.sort = childIndex; childItem.sort = childIndex;
return childItem; return childItem;
}) });
return item; return item;
}) });
content.questionAnswerDescList.map((item, index)=> { content.questionAnswerDescList.map((item, index) => {
item.sort = index; item.sort = index;
return item; return item;
})
let params = {
...content,
categoryId: getParameterByName("categoryId"),
source: 0,
tenantId: User.getStoreId(),
userId: User.getUserId(),
};
QuestionBankService.addQuestion(params).then((res) => {
console.log(res);
}); });
let params = {};
let categoryId = getParameterByName("categoryId");
if (getParameterByName("id")) {
params = {
...content,
id: getParameterByName("id"),
categoryId: categoryId || null,
source: 0,
tenantId: User.getStoreId(),
userId: User.getStoreUserId(),
};
QuestionBankService.editQuestion(params).then((res) => {
if (res.success) {
message.success("保存成功");
window.RCHistory.push({
pathname: `/question-bank-index?categoryId=${params.categoryId}`,
});
}
});
} else {
params = {
...content,
categoryId: getParameterByName("categoryId"),
source: 0,
tenantId: User.getStoreId(),
userId: User.getStoreUserId(),
};
QuestionBankService.addQuestion(params).then((res) => {
if (res.success) {
message.success("保存成功");
window.RCHistory.push({
pathname: `/question-bank-index?categoryId=${params.categoryId}`,
});
}
});
}
}; };
confirmSaveQuestion = () => { confirmSaveQuestion = () => {
...@@ -71,12 +134,14 @@ class AddNewQuestion extends Component { ...@@ -71,12 +134,14 @@ class AddNewQuestion extends Component {
} = this.state; } = this.state;
switch (this.state.activeKey) { switch (this.state.activeKey) {
case "SINGLE_CHOICE": case "SINGLE_CHOICE":
if (this.singleRef.checkInput() === 0) { if (this.singleChoiceRef.checkInput() === 0) {
this.saveCurrentQuestion(singleChoiceContent); this.saveCurrentQuestion(singleChoiceContent);
} }
break; break;
case "MULTI_CHOICE": case "MULTI_CHOICE":
this.multipleRef.checkInput(); if (this.multiChoiceRef.checkInput() === 0) {
this.saveCurrentQuestion(multiChoiceContent);
}
break; break;
case "JUDGE": case "JUDGE":
this.judgeRef.checkInput(); this.judgeRef.checkInput();
...@@ -85,19 +150,21 @@ class AddNewQuestion extends Component { ...@@ -85,19 +150,21 @@ class AddNewQuestion extends Component {
this.CompletionRef.checkInput(); this.CompletionRef.checkInput();
break; break;
case "INDEFINITE_CHOICE": case "INDEFINITE_CHOICE":
this.indefiniteRef.checkInput(); if (this.indefiniteRef.checkInput() === 0) {
this.saveCurrentQuestion(indefiniteChoiceContent);
}
break; break;
} }
}; };
handleLogger = (en, cn) => {
const { onLogger } = this.props;
onLogger && onLogger(en, cn);
};
render() { render() {
const { const {
activeKey, activeKey,
singleContent,
multipleContent,
judgeContent1,
completionContent,
indefiniteContent,
singleChoiceContent, singleChoiceContent,
multiChoiceContent, multiChoiceContent,
judgeContent, judgeContent,
...@@ -106,7 +173,10 @@ class AddNewQuestion extends Component { ...@@ -106,7 +173,10 @@ class AddNewQuestion extends Component {
} = this.state; } = this.state;
return ( return (
<div className="page add-new-question"> <div className="page add-new-question">
<Breadcrumbs navList="新增题目" goBack={() => RCHistory.goBack()} /> <Breadcrumbs
navList={getParameterByName("id") ? "编辑题目" : "新增题目"}
goBack={() => RCHistory.goBack()}
/>
<div className="box"> <div className="box">
<div className="show-tips"> <div className="show-tips">
<ShowTips message="请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企培保有依据国家规定及平台规则进行处理的权利" /> <ShowTips message="请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企培保有依据国家规定及平台规则进行处理的权利" />
...@@ -125,13 +195,13 @@ class AddNewQuestion extends Component { ...@@ -125,13 +195,13 @@ class AddNewQuestion extends Component {
<NewQuestionTab <NewQuestionTab
questionTypeKey="SINGLE_CHOICE" questionTypeKey="SINGLE_CHOICE"
onRef={(ref) => { onRef={(ref) => {
this.singleRef = ref; this.singleChoiceRef = ref;
}} }}
questionInfo={singleChoiceContent} questionInfo={singleChoiceContent}
onSetState={(newContent) => { onSetState={(newContent) => {
console.log(newContent);
Object.assign(singleChoiceContent, newContent); Object.assign(singleChoiceContent, newContent);
}} }}
onLogger={this.handleLogger}
/> />
</TabPane> </TabPane>
<TabPane <TabPane
...@@ -141,12 +211,13 @@ class AddNewQuestion extends Component { ...@@ -141,12 +211,13 @@ class AddNewQuestion extends Component {
<NewQuestionTab <NewQuestionTab
questionTypeKey="MULTI_CHOICE" questionTypeKey="MULTI_CHOICE"
onRef={(ref) => { onRef={(ref) => {
this.multipleRef = ref; this.multiChoiceRef = ref;
}} }}
questionInfo={multiChoiceContent} questionInfo={multiChoiceContent}
onSetState={(newContent) => { onSetState={(newContent) => {
Object.assign(multiChoiceContent, newContent); Object.assign(multiChoiceContent, newContent);
}} }}
onLogger={this.handleLogger}
/> />
</TabPane> </TabPane>
<TabPane <TabPane
...@@ -199,6 +270,7 @@ class AddNewQuestion extends Component { ...@@ -199,6 +270,7 @@ class AddNewQuestion extends Component {
onSetState={(newContent) => { onSetState={(newContent) => {
Object.assign(indefiniteChoiceContent, newContent); Object.assign(indefiniteChoiceContent, newContent);
}} }}
onLogger={this.handleLogger}
/> />
</TabPane> </TabPane>
</Tabs> </Tabs>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-21 17:51:01 * @Date: 2021-02-21 17:51:01
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 16:48:23 * @LastEditTime: 2021-03-15 14:46:12
* @Description: 助学工具-题库-题库主页面 * @Description: 助学工具-题库-题库主页面
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
import React, { Component } from "react"; import React, { Component } from "react";
import "./QuestionBankIndex.less"; import "./QuestionBankIndex.less";
import QuestionBankSider from "./components/QuestionBankSider"; import QuestionBankSider from "./components/QuestionBankSider";
import QuestionManageList from "./components/QuestionManageContent"; import QuestionManageContent from "./components/QuestionManageContent";
import User from "@/common/js/user"; import User from "@/common/js/user";
import QuestionBankService from "@/domains/question-bank-domain/QuestionBankService"; import QuestionBankService from "@/domains/question-bank-domain/QuestionBankService";
...@@ -25,10 +25,7 @@ class QuestionBankIndex extends Component { ...@@ -25,10 +25,7 @@ class QuestionBankIndex extends Component {
}; };
} }
componentDidMount() { componentDidMount() {}
// TODO
// 接口请求 初始化数据
}
getCategoryIdFromSider = (selectedCategoryId) => { getCategoryIdFromSider = (selectedCategoryId) => {
if (selectedCategoryId && selectedCategoryId.length > 0) { if (selectedCategoryId && selectedCategoryId.length > 0) {
...@@ -36,6 +33,10 @@ class QuestionBankIndex extends Component { ...@@ -36,6 +33,10 @@ class QuestionBankIndex extends Component {
} }
}; };
updatedSiderTreeFromList = (updatedCategoryId) => {
this.setState({updatedCategoryId});
};
render() { render() {
return ( return (
<div className="question-bank-index page"> <div className="question-bank-index page">
...@@ -44,10 +45,14 @@ class QuestionBankIndex extends Component { ...@@ -44,10 +45,14 @@ class QuestionBankIndex extends Component {
<div className="sider"> <div className="sider">
<QuestionBankSider <QuestionBankSider
getSelectedCategoryId={this.getCategoryIdFromSider.bind(this)} getSelectedCategoryId={this.getCategoryIdFromSider.bind(this)}
updatedCategoryId={this.state.updatedCategoryId}
/> />
</div> </div>
<div className="content"> <div className="content">
<QuestionManageList selectedCategoryId={this.state.selectedCategoryId} /> <QuestionManageContent
updatedSiderTree={this.updatedSiderTreeFromList.bind(this)}
selectedCategoryId={this.state.selectedCategoryId}
/>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-23 18:28:50 * @Date: 2021-02-23 18:28:50
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 19:53:48 * @LastEditTime: 2021-03-15 15:14:10
* @Description: 助学工具-题库-主页面分类管理 * @Description: 助学工具-题库-主页面分类管理
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -23,7 +23,6 @@ import { ...@@ -23,7 +23,6 @@ import {
Modal, Modal,
} from "antd"; } from "antd";
import ShowTips from "@/components/ShowTips"; import ShowTips from "@/components/ShowTips";
import user from "@/common/js/user";
const { DirectoryTree } = Tree; const { DirectoryTree } = Tree;
const { Search } = Input; const { Search } = Input;
const { confirm } = Modal; const { confirm } = Modal;
...@@ -34,7 +33,7 @@ class QuestionCategoryManage extends Component { ...@@ -34,7 +33,7 @@ class QuestionCategoryManage extends Component {
NewEditQuestionBankCategory: null, //新增或编辑分类模态框 NewEditQuestionBankCategory: null, //新增或编辑分类模态框
treeData: [], treeData: [],
treeMap: {}, treeMap: {},
selectedKeys: ["0"] selectedKeys: ["0"],
}; };
} }
...@@ -47,12 +46,12 @@ class QuestionCategoryManage extends Component { ...@@ -47,12 +46,12 @@ class QuestionCategoryManage extends Component {
let query = { let query = {
source: 0, source: 0,
categoryName, categoryName,
userId: User.getUserId(), userId: User.getStoreUserId(),
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
}; };
QuestionBankService.queryCategoryTree(query).then((res) => { QuestionBankService.queryCategoryTree(query).then((res) => {
const { result = [] } = res; const { result = [] } = res;
const defaultNode = { id: "0", categoryName:"未分类", categoryCount: 0} const defaultNode = { id: "0", categoryName: "未分类", categoryCount: 0 };
result.unshift(defaultNode); result.unshift(defaultNode);
this.setState({ treeData: this.renderTreeNodes(result, categoryName) }); this.setState({ treeData: this.renderTreeNodes(result, categoryName) });
this.setState({ this.setState({
...@@ -78,7 +77,7 @@ class QuestionCategoryManage extends Component { ...@@ -78,7 +77,7 @@ class QuestionCategoryManage extends Component {
categoryId: item.id, categoryId: item.id,
source: 0, source: 0,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getUserId(), userId: User.getStoreUserId(),
}; };
QuestionBankService.delCategory(params).then((res) => { QuestionBankService.delCategory(params).then((res) => {
if (res.success) { if (res.success) {
...@@ -168,7 +167,11 @@ class QuestionCategoryManage extends Component { ...@@ -168,7 +167,11 @@ class QuestionCategoryManage extends Component {
onDrop = (info) => { onDrop = (info) => {
// 未分类不可以拖拽 // 未分类不可以拖拽
if (info.dragNode.categoryName === "未分类" || info.node.categoryName === "未分类") return; if (
info.dragNode.categoryName === "未分类" ||
info.node.categoryName === "未分类"
)
return;
// 不允许其他节点拖拽到未分类之前 // 不允许其他节点拖拽到未分类之前
if ( if (
info.node.categoryName === "未分类" && info.node.categoryName === "未分类" &&
...@@ -209,7 +212,11 @@ class QuestionCategoryManage extends Component { ...@@ -209,7 +212,11 @@ class QuestionCategoryManage extends Component {
}); });
if (sameNameNodes.length > 0) { if (sameNameNodes.length > 0) {
sufIndex++; sufIndex++;
return getSuf(originCategoryName + `(${sufIndex})`, originCategoryName, sufIndex); return getSuf(
originCategoryName + `(${sufIndex})`,
originCategoryName,
sufIndex
);
} }
} }
return sufIndex; return sufIndex;
...@@ -225,9 +232,12 @@ class QuestionCategoryManage extends Component { ...@@ -225,9 +232,12 @@ class QuestionCategoryManage extends Component {
item.originCategoryName = item.categoryName; item.originCategoryName = item.categoryName;
} }
info.dragNode.categoryName = item.originCategoryName; info.dragNode.categoryName = item.originCategoryName;
let sufIndex = getSuf(info.dragNode.categoryName, item.originCategoryName, 0); let sufIndex = getSuf(
item.categoryName = info.dragNode.categoryName,
item.categoryName + (sufIndex ? `(${sufIndex})` : ""); item.originCategoryName,
0
);
item.categoryName = item.categoryName + (sufIndex ? `(${sufIndex})` : "");
item.categoryName = item.categoryName =
item.originCategoryName + (sufIndex ? `(${sufIndex})` : ""); item.originCategoryName + (sufIndex ? `(${sufIndex})` : "");
dragObj = item; dragObj = item;
...@@ -267,7 +277,7 @@ class QuestionCategoryManage extends Component { ...@@ -267,7 +277,7 @@ class QuestionCategoryManage extends Component {
categoryList: newTreeData, categoryList: newTreeData,
source: 0, source: 0,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getUserId(), userId: User.getStoreUserId(),
}; };
QuestionBankService.editCategoryTree(params).then((res) => { QuestionBankService.editCategoryTree(params).then((res) => {
this.queryCategoryTree(); this.queryCategoryTree();
...@@ -430,14 +440,20 @@ class QuestionCategoryManage extends Component { ...@@ -430,14 +440,20 @@ class QuestionCategoryManage extends Component {
/** 树状选中事件 */ /** 树状选中事件 */
onSelect = (selectedKeys) => { onSelect = (selectedKeys) => {
this.setState({ selectedKeys }); this.setState({ selectedKeys });
// TODO调用查询题目接口
}; };
render() { render() {
const { treeData, expandedKeys, selectedKeys } = this.state; const { treeData, expandedKeys, selectedKeys } = this.state;
return ( return (
<div className="page question-category-manage"> <div className="page question-category-manage">
<Breadcrumbs navList="课程分类" goBack={() => RCHistory.goBack()} /> <Breadcrumbs
navList="课程分类"
goBack={() =>
window.RCHistory.push({
pathname: "/question-bank-index",
})
}
/>
<div className="box"> <div className="box">
<div className="search-condition"> <div className="search-condition">
<span className="search-label">搜索名称:</span> <span className="search-label">搜索名称:</span>
......
...@@ -284,6 +284,89 @@ ...@@ -284,6 +284,89 @@
.question-item_analysis__content { .question-item_analysis__content {
flex: 1; flex: 1;
margin-right: 187px; margin-right: 187px;
.question-desc-box {
margin-top: 12px;
.desc-picture-box {
margin-bottom: 28px;
.picture-box {
position: relative;
display: inline-block;
width: 100px;
height: 100px;
overflow: hidden;
align-items: center;
justify-content: center;
padding: 12px 12px 0 0;
img {
max-width: 88px;
max-height: 88px;
border-radius: 4px;
}
.icon_arrow {
position: absolute;
top: 0px;
right: 5px;
color: #bfbfbf;
cursor: pointer;
font-size: 16px;
}
}
}
.desc-audio-box {
margin-bottom: 28px;
.audio-box {
position: relative;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
padding: 10px 20px;
width: 320px;
margin-bottom: 12px;
.icon_sider {
color: #bfbfbf;
cursor: pointer;
font-size: 16px;
padding: 12px;
position: absolute;
top: 0px;
left: 320px;
}
}
}
.desc-video-box {
.video-box {
position: relative;
display: inline-block;
width: 208px;
// height: calc(208px * 9 / 16);
position: relative;
overflow: hidden;
// background-color: #000;
padding-top: 12px;
margin: 0px 12px 12px 0;
&_content {
max-width: 200px;
max-height: 200px;
border-radius: 4px;
}
&_btn {
width: 32px;
height: 32px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -8px;
margin-left: -16px;
}
.icon_arrow {
position: absolute;
top: 0px;
right: 0px;
color: #bfbfbf;
cursor: pointer;
font-size: 16px;
}
}
}
}
} }
.completion-answer-box { .completion-answer-box {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-22 10:59:43 * @Date: 2021-02-22 10:59:43
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 20:29:29 * @LastEditTime: 2021-03-15 15:22:13
* @Description: 助学工具-题库-题库主页面侧边栏 * @Description: 助学工具-题库-题库主页面侧边栏
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -19,7 +19,7 @@ class QuestionBankSider extends Component { ...@@ -19,7 +19,7 @@ class QuestionBankSider extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
selectedKeys: ["0"], selectedKeys: getParameterByName("categoryId") ? [getParameterByName("categoryId")] : ["0"],
searchValue: null, searchValue: null,
NewEditQuestionBankCategory: null, //新增或编辑分类模态框 NewEditQuestionBankCategory: null, //新增或编辑分类模态框
ImportCourseCategory: null, // 引用课程分类模态框 ImportCourseCategory: null, // 引用课程分类模态框
...@@ -29,6 +29,15 @@ class QuestionBankSider extends Component { ...@@ -29,6 +29,15 @@ class QuestionBankSider extends Component {
componentDidMount() { componentDidMount() {
this.queryCategoryTree(); this.queryCategoryTree();
this.props.getSelectedCategoryId(getParameterByName("categoryId") ? [getParameterByName("categoryId")] : ["0"],)
}
shouldComponentUpdate(nextProps, nextState) {
const { updatedCategoryId } = nextProps;
if (this.props.updatedCategoryId !== updatedCategoryId) {
this.setState({ selectedKeys: [updatedCategoryId] }, () => this.queryCategoryTree());
}
return true;
} }
/** 获取树状第一级key 设置默认展开第一项 */ /** 获取树状第一级key 设置默认展开第一项 */
...@@ -58,12 +67,12 @@ class QuestionBankSider extends Component { ...@@ -58,12 +67,12 @@ class QuestionBankSider extends Component {
let query = { let query = {
source: 0, source: 0,
categoryName, categoryName,
userId: User.getUserId(), userId: User.getStoreUserId(),
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
}; };
QuestionBankService.queryQuestionCategoryTree(query).then((res) => { QuestionBankService.queryQuestionCategoryTree(query).then((res) => {
const { categoryList = [] } = res.result; const { categoryList = [], noCategoryCnt = 0 } = res.result;
const defaultNode = { id: "0", categoryName:"未分类", categoryCount: 0} const defaultNode = { id: "0", categoryName:"未分类", categoryCount: noCategoryCnt}
categoryList.unshift(defaultNode); categoryList.unshift(defaultNode);
this.setState({ treeData: this.renderTreeNodes(categoryList, categoryName) }); this.setState({ treeData: this.renderTreeNodes(categoryList, categoryName) });
this.setState({ this.setState({
......
...@@ -37,6 +37,7 @@ class QuestionEditor extends Component { ...@@ -37,6 +37,7 @@ class QuestionEditor extends Component {
isShowSingleInput: true, isShowSingleInput: true,
contentLength: 0, contentLength: 0,
errorInput: false, errorInput: false,
detailInfo: props.detailInfo || {}
}; };
} }
...@@ -44,6 +45,16 @@ class QuestionEditor extends Component { ...@@ -44,6 +45,16 @@ class QuestionEditor extends Component {
this.renderEditor(); this.renderEditor();
} }
shouldComponentUpdate(nextProps, nextState) {
const { detailInfo } = nextProps;
if (this.props.detailInfo !== detailInfo) {
this.setState({detailInfo: nextProps.detailInfo}, () => {
this.renderEditor();
})
}
return true;
}
handleUploadMedia = (key) => { handleUploadMedia = (key) => {
this.props.onUploadMedia && this.props.onUploadMedia(key); this.props.onUploadMedia && this.props.onUploadMedia(key);
}; };
...@@ -72,8 +83,8 @@ class QuestionEditor extends Component { ...@@ -72,8 +83,8 @@ class QuestionEditor extends Component {
}; };
renderEditor() { renderEditor() {
const { editorId } = this.state; const { editorId, detailInfo} = this.state;
const { detail = {}, detailInfo = {}, onChange, bindChangeContent } = this.props; const { onChange, bindChangeContent } = this.props;
const editorRoot = new E( const editorRoot = new E(
`#editor${editorId}_tabbar`, `#editor${editorId}_tabbar`,
`#editor${editorId}_content` `#editor${editorId}_content`
...@@ -156,27 +167,6 @@ class QuestionEditor extends Component { ...@@ -156,27 +167,6 @@ class QuestionEditor extends Component {
editorRoot.create(); editorRoot.create();
this.editorRoot = editorRoot; this.editorRoot = editorRoot;
if (detail.content) {
const contentHtml = /^\<p/.test(detail.content)
? detail.content
: `<p>${detail.content}</p>`;
editorRoot.txt.html(detail.content);
const textLength = editorRoot.txt.text().replace(/\&nbsp\;/gi, " ")
.length;
const imgLength = contentHtml.match(/<img/g)
? contentHtml.match(/<img/g).length * 2
: 0;
const contentLength = imgLength + textLength;
this.setState(
{
contentLength,
visiblePlacehold: contentLength === 0 && !this.state.focusFlag,
},
() => {
onChange && onChange(contentHtml, this.state.contentLength);
}
);
}
if (detailInfo.content) { if (detailInfo.content) {
const contentHtml = /^\<p/.test(detailInfo.content) const contentHtml = /^\<p/.test(detailInfo.content)
? detailInfo.content ? detailInfo.content
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-25 11:26:28 * @Date: 2021-02-25 11:26:28
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 16:42:41 * @LastEditTime: 2021-03-15 09:42:30
* @Description: 助学工具-题库-题目管理右侧内容样式 * @Description: 助学工具-题库-题目管理右侧内容样式
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
.question-manage-content { .question-manage-content {
.question-manage-filter { .question-manage-filter {
position: relative; position: relative;
.search-condition { .search-condition {
...@@ -57,12 +57,10 @@ ...@@ -57,12 +57,10 @@
cursor: pointer; cursor: pointer;
} }
.record-name { .record-name {
word-break: break-all;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; white-space: nowrap;
-webkit-line-clamp: 5; width: 232px;
-webkit-box-orient: vertical;
} }
.record-operate { .record-operate {
display: flex; display: flex;
......
/* /*
* @Author: chenjianyu * @Author: chenjianyu
* @Date: 2020-09-12 17:00:44 * @Date: 2020-09-12 17:00:44
* @LastEditTime: 2021-03-13 11:19:38 * @LastEditTime: 2021-03-15 13:00:10
* @LastEditors: yuananting * @LastEditors: yuananting
* @Description: 答题模式模板 * @Description: 答题模式模板
* @Copyright © 2020 杭州杰竞科技有限公司 版权所有 * @Copyright © 2020 杭州杰竞科技有限公司 版权所有
...@@ -73,7 +73,7 @@ export function defineQuestionInfo(questionType) { ...@@ -73,7 +73,7 @@ export function defineQuestionInfo(questionType) {
export function defineOptionInfo() { export function defineOptionInfo() {
return { return {
isCorrectAnswer: false, // 是否为正确答案选项 isCorrectAnswer: 0, // 是否为正确答案选项
questionOptionContentList: [ // 选项内容 questionOptionContentList: [ // 选项内容
{ {
contentType: "QUESTION_OPTION", // 内容类型(默认选项) contentType: "QUESTION_OPTION", // 内容类型(默认选项)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-22 17:51:28 * @Date: 2021-02-22 17:51:28
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-13 14:26:31 * @LastEditTime: 2021-03-15 09:56:59
* @Description: 助学工具-题库-题库新建或编辑题库分类模态框 * @Description: 助学工具-题库-题库新建或编辑题库分类模态框
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -10,7 +10,6 @@ import React, { Component } from "react"; ...@@ -10,7 +10,6 @@ import React, { Component } from "react";
import { Modal, Form, Input, message } from "antd"; import { Modal, Form, Input, message } from "antd";
import User from "@/common/js/user"; import User from "@/common/js/user";
import QuestionBankService from "@/domains/question-bank-domain/QuestionBankService"; import QuestionBankService from "@/domains/question-bank-domain/QuestionBankService";
import { node } from "prop-types";
class NewEditQuestionBankCategory extends Component { class NewEditQuestionBankCategory extends Component {
formRef = React.createRef(); formRef = React.createRef();
constructor(props) { constructor(props) {
...@@ -31,7 +30,7 @@ class NewEditQuestionBankCategory extends Component { ...@@ -31,7 +30,7 @@ class NewEditQuestionBankCategory extends Component {
queryCategoryTree = () => { queryCategoryTree = () => {
let query = { let query = {
source: 0, source: 0,
userId: User.getUserId(), userId: User.getStoreUserId(),
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
}; };
QuestionBankService.queryCategoryTree(query).then((res) => { QuestionBankService.queryCategoryTree(query).then((res) => {
...@@ -47,7 +46,7 @@ class NewEditQuestionBankCategory extends Component { ...@@ -47,7 +46,7 @@ class NewEditQuestionBankCategory extends Component {
let params = { let params = {
source: 0, source: 0,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getUserId(), userId: User.getStoreUserId(),
}; };
if (type === "new") { if (type === "new") {
//新增 //新增
......
.question-modal-content {
position: relative;
.question-type {
margin-bottom: 16px;
&__title {
height: 22px;
font-size: 16px;
color: #333333;
line-height: 22px;
margin-bottom: 8px;
}
&__content {
font-size: 14px;
font-weight: 400;
color: #666666;
}
}
.question-stem {
margin-bottom: 16px;
img {
max-width: 88px;
max-height: 88px;
}
&__title {
height: 22px;
font-size: 16px;
color: #333333;
line-height: 22px;
margin-bottom: 8px;
}
&__content {
font-size: 14px;
font-weight: 400;
color: #666666;
.input-box {
margin-bottom: 8px;
* {
display: inline-block;
}
}
.picture-box {
display: inline-flex;
margin: 12px 12px 0 0;
}
.voice-box {
margin-bottom: 12px;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
padding: 10px 20px;
width: 320px;
}
}
}
.question-option {
margin-bottom: 16px;
img {
max-width: 88px;
max-height: 88px;
}
&__title {
height: 22px;
font-size: 16px;
color: #333333;
line-height: 22px;
margin-bottom: 8px;
}
&__content {
font-size: 14px;
font-weight: 400;
color: #666666;
.option-box {
color: #666666;
margin-bottom: 8px;
.option-box-header {
.option-sort {
display: inline-block;
margin-right: 5px;
}
.input-box {
display: inline-block;
max-width: calc(100% - 20px);
vertical-align: top;
}
}
.picture-box {
display: inline-flex;
margin: 12px 12px 0 0;
}
.voice-box {
margin-bottom: 12px;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
padding: 10px 20px;
width: 320px;
}
}
}
}
.question-answer {
margin-bottom: 16px;
img {
max-width: 88px;
max-height: 88px;
}
&__title {
height: 22px;
font-size: 16px;
color: #333333;
line-height: 22px;
margin-bottom: 8px;
}
&__content {
font-size: 14px;
font-weight: 400;
color: #666666;
.option-sort {
display: inline-block;
margin-right: 8px;
}
}
}
.question-desc {
margin-bottom: 16px;
&__title {
height: 22px;
font-size: 16px;
color: #333333;
line-height: 22px;
margin-bottom: 8px;
}
&__content {
font-size: 14px;
font-weight: 400;
color: #666666;
.desc-input-box {
margin-bottom: 8px;
* {
display: inline-block;
}
}
.desc-picture-box {
display: inline-flex;
margin-bottom: 28px;
.picture-box {
width: 88px;
height: 88px;
border-radius: 4px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
margin-right: 12px;
.img-box {
max-width: 88px;
max-height: 88px;
border-radius: 4px;
}
}
}
.desc-audio-box {
margin-bottom: 28px;
.audio-box {
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
padding: 10px 20px;
width: 320px;
margin-bottom: 12px;
}
}
.desc-video-box {
.video-box {
position: relative;
display: inline-block;
width: 208px;
overflow: hidden;
padding-top: 12px;
margin: 0px 12px 12px 0;
&_content {
max-width: 200px;
max-height: 200px;
border-radius: 4px;
}
&_btn {
width: 32px;
height: 32px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -8px;
margin-left: -16px;
}
}
}
}
}
}
.question-preview-modal.ant-modal {
max-height: 60% !important;
}
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