Commit a9eec6b0 by yuananting

fix:bug修复

parent 61203172
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-25 14:34:29 * @Date: 2021-02-25 14:34:29
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-22 13:22:50 * @LastEditTime: 2021-03-22 16:53:42
* @Description: 助学工具-题库-题目管理-新建题目Tab * @Description: 助学工具-题库-题目管理-新建题目Tab
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -613,7 +613,7 @@ class NewQuestionTab extends Component { ...@@ -613,7 +613,7 @@ class NewQuestionTab extends Component {
this.setState({ blanksList: _blanksList }); this.setState({ blanksList: _blanksList });
}; };
handleTagClose = (optionItem, removedTag) => { handleTagClose = (optionItem, removedTag, removedIndex) => {
const _blanksList = this.state.blanksList; const _blanksList = this.state.blanksList;
const { gapFillingAnswer } = this.state; const { gapFillingAnswer } = this.state;
let _gapFillingAnswer = [...gapFillingAnswer]; let _gapFillingAnswer = [...gapFillingAnswer];
...@@ -621,7 +621,9 @@ class NewQuestionTab extends Component { ...@@ -621,7 +621,9 @@ class NewQuestionTab extends Component {
if (item.id === optionItem.id) { if (item.id === optionItem.id) {
_gapFillingAnswer[index].correctAnswerList = _gapFillingAnswer[ _gapFillingAnswer[index].correctAnswerList = _gapFillingAnswer[
index index
].correctAnswerList.filter((tag) => tag !== removedTag); ].correctAnswerList.filter(
(tag, index) => tag !== removedTag || index !== removedIndex
);
} }
}); });
this.setState({ gapFillingAnswer: _gapFillingAnswer }, () => this.setState({ gapFillingAnswer: _gapFillingAnswer }, () =>
...@@ -671,7 +673,7 @@ class NewQuestionTab extends Component { ...@@ -671,7 +673,7 @@ class NewQuestionTab extends Component {
className="edit-tag" className="edit-tag"
visible visible
closable closable
onClose={() => this.handleTagClose(optionItem, tag)} onClose={() => this.handleTagClose(optionItem, tag, index)}
> >
{tag} {tag}
</Tag> </Tag>
......
...@@ -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-22 14:28:13 * @LastEditTime: 2021-03-22 15:26:27
* @Description: 助学工具-题库-题库主页面侧边栏 * @Description: 助学工具-题库-题库主页面侧边栏
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -18,9 +18,12 @@ const { DirectoryTree } = Tree; ...@@ -18,9 +18,12 @@ const { DirectoryTree } = Tree;
class QuestionBankSider extends Component { class QuestionBankSider extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
const categoryId = getParameterByName("categoryId");
this.state = { this.state = {
selectedKeys: getParameterByName("categoryId") selectedKeys: categoryId
? [getParameterByName("categoryId")] ? categoryId === "null"
? ["0"]
: [categoryId]
: ["0"], : ["0"],
searchValue: null, searchValue: null,
NewEditQuestionBankCategory: null, //新增或编辑分类模态框 NewEditQuestionBankCategory: null, //新增或编辑分类模态框
...@@ -41,7 +44,10 @@ class QuestionBankSider extends Component { ...@@ -41,7 +44,10 @@ class QuestionBankSider extends Component {
shouldComponentUpdate(nextProps, nextState) { shouldComponentUpdate(nextProps, nextState) {
const { currentTotal, updatedCategoryId } = nextProps; const { currentTotal, updatedCategoryId } = nextProps;
if (this.props.currentTotal !== currentTotal && this.props.updatedCategoryId === updatedCategoryId) { if (
this.props.currentTotal !== currentTotal &&
this.props.updatedCategoryId === updatedCategoryId
) {
this.queryCategoryTree(); this.queryCategoryTree();
} }
return true; return true;
...@@ -185,17 +191,19 @@ class QuestionBankSider extends Component { ...@@ -185,17 +191,19 @@ class QuestionBankSider extends Component {
this.queryCategoryTree(value); this.queryCategoryTree(value);
}} }}
/> />
{User.getUserRole() !== "CloudLecturer" && <div className="sider-btn"> {User.getUserRole() !== "CloudLecturer" && (
<Button <div className="sider-btn">
onClick={() => { <Button
window.RCHistory.push({ onClick={() => {
pathname: "/question-category-manage?from=aid", window.RCHistory.push({
}); pathname: "/question-category-manage?from=aid",
}} });
> }}
分类管理 >
</Button> 分类管理
</div>} </Button>
</div>
)}
<div className="sider-tree"> <div className="sider-tree">
<DirectoryTree <DirectoryTree
expandedKeys={expandedKeys} expandedKeys={expandedKeys}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-25 11:23:47 * @Date: 2021-02-25 11:23:47
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-22 14:28:40 * @LastEditTime: 2021-03-22 15:26:55
* @Description: 助学工具-题库-题目管理主页面列表数据 * @Description: 助学工具-题库-题目管理主页面列表数据
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -84,12 +84,15 @@ class QuestionManageContent extends Component { ...@@ -84,12 +84,15 @@ class QuestionManageContent extends Component {
}; };
} }
componentDidMount() { } componentDidMount() {}
shouldComponentUpdate(nextProps, nextState) { shouldComponentUpdate(nextProps, nextState) {
const { selectedCategoryId } = nextProps; let { selectedCategoryId } = nextProps;
const _query = this.state.query; const _query = this.state.query;
if (this.props.selectedCategoryId !== selectedCategoryId) { if (this.props.selectedCategoryId !== selectedCategoryId) {
if (selectedCategoryId === "null") {
selectedCategoryId = null;
}
_query.categoryId = selectedCategoryId; _query.categoryId = selectedCategoryId;
_query.questionName = null; _query.questionName = null;
_query.questionType = null; _query.questionType = null;
...@@ -105,7 +108,9 @@ class QuestionManageContent extends Component { ...@@ -105,7 +108,9 @@ class QuestionManageContent extends Component {
QuestionBankService.queryQuestionPageList(_query).then((res) => { QuestionBankService.queryQuestionPageList(_query).then((res) => {
const { records = [], total = 0 } = res.result; const { records = [], total = 0 } = res.result;
this.setState({ dataSource: records }); this.setState({ dataSource: records });
this.setState({ total }, () => this.props.updatedSiderTree(total, this.props.selectedCategoryId)); this.setState({ total }, () =>
this.props.updatedSiderTree(total, this.props.selectedCategoryId)
);
}); });
}; };
...@@ -210,7 +215,9 @@ class QuestionManageContent extends Component { ...@@ -210,7 +215,9 @@ class QuestionManageContent extends Component {
// 表头设置 // 表头设置
parseColumns = () => { parseColumns = () => {
const isPermiss = ["CloudManager", "StoreManager"].includes(User.getUserRole()); const isPermiss = ["CloudManager", "StoreManager"].includes(
User.getUserRole()
);
const columns = [ const columns = [
{ {
title: "题目", title: "题目",
...@@ -271,22 +278,30 @@ class QuestionManageContent extends Component { ...@@ -271,22 +278,30 @@ class QuestionManageContent extends Component {
> >
预览 预览
</div> </div>
{isPermiss && <span className="record-operate__item split"> | </span>} {isPermiss && (
{isPermiss && <div <span className="record-operate__item split"> | </span>
className="record-operate__item" )}
onClick={() => {isPermiss && (
this.toEditQuetion(record.id, record.questionTypeEnum) <div
} className="record-operate__item"
> onClick={() =>
编辑 this.toEditQuetion(record.id, record.questionTypeEnum)
</div>} }
{isPermiss && <span className="record-operate__item split"> | </span>} >
{isPermiss && <div 编辑
className="record-operate__item" </div>
onClick={() => this.delCategoryConfirm(record)} )}
> {isPermiss && (
删除 <span className="record-operate__item split"> | </span>
</div>} )}
{isPermiss && (
<div
className="record-operate__item"
onClick={() => this.delCategoryConfirm(record)}
>
删除
</div>
)}
</div> </div>
); );
}, },
...@@ -306,16 +321,22 @@ class QuestionManageContent extends Component { ...@@ -306,16 +321,22 @@ class QuestionManageContent extends Component {
}} }}
description={ description={
<div> <div>
<span>还没有题目</span>{(["CloudManager", "StoreManager"].includes(User.getUserRole()) && !["0", null].includes(categoryId)) && (<span>,快去 <span>还没有题目</span>
<span {["CloudManager", "StoreManager"].includes(User.getUserRole()) &&
className="empty-list-tip" !["0", null].includes(categoryId) && (
onClick={() => { <span>
this.handleCreateQuestionBank() ,快去
}} <span
> className="empty-list-tip"
新建一个 onClick={() => {
</span> this.handleCreateQuestionBank();
吧!</span>)} }}
>
新建一个
</span>
吧!
</span>
)}
</div> </div>
} }
></Empty> ></Empty>
...@@ -353,7 +374,10 @@ class QuestionManageContent extends Component { ...@@ -353,7 +374,10 @@ class QuestionManageContent extends Component {
const ImportQuestionModal = ( const ImportQuestionModal = (
<BatchImportQuestionModal <BatchImportQuestionModal
close={() => { close={() => {
this.setState({ ImportQuestionModal: null }, () => { this.queryQuestionPageList(); this.props.updatedSiderTree(this.props.selectedCategoryId) }); this.setState({ ImportQuestionModal: null }, () => {
this.queryQuestionPageList();
this.props.updatedSiderTree(this.props.selectedCategoryId);
});
}} }}
categoryId={categoryId} categoryId={categoryId}
/> />
...@@ -427,14 +451,15 @@ class QuestionManageContent extends Component { ...@@ -427,14 +451,15 @@ class QuestionManageContent extends Component {
</div> </div>
</Row> </Row>
</div> </div>
{(["CloudManager", "StoreManager"].includes(User.getUserRole()) && !["0", null].includes(categoryId)) && ( {["CloudManager", "StoreManager"].includes(User.getUserRole()) &&
<Space size="large"> !["0", null].includes(categoryId) && (
<Button type="primary" onClick={this.handleCreateQuestionBank}> <Space size="large">
新建题目 <Button type="primary" onClick={this.handleCreateQuestionBank}>
</Button> 新建题目
<Button onClick={this.batchImportQuestion}>批量导入</Button> </Button>
</Space> <Button onClick={this.batchImportQuestion}>批量导入</Button>
)} </Space>
)}
<div className="question-manage-list"> <div className="question-manage-list">
<ConfigProvider renderEmpty={this.customizeRenderEmpty}> <ConfigProvider renderEmpty={this.customizeRenderEmpty}>
<Table <Table
......
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-03-18 10:01:28 * @Date: 2020-03-18 10:01:28
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-03-22 09:46:07 * @LastEditTime: 2021-03-22 16:59:29
* @Description: 录音组件 * @Description: 录音组件
*/ */
import React, { Component } from 'react'; import React, { Component } from "react";
import { Button, Modal } from 'antd'; import { Button, Modal } from "antd";
import UploadOss from '@/core/upload'; import UploadOss from "@/core/upload";
import { RECORD_ERROR } from '@/common/constants/academic'; import { RECORD_ERROR } from "@/common/constants/academic";
import AudioRecorder from './audioRecord'; import AudioRecorder from "./audioRecord";
import './XMRecord.less'; import "./XMRecord.less";
class XMRecord extends Component { class XMRecord extends Component {
constructor(props) { constructor(props) {
...@@ -35,7 +35,7 @@ class XMRecord extends Component { ...@@ -35,7 +35,7 @@ class XMRecord extends Component {
this.getAudioRecorderDevice(); this.getAudioRecorderDevice();
} }
componentWillUnmount() { } componentWillUnmount() {}
getAudioRecorderDevice = () => { getAudioRecorderDevice = () => {
//仅用来进行录音 //仅用来进行录音
...@@ -50,10 +50,14 @@ class XMRecord extends Component { ...@@ -50,10 +50,14 @@ class XMRecord extends Component {
navigator.mediaDevices.getUserMedia = function (constraints) { navigator.mediaDevices.getUserMedia = function (constraints) {
// 首先,如果有getUserMedia的话,就获得它 // 首先,如果有getUserMedia的话,就获得它
var getUserMedia = var getUserMedia =
navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia;
// 一些浏览器根本没实现它 - 那么就返回一个error到promise的reject来保持一个统一的接口 // 一些浏览器根本没实现它 - 那么就返回一个error到promise的reject来保持一个统一的接口
if (!getUserMedia) { if (!getUserMedia) {
return Promise.reject(new Error('getUserMedia is not implemented in this browser')); return Promise.reject(
new Error("getUserMedia is not implemented in this browser")
);
} }
// 否则,为老的navigator.getUserMedia方法包裹一个Promise // 否则,为老的navigator.getUserMedia方法包裹一个Promise
...@@ -65,12 +69,12 @@ class XMRecord extends Component { ...@@ -65,12 +69,12 @@ class XMRecord extends Component {
}; };
openDeviceFailure = (reason) => { openDeviceFailure = (reason) => {
const { title = '麦克风调用错误', content = '请检查麦克风是否可用' } = const { title = "麦克风调用错误", content = "请检查麦克风是否可用" } =
RECORD_ERROR[reason.name] || {}; RECORD_ERROR[reason.name] || {};
Modal.info({ Modal.info({
title, title,
content, content,
okText: '我知道了', okText: "我知道了",
}); });
}; };
...@@ -115,17 +119,20 @@ class XMRecord extends Component { ...@@ -115,17 +119,20 @@ class XMRecord extends Component {
handleFinishRecord = () => { handleFinishRecord = () => {
const blob = this.mMediaRecorder.upload(); const blob = this.mMediaRecorder.upload();
UploadOss.uploadBlobToOSS(blob, window.random_string(16) + '.wav').then((mp3URL) => { UploadOss.uploadBlobToOSS(blob, window.random_string(16) + ".wav").then(
const { recordTime } = this.state; (mp3URL) => {
const { recordTime } = this.state;
this.props.onFinish(mp3URL, recordTime * 1000); this.props.onFinish(mp3URL, recordTime * 1000);
this.setState({ this.setState({
recordTime: 0, recordTime: 0,
isFinished: true, isFinished: true,
}); });
window.clearInterval(this.timer); window.clearInterval(this.timer);
this.mMediaRecorder.stop(); if (this.mMediaRecorder) {
}); this.mMediaRecorder.stop();
}
}
);
}; };
// 格式化当前录音时长 // 格式化当前录音时长
...@@ -148,8 +155,10 @@ class XMRecord extends Component { ...@@ -148,8 +155,10 @@ class XMRecord extends Component {
}, },
() => { () => {
this.props.onCancel(); this.props.onCancel();
this.mMediaRecorder.stop(); if (this.mMediaRecorder) {
}, this.mMediaRecorder.stop();
}
}
); );
}; };
...@@ -157,7 +166,7 @@ class XMRecord extends Component { ...@@ -157,7 +166,7 @@ class XMRecord extends Component {
const { isFinished, recordTime } = this.state; const { isFinished, recordTime } = this.state;
const { visible, maxTime = 180 } = this.props; const { visible, maxTime = 180 } = this.props;
return ( return (
<div className={`xm-record ${visible ? 'visible' : 'hidden'}`}> <div className={`xm-record ${visible ? "visible" : "hidden"}`}>
<div className="record-left"> <div className="record-left">
<div className="text"> <div className="text">
{isFinished ? ( {isFinished ? (
...@@ -170,9 +179,9 @@ class XMRecord extends Component { ...@@ -170,9 +179,9 @@ class XMRecord extends Component {
)} )}
{isFinished ? <span>录音</span> : <span>录音中...</span>} {isFinished ? <span>录音</span> : <span>录音中...</span>}
</div> </div>
<div className="time">{`${this.formatRecordTime(recordTime)}/${this.formatRecordTime( <div className="time">{`${this.formatRecordTime(
maxTime, recordTime
)}`}</div> )}/${this.formatRecordTime(maxTime)}`}</div>
</div> </div>
<div className="btn-wrapper"> <div className="btn-wrapper">
...@@ -182,7 +191,11 @@ class XMRecord extends Component { ...@@ -182,7 +191,11 @@ class XMRecord extends Component {
开始 开始
</Button> </Button>
) : ( ) : (
<Button type="primary" className="finish" onClick={this.handleFinishRecord}> <Button
type="primary"
className="finish"
onClick={this.handleFinishRecord}
>
完成 完成
</Button> </Button>
)} )}
......
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