Commit 61e2ddca by maolipeng

Merge branch 'feature/zhujian/0726/qwLiving' into dev

# Conflicts:
#	src/modules/course-manage/components/LiveCourseList.jsx
parents 7fce7a30 fcd6c2fb
......@@ -23,6 +23,7 @@ class routeHook {
}
cancel() { //取消跳转
console.log('jhgjh')
this.routeFun.pop()
}
......@@ -42,7 +43,10 @@ class routeHook {
// **
addSaveCase() { //离开保存校验时将方法注入
this.add(this.saveBeforeLeave.bind(this))
setTimeout(()=>{
this.add(this.saveBeforeLeave.bind(this))
},100)
}
saveBeforeLeave() { //离开保存时触发的方法
......
......@@ -69,6 +69,7 @@ window.RCHistory = _.extend({}, history, {
});
window.onhashchange = () => {
console.log(132121)
routeHook.cancel()
}
......
......@@ -195,11 +195,6 @@ function CreateWorkWXCourse() {
}
}
// 修改简介
function handleChangeIntroInfo(field, value) {
};
// 完成创建/编辑
function handleSubmit() {
//过期判断
......@@ -223,8 +218,8 @@ function CreateWorkWXCourse() {
});
return;
}
// this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit, editorTextLength).then((res) => {
// if (!res) return;
handleValidate().then((res) => {
if (!res) return;
//上传简介
Upload.uploadTextToOSS(
introduce,
......@@ -234,7 +229,7 @@ function CreateWorkWXCourse() {
},
() => message.warning('上传课程简介失败')
);
// });
});
};
function submitRemote({ introduceId, id }) {
......@@ -242,7 +237,9 @@ function CreateWorkWXCourse() {
} else {
}
console.log('取消')
routeHook.cancel()
if (type === 'add') {
if (endTime !== 0) {
classInfo.duration = String((endTime - classInfo.startTime)/1000)
......@@ -257,6 +254,7 @@ function CreateWorkWXCourse() {
CourseService.createWorkWXLiveCourse(params).then((res) => {
if (res.success) {
message.success('新建成功');
Bus.trigger('freshCourseList')
window.RCHistory.push({
pathname: `/live-course`,
});
......@@ -276,6 +274,7 @@ function CreateWorkWXCourse() {
};
CourseService.updateWorkWXLiveCourse(params).then((res) => {
if (res.success) {
Bus.trigger('freshCourseList')
message.success('更新成功');
window.RCHistory.push({
pathname: `/live-course`,
......@@ -284,103 +283,33 @@ function CreateWorkWXCourse() {
});
}
};
/*
handleValidate = (addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit, editorTextLength) => {
return new Promise((resolve) => {
const { type } = this.state;
const { courseName, categoryId } = addLiveBasicInfo;
const { liveDate, timeHorizonStart, timeHorizonEnd, teacherId, calendarTime } = addLiveClassInfo;
const { liveCourseMediaRequests } = addLiveIntroInfo;
const currentTime = +new Date();
if (!courseName) {
message.warning('请输入课程名称');
resolve(false);
return;
}
if (!categoryId) {
message.warning('请选择课程分类');
resolve(false);
return;
function handleValidate() {
return new Promise((resolve) => {
if (_.isEmpty(basicInfo.courseName)) {
message.warning("课程名称不能为空")
resolve(false)
return
}
if (type === 'add') {
const { startTime, endTime } = addLiveClassInfo;
if (calendarTime.length === 0) {
message.warning('请选择上课日期');
resolve(false);
return;
} else if (startTime === endTime || startTime > endTime) {
message.warning('结束时间必须晚于开始时间');
resolve(false);
return;
}
// 若有今日排课 校验当前时间
const currentDay = moment(currentTime).format('YYYY-MM-DD');
const itemToday = _.find(calendarTime, (item) => {
const itemDay = moment(item).format('YYYY-MM-DD');
return itemDay === currentDay;
});
if (itemToday) {
const itemDay = moment(itemToday).format('YYYY-MM-DD');
const itemHour = moment(startTime).format('HH:mm');
if (itemDay === currentDay) {
if (moment(itemDay + ' ' + itemHour).format('x') < currentTime) {
message.warning('开始时间不能早于现在');
resolve(false);
return;
}
}
}
} else {
const _liveDate = moment(liveDate).format('YYYY-MM-DD');
const _timeHorizonStart = moment(timeHorizonStart).format('HH:mm');
const _timeHorizonEnd = moment(timeHorizonEnd).format('HH:mm');
const startTime = moment(_liveDate + ' ' + _timeHorizonStart).format('x');
const endTime = moment(_liveDate + ' ' + _timeHorizonEnd).format('x');
if (!startTime || !endTime) {
message.warning('日期不能为空');
resolve(false);
return;
} else if (!timeHorizonStart) {
message.warning('开始时间不能为空');
resolve(false);
return;
} else if (!timeHorizonEnd) {
message.warning('结束时间不能为空');
resolve(false);
return;
} else if (isEdit && startTime < currentTime) {
message.warning('开始时间不能早于当前时间');
resolve(false);
return;
} else if (isEdit && endTime < currentTime) {
message.warning('结束时间不能早于当前时间');
resolve(false);
return;
} else if (isEdit && endTime <= startTime) {
message.warning('结束时间不能早于开始时间');
resolve(false);
return;
}
if (_.isEmpty(basicInfo.categoryId)) {
message.warning("课程分类未选择")
resolve(false)
return
}
if (!teacherId) {
message.warning('请选择讲师');
resolve(false);
return;
if (!classInfo.startTime) {
message.warning("未设置开始时间")
resolve(false)
return
}
if (editorTextLength > 1000) {
message.warning('课程简介超过字数限定');
resolve(false);
return;
if (_.isEmpty(classInfo.teacherId)) {
message.warning("课程分类未选择")
resolve(false)
return
}
resolve(true);
resolve(true)
});
};
*/
// 显示预览课程弹窗
function handleShowPreviewModal() {
......
......@@ -24,6 +24,7 @@ import DataList from '../DataList/DataList';
import ManageCoursewareModal from '../modal/ManageCoursewareModal';
import RelatedPlanModal from '../modal/RelatedPlanModal';
import ShareLiveModal from '../modal/ShareLiveModal';
import Bus from '@/core/bus';
import './LiveCourseList.less';
const { confirm } = Modal
......@@ -64,7 +65,11 @@ class LiveCourseList extends React.Component {
this.parseColumns()
}
componentDidMount() {
this.getDownloadVersion()
Bus.bind('freshCourseList',()=>{
this.refreshCourseList()
})
}
// 显示分享弹窗
handleShowShareModal = (item, needStr = false) => {
......
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