Commit 0e1a2057 by yuananting

feat:云盘上传文件

parent 83229b62
/*
* @Author: 陈剑宇
* @Date: 2020-10-28 14:27:07
* @LastEditTime: 2021-02-28 14:22:13
* @LastEditTime: 2021-03-17 20:27:44
* @LastEditors: yuananting
* @Description:
* @FilePath: /xiaomai-web-b/app/common/constants/punchClock/punchClock.js
......@@ -113,6 +113,12 @@ export const FILE_ACCEPT = {
VOICE: 'audio/x-mpeg,audio/mp3,audio/mpeg,audio/wav,audio/x-m4a'
}
export const MEDIA_FILE_ACCEPT = {
PICTURE: 'JPG,JPEG,PNG,BMP,GIF',
VIDEO: 'MP4',
VOICE: 'MP3'
}
export const QUESTION_FILE_ACCEPT = {
PICTURE: 'image/jpg,image/jpeg,image/png,image/gif',
VIDEO: 'audio/mp4,video/mp4',
......
......@@ -2,12 +2,12 @@
* @Author: yuananting
* @Date: 2021-02-25 13:46:35
* @LastEditors: yuananting
* @LastEditTime: 2021-03-17 10:45:10
* @LastEditTime: 2021-03-18 09:32:02
* @Description: 助学工具-题库-题目管理-新增题目
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import React, { Component } from "react";
import { Tabs, Button, Tooltip, message } from "antd";
import { Tabs, Button, Tooltip, message, Modal } from "antd";
import Breadcrumbs from "@/components/Breadcrumbs";
import ShowTips from "@/components/ShowTips";
import "./AddNewQuestion.less";
......@@ -21,8 +21,16 @@ const { TabPane } = Tabs;
class AddNewQuestion extends Component {
constructor(props) {
super(props);
let activeKey = ""
if (getParameterByName("type")) {
activeKey = getParameterByName("type")
} else if (getParameterByName("key")) {
activeKey = getParameterByName("key")
} else {
activeKey = "SINGLE_CHOICE"
}
this.state = {
activeKey: getParameterByName("type") || "SINGLE_CHOICE",
activeKey: activeKey,
// 构建题目基本结构
singleChoiceContent: defineQuestionInfo("SINGLE_CHOICE"), // 单选题
multiChoiceContent: defineQuestionInfo("MULTI_CHOICE"), // 多选题
......@@ -69,7 +77,7 @@ class AddNewQuestion extends Component {
});
};
saveCurrentQuestion = (content) => {
saveCurrentQuestion = (content, type, next) => {
content.questionStemList.map((item, index) => {
item.sort = index;
return item;
......@@ -101,9 +109,16 @@ class AddNewQuestion extends Component {
QuestionBankService.editQuestion(params).then((res) => {
if (res.success) {
message.success("保存成功");
window.RCHistory.push({
pathname: `/question-bank-index?categoryId=${params.categoryId}`,
});
if (next === 'add') {
window.RCHistory.push({
pathname: `/create-new-question?categoryId=${params.categoryId}&key=${type}`,
});
}
if (next === 'close') {
window.RCHistory.push({
pathname: `/question-bank-index?categoryId=${params.categoryId}`,
});
}
}
});
} else {
......@@ -117,15 +132,36 @@ class AddNewQuestion extends Component {
QuestionBankService.addQuestion(params).then((res) => {
if (res.success) {
message.success("保存成功");
window.RCHistory.push({
pathname: `/question-bank-index?categoryId=${params.categoryId}`,
});
if (next === 'add') {
window.RCHistory.push({
pathname: `/create-new-question?categoryId=${params.categoryId}&key=${type}`,
});
}
if (next === 'close') {
window.RCHistory.push({
pathname: `/question-bank-index?categoryId=${params.categoryId}`,
});
}
}
});
}
};
confirmSaveQuestion = () => {
// 取消编辑并返回上一级路由
handleGoBack = () => {
Modal.confirm({
title: '确定要返回吗?',
content: '返回后,本次编辑的内容将不被保存',
okText: '确认返回',
cancelText: '留在本页',
icon: <span className="icon iconfont default-confirm-icon">&#xe6f4;</span>,
onOk: () => {
window.RCHistory.goBack();
}
})
}
confirmSaveQuestion = (next) => {
const {
singleChoiceContent,
multiChoiceContent,
......@@ -136,27 +172,27 @@ class AddNewQuestion extends Component {
switch (this.state.activeKey) {
case "SINGLE_CHOICE":
if (this.singleChoiceRef.checkInput() === 0) {
this.saveCurrentQuestion(singleChoiceContent);
this.saveCurrentQuestion(singleChoiceContent, "SINGLE_CHOICE", next);
}
break;
case "MULTI_CHOICE":
if (this.multiChoiceRef.checkInput() === 0) {
this.saveCurrentQuestion(multiChoiceContent);
this.saveCurrentQuestion(multiChoiceContent, "MULTI_CHOICE", next);
}
break;
case "JUDGE":
if (this.judgeRef.checkInput() === 0) {
this.saveCurrentQuestion(judgeContent);
this.saveCurrentQuestion(judgeContent, "JUDGE", next);
}
break;
case "GAP_FILLING":
if (this.gapRef.checkInput() === 0) {
this.saveCurrentQuestion(gapFillingContent);
}
// if (this.gapRef.checkInput() === 0) {
this.saveCurrentQuestion(gapFillingContent, "GAP_FILLING", next);
// }
break;
case "INDEFINITE_CHOICE":
if (this.indefiniteRef.checkInput() === 0) {
this.saveCurrentQuestion(indefiniteChoiceContent);
this.saveCurrentQuestion(indefiniteChoiceContent, "INDEFINITE_CHOICE", next);
}
break;
}
......@@ -180,7 +216,7 @@ class AddNewQuestion extends Component {
<div className="page add-new-question">
<Breadcrumbs
navList={getParameterByName("id") ? "编辑题目" : "新增题目"}
goBack={() => RCHistory.goBack()}
goBack={() => this.handleGoBack()}
/>
<div className="box">
<div className="show-tips">
......@@ -198,12 +234,13 @@ class AddNewQuestion extends Component {
key="SINGLE_CHOICE"
>
<NewQuestionTab
questionTypeKey="SINGLE_CHOICE"
questionTypeKey={activeKey}
onRef={(ref) => {
this.singleChoiceRef = ref;
}}
questionInfo={singleChoiceContent}
onSetState={(newContent) => {
console.log("newContent:", newContent)
Object.assign(singleChoiceContent, newContent);
}}
onLogger={this.handleLogger}
......@@ -214,7 +251,7 @@ class AddNewQuestion extends Component {
key="MULTI_CHOICE"
>
<NewQuestionTab
questionTypeKey="MULTI_CHOICE"
questionTypeKey={activeKey}
onRef={(ref) => {
this.multiChoiceRef = ref;
}}
......@@ -230,7 +267,7 @@ class AddNewQuestion extends Component {
key="JUDGE"
>
<NewQuestionTab
questionTypeKey="JUDGE"
questionTypeKey={activeKey}
onRef={(ref) => {
this.judgeRef = ref;
}}
......@@ -245,14 +282,14 @@ class AddNewQuestion extends Component {
key="GAP_FILLING"
>
<NewQuestionTab
questionTypeKey="GAP_FILLING"
questionTypeKey={activeKey}
onRef={(ref) => {
this.gapRef = ref;
}}
questionInfo={gapFillingContent}
onSetState={(newContent) => {
Object.assign(gapFillingContent, newContent);
console.log("gapFillingContent:", gapFillingContent);
console.log("gapFillingContent:", newContent);
}}
/>
</TabPane>
......@@ -268,7 +305,7 @@ class AddNewQuestion extends Component {
key="INDEFINITE_CHOICE"
>
<NewQuestionTab
questionTypeKey="INDEFINITE_CHOICE"
questionTypeKey={activeKey}
onRef={(ref) => {
this.indefiniteRef = ref;
}}
......@@ -282,12 +319,14 @@ class AddNewQuestion extends Component {
</Tabs>
</div>
<div className="footer">
<Button>取消</Button>
<Button>保存并继续添加</Button>
<Button onClick={() => { this.handleGoBack() }}>取消</Button>
<Button onClick={() => {
this.confirmSaveQuestion("add");
}}>保存并继续添加</Button>
<Button
type="primary"
onClick={() => {
this.confirmSaveQuestion();
this.confirmSaveQuestion("close");
}}
>
保存
......
......@@ -2,11 +2,11 @@
* @Author: yuananting
* @Date: 2021-02-25 13:52:01
* @LastEditors: yuananting
* @LastEditTime: 2021-03-08 19:07:56
* @LastEditTime: 2021-03-18 09:32:11
* @Description: 助学工具-题库-题目管理-新增题目样式
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
.add-new-question {
.add-new-question {
position: relative !important;
.box {
margin-bottom: 66px !important;
......
......@@ -33,7 +33,7 @@ class QuestionBankIndex extends Component {
}
};
updatedSiderTreeFromList = (updatedCategoryId) => {
updatedSiderTreeFromList = (updatedCategoryId) => {
this.setState({updatedCategoryId});
};
......
......@@ -2,11 +2,11 @@
* @Author: yuananting
* @Date: 2021-02-21 18:27:43
* @LastEditors: yuananting
* @LastEditTime: 2021-03-11 19:10:44
* @LastEditTime: 2021-03-18 09:32:24
* @Description: 助学工具-题库-题库主页面样式
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
.question-bank-index {
.question-bank-index {
.content-body {
display: flex;
.site-layout-background {
......
......@@ -2,11 +2,11 @@
* @Author: yuananting
* @Date: 2021-02-23 19:41:42
* @LastEditors: yuananting
* @LastEditTime: 2021-03-05 09:34:00
* @LastEditTime: 2021-03-18 09:32:37
* @Description: 助学工具-题库-题目分类管理样式
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
.question-category-manage {
.question-category-manage {
position: relative;
.search-condition {
width: 30%;
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-22 10:59:43
* @LastEditors: yuananting
* @LastEditTime: 2021-03-15 15:22:13
* @LastEditTime: 2021-03-18 09:33:50
* @Description: 助学工具-题库-题库主页面侧边栏
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......
......@@ -2,11 +2,11 @@
* @Author: yuananting
* @Date: 2021-02-22 12:02:34
* @LastEditors: yuananting
* @LastEditTime: 2021-03-11 20:29:44
* @LastEditTime: 2021-03-18 09:34:06
* @Description: 助学工具-题库-题库主页面侧边栏样式
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
.question-bank-sider {
.question-bank-sider {
position: relative;
.sider-title {
height: 22px;
......
......@@ -49,9 +49,15 @@ class QuestionEditor extends Component {
this.renderEditor();
}
static getDerivedStateFromProps(nextProps, prevState) {
return {
detailInfo: nextProps.detailInfo
}
}
shouldComponentUpdate(nextProps, nextState) {
const { detailInfo } = nextProps;
if (this.props.detailInfo !== detailInfo) {
if (this.state.detailInfo !== detailInfo) {
this.setState({ detailInfo: nextProps.detailInfo }, () => {
this.renderEditor();
});
......@@ -127,7 +133,6 @@ class QuestionEditor extends Component {
};
editorRoot.customConfig.onchange = (html) => {
console.log("触发:+——+++++++", this.state.blanksList);
const { focusFlag } = this.state;
const textLength = editorRoot.txt.text().replace(/\&nbsp\;/gi, " ")
.length;
......@@ -174,27 +179,27 @@ class QuestionEditor extends Component {
editorRoot.create();
this.editorRoot = editorRoot;
if (detailInfo.content) {
const contentHtml = /^\<p/.test(detailInfo.content)
? detailInfo.content
: `<p>${detailInfo.content}</p>`;
editorRoot.txt.html(detailInfo.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 && detailInfo.content) {
const contentHtml = /^\<p/.test(detailInfo.content)
? detailInfo.content
: `<p>${detailInfo.content}</p>`;
editorRoot.txt.html(detailInfo.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);
}
);
// }
bindChangeContent && bindChangeContent(this.handleChangeContent);
}
......@@ -207,6 +212,9 @@ class QuestionEditor extends Component {
var _blanksList = [];
_blanksList = document.getElementsByClassName("add-fill-line");
this.setState({ blanksList: _blanksList });
this.setState({
visiblePlacehold: false,
});
// this.props.changeBlankCount(_blanksList);
};
......@@ -288,9 +296,8 @@ class QuestionEditor extends Component {
</div>
)}
<div
className={`editor-limit-tip${
contentLength > limitLength ? " mt6" : ""
}`}
className={`editor-limit-tip${contentLength > limitLength ? " mt6" : ""
}`}
style={{ height: contentLength > limitLength ? 20 : 0 }}
>
最多只能输入1000字
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-25 11:23:47
* @LastEditors: yuananting
* @LastEditTime: 2021-03-17 12:43:53
* @LastEditTime: 2021-03-18 09:35:03
* @Description: 助学工具-题库-题目管理主页面列表数据
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......@@ -84,7 +84,7 @@ class QuestionManageContent extends Component {
};
}
componentDidMount() {}
componentDidMount() { }
shouldComponentUpdate(nextProps, nextState) {
const { selectedCategoryId } = nextProps;
......@@ -211,6 +211,8 @@ class QuestionManageContent extends Component {
// 表头设置
parseColumns = () => {
const isPermiss = ["CloudManager", "StoreManager"].includes(User.getUserRole());
console.log(isPermiss, User.getUserRole())
const columns = [
{
title: "题目",
......@@ -273,22 +275,22 @@ class QuestionManageContent extends Component {
>
预览
</div>
<span className="record-operate__item split"> | </span>
<div
{isPermiss && <span className="record-operate__item split"> | </span>}
{isPermiss && <div
className="record-operate__item"
onClick={() =>
this.toEditQuetion(record.id, record.questionTypeEnum)
}
>
编辑
</div>
<span className="record-operate__item split"> | </span>
<div
</div>}
{isPermiss && <span className="record-operate__item split"> | </span>}
{isPermiss && <div
className="record-operate__item"
onClick={() => this.delCategoryConfirm(record)}
>
删除
</div>
</div>}
</div>
);
},
......@@ -311,9 +313,7 @@ class QuestionManageContent extends Component {
<span
className="empty-list-tip"
onClick={() => {
window.RCHistory.push({
pathname: "/create-question-bank",
});
this.handleCreateQuestionBank()
}}
>
新建一个
......@@ -356,7 +356,7 @@ class QuestionManageContent extends Component {
const ImportQuestionModal = (
<BatchImportQuestionModal
close={() => {
this.setState({ ImportQuestionModal: null });
this.setState({ ImportQuestionModal: null }, () => { this.queryQuestionPageList(); this.props.updatedSiderTree(this.props.selectedCategoryId) });
}}
categoryId={categoryId}
/>
......@@ -430,7 +430,7 @@ class QuestionManageContent extends Component {
</div>
</Row>
</div>
{!["0", null].includes(categoryId) && (
{(["CloudManager", "StoreManager"].includes(User.getUserRole()) && !["0", null].includes(categoryId)) && (
<Space size="large">
<Button type="primary" onClick={this.handleCreateQuestionBank}>
新建题目
......
/*
* @Author: chenjianyu
* @Date: 2020-09-12 17:00:44
* @LastEditTime: 2021-03-15 13:00:10
* @LastEditTime: 2021-03-18 09:33:26
* @LastEditors: yuananting
* @Description: 答题模式模板
* @Copyright © 2020 杭州杰竞科技有限公司 版权所有
......@@ -54,7 +54,7 @@ export function defineQuestionInfo(questionType) {
type: "RICH_TEXT", // 内容项形式(0:富文本 1:文字 2:图片 3:语音 4:视频 5文件 6.课件)
}
], // 题干
optionList: [], // 非填空题选项
optionList: questionType === "JUDGE" ? [] : [], // 非填空题选项
gapFillingAnswerList: [
{
correctAnswerList: []
......@@ -84,6 +84,19 @@ export function defineOptionInfo() {
}
}
export function defineJudgeOptionInfo(content) {
return {
isCorrectAnswer: 0, // 是否为正确答案选项
questionOptionContentList: [ // 选项内容
{
contentType: "QUESTION_OPTION", // 内容类型(默认选项)
content, // 内容
type: "RICH_TEXT",
}
]
}
}
export function defineOptionData(content = '') {
return {
itemContentVOList: [{
......
......@@ -101,6 +101,7 @@ class BatchImportQuestionModal extends Component {
return (
<div>
<Modal
closable={status !== "uploading"}
className="import-score-modal"
title="导入题目信息"
visible={true}
......@@ -218,7 +219,11 @@ class BatchImportQuestionModal extends Component {
<Button
type="primary"
className="down-btn"
// onClick={}
onClick={() => {
this.setState({ status: "init" })
this.setState({ uploadFile: null })
this.setState({ showSelectFileModal: true })
}}
>
重新上传文件
</Button>
......
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-02-22 17:51:28
* @LastEditors: yuananting
* @LastEditTime: 2021-03-15 09:56:59
* @LastEditTime: 2021-03-18 09:32:59
* @Description: 助学工具-题库-题库新建或编辑题库分类模态框
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
......
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