Commit 35133ea3 by chenshu

feat:初始化

parent 711245c2
......@@ -22,12 +22,9 @@ import {
} from 'antd';
import $ from 'jquery';
import { DISK_MAP, FileTypeIcon, FileVerifyMap } from '@/common/constants/academic/lessonEnum';
import { ImgCutModalNew } from '@/components';
import RangePicker from "@/modules/common/DateRangePicker";
import ShowTips from "@/components/ShowTips";
import Breadcrumbs from "@/components/Breadcrumbs";
import AddGraphicsIntro from './components/AddGraphicsIntro';
import SelectStudent from '../modal/select-student';
import SelectPrepareFileModal from '../../prepare-lesson/modal/SelectPrepareFileModal';
import PreviewGraphicsModal from '../modal/PreviewGraphicsModal';
......@@ -36,6 +33,7 @@ import Service from '@/common/js/service';
import { randomString } from '@/domains/basic-domain/utils';
import User from '@/common/js/user';
import _ from "underscore";
import moment from 'moment';
import Upload from '@/core/upload';
import GraphicsEditor from '../components/GraphicsEditor';
import MultipleDatePicker from '@/components/MultipleDatePicker';
......@@ -45,7 +43,6 @@ const EDIT_BOX_KEY = Math.random();
const fieldNames = { label: 'categoryName', value: 'id', children: 'sonCategoryList' };
const { Option } = Select;
//添加课程时课程默认的一些值
const defaultShelfState = 'YES';
const whetherVisitorsJoin = 'NO'
const defaultCoverUrl = 'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png';
let cutFlag = false;
......@@ -70,11 +67,9 @@ class AddOfflineCourse extends React.Component {
courseName: null, // 线下课名称
courseMedia: '',
introduce: '',
courseMediaId: null, // 线下课链接
coverId: null, // 线下封面的recourceId
coverUrl: defaultCoverUrl, // 线下课封面
studentList: [], // 上课学员列表
shelfState:'YES', //是否开启学院展示
diskList: [], // 机构可见磁盘目录
selectedFileList: [], // 已经从资料云盘中勾选的文件
showCutModal: false, // 是否显示截图弹窗
......@@ -166,7 +161,6 @@ class AddOfflineCourse extends React.Component {
const { result = {} } = res || {};
const {
courseName,
shelfState,
whetherVisitorsJoin,
courseMediaVOS,
categoryOneName,
......@@ -207,7 +201,6 @@ class AddOfflineCourse extends React.Component {
coverId,
coverUrl,
courseName,
shelfState,
whetherVisitorsJoin,
categoryName,
categoryId
......@@ -233,12 +226,10 @@ class AddOfflineCourse extends React.Component {
videoName,
videoDuration,
courseName,
courseMediaId,
categoryId,
shelfState,
whetherVisitorsJoin
} = this.state;
if(videoName || videoDuration || courseMediaId || categoryId || courseName || coverId || shelfState !== defaultShelfState || whetherVisitorsJoin !== whetherVisitorsJoin ){
if(videoName || videoDuration || categoryId || courseName || coverId || whetherVisitorsJoin !== whetherVisitorsJoin ){
Modal.confirm({
title: '确认要返回吗?',
content: '返回后,本次编辑的内容将不被保存。',
......@@ -456,43 +447,56 @@ class AddOfflineCourse extends React.Component {
courseMedia,
introduce,
categoryId,
shelfState,
offlinePlace,
whetherVisitorsJoin,
whetherSetApply,
whetherSetSignIn,
whetherSetSignOut,
teacherId,
coverUrl,
} = this.state;
let coverObj ={
contentType:'COVER',
mediaContent: coverId,
mediaType:'PICTURE',
mediaUrl: coverUrl,
}
let scheduleMediaRequests = [];
if(coverId){
scheduleMediaRequests = [coverObj]
}
const commonParams = {
categoryId,
courseName,
coverId,
operatorId:User.getStoreUserId(),
storeId:User.getStoreId(),
shelfState,
scheduleMediaRequests,
storeId: User.getStoreId(),
offlinePlace,
whetherVisitorsJoin,
courseType: 'PICTURE',
whetherSetApply,
whetherSetSignIn,
whetherSetSignOut,
teacherId,
};
// 校验必填字段:课程名称, 课程线下
this.handleValidate(courseName, courseMedia, categoryId).then((res) => {
if (!res) return;
Upload.uploadTextToOSS(courseMedia, `${randomString()}.txt`, (courseMediaId) => {
Upload.uploadTextToOSS(introduce, `${randomString()}.txt`, (introduceId) => {
this.submitRemote({
id,
pageType,
commonParams,
courseMediaId,
introduceId,
});
}, () => message.warning('上传课程简介失败'));
}, () => message.warning('上传课程内容失败'));
Upload.uploadTextToOSS(introduce, `${randomString()}.txt`, (introduceId) => {
this.submitRemote({
id,
pageType,
commonParams,
introduceId,
});
}, () => message.warning('上传课程简介失败'));
});
}
submitRemote = (data) => {
const { id, pageType, commonParams, courseMediaId, introduceId } = data;
commonParams.courseMediaId = courseMediaId;
const { id, pageType, commonParams, introduceId } = data;
commonParams.introduceId = introduceId;
if (pageType === 'add') {
Service.Hades('public/hades/createMediaCourse', commonParams).then((res) => {
Service.Hades('public/hades/createOfflineCourse', commonParams).then((res) => {
if (!res) return;
message.success("新建成功");
window.RCHistory.push({
......@@ -521,24 +525,11 @@ class AddOfflineCourse extends React.Component {
resolve(false);
return false
}
if (!courseMedia) {
message.warning('请输入课程内容');
resolve(false);
return false
}
if(!categoryId){
message.warning('请选择课程分类');
resolve(false);
return false
}
// const textMedia = scheduleMedia.filter((item) => item.mediaType === 'TEXT');
// for (let i = 0, len = textMedia.length; i < len; i++) {
// if (textMedia[i].mediaContentLength && textMedia[i].mediaContentLength.length > 1000) {
// message.warning(`第${i+1}个文字简介的字数超过了1000个字`);
// resolve(false);
// return false
// }
// }
resolve(true);
});
}
......@@ -611,31 +602,30 @@ class AddOfflineCourse extends React.Component {
this.setState(data);
}
whetherVisitorsJoinChange = ()=>{
if(this.props.data.whetherVisitorsJoin==="NO"){
this.setState({ whetherVisitorsJoin: 'YES' });
}else{
this.setState({ whetherVisitorsJoin: 'NO' });
}
}
render() {
const {
id,
pageType,
courseName,
coverUrl,
studentList,
courseMedia,
introduce,
showCutModal,
diskList,
imageFile,
videoType,
shelfState,
categoryName,
courseCatalogList,
whetherVisitorsJoin,
loadcourseMedia,
loadintroduce,
showSelectCoverModal,
visible,
hasImgReady,
cutImageBlob,
teacherName,
teacherId,
teacherList,
calendarTime,
startTime,
......@@ -655,13 +645,9 @@ class AddOfflineCourse extends React.Component {
signInType,
signOutType,
quota,
offlinePlace,
} = this.state;
// 已选择的上课学员数量
const hasSelectedStu = studentList.length;
const courseWareIcon = FileVerifyMap[videoType] ? FileTypeIcon[FileVerifyMap[videoType].type] : FileTypeIcon[videoType];
const isDefaultCover = coverUrl === defaultCoverUrl;
return (
<div className="page add-offline-course-page">
<Breadcrumbs
......@@ -723,12 +709,15 @@ class AddOfflineCourse extends React.Component {
</div>
<div className="course-catalog">
<span className="label"><span className="require">*</span>上课地点:</span>
<Select
<Input
value={offlinePlace}
maxLength={40}
style={{ width: 240 }}
placeholder="请输入上课地点(40字以内)"
>
</Select>
onChange={(e) => {
this.setState({ offlinePlace: e.target.value })
}}
/>
</div>
<div className="course-catalog" id="teacher">
<span className="label"><span className="require">* </span>讲师:</span>
......
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