Commit 3de96d01 by zhangleyuan

feat:修改课程的数量限制

parent caba870f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: zhangleyuan * @Author: zhangleyuan
* @Date: 2021-02-20 16:45:51 * @Date: 2021-02-20 16:45:51
* @LastEditors: zhangleyuan * @LastEditors: zhangleyuan
* @LastEditTime: 2021-03-09 19:54:25 * @LastEditTime: 2021-03-10 10:35:50
* @Description: 描述一下 * @Description: 描述一下
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -258,7 +258,7 @@ class TrainingTask extends React.Component { ...@@ -258,7 +258,7 @@ class TrainingTask extends React.Component {
taskName: '', taskName: '',
index:dataSource.length, index:dataSource.length,
type:'input', type:'input',
open:false, open:true,
courseList:[ courseList:[
] ]
} }
......
...@@ -53,14 +53,15 @@ class SelectOperatorModal extends React.Component { ...@@ -53,14 +53,15 @@ class SelectOperatorModal extends React.Component {
videoTotalCount:0, videoTotalCount:0,
selectVideo:[], //弹窗内已选择的视频课程 selectVideo:[], //弹窗内已选择的视频课程
currentVideoCourseListData:[], //页面中已关联的视频课程 currentVideoCourseListData:[], //页面中已关联的视频课程
activeKey:'video' activeKey:'video',
currentTaskCourseData:this.props.data[this.props.selectedTaskIndex].courseList || []
} }
} }
componentDidMount() { componentDidMount() {
this.handleFetchLiveDataList(); this.handleFetchLiveDataList();
this.handleFetchVideoDataList(); this.handleFetchVideoDataList();
console.log('courseLisData',this.props.data)
} }
// 获取直播课列表 // 获取直播课列表
...@@ -269,14 +270,14 @@ class SelectOperatorModal extends React.Component { ...@@ -269,14 +270,14 @@ class SelectOperatorModal extends React.Component {
return columns; return columns;
} }
selectLiveList = (record,selected) =>{ selectLiveList = (record,selected) =>{
const {selectVideo,currentVideoCourseListData,currentLiveCourseListData,selectLive} = this.state; const {selectVideo,currentTaskCourseData,selectLive} = this.state;
let _list = []; let _list = [];
if (selected || !_.find(selectLive, (item) => item.liveCourseId == record.liveCourseId)) { if (selected || !_.find(selectLive, (item) => item.liveCourseId == record.liveCourseId)) {
_list = _.uniq(selectLive.concat([record]), false, (item) => item.liveCourseId); _list = _.uniq(selectLive.concat([record]), false, (item) => item.liveCourseId);
} else { } else {
_list = _.reject(selectLive, (item) => item.liveCourseId === record.liveCourseId); _list = _.reject(selectLive, (item) => item.liveCourseId === record.liveCourseId);
} }
if(_list.length + currentVideoCourseListData.length + currentLiveCourseListData.length + selectVideo.length> 20){ if(_list.length + currentTaskCourseData.length + selectVideo.length> 20){
message.warning('无法继续选择,一个任务最多关联20个课程'); message.warning('无法继续选择,一个任务最多关联20个课程');
return; return;
} }
...@@ -284,14 +285,14 @@ class SelectOperatorModal extends React.Component { ...@@ -284,14 +285,14 @@ class SelectOperatorModal extends React.Component {
} }
selectVideoList = (record,selected) =>{ selectVideoList = (record,selected) =>{
const {selectVideo,currentVideoCourseListData,currentLiveCourseListData,selectLive} = this.state; const {selectVideo,currentTaskCourseData,selectLive} = this.state;
let _list = []; let _list = [];
if (selected || !_.find(selectVideo, (item) => item.id == record.id)) { if (selected || !_.find(selectVideo, (item) => item.id == record.id)) {
_list = _.uniq(selectVideo.concat([record]), false, (item) => item.id); _list = _.uniq(selectVideo.concat([record]), false, (item) => item.id);
} else { } else {
_list = _.reject(selectVideo, (item) => item.id === record.id); _list = _.reject(selectVideo, (item) => item.id === record.id);
} }
if(_list.length + currentVideoCourseListData.length + currentLiveCourseListData.length + selectLive.length> 20){ if(_list.length + currentTaskCourseData.length + selectLive.length> 20){
message.warning('无法继续选择,一个任务最多关联20个课程'); message.warning('无法继续选择,一个任务最多关联20个课程');
return; return;
} }
...@@ -325,7 +326,7 @@ class SelectOperatorModal extends React.Component { ...@@ -325,7 +326,7 @@ class SelectOperatorModal extends React.Component {
} }
render() { render() {
const { visible } = this.props; const { visible } = this.props;
const { liveDataSource,liveSize,liveQuery,liveTotalCount,selectLive,currentLiveCourseListData,videoDataSource,videoSize,videoQuery,videoTotalCount,selectVideo,currentVideoCourseListData,activeKey} = this.state; const { liveDataSource,liveSize,liveQuery,liveTotalCount,selectLive,videoDataSource,videoSize,videoQuery,videoTotalCount,selectVideo,currentTaskCourseData,activeKey} = this.state;
return ( return (
<Modal <Modal
...@@ -369,7 +370,7 @@ class SelectOperatorModal extends React.Component { ...@@ -369,7 +370,7 @@ class SelectOperatorModal extends React.Component {
<span>已选择{selectVideo.length + selectLive.length}</span> <span>已选择{selectVideo.length + selectLive.length}</span>
<span onClick={this.clearSelectCourse}>清空</span> <span onClick={this.clearSelectCourse}>清空</span>
</span> </span>
<span>该任务已关联{currentVideoCourseListData.length + currentLiveCourseListData.length}个课程,可继续选择{20-(currentVideoCourseListData.length + currentLiveCourseListData.length )}</span> <span>该任务已关联{currentTaskCourseData.length}个课程,可继续选择{20- currentTaskCourseData.length }</span>
</div> </div>
<div> <div>
<Table <Table
...@@ -422,7 +423,7 @@ class SelectOperatorModal extends React.Component { ...@@ -422,7 +423,7 @@ class SelectOperatorModal extends React.Component {
<span>已选择{selectVideo.length + selectLive.length}</span> <span>已选择{selectVideo.length + selectLive.length}</span>
<span onClick={this.clearSelectCourse}>清空</span> <span onClick={this.clearSelectCourse}>清空</span>
</span> </span>
<span>该任务已关联{currentVideoCourseListData.length + currentLiveCourseListData.length}个课程,可继续选择{20-(currentVideoCourseListData.length + currentLiveCourseListData.length )}</span> <span>该任务已关联{currentTaskCourseData.length}个课程,可继续选择{20- currentTaskCourseData.length }</span>
</div> </div>
<div> <div>
<Table <Table
......
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