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 { ...@@ -23,6 +23,7 @@ class routeHook {
} }
cancel() { //取消跳转 cancel() { //取消跳转
console.log('jhgjh')
this.routeFun.pop() this.routeFun.pop()
} }
...@@ -42,7 +43,10 @@ class routeHook { ...@@ -42,7 +43,10 @@ class routeHook {
// ** // **
addSaveCase() { //离开保存校验时将方法注入 addSaveCase() { //离开保存校验时将方法注入
setTimeout(()=>{
this.add(this.saveBeforeLeave.bind(this)) this.add(this.saveBeforeLeave.bind(this))
},100)
} }
saveBeforeLeave() { //离开保存时触发的方法 saveBeforeLeave() { //离开保存时触发的方法
......
...@@ -69,6 +69,7 @@ window.RCHistory = _.extend({}, history, { ...@@ -69,6 +69,7 @@ window.RCHistory = _.extend({}, history, {
}); });
window.onhashchange = () => { window.onhashchange = () => {
console.log(132121)
routeHook.cancel() routeHook.cancel()
} }
......
...@@ -195,11 +195,6 @@ function CreateWorkWXCourse() { ...@@ -195,11 +195,6 @@ function CreateWorkWXCourse() {
} }
} }
// 修改简介
function handleChangeIntroInfo(field, value) {
};
// 完成创建/编辑 // 完成创建/编辑
function handleSubmit() { function handleSubmit() {
//过期判断 //过期判断
...@@ -223,8 +218,8 @@ function CreateWorkWXCourse() { ...@@ -223,8 +218,8 @@ function CreateWorkWXCourse() {
}); });
return; return;
} }
// this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit, editorTextLength).then((res) => { handleValidate().then((res) => {
// if (!res) return; if (!res) return;
//上传简介 //上传简介
Upload.uploadTextToOSS( Upload.uploadTextToOSS(
introduce, introduce,
...@@ -234,7 +229,7 @@ function CreateWorkWXCourse() { ...@@ -234,7 +229,7 @@ function CreateWorkWXCourse() {
}, },
() => message.warning('上传课程简介失败') () => message.warning('上传课程简介失败')
); );
// }); });
}; };
function submitRemote({ introduceId, id }) { function submitRemote({ introduceId, id }) {
...@@ -242,7 +237,9 @@ function CreateWorkWXCourse() { ...@@ -242,7 +237,9 @@ function CreateWorkWXCourse() {
} else { } else {
} }
console.log('取消')
routeHook.cancel()
if (type === 'add') { if (type === 'add') {
if (endTime !== 0) { if (endTime !== 0) {
classInfo.duration = String((endTime - classInfo.startTime)/1000) classInfo.duration = String((endTime - classInfo.startTime)/1000)
...@@ -257,6 +254,7 @@ function CreateWorkWXCourse() { ...@@ -257,6 +254,7 @@ function CreateWorkWXCourse() {
CourseService.createWorkWXLiveCourse(params).then((res) => { CourseService.createWorkWXLiveCourse(params).then((res) => {
if (res.success) { if (res.success) {
message.success('新建成功'); message.success('新建成功');
Bus.trigger('freshCourseList')
window.RCHistory.push({ window.RCHistory.push({
pathname: `/live-course`, pathname: `/live-course`,
}); });
...@@ -276,6 +274,7 @@ function CreateWorkWXCourse() { ...@@ -276,6 +274,7 @@ function CreateWorkWXCourse() {
}; };
CourseService.updateWorkWXLiveCourse(params).then((res) => { CourseService.updateWorkWXLiveCourse(params).then((res) => {
if (res.success) { if (res.success) {
Bus.trigger('freshCourseList')
message.success('更新成功'); message.success('更新成功');
window.RCHistory.push({ window.RCHistory.push({
pathname: `/live-course`, pathname: `/live-course`,
...@@ -284,103 +283,33 @@ function CreateWorkWXCourse() { ...@@ -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) { function handleValidate() {
message.warning('请选择课程分类'); return new Promise((resolve) => {
resolve(false); if (_.isEmpty(basicInfo.courseName)) {
return; 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) { if (!classInfo.startTime) {
message.warning('请选择讲师'); message.warning("未设置开始时间")
resolve(false); resolve(false)
return; return
} }
if (_.isEmpty(classInfo.teacherId)) {
if (editorTextLength > 1000) { message.warning("课程分类未选择")
message.warning('课程简介超过字数限定'); resolve(false)
resolve(false); return
return;
} }
resolve(true); resolve(true)
}); });
}; };
*/
// 显示预览课程弹窗 // 显示预览课程弹窗
function handleShowPreviewModal() { function handleShowPreviewModal() {
......
...@@ -24,6 +24,7 @@ import DataList from '../DataList/DataList'; ...@@ -24,6 +24,7 @@ import DataList from '../DataList/DataList';
import ManageCoursewareModal from '../modal/ManageCoursewareModal'; import ManageCoursewareModal from '../modal/ManageCoursewareModal';
import RelatedPlanModal from '../modal/RelatedPlanModal'; import RelatedPlanModal from '../modal/RelatedPlanModal';
import ShareLiveModal from '../modal/ShareLiveModal'; import ShareLiveModal from '../modal/ShareLiveModal';
import Bus from '@/core/bus';
import './LiveCourseList.less'; import './LiveCourseList.less';
const { confirm } = Modal const { confirm } = Modal
...@@ -64,7 +65,11 @@ class LiveCourseList extends React.Component { ...@@ -64,7 +65,11 @@ class LiveCourseList extends React.Component {
this.parseColumns() this.parseColumns()
} }
componentDidMount() { componentDidMount() {
this.getDownloadVersion() this.getDownloadVersion()
Bus.bind('freshCourseList',()=>{
this.refreshCourseList()
})
} }
// 显示分享弹窗 // 显示分享弹窗
handleShowShareModal = (item, needStr = false) => { 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