Commit 59fa070f by yuananting

fix:添加因合并分支丢失的视频上传相关方法的代码

parent 3ef91dc7
/*
* @Author: 吴文洁
* @Date: 2020-08-05 10:07:47
* @LastEditors: Please set LastEditors
* @LastEditTime: 2021-07-09 11:50:51
* @LastEditors: yuananting
* @LastEditTime: 2021-07-09 14:16:04
* @Description: 视频课新增/编辑页
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
......@@ -341,40 +341,179 @@ class AddVideoCourse extends React.Component {
})
}
// 校验课节名称
handleValidateChapterName = (chapterName)=> {
let hasError = false;
return new Promise((resolve) => {
if(!chapterName) {
this.setState({
chapterNameValidateStatus: "error",
chapterNameHelpMsg: '请输入课节名称'
})
hasError = true;
resolve(false)
return false
}
if(chapterName.length > 40) {
this.setState({
chapterNameValidateStatus: "error",
chapterNameHelpMsg: '不要超过40字'
})
hasError = true;
resolve(false)
return false
}
if(!hasError){
resolve(true)
this.setState({
chapterNameValidateStatus: "",
chapterNameHelpMsg: ""
})
// 校验课节名称
handleValidateChapterName = (chapterName)=> {
let hasError = false;
return new Promise((resolve) => {
if(!chapterName) {
this.setState({
chapterNameValidateStatus: "error",
chapterNameHelpMsg: '请输入课节名称'
})
hasError = true;
resolve(false)
return false
}
if(chapterName.length > 40) {
this.setState({
chapterNameValidateStatus: "error",
chapterNameHelpMsg: '不要超过40字'
})
hasError = true;
resolve(false)
return false
}
if(!hasError){
resolve(true)
this.setState({
chapterNameValidateStatus: "",
chapterNameHelpMsg: ""
})
}
})
}
// 重命名
handleRenameCourseChapter = (chapterId) => {
const { mediaNameAlias } = this.state;
this.handleValidateChapterName(mediaNameAlias).then((res) => {
// 校验不通过不能点确定保存修改课节名称
if (!res) {
this.setState({
chapterNameValidateStatus: '',
chapterNameHelpMsg: '',
mediaNameAlias: '',
});
return message.warning('重命名失败');
}
let { courseChapterList } = this.state;
let _courseChapterList = [];
_courseChapterList = courseChapterList.map((item, index) => {
if (item.id === chapterId) {
item.mediaName = mediaNameAlias;
}
})
return item;
});
this.setState({
courseChapterList: _courseChapterList,
chapterNameValidateStatus: '',
chapterNameHelpMsg: '',
mediaNameAlias: '',
});
});
};
// 校验课节名称
handleValidateChapterName = (chapterName) => {
let hasError = false;
return new Promise((resolve) => {
if (!chapterName) {
this.setState({
chapterNameValidateStatus: 'error',
chapterNameHelpMsg: '请输入课节名称',
});
hasError = true;
resolve(false);
return false;
}
if (chapterName.length > 40) {
this.setState({
chapterNameValidateStatus: 'error',
chapterNameHelpMsg: '不要超过40字',
});
hasError = true;
resolve(false);
return false;
}
if (!hasError) {
resolve(true);
this.setState({
chapterNameValidateStatus: '',
chapterNameHelpMsg: '',
});
}
});
};
handleDeleteCourseChapter = (chapterId) => {
console.log('chapterId---', chapterId);
let { courseChapterList } = this.state;
let _courseChapterList = courseChapterList.filter((item, index) => {
return item.id !== chapterId;
});
this.setState({
courseChapterList: _courseChapterList,
});
};
renderChapterTitle = (item) => {
const { chapterNameValidateStatus, chapterNameHelpMsg } = this.state;
return (
<div className='course-chapter-title-popover'>
<div className='tag-title'>课节名称</div>
<Form>
<Form.Item validateStatus={chapterNameValidateStatus} help={chapterNameHelpMsg}>
<TextArea
defaultValue={item.mediaName}
placeholder='请输入课节名称'
maxLength={40}
autoSize
style={{ width: '318px' }}
onChange={(e) => {
this.setState(
{
mediaNameAlias: e.target.value.trim(),
},
() => {
this.handleValidateChapterName(this.state.mediaNameAlias);
}
);
}}
/>
</Form.Item>
</Form>
</div>
);
};
// 上下移动
handleChangeIndex = (isUp, sortIndex) => {
const { courseChapterList } = this.state;
// 第一个上移和最后一个下移不能使用
if ((isUp && sortIndex === 0) || (!isUp && sortIndex === courseChapterList.length - 1)) {
return;
}
let _courseChapterList = [...courseChapterList];
const temp = courseChapterList[sortIndex];
// 若上移
if (isUp) {
_courseChapterList[sortIndex - 1] = temp;
_courseChapterList[sortIndex - 1].sort = sortIndex - 1;
_courseChapterList[sortIndex] = courseChapterList[sortIndex - 1];
_courseChapterList[sortIndex].sort = sortIndex;
} else {
// 若下移
_courseChapterList[sortIndex + 1] = temp;
_courseChapterList[sortIndex + 1].sort = sortIndex + 1;
_courseChapterList[sortIndex] = courseChapterList[sortIndex + 1];
_courseChapterList[sortIndex].sort = sortIndex;
}
this.setState({
courseChapterList: _courseChapterList,
});
};
// 保存
handleSubmit = () => {
//过期判断
......
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