Commit 95bec18d by guomingpang

docs:删除无用的注释

parent c6b1c283
...@@ -7,33 +7,33 @@ ...@@ -7,33 +7,33 @@
* @Copyright: 杭州杰竞科技有限公司 版权所有 * @Copyright: 杭州杰竞科技有限公司 版权所有
*/ */
import React from 'react' import React from 'react';
import { Button, Input, message, Modal, Tooltip, Form, Popconfirm, Menu, Dropdown } from 'antd' import { Button, Input, message, Modal, Tooltip, Form, Popconfirm, Menu, Dropdown } from 'antd';
import { FileTypeIcon } from '@/common/constants/academic/lessonEnum' import { FileTypeIcon } from '@/common/constants/academic/lessonEnum';
import { CourseCatalogSelect } from '@/modules/common' import { CourseCatalogSelect } from '@/modules/common';
import ShowTips from '@/components/ShowTips' import ShowTips from '@/components/ShowTips';
import Breadcrumbs from '@/components/Breadcrumbs' import Breadcrumbs from '@/components/Breadcrumbs';
import moment from 'moment' import moment from 'moment';
import AddVideoIntro from './components/AddVideoIntro' import AddVideoIntro from './components/AddVideoIntro';
import SelectStudent from '../modal/select-student' import SelectStudent from '../modal/select-student';
import SelectPrepareFileModal from '../../prepare-lesson/modal/SelectPrepareFileModal' import SelectPrepareFileModal from '../../prepare-lesson/modal/SelectPrepareFileModal';
import PreviewCourseModal from '../modal/PreviewCourseModal' import PreviewCourseModal from '../modal/PreviewCourseModal';
import CourseService from '@/domains/course-domain/CourseService' import CourseService from '@/domains/course-domain/CourseService';
import Service from '@/common/js/service' import Service from '@/common/js/service';
import User from '@/common/js/user' import User from '@/common/js/user';
import _ from 'underscore' import _ from 'underscore';
import Upload from '@/core/upload' import Upload from '@/core/upload';
import { randomString } from '@/domains/basic-domain/utils' import { randomString } from '@/domains/basic-domain/utils';
import ImgClipModal from '@/components/ImgClipModal' import ImgClipModal from '@/components/ImgClipModal';
import $ from 'jquery' import $ from 'jquery';
import './AddVideoCourse.less' import './AddVideoCourse.less';
import Bus from '@/core/bus' import Bus from '@/core/bus';
const { TextArea } = Input const { TextArea } = Input;
const EDIT_BOX_KEY = Math.random() const EDIT_BOX_KEY = Math.random();
//添加课程时课程默认的一些值 //添加课程时课程默认的一些值
const defaultShelfState = 'YES' const defaultShelfState = 'YES';
const defaultScheduleMedia = [ const defaultScheduleMedia = [
{ {
contentType: 'INTRO', contentType: 'INTRO',
...@@ -41,23 +41,23 @@ const defaultScheduleMedia = [ ...@@ -41,23 +41,23 @@ const defaultScheduleMedia = [
mediaContent: '', mediaContent: '',
key: EDIT_BOX_KEY, key: EDIT_BOX_KEY,
}, },
] ];
const whetherVisitorsJoin = 'NO' const whetherVisitorsJoin = 'NO';
let cutFlag = false let cutFlag = false;
const SUPPORT_WORD_PDF = [ const SUPPORT_WORD_PDF = [
'application/msword', 'application/msword',
'application/wps-writer', 'application/wps-writer',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/pdf', 'application/pdf',
'application/wps-office.pdf', 'application/wps-office.pdf',
] ];
class AddVideoCourse extends React.Component { class AddVideoCourse extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props);
const id = getParameterByName('id') const id = getParameterByName('id');
const pageType = getParameterByName('type') const pageType = getParameterByName('type');
this.state = { this.state = {
id, // 线上课ID,编辑的时候从URL上带过来 id, // 线上课ID,编辑的时候从URL上带过来
...@@ -93,59 +93,59 @@ class AddVideoCourse extends React.Component { ...@@ -93,59 +93,59 @@ class AddVideoCourse extends React.Component {
mediaNameAlias: '', // 任一视频重命名的名称(气泡框) mediaNameAlias: '', // 任一视频重命名的名称(气泡框)
selectTypeList: ['MP4'], selectTypeList: ['MP4'],
accept: 'video/mp4', accept: 'video/mp4',
} };
} }
componentWillMount() { componentWillMount() {
const { id, pageType } = this.state const { id, pageType } = this.state;
if (pageType === 'edit') { if (pageType === 'edit') {
this.handleFetchScheudleDetail(id) this.handleFetchScheudleDetail(id);
} }
Bus.bind('editorLimit', (editorTextLength) => { Bus.bind('editorLimit', (editorTextLength) => {
this.setState({ this.setState({
editorTextLength, editorTextLength,
}) });
}) });
} }
handleChangeCatalogList = (value, label) => { handleChangeCatalogList = (value, label) => {
this.setState({ categoryId: value, categoryName: label[0] }) this.setState({ categoryId: value, categoryName: label[0] });
} };
// 获取线上课详情 // 获取线上课详情
handleFetchScheudleDetail = (courseId) => { handleFetchScheudleDetail = (courseId) => {
CourseService.videoScheduleDetail({ CourseService.videoScheduleDetail({
courseId, courseId,
}).then((res) => { }).then((res) => {
const { result = {} } = res || {} const { result = {} } = res || {};
const { courseName, shelfState, whetherVisitorsJoin, courseMediaVOS, categoryId, courseChapterVOList = [] } = result const { courseName, shelfState, whetherVisitorsJoin, courseMediaVOS, categoryId, courseChapterVOList = [] } = result;
let coverId let coverId;
let coverUrl let coverUrl;
let scheduleMedia = [] let scheduleMedia = [];
let scheduleVideoUrl let scheduleVideoUrl;
let hasIntro let hasIntro;
courseMediaVOS.map((item) => { courseMediaVOS.map((item) => {
switch (item.contentType) { switch (item.contentType) {
case 'COVER': case 'COVER':
coverId = item.mediaContent coverId = item.mediaContent;
coverUrl = item.mediaUrl coverUrl = item.mediaUrl;
break break;
case 'INTRO': case 'INTRO':
hasIntro = true hasIntro = true;
this.getTextDetail('introduce', item.mediaUrl) this.getTextDetail('introduce', item.mediaUrl);
break break;
default: default:
break break;
} }
return item return item;
}) });
const _courseChapterVOList = courseChapterVOList.map((item) => { const _courseChapterVOList = courseChapterVOList.map((item) => {
item.mediaName = item.name item.mediaName = item.name;
item.resourceId = item.id item.resourceId = item.id;
return item return item;
}) });
this.setState({ this.setState({
loadintroduce: !hasIntro, loadintroduce: !hasIntro,
...@@ -158,9 +158,9 @@ class AddVideoCourse extends React.Component { ...@@ -158,9 +158,9 @@ class AddVideoCourse extends React.Component {
whetherVisitorsJoin, whetherVisitorsJoin,
categoryId, categoryId,
courseChapterList: _courseChapterVOList, courseChapterList: _courseChapterVOList,
}) });
}) });
} };
getTextDetail = (key, url) => { getTextDetail = (key, url) => {
$.ajax({ $.ajax({
...@@ -169,13 +169,13 @@ class AddVideoCourse extends React.Component { ...@@ -169,13 +169,13 @@ class AddVideoCourse extends React.Component {
url, url,
contentType: 'application/x-www-form-urlencoded; charset=UTF-8', contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
success: (res) => { success: (res) => {
this.setState({ [key]: res, [`load${key}`]: true }) this.setState({ [key]: res, [`load${key}`]: true });
}, },
}) });
} };
handleGoBack = () => { handleGoBack = () => {
const { coverId, courseName, scheduleMedia, courseChapterList, categoryId, shelfState, whetherVisitorsJoin } = this.state const { coverId, courseName, scheduleMedia, courseChapterList, categoryId, shelfState, whetherVisitorsJoin } = this.state;
if ( if (
!courseChapterList.length || !courseChapterList.length ||
!_.isEqual(scheduleMedia, defaultScheduleMedia) || !_.isEqual(scheduleMedia, defaultScheduleMedia) ||
...@@ -194,29 +194,29 @@ class AddVideoCourse extends React.Component { ...@@ -194,29 +194,29 @@ class AddVideoCourse extends React.Component {
onOk: () => { onOk: () => {
window.RCHistory.push({ window.RCHistory.push({
pathname: `/video-course`, pathname: `/video-course`,
}) });
}, },
}) });
} else { } else {
window.RCHistory.push({ window.RCHistory.push({
pathname: `/video-course`, pathname: `/video-course`,
}) });
}
} }
};
// 修改表单 // 修改表单
handleChangeForm = (field, value, coverUrl) => { handleChangeForm = (field, value, coverUrl) => {
this.setState({ this.setState({
[field]: value, [field]: value,
coverUrl: coverUrl ? coverUrl : this.state.coverUrl, coverUrl: coverUrl ? coverUrl : this.state.coverUrl,
}) });
} };
// 显示选择学员弹窗 // 显示选择学员弹窗
handleShowSelectStuModal = () => { handleShowSelectStuModal = () => {
this.setState({ studentModal: true }) this.setState({ studentModal: true });
const { studentList, selectedStuList } = this.state const { studentList, selectedStuList } = this.state;
const studentModal = ( const studentModal = (
<SelectStudent <SelectStudent
showTabs={true} showTabs={true}
...@@ -227,35 +227,35 @@ class AddVideoCourse extends React.Component { ...@@ -227,35 +227,35 @@ class AddVideoCourse extends React.Component {
close={() => { close={() => {
this.setState({ this.setState({
studentModal: null, studentModal: null,
}) });
}} }}
/> />
) );
this.setState({ studentModal }) this.setState({ studentModal });
} };
handleSelectStudent = (studentIds) => { handleSelectStudent = (studentIds) => {
let studentList = [] let studentList = [];
_.each(studentIds, (item) => { _.each(studentIds, (item) => {
studentList.push({ studentId: item }) studentList.push({ studentId: item });
}) });
this.setState({ studentList }) this.setState({ studentList });
this.setState({ studentModal: false }) this.setState({ studentModal: false });
} };
// 显示预览弹窗 // 显示预览弹窗
handleShowPreviewModal = () => { handleShowPreviewModal = () => {
const { coverUrl, scheduleVideoUrl, courseName, scheduleMedia, introduce, courseChapterList, categoryName } = this.state const { coverUrl, scheduleVideoUrl, courseName, scheduleMedia, introduce, courseChapterList, categoryName } = this.state;
const courseBasinInfo = { const courseBasinInfo = {
coverUrl, coverUrl,
scheduleVideoUrl, scheduleVideoUrl,
courseName, courseName,
} };
const courseIntroInfo = { const courseIntroInfo = {
liveCourseMediaRequests: scheduleMedia, liveCourseMediaRequests: scheduleMedia,
introduce, introduce,
categoryName, categoryName,
} };
const previewCourseModal = ( const previewCourseModal = (
<PreviewCourseModal <PreviewCourseModal
...@@ -265,35 +265,35 @@ class AddVideoCourse extends React.Component { ...@@ -265,35 +265,35 @@ class AddVideoCourse extends React.Component {
close={() => { close={() => {
this.setState({ this.setState({
previewCourseModal: null, previewCourseModal: null,
}) });
}} }}
courseChapterList={courseChapterList} courseChapterList={courseChapterList}
/> />
) );
this.setState({ previewCourseModal }) this.setState({ previewCourseModal });
} };
// 选择视频 // 选择视频
handleSelectVideo = (addFolderIds, selectedFileList) => { handleSelectVideo = (addFolderIds, selectedFileList) => {
this.setState({ this.setState({
showSelectFileModal: false, showSelectFileModal: false,
}) });
let { courseChapterList } = this.state let { courseChapterList } = this.state;
let _courseChapterList = [...courseChapterList] let _courseChapterList = [...courseChapterList];
if (selectedFileList.length + courseChapterList.length > 20) { if (selectedFileList.length + courseChapterList.length > 20) {
message.warning(`最多只能上传20个文件`) message.warning(`最多只能上传20个文件`);
return return;
} }
selectedFileList.map((file, index) => { selectedFileList.map((file, index) => {
const { ossUrl, resourceId, folderName, folderFormat, folderSize } = file const { ossUrl, resourceId, folderName, folderFormat, folderSize } = file;
const _mediaName = folderName.replace(`.${_.last(folderName.split('.')).toLowerCase()}`, '') const _mediaName = folderName.replace(`.${_.last(folderName.split('.')).toLowerCase()}`, '');
console.log('folderFormat', folderFormat) console.log('folderFormat', folderFormat);
if (folderFormat === 'MP4' || folderFormat === 'video/mp4') { if (folderFormat === 'MP4' || folderFormat === 'video/mp4') {
const videoDom = document.createElement('video') const videoDom = document.createElement('video');
videoDom.src = ossUrl videoDom.src = ossUrl;
videoDom.onloadedmetadata = () => { videoDom.onloadedmetadata = () => {
_courseChapterList.push({ _courseChapterList.push({
mediaContent: resourceId, mediaContent: resourceId,
...@@ -304,13 +304,13 @@ class AddVideoCourse extends React.Component { ...@@ -304,13 +304,13 @@ class AddVideoCourse extends React.Component {
resourceId, resourceId,
mediaUrl: ossUrl, mediaUrl: ossUrl,
sort: _courseChapterList.length, sort: _courseChapterList.length,
}) });
this.setState({ this.setState({
courseChapterList: _courseChapterList, courseChapterList: _courseChapterList,
}) });
} };
} else if (folderFormat === 'WORD' || folderFormat === 'PDF' || SUPPORT_WORD_PDF.indexOf(folderFormat) > -1) { } else if (folderFormat === 'WORD' || folderFormat === 'PDF' || SUPPORT_WORD_PDF.indexOf(folderFormat) > -1) {
const suffix = _.last(folderName.split('.')).toUpperCase() const suffix = _.last(folderName.split('.')).toUpperCase();
_courseChapterList.push({ _courseChapterList.push({
mediaContent: resourceId, mediaContent: resourceId,
contentType: 'SCHEDULE', contentType: 'SCHEDULE',
...@@ -319,47 +319,47 @@ class AddVideoCourse extends React.Component { ...@@ -319,47 +319,47 @@ class AddVideoCourse extends React.Component {
resourceId, resourceId,
mediaUrl: ossUrl, mediaUrl: ossUrl,
sort: _courseChapterList.length, sort: _courseChapterList.length,
}) });
this.setState({ this.setState({
courseChapterList: _courseChapterList, courseChapterList: _courseChapterList,
}) });
}
})
} }
});
};
// 校验课节名称 // 校验课节名称
handleValidateChapterName = (chapterName) => { handleValidateChapterName = (chapterName) => {
let hasError = false let hasError = false;
return new Promise((resolve) => { return new Promise((resolve) => {
if (!chapterName) { if (!chapterName) {
this.setState({ this.setState({
chapterNameValidateStatus: 'error', chapterNameValidateStatus: 'error',
chapterNameHelpMsg: '请输入课节名称', chapterNameHelpMsg: '请输入课节名称',
}) });
hasError = true hasError = true;
resolve(false) resolve(false);
return false return false;
} }
if (chapterName.length > 40) { if (chapterName.length > 40) {
this.setState({ this.setState({
chapterNameValidateStatus: 'error', chapterNameValidateStatus: 'error',
chapterNameHelpMsg: '不要超过40字', chapterNameHelpMsg: '不要超过40字',
}) });
hasError = true hasError = true;
resolve(false) resolve(false);
return false return false;
} }
if (!hasError) { if (!hasError) {
resolve(true) resolve(true);
this.setState({ this.setState({
chapterNameValidateStatus: '', chapterNameValidateStatus: '',
chapterNameHelpMsg: '', chapterNameHelpMsg: '',
}) });
}
})
} }
});
};
// 保存 // 保存
handleSubmit = () => { handleSubmit = () => {
...@@ -369,8 +369,8 @@ class AddVideoCourse extends React.Component { ...@@ -369,8 +369,8 @@ class AddVideoCourse extends React.Component {
title: '服务已到期', title: '服务已到期',
content: '当前企业购买的小麦企学院服务已到期,如需继续使用学院功能,请尽快续费购买', content: '当前企业购买的小麦企学院服务已到期,如需继续使用学院功能,请尽快续费购买',
okText: '我知道了', okText: '我知道了',
}) });
return return;
} }
const { const {
...@@ -387,7 +387,7 @@ class AddVideoCourse extends React.Component { ...@@ -387,7 +387,7 @@ class AddVideoCourse extends React.Component {
introduce, introduce,
courseChapterList, courseChapterList,
editorTextLength, editorTextLength,
} = this.state } = this.state;
const commonParams = { const commonParams = {
// videoName, // videoName,
...@@ -402,75 +402,75 @@ class AddVideoCourse extends React.Component { ...@@ -402,75 +402,75 @@ class AddVideoCourse extends React.Component {
whetherVisitorsJoin, whetherVisitorsJoin,
courseType: 'VOICE', courseType: 'VOICE',
courseChapterList, courseChapterList,
} };
// 校验必填字段:课程名称, 课程视频 // 校验必填字段:课程名称, 课程视频
this.handleValidate(courseName, courseChapterList, categoryId, scheduleMedia, editorTextLength).then((res) => { this.handleValidate(courseName, courseChapterList, categoryId, scheduleMedia, editorTextLength).then((res) => {
if (!res) return if (!res) return;
Upload.uploadTextToOSS(introduce, `${randomString()}.txt`, (introduceId) => { Upload.uploadTextToOSS(introduce, `${randomString()}.txt`, (introduceId) => {
this.submitRemote({ id, pageType, commonParams: { ...commonParams, introduceId } }) this.submitRemote({ id, pageType, commonParams: { ...commonParams, introduceId } });
}) });
}) });
} };
submitRemote = ({ id, pageType, commonParams }) => { submitRemote = ({ id, pageType, commonParams }) => {
if (pageType === 'add') { if (pageType === 'add') {
Service.Hades('public/hades/createVideoSchedule', commonParams).then((res) => { Service.Hades('public/hades/createVideoSchedule', commonParams).then((res) => {
if (!res) return if (!res) return;
message.success('新建成功') message.success('新建成功');
window.RCHistory.push({ window.RCHistory.push({
pathname: `/video-course`, pathname: `/video-course`,
}) });
}) });
} else { } else {
const editParams = { const editParams = {
courseId: id, courseId: id,
...commonParams, ...commonParams,
} };
Service.Hades('public/hades/editVideoSchedule', editParams).then((res) => { Service.Hades('public/hades/editVideoSchedule', editParams).then((res) => {
if (!res) return if (!res) return;
message.success('保存成功') message.success('保存成功');
window.RCHistory.push({ window.RCHistory.push({
pathname: `/video-course`, pathname: `/video-course`,
}) });
}) });
}
} }
};
handleValidate = (courseName, courseChapterList, categoryId, scheduleMedia, editorTextLength) => { handleValidate = (courseName, courseChapterList, categoryId, scheduleMedia, editorTextLength) => {
return new Promise((resolve) => { return new Promise((resolve) => {
if (!courseName) { if (!courseName) {
message.warning('请输入课程名称') message.warning('请输入课程名称');
resolve(false) resolve(false);
return false return false;
} }
if (!courseChapterList.length) { if (!courseChapterList.length) {
message.warning('请上传课节') message.warning('请上传课节');
resolve(false) resolve(false);
return false return false;
} }
if (!categoryId) { if (!categoryId) {
message.warning('请选择课程分类') message.warning('请选择课程分类');
resolve(false) resolve(false);
return false return false;
} }
if (editorTextLength > 1000) { if (editorTextLength > 1000) {
message.warning('课程简介超过字数限定') message.warning('课程简介超过字数限定');
resolve(false) resolve(false);
return return;
}
resolve(true)
})
} }
resolve(true);
});
};
handleSelectCover = (file) => { handleSelectCover = (file) => {
if (!file) { if (!file) {
message.info('请选择文件!') message.info('请选择文件!');
return return;
} }
this.setState({ this.setState({
visible: true, visible: true,
imageFile: file, imageFile: file,
}) });
} };
//获取resourceId //获取resourceId
getSignature = (blob, fileName) => { getSignature = (blob, fileName) => {
Upload.uploadBlobToOSS(blob, 'cover' + new Date().valueOf(), null, 'signInfo').then((signInfo) => { Upload.uploadBlobToOSS(blob, 'cover' + new Date().valueOf(), null, 'signInfo').then((signInfo) => {
...@@ -481,77 +481,77 @@ class AddVideoCourse extends React.Component { ...@@ -481,77 +481,77 @@ class AddVideoCourse extends React.Component {
visible: false, visible: false,
}, },
() => this.updateCover() () => this.updateCover()
) );
}) });
} };
updateCover = () => { updateCover = () => {
const { coverClicpPath, coverId } = this.state const { coverClicpPath, coverId } = this.state;
this.setState({ this.setState({
showSelectCoverModal: false, showSelectCoverModal: false,
coverUrl: coverClicpPath, coverUrl: coverClicpPath,
coverId: coverId, coverId: coverId,
}) });
} };
handleRenameCourseChapter = (chapterId, chapterIndex) => { handleRenameCourseChapter = (chapterId, chapterIndex) => {
const { mediaNameAlias } = this.state const { mediaNameAlias } = this.state;
this.handleValidateChapterName(mediaNameAlias).then((res) => { this.handleValidateChapterName(mediaNameAlias).then((res) => {
// 校验不通过不能点确定保存修改课节名称 // 校验不通过不能点确定保存修改课节名称
if (!res) { if (!res) {
return message.warning('重命名失败') return message.warning('重命名失败');
} }
let { courseChapterList } = this.state let { courseChapterList } = this.state;
let _courseChapterList = [] let _courseChapterList = [];
_courseChapterList = courseChapterList.map((item, index) => { _courseChapterList = courseChapterList.map((item, index) => {
if (item.resourceId === chapterId && chapterIndex === index) { if (item.resourceId === chapterId && chapterIndex === index) {
item.mediaName = mediaNameAlias item.mediaName = mediaNameAlias;
item.visible = false item.visible = false;
} }
return item return item;
}) });
this.setState({ this.setState({
courseChapterList: _courseChapterList, courseChapterList: _courseChapterList,
chapterNameValidateStatus: '', chapterNameValidateStatus: '',
chapterNameHelpMsg: '', chapterNameHelpMsg: '',
mediaNameAlias: '', mediaNameAlias: '',
}) });
}) });
} };
handleChangePopConfirmVisible = (chapterId, chapterNameIndex, visible) => { handleChangePopConfirmVisible = (chapterId, chapterNameIndex, visible) => {
let { courseChapterList } = this.state let { courseChapterList } = this.state;
let _courseChapterList = [] let _courseChapterList = [];
_courseChapterList = courseChapterList.map((item, index) => { _courseChapterList = courseChapterList.map((item, index) => {
if (item.resourceId === chapterId && chapterNameIndex === index) { if (item.resourceId === chapterId && chapterNameIndex === index) {
item.visible = visible item.visible = visible;
} else { } else {
item.visible = false item.visible = false;
} }
return item return item;
}) });
this.setState({ this.setState({
courseChapterList: _courseChapterList, courseChapterList: _courseChapterList,
}) });
} };
handleDeleteCourseChapter = (chapterId, chapterIndex) => { handleDeleteCourseChapter = (chapterId, chapterIndex) => {
console.log('chapterId---', chapterId, chapterIndex) console.log('chapterId---', chapterId, chapterIndex);
let { courseChapterList } = this.state let { courseChapterList } = this.state;
let _courseChapterList = courseChapterList.filter((item, index) => { let _courseChapterList = courseChapterList.filter((item, index) => {
return item.resourceId !== chapterId || (item.resourceId === chapterId && chapterIndex !== index) return item.resourceId !== chapterId || (item.resourceId === chapterId && chapterIndex !== index);
}) });
_courseChapterList.map((item, index) => { _courseChapterList.map((item, index) => {
item.sort = index item.sort = index;
}) });
this.setState({ this.setState({
courseChapterList: _courseChapterList, courseChapterList: _courseChapterList,
}) });
} };
renderChapterTitle = (item) => { renderChapterTitle = (item) => {
const { chapterNameValidateStatus, chapterNameHelpMsg } = this.state const { chapterNameValidateStatus, chapterNameHelpMsg } = this.state;
return ( return (
<div className='course-chapter-title-popover'> <div className='course-chapter-title-popover'>
...@@ -570,54 +570,54 @@ class AddVideoCourse extends React.Component { ...@@ -570,54 +570,54 @@ class AddVideoCourse extends React.Component {
mediaNameAlias: e.target.value.trim(), mediaNameAlias: e.target.value.trim(),
}, },
() => { () => {
this.handleValidateChapterName(this.state.mediaNameAlias) this.handleValidateChapterName(this.state.mediaNameAlias);
} }
) );
}} }}
/> />
</Form.Item> </Form.Item>
</Form> </Form>
</div> </div>
) );
} };
// 上下移动 // 上下移动
handleChangeIndex = (isUp, sortIndex) => { handleChangeIndex = (isUp, sortIndex) => {
const { courseChapterList } = this.state const { courseChapterList } = this.state;
// 第一个上移和最后一个下移不能使用 // 第一个上移和最后一个下移不能使用
if ((isUp && sortIndex === 0) || (!isUp && sortIndex === courseChapterList.length - 1)) { if ((isUp && sortIndex === 0) || (!isUp && sortIndex === courseChapterList.length - 1)) {
return return;
} }
let _courseChapterList = [...courseChapterList] let _courseChapterList = [...courseChapterList];
const temp = courseChapterList[sortIndex] const temp = courseChapterList[sortIndex];
// 若上移 // 若上移
if (isUp) { if (isUp) {
_courseChapterList[sortIndex - 1] = temp _courseChapterList[sortIndex - 1] = temp;
_courseChapterList[sortIndex - 1].sort = sortIndex - 1 _courseChapterList[sortIndex - 1].sort = sortIndex - 1;
_courseChapterList[sortIndex] = courseChapterList[sortIndex - 1] _courseChapterList[sortIndex] = courseChapterList[sortIndex - 1];
_courseChapterList[sortIndex].sort = sortIndex _courseChapterList[sortIndex].sort = sortIndex;
} else { } else {
// 若下移 // 若下移
_courseChapterList[sortIndex + 1] = temp _courseChapterList[sortIndex + 1] = temp;
_courseChapterList[sortIndex + 1].sort = sortIndex + 1 _courseChapterList[sortIndex + 1].sort = sortIndex + 1;
_courseChapterList[sortIndex] = courseChapterList[sortIndex + 1] _courseChapterList[sortIndex] = courseChapterList[sortIndex + 1];
_courseChapterList[sortIndex].sort = sortIndex _courseChapterList[sortIndex].sort = sortIndex;
} }
this.setState({ this.setState({
courseChapterList: _courseChapterList, courseChapterList: _courseChapterList,
}) });
} };
renderTypemenu = () => { renderTypemenu = () => {
return ( return (
<Menu> <Menu>
<Menu.Item> <Menu.Item>
<span <span
onClick={() => { onClick={() => {
this.selectFileType('VIDEO') this.selectFileType('VIDEO');
}}> }}>
视频文件 视频文件
</span> </span>
...@@ -625,34 +625,34 @@ class AddVideoCourse extends React.Component { ...@@ -625,34 +625,34 @@ class AddVideoCourse extends React.Component {
<Menu.Item> <Menu.Item>
<span <span
onClick={() => { onClick={() => {
this.selectFileType('WORD_PDF') this.selectFileType('WORD_PDF');
}}> }}>
资料文件 资料文件
</span> </span>
</Menu.Item> </Menu.Item>
</Menu> </Menu>
) );
} };
selectFileType = (type) => { selectFileType = (type) => {
const { courseChapterList } = this.state const { courseChapterList } = this.state;
if (courseChapterList.length >= 20) { if (courseChapterList.length >= 20) {
message.warning(`最多只能上传20个文件`) message.warning(`最多只能上传20个文件`);
return return;
} }
if (type === 'VIDEO') { if (type === 'VIDEO') {
this.setState({ this.setState({
showSelectFileModal: true, showSelectFileModal: true,
selectTypeList: ['MP4'], selectTypeList: ['MP4'],
accept: 'video/mp4', accept: 'video/mp4',
}) });
} else { } else {
this.setState({ this.setState({
showSelectFileModal: true, showSelectFileModal: true,
selectTypeList: ['DOC', 'DOCX', 'PDF'], selectTypeList: ['DOC', 'DOCX', 'PDF'],
accept: '.doc,.docx,.pdf', accept: '.doc,.docx,.pdf',
}) });
}
} }
};
renderToolTipTitle = () => { renderToolTipTitle = () => {
return ( return (
...@@ -660,8 +660,8 @@ class AddVideoCourse extends React.Component { ...@@ -660,8 +660,8 @@ class AddVideoCourse extends React.Component {
<p>视频支持mp4格式,大小不超过2G;</p> <p>视频支持mp4格式,大小不超过2G;</p>
<p>文件支持PDF、docx、doc格式,大小不超过100M</p> <p>文件支持PDF、docx、doc格式,大小不超过100M</p>
</div> </div>
) );
} };
render() { render() {
const { const {
...@@ -685,9 +685,9 @@ class AddVideoCourse extends React.Component { ...@@ -685,9 +685,9 @@ class AddVideoCourse extends React.Component {
imageFile, imageFile,
selectTypeList, selectTypeList,
accept, accept,
} = this.state } = this.state;
const defaultCover = 'https://image.xiaomaiketang.com/xm/TwtGPQGE4K.png' const defaultCover = 'https://image.xiaomaiketang.com/xm/TwtGPQGE4K.png';
const isDefaultCover = coverUrl === defaultCover || coverUrl == null const isDefaultCover = coverUrl === defaultCover || coverUrl == null;
return ( return (
<div className='page add-video-course-page'> <div className='page add-video-course-page'>
...@@ -707,7 +707,7 @@ class AddVideoCourse extends React.Component { ...@@ -707,7 +707,7 @@ class AddVideoCourse extends React.Component {
maxLength={40} maxLength={40}
style={{ width: 240 }} style={{ width: 240 }}
onChange={(e) => { onChange={(e) => {
this.handleChangeForm('courseName', e.target.value) this.handleChangeForm('courseName', e.target.value);
}} }}
/> />
</div> </div>
...@@ -790,15 +790,15 @@ class AddVideoCourse extends React.Component { ...@@ -790,15 +790,15 @@ class AddVideoCourse extends React.Component {
chapterNameValidateStatus: '', chapterNameValidateStatus: '',
chapterNameHelpMsg: '', chapterNameHelpMsg: '',
mediaNameAlias: '', mediaNameAlias: '',
}) });
}} }}
onCancel={() => this.handleChangePopConfirmVisible(item.resourceId, index, false)}> onCancel={() => this.handleChangePopConfirmVisible(item.resourceId, index, false)}>
<div <div
className='rename' className='rename'
onClick={() => { onClick={() => {
this.setState({ mediaNameAlias: item.mediaName }, () => { this.setState({ mediaNameAlias: item.mediaName }, () => {
this.handleChangePopConfirmVisible(item.resourceId, index, true) this.handleChangePopConfirmVisible(item.resourceId, index, true);
}) });
}}> }}>
重命名 重命名
</div> </div>
...@@ -809,7 +809,7 @@ class AddVideoCourse extends React.Component { ...@@ -809,7 +809,7 @@ class AddVideoCourse extends React.Component {
</div> </div>
</div> </div>
</div> </div>
) );
})} })}
</div> </div>
</div> </div>
...@@ -822,7 +822,7 @@ class AddVideoCourse extends React.Component { ...@@ -822,7 +822,7 @@ class AddVideoCourse extends React.Component {
<div> <div>
<Button <Button
onClick={() => { onClick={() => {
this.setState({ showSelectCoverModal: true }) this.setState({ showSelectCoverModal: true });
}}>{`${pageType === 'add' && !coverUrl ? '上传' : '修改'}封面`}</Button> }}>{`${pageType === 'add' && !coverUrl ? '上传' : '修改'}封面`}</Button>
<span <span
className={`span ${coverUrl ? 'defalut-span' : ''}`} className={`span ${coverUrl ? 'defalut-span' : ''}`}
...@@ -830,7 +830,7 @@ class AddVideoCourse extends React.Component { ...@@ -830,7 +830,7 @@ class AddVideoCourse extends React.Component {
this.setState({ this.setState({
coverUrl: '', coverUrl: '',
coverId: '', coverId: '',
}) });
}}> }}>
使用默认图 使用默认图
</span> </span>
...@@ -850,7 +850,7 @@ class AddVideoCourse extends React.Component { ...@@ -850,7 +850,7 @@ class AddVideoCourse extends React.Component {
<CourseCatalogSelect <CourseCatalogSelect
value={categoryId} value={categoryId}
onChange={(value, label) => { onChange={(value, label) => {
this.handleChangeCatalogList(value, label) this.handleChangeCatalogList(value, label);
}} }}
/> />
</div> </div>
...@@ -895,7 +895,7 @@ class AddVideoCourse extends React.Component { ...@@ -895,7 +895,7 @@ class AddVideoCourse extends React.Component {
diskList={diskList} diskList={diskList}
addVideo={true} addVideo={true}
onClose={() => { onClose={() => {
this.setState({ showSelectFileModal: false }) this.setState({ showSelectFileModal: false });
}} }}
onSelect={this.handleSelectVideo} onSelect={this.handleSelectVideo}
/> />
...@@ -910,7 +910,7 @@ class AddVideoCourse extends React.Component { ...@@ -910,7 +910,7 @@ class AddVideoCourse extends React.Component {
tooltip='支持文件类型:jpg、jpeg、png' tooltip='支持文件类型:jpg、jpeg、png'
isOpen={showSelectCoverModal} isOpen={showSelectCoverModal}
onClose={() => { onClose={() => {
this.setState({ showSelectCoverModal: false }) this.setState({ showSelectCoverModal: false });
}} }}
onSelect={this.handleSelectCover} onSelect={this.handleSelectCover}
/> />
...@@ -921,14 +921,14 @@ class AddVideoCourse extends React.Component { ...@@ -921,14 +921,14 @@ class AddVideoCourse extends React.Component {
imgUrl={imageFile.ossUrl} imgUrl={imageFile.ossUrl}
onConfirm={this.getSignature} onConfirm={this.getSignature}
onClose={() => { onClose={() => {
this.setState({ visible: false }) this.setState({ visible: false });
}} }}
/> />
)} )}
{this.state.previewCourseModal} {this.state.previewCourseModal}
</div> </div>
) );
} }
} }
export default AddVideoCourse export default AddVideoCourse;
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