Commit a9eec6b0 by yuananting

fix:bug修复

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