Commit 5bd610bd by guomingpang

fix:1。修复知识库。添加分类视频课时,分类筛选未初始化的问题。2、修复课程管理视频课程无法分享的问题

parent e22f9e10
/*
* @Author: 吴文洁
* @Date: 2020-08-05 10:12:45
* @LastEditors: wufan
* @LastEditTime: 2021-05-30 17:33:54
* @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-31 18:04:10
* @Description: 视频课-列表模块
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
import React from 'react'
import { Table, Modal, message, Tooltip, Switch, Dropdown } from 'antd'
import _ from 'underscore'
import { PageControl } from '@/components'
import { LIVE_SHARE } from '@/domains/course-domain/constants'
import React from 'react';
import { Table, Modal, message, Tooltip, Switch, Dropdown } from 'antd';
import _ from 'underscore';
import { PageControl } from '@/components';
import { LIVE_SHARE } from '@/domains/course-domain/constants';
import ShareLiveModal from '@/modules/course-manage/modal/ShareLiveModal'
import WatchDataModal from '../modal/WatchDataModal'
import CourseService from '@/domains/course-domain/CourseService'
import RelatedPlanModal from '../../modal/RelatedPlanModal'
import User from '@/common/js/user'
import ShareLiveModal from '@/modules/course-manage/modal/ShareLiveModal';
import WatchDataModal from '../modal/WatchDataModal';
import CourseService from '@/domains/course-domain/CourseService';
import RelatedPlanModal from '../../modal/RelatedPlanModal';
import User from '@/common/js/user';
import './VideoCourseList.less'
import './VideoCourseList.less';
class VideoCourseList extends React.Component {
constructor(props) {
super(props)
super(props);
this.state = {
id: '', // 视频课ID
studentIds: [],
......@@ -30,14 +30,14 @@ class VideoCourseList extends React.Component {
selectPlanList: {},
ShelfLoading: false,
// dataSource: [],
}
};
}
componentDidMount() {
const videoCourseItem = localStorage.getItem('videoCourseItem')
const videoCourseItem = localStorage.getItem('videoCourseItem');
if (videoCourseItem) {
const _videoCourseItem = JSON.parse(videoCourseItem)
this.handleShowShareModal(_videoCourseItem, true)
const _videoCourseItem = JSON.parse(videoCourseItem);
this.handleShowShareModal(_videoCourseItem, true);
}
}
......@@ -50,17 +50,17 @@ class VideoCourseList extends React.Component {
close={() => {
this.setState({
watchDataModal: null,
})
});
}}
/>
)
this.setState({ watchDataModal })
}
);
this.setState({ watchDataModal });
};
// 请求表头
parseColumns = () => {
const { type } = this.props
const { ShelfLoading } = this.state
const { type } = this.props;
const { ShelfLoading } = this.state;
const columns = [
{
title: '视频课',
......@@ -69,7 +69,7 @@ class VideoCourseList extends React.Component {
width: 321,
fixed: 'left',
render: (val, record) => {
const { coverUrl, scheduleVideoUrl } = record
const { coverUrl, scheduleVideoUrl } = record;
return (
<div className='record__item'>
{/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */}
......@@ -92,7 +92,7 @@ class VideoCourseList extends React.Component {
</Otherwise>
</Choose>
</div>
)
);
},
},
{
......@@ -124,7 +124,7 @@ class VideoCourseList extends React.Component {
<div className='record__item'>{record.categorySonName}</div>
</Otherwise>
</Choose>
)
);
},
},
{
......@@ -141,14 +141,27 @@ class VideoCourseList extends React.Component {
</Tooltip>
)}
</div>
)
);
},
},
{
title: <span>
<span>学院展示</span>
<Tooltip title={<div>开启后,学员可在学院内查看到此课程。<br/>关闭后,学院内不再展示此课程,但学员仍可通过分享的海报/链接查看此课程。</div>}><i className="icon iconfont" style={{ marginLeft: '5px',cursor:'pointer',color:'#bfbfbf',fontSize:'14px',fontWeight:'normal'}}>&#xe61d;</i></Tooltip>
</span>,
title: (
<span>
<span>学院展示</span>
<Tooltip
title={
<div>
开启后,学员可在学院内查看到此课程。
<br />
关闭后,学院内不再展示此课程,但学员仍可通过分享的海报/链接查看此课程。
</div>
}>
<i className='icon iconfont' style={{ marginLeft: '5px', cursor: 'pointer', color: '#bfbfbf', fontSize: '14px', fontWeight: 'normal' }}>
&#xe61d;
</i>
</Tooltip>
</span>
),
width: 120,
key: 'shelfState',
dataIndex: 'shelfState',
......@@ -159,10 +172,10 @@ class VideoCourseList extends React.Component {
checked={item.shelfState === 'YES'}
defaultChecked={item.shelfState}
onClick={(checked) => {
this.changeShelfState(checked, item, index)
this.changeShelfState(checked, item, index);
}}
/>
)
);
},
},
{
......@@ -171,7 +184,7 @@ class VideoCourseList extends React.Component {
key: 'watchUserCount',
dataIndex: 'watchUserCount',
render: (val, item) => {
return <div className='watchUserCount'>{val || 0}</div>
return <div className='watchUserCount'>{val || 0}</div>;
},
},
{
......@@ -181,7 +194,7 @@ class VideoCourseList extends React.Component {
dataIndex: 'created',
sorter: true,
render: (val) => {
return formatDate('YYYY-MM-DD H:i', val)
return formatDate('YYYY-MM-DD H:i', val);
},
},
{
......@@ -191,7 +204,7 @@ class VideoCourseList extends React.Component {
dataIndex: 'updated',
sorter: true,
render: (val) => {
return formatDate('YYYY-MM-DD H:i', val)
return formatDate('YYYY-MM-DD H:i', val);
},
},
{
......@@ -210,7 +223,7 @@ class VideoCourseList extends React.Component {
<span>
{item.planName} {index < record.relatedPlanList.length - 1 && <span></span>}
</span>
)
);
})}
</Tooltip>
</When>
......@@ -219,7 +232,7 @@ class VideoCourseList extends React.Component {
</Otherwise>
</Choose>
</div>
)
);
},
},
{
......@@ -234,7 +247,6 @@ class VideoCourseList extends React.Component {
<div className='operate__item' onClick={() => this.handleShowWatchDataModal(record)}>
观看数据
</div>
<If condition={type === 'internal'}>
<span className='operate__item split'> | </span>
<div className='operate__item' onClick={() => this.handleShowShareModal(record)}>
......@@ -243,28 +255,25 @@ class VideoCourseList extends React.Component {
</If>
<span className='operate__item split'> | </span>
<Dropdown overlay={this.renderMoreOperate(record)}>
<span className="more-operate">
<span className="operate-text">更多</span>
<span
className="iconfont icon"
style={{ color: "#2966FF" }}
>
<span className='more-operate'>
<span className='operate-text'>更多</span>
<span className='iconfont icon' style={{ color: '#2966FF' }}>
&#xe824;
</span>
</span>
</Dropdown>
</div>
)
);
},
},
]
];
type !== 'internal' && columns.splice(2, 1)
return columns
}
type !== 'internal' && columns.splice(2, 1);
return columns;
};
renderMoreOperate = (item) => {
const { type } = this.props
const { type } = this.props;
return (
<div className='live-course-more-menu'>
<If condition={type !== 'internal'}>
......@@ -281,7 +290,7 @@ class VideoCourseList extends React.Component {
<div
className='operate__item'
onClick={() => {
window.RCHistory.push(`/create-video-course?type=edit&id=${item.id}`)
window.RCHistory.push(`/create-video-course?type=edit&id=${item.id}`);
}}>
编辑
</div>
......@@ -290,41 +299,41 @@ class VideoCourseList extends React.Component {
</div>
</If>
</div>
)
}
);
};
handlePlanName = (planArray) => {
let planStr = ''
let planStr = '';
planArray.map((item, index) => {
if (index < planArray.length - 1) {
planStr = planStr + item.planName + '、'
planStr = planStr + item.planName + '、';
} else {
planStr = planStr + item.planName
planStr = planStr + item.planName;
}
})
return planStr
}
});
return planStr;
};
//改变上架状态
changeShelfState = (checked, item, index) => {
let _shelfState = checked ? 'YES' : 'NO'
let _shelfState = checked ? 'YES' : 'NO';
if (checked) {
_shelfState = 'YES'
_shelfState = 'YES';
} else {
_shelfState = 'NO'
_shelfState = 'NO';
}
const params = {
courseId: item.id,
shelfState: _shelfState,
}
};
CourseService.changeVideoShelfState(params).then(() => {
if (_shelfState === 'YES') {
message.success('已开启展示')
message.success('已开启展示');
} else {
message.success('已取消展示')
message.success('已取消展示');
}
this.props.changeShelfState(index, _shelfState)
})
}
this.props.changeShelfState(index, _shelfState);
});
};
// 删除视频课
handleDeleteVideoCourse = (scheduleId) => {
......@@ -339,28 +348,28 @@ class VideoCourseList extends React.Component {
const param = {
courseId: scheduleId,
storeId: User.getStoreId(),
}
};
CourseService.delVideoSchedule(param).then(() => {
message.success('删除成功')
this.props.onChange()
})
message.success('删除成功');
this.props.onChange();
});
},
})
}
});
};
// 显示分享弹窗
handleShowShareModal = (record, needStr = false) => {
const { type } = this.props
const { id, scheduleVideoUrl } = record
const htmlUrl = `${LIVE_SHARE}video_detail/${id}?id=${User.getStoreId()}`
const longUrl = htmlUrl
const { coverUrl, courseName } = record
const { type } = this.props;
const { id, scheduleVideoUrl } = record;
const htmlUrl = `${LIVE_SHARE}video_detail/${id}?id=${User.getStoreId()}`;
const longUrl = htmlUrl;
const { coverUrl, courseName } = record;
const shareData = {
longUrl,
coverUrl,
scheduleVideoUrl,
courseName,
}
};
const shareLiveModal = (
<ShareLiveModal
......@@ -372,82 +381,82 @@ class VideoCourseList extends React.Component {
close={() => {
this.setState({
shareLiveModal: null,
})
localStorage.setItem('videoCourseItem', '')
});
localStorage.setItem('videoCourseItem', '');
}}
/>
)
);
this.setState({ shareLiveModal })
}
this.setState({ shareLiveModal });
};
handleChangeTable = (pagination, filters, sorter) => {
const { columnKey, order } = sorter
const { query } = this.props
let { order: _order } = query
const { columnKey, order } = sorter;
const { query } = this.props;
let { order: _order } = query;
// 按创建时间升序排序
if (columnKey === 'created' && order === 'ascend') {
_order = 'CREATED_ASC'
_order = 'CREATED_ASC';
}
// 按创建时间降序排序
if (columnKey === 'created' && order === 'descend') {
_order = 'CREATED_DESC'
_order = 'CREATED_DESC';
}
// 按更新时间升序排序
if (columnKey === 'updated' && order === 'ascend') {
_order = 'UPDATED_ASC'
_order = 'UPDATED_ASC';
}
// 按更新时间降序排序
if (columnKey === 'updated' && order === 'descend') {
_order = 'UPDATED_DESC'
_order = 'UPDATED_DESC';
}
const _query = {
...query,
orderEnum: _order,
}
this.props.onChange(_query)
}
};
this.props.onChange(_query);
};
handleRelatedModalShow = (item) => {
const selectPlanList = {}
const selectPlanList = {};
if (item.relatedPlanList) {
item.relatedPlanList.map((item, index) => {
selectPlanList[item.planId] = {}
selectPlanList[item.planId].planId = item.planId
selectPlanList[item.planId].taskBaseVOList = [{ taskId: item.taskId }]
return item
})
selectPlanList[item.planId] = {};
selectPlanList[item.planId].planId = item.planId;
selectPlanList[item.planId].taskBaseVOList = [{ taskId: item.taskId }];
return item;
});
}
this.setState({
RelatedPlanModalVisible: true,
selectCourseId: item.id,
selectPlanList: selectPlanList,
})
}
});
};
closeRelatedPlanModalVisible = () => {
this.setState({
RelatedPlanModalVisible: false,
})
}
});
};
onChangeSelectPlanList = (selectPlanList) => {
this.setState({
selectPlanList: selectPlanList,
})
}
});
};
onConfirmSelectPlanList = () => {
this.setState(
{
RelatedPlanModalVisible: false,
},
() => {
this.props.onChange()
}
)
}
this.props.onChange();
},
);
};
render() {
const { dataSource = [], totalCount, query, type } = this.props
const { current, size } = query
const { RelatedPlanModalVisible, selectPlanList, selectCourseId } = this.state
const { dataSource = [], totalCount, query, type } = this.props;
const { current, size } = query;
const { RelatedPlanModalVisible, selectPlanList, selectCourseId } = this.state;
return (
<div className={`video-course-list ${type !== 'internal' ? 'video-course-list-mt' : ''}`}>
<Table
......@@ -467,8 +476,8 @@ class VideoCourseList extends React.Component {
pageSize={size}
total={totalCount}
toPage={(page) => {
const _query = { ...query, current: page + 1 }
this.props.onChange(_query)
const _query = { ...query, current: page + 1 };
this.props.onChange(_query);
}}
/>
</div>
......@@ -485,8 +494,8 @@ class VideoCourseList extends React.Component {
{this.state.shareLiveModal}
{this.state.watchDataModal}
</div>
)
);
}
}
export default VideoCourseList
export default VideoCourseList;
......@@ -2,30 +2,30 @@
* @Description:
* @Author: zangsuyun
* @Date: 2021-03-13 09:54:26
* @LastEditors: wufan
* @LastEditTime: 2021-05-30 17:35:11
* @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-31 18:23:28
* @Copyright: © 2020 杭州杰竞科技有限公司 版权所有
*/
import React from 'react'
import { Row, Modal, Button, message, Radio, Table, Input, Tabs, Tooltip, TreeSelect } from 'antd'
import { PageControl } from '@/components'
import TableSelectedData from '@/components/TableSelectedData'
import KnowledgeAPI from '@/data-source/knowledge/request-api'
import AidToolService from '@/domains/aid-tool-domain/AidToolService'
import User from '@/common/js/user'
import './LiveList.less'
import React from 'react';
import { Row, Modal, Button, message, Radio, Table, Input, Tabs, Tooltip, TreeSelect } from 'antd';
import { PageControl } from '@/components';
import TableSelectedData from '@/components/TableSelectedData';
import KnowledgeAPI from '@/data-source/knowledge/request-api';
import AidToolService from '@/domains/aid-tool-domain/AidToolService';
import User from '@/common/js/user';
import './LiveList.less';
import _ from 'underscore'
import dealTimeDuration from '../../course-manage/utils/dealTimeDuration'
import _ from 'underscore';
import dealTimeDuration from '../../course-manage/utils/dealTimeDuration';
const { Search } = Input
const { TabPane } = Tabs
const { Search } = Input;
const { TabPane } = Tabs;
const courseStateShow = {
UN_START: {
code: 1,
title: "待开课",
color: "#FFB129",
title: '待开课',
color: '#FFB129',
},
STARTING: {
code: 2,
......@@ -42,11 +42,11 @@ const courseStateShow = {
title: '未成功开课',
color: '#999',
},
}
};
class AddCourse extends React.Component {
constructor(props) {
super(props)
super(props);
this.state = {
liveDataSource: [],
liveSize: 10,
......@@ -126,13 +126,13 @@ class AddCourse extends React.Component {
selectPicture: [], //弹窗内已选择的图文课程
categoryList: [], //内部分类列表
categoryListExternal: [], //外部分类列表
}
};
}
componentDidMount() {
this.handleFetchLiveList()
this.handleFetchVideoList()
this.handleFetchPictureList()
this.queryCategoryTree()
this.handleFetchLiveList();
this.handleFetchVideoList();
this.handleFetchPictureList();
this.queryCategoryTree();
}
// 查询分类树
......@@ -140,27 +140,27 @@ class AddCourse extends React.Component {
let query = {
storeId: User.getStoreId(),
withCount: false,
}
};
let queryInternal = {
bizType: 'QUESTION',
source: 2,
tenantId: User.getStoreId(),
userId: User.getStoreUserId(),
count: false,
}
};
AidToolService.queryExternalCategoryTree(queryInternal).then((res) => {
const { categoryList = [] } = res.result
const { categoryList = [] } = res.result;
this.setState({
categoryListExternal: this.renderTreeNodes(categoryList),
})
})
});
});
KnowledgeAPI.getCategoryTree(query).then((res) => {
const { categoryList = [] } = res.result
const { categoryList = [] } = res.result;
this.setState({
categoryList: this.renderTreeNodes(categoryList),
})
})
}
});
});
};
renderTreeNodes = (data) => {
let newTreeData = data.map((item) => {
......@@ -171,50 +171,50 @@ class AddCourse extends React.Component {
</span>
{item.categoryName}
</span>
)
item.key = item.id
);
item.key = item.id;
if (item.sonCategoryList) {
item.children = this.renderTreeNodes(item.sonCategoryList)
item.children = this.renderTreeNodes(item.sonCategoryList);
}
return item
})
return newTreeData
}
return item;
});
return newTreeData;
};
// 获取直播课列表
handleFetchLiveList = () => {
const { liveQuery, liveSize } = this.state
const { liveQuery, liveSize } = this.state;
const params = {
...liveQuery,
size: liveSize,
}
};
// CourseService.getLiveCloudCoursePage(params).then((res) => {
KnowledgeAPI.knowledgeLiveCoursePage(params).then((res) => {
const { result = {} } = res
const { records = [], total = 0 } = result
const { result = {} } = res;
const { records = [], total = 0 } = result;
this.setState({
liveDataSource: records,
liveTotalCount: Number(total),
})
})
}
});
});
};
// 获取视频课列表
handleFetchVideoList = () => {
const { videoQuery, videoSize, videoCourseDivision, videoDataSource, videoTotalCount } = this.state
const { videoQuery, videoSize, videoCourseDivision, videoDataSource, videoTotalCount } = this.state;
const params = {
...videoQuery[videoCourseDivision],
size: videoSize[videoCourseDivision],
courseDivision: videoCourseDivision === 'internal' ? 'INTERNAL' : 'EXTERNAL',
}
};
// CourseService.videoSchedulePage(query).then((res) => {
KnowledgeAPI.knowledgeMediaCoursePage(params).then((res) => {
const { result = {} } = res || {}
const { records = [], total = 0 } = result
const { result = {} } = res || {};
const { records = [], total = 0 } = result;
this.setState({
videoDataSource: {
...videoDataSource,
......@@ -224,71 +224,71 @@ class AddCourse extends React.Component {
...videoTotalCount,
[videoCourseDivision]: Number(total),
},
})
})
}
});
});
};
// 获取图文课列表
handleFetchPictureList = () => {
const { pictureQuery, pictureSize } = this.state
const { pictureQuery, pictureSize } = this.state;
const params = {
...pictureQuery,
size: pictureSize,
}
};
// CourseService.pictureSchedulePage(query).then((res) => {
KnowledgeAPI.knowledgeMediaCoursePage(params).then((res) => {
const { result = {} } = res || {}
const { records = [], total = 0 } = result
const { result = {} } = res || {};
const { records = [], total = 0 } = result;
this.setState({
pictureDataSource: records,
pictureTotalCount: Number(total),
})
})
}
});
});
};
onShowLiveSizeChange = (current, size) => {
if (current === size) {
return
return;
}
this.setState(
{
liveSize: size,
},
() => {
this.handleFetchLiveList()
}
)
}
this.handleFetchLiveList();
},
);
};
onShowVideoSizeChange = (current, size) => {
if (current === size) {
return
return;
}
this.setState(
{
videoSize: size,
},
() => {
this.handleFetchVideoList()
}
)
}
this.handleFetchVideoList();
},
);
};
onShowPictureSizeChange = (current, size) => {
if (current === size) {
return
return;
}
this.setState(
{
pictureSize: size,
},
() => {
this.handleFetchPictureList()
}
)
}
this.handleFetchPictureList();
},
);
};
liveColumns = () => {
const columns = [
......@@ -300,13 +300,12 @@ class AddCourse extends React.Component {
<i
className='icon iconfont'
style={{
marginLeft: "5px",
cursor: "pointer",
color: "#bfbfbf",
fontSize: "14px",
fontWeight:"400"
}}
>
marginLeft: '5px',
cursor: 'pointer',
color: '#bfbfbf',
fontSize: '14px',
fontWeight: '400',
}}>
&#xe61d;
</i>
</Tooltip>
......@@ -316,13 +315,13 @@ class AddCourse extends React.Component {
key: 'course',
dataIndex: 'courseName',
render: (val, record) => {
let hasCover = false
let hasCover = false;
return (
<div className='record__item'>
{record.courseMediaVOS.map((item) => {
if (item.contentType === 'COVER') {
hasCover = true
return <img className='course-cover' src={item.mediaUrl} alt='' />
hasCover = true;
return <img className='course-cover' src={item.mediaUrl} alt='' />;
}
})}
{!hasCover && <img className='course-cover' src={'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'} alt='' />}
......@@ -349,7 +348,7 @@ class AddCourse extends React.Component {
</div>
</div>
</div>
)
);
},
},
{
......@@ -363,7 +362,7 @@ class AddCourse extends React.Component {
{formatDate('YYYY-MM-DD', parseInt(item.startTime))} <br></br>
{formatDate('H:i', parseInt(item.startTime))}~{formatDate('H:i', parseInt(item.endTime))}
</span>
)
);
},
},
......@@ -378,16 +377,16 @@ class AddCourse extends React.Component {
{record.categoryOneName}
{record.categoryTwoName ? `-${record.categoryTwoName}` : ''}
</div>
)
);
},
},
]
];
return columns
}
return columns;
};
videoColumns = () => {
const { videoCourseDivision } = this.state
const { videoCourseDivision } = this.state;
const columns = [
{
title: (
......@@ -397,13 +396,12 @@ class AddCourse extends React.Component {
<i
className='icon iconfont'
style={{
marginLeft: "5px",
cursor: "pointer",
color: "#bfbfbf",
fontSize: "14px",
fontWeight:"400"
}}
>
marginLeft: '5px',
cursor: 'pointer',
color: '#bfbfbf',
fontSize: '14px',
fontWeight: '400',
}}>
&#xe61d;
</i>
</Tooltip>
......@@ -413,7 +411,7 @@ class AddCourse extends React.Component {
dataIndex: 'scheduleName',
width: 300,
render: (val, record) => {
const { coverUrl, mediaCourseUrl } = record
const { coverUrl, mediaCourseUrl } = record;
return (
<div className='record__item'>
{/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */}
......@@ -438,7 +436,7 @@ class AddCourse extends React.Component {
</Otherwise>
</Choose>
</div>
)
);
},
},
{
......@@ -447,7 +445,7 @@ class AddCourse extends React.Component {
width: 80,
dataIndex: 'videoDuration',
render: (text, item) => {
return <span>{text ? dealTimeDuration(text) : '-'}</span>
return <span>{text ? dealTimeDuration(text) : '-'}</span>;
},
},
......@@ -468,12 +466,12 @@ class AddCourse extends React.Component {
<div className='record__item'>{record.categorySonName}</div>
</Otherwise>
</Choose>
)
);
},
},
]
return columns
}
];
return columns;
};
pictureColumns = () => {
const columns = [
......@@ -485,13 +483,12 @@ class AddCourse extends React.Component {
<i
className='icon iconfont'
style={{
marginLeft: "5px",
cursor: "pointer",
color: "#bfbfbf",
fontSize: "14px",
fontWeight:"400"
}}
>
marginLeft: '5px',
cursor: 'pointer',
color: '#bfbfbf',
fontSize: '14px',
fontWeight: '400',
}}>
&#xe61d;
</i>
</Tooltip>
......@@ -501,7 +498,7 @@ class AddCourse extends React.Component {
dataIndex: 'scheduleName',
width: 371,
render: (val, record) => {
const { coverUrl } = record
const { coverUrl } = record;
return (
<div className='record__item'>
{/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */}
......@@ -517,7 +514,7 @@ class AddCourse extends React.Component {
</Otherwise>
</Choose>
</div>
)
);
},
},
{
......@@ -530,34 +527,34 @@ class AddCourse extends React.Component {
{record.categoryOneName}
{record.categoryTwoName ? `-${record.categoryTwoName}` : ''}
</div>
)
);
},
},
]
return columns
}
];
return columns;
};
selectLiveList = (record, selected) => {
let { selectLive } = this.state
let _list = []
let { selectLive } = this.state;
let _list = [];
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 {
_list = _.reject(selectLive, (item) => item.liveCourseId === record.liveCourseId)
_list = _.reject(selectLive, (item) => item.liveCourseId === record.liveCourseId);
}
this.setState({ selectLive: _list })
}
this.setState({ selectLive: _list });
};
selectVideoList = (record, selected) => {
const { selectVideo, videoCourseDivision } = this.state
const { selectVideo, videoCourseDivision } = this.state;
let { [videoCourseDivision]: selectList } = selectVideo
let { [videoCourseDivision]: selectList } = selectVideo;
let _list = []
let _list = [];
if (selected || !_.find(selectList, (item) => item.id === record.id)) {
_list = _.uniq(selectList.concat([record]), false, (item) => item.id)
_list = _.uniq(selectList.concat([record]), false, (item) => item.id);
} else {
_list = _.reject(selectList, (item) => item.id === record.id)
_list = _.reject(selectList, (item) => item.id === record.id);
}
this.setState({
......@@ -565,79 +562,79 @@ class AddCourse extends React.Component {
...selectVideo,
[videoCourseDivision]: _list,
},
})
}
});
};
selectPictureList = (record, selected) => {
console.log(record)
let { selectPicture } = this.state
let _list = []
console.log(record);
let { selectPicture } = this.state;
let _list = [];
if (selected || !_.find(selectPicture, (item) => item.id == record.id)) {
_list = _.uniq(selectPicture.concat([record]), false, (item) => item.id)
_list = _.uniq(selectPicture.concat([record]), false, (item) => item.id);
} else {
_list = _.reject(selectPicture, (item) => item.id === record.id)
_list = _.reject(selectPicture, (item) => item.id === record.id);
}
this.setState({ selectPicture: _list })
}
this.setState({ selectPicture: _list });
};
callback(key) {
console.log(key)
console.log(key);
}
handleChangVideoFilter = (key, value) => {
const { videoQuery, videoCourseDivision, videoSearchDefalt } = this.state
videoQuery[videoCourseDivision][key] = value
videoSearchDefalt[videoCourseDivision][key] = value
videoQuery[videoCourseDivision].current = 1
const { videoQuery, videoCourseDivision, videoSearchDefalt } = this.state;
videoQuery[videoCourseDivision][key] = value;
videoSearchDefalt[videoCourseDivision][key] = value;
videoQuery[videoCourseDivision].current = 1;
this.setState(
{
videoQuery,
videoSearchDefalt,
},
() => {
this.handleFetchVideoList()
}
)
}
this.handleFetchVideoList();
},
);
};
handleChangVideoCourseName = (e) => {
const { videoSearchDefalt, videoCourseDivision } = this.state
videoSearchDefalt[videoCourseDivision].courseName = e.target.value
const { videoSearchDefalt, videoCourseDivision } = this.state;
videoSearchDefalt[videoCourseDivision].courseName = e.target.value;
this.setState({
videoSearchDefalt,
})
}
});
};
handleChangLiveFilter = (key, value) => {
const { liveQuery } = this.state
liveQuery[key] = value
liveQuery.current = 1
const { liveQuery } = this.state;
liveQuery[key] = value;
liveQuery.current = 1;
this.setState(
{
liveQuery,
},
() => {
this.handleFetchLiveList()
}
)
}
this.handleFetchLiveList();
},
);
};
handleChangPictureFilter = (key, value) => {
const { pictureQuery } = this.state
pictureQuery[key] = value
pictureQuery.current = 1
const { pictureQuery } = this.state;
pictureQuery[key] = value;
pictureQuery.current = 1;
this.setState(
{
pictureQuery,
},
() => {
this.handleFetchPictureList()
}
)
}
this.handleFetchPictureList();
},
);
};
handAddCourse = () => {
const { selectVideo, selectLive, selectPicture } = this.state
const batchAddList = []
const { selectVideo, selectLive, selectPicture } = this.state;
const batchAddList = [];
if (selectVideo.external.length) {
batchAddList.push({
categoryId: this.props.categoryId,
......@@ -645,7 +642,7 @@ class AddCourse extends React.Component {
storeId: User.getStoreId(),
type: 'VOICE',
createId: User.getStoreUserId(),
})
});
}
if (selectVideo.internal.length) {
batchAddList.push({
......@@ -654,7 +651,7 @@ class AddCourse extends React.Component {
storeId: User.getStoreId(),
type: 'VOICE',
createId: User.getStoreUserId(),
})
});
}
if (selectLive.length) {
batchAddList.push({
......@@ -663,7 +660,7 @@ class AddCourse extends React.Component {
storeId: User.getStoreId(),
type: 'LIVE',
createId: User.getStoreUserId(),
})
});
}
if (selectPicture.length) {
batchAddList.push({
......@@ -672,20 +669,20 @@ class AddCourse extends React.Component {
storeId: User.getStoreId(),
type: 'PICTURE',
createId: User.getStoreUserId(),
})
});
}
KnowledgeAPI.addDifTypeKnowledge({ batchAddList }).then(({ success }) => {
if (success) {
message.success('新增成功')
this.props.onClose()
this.props.onChange()
this.props.updateCategoryTree()
message.success('新增成功');
this.props.onClose();
this.props.onChange();
this.props.updateCategoryTree();
}
})
}
});
};
videoCourseDivisionChange = (e) => {
const { videoQuery, videoSearchDefalt } = this.state
const { videoQuery, videoSearchDefalt } = this.state;
this.setState(
{
videoCourseDivision: e.target.value,
......@@ -698,13 +695,13 @@ class AddCourse extends React.Component {
},
},
() => {
this.handleFetchVideoList()
}
)
}
this.handleFetchVideoList();
},
);
};
renderFooter = () => {
const { selectVideo, selectPicture, selectLive } = this.state
const { selectVideo, selectPicture, selectLive } = this.state;
return (
<div>
<Button onClick={this.props.onClose}>取消</Button>
......@@ -715,8 +712,8 @@ class AddCourse extends React.Component {
确定
</Button>
</div>
)
}
);
};
render() {
const {
......@@ -739,54 +736,54 @@ class AddCourse extends React.Component {
videoSearchDefalt,
categoryList,
categoryListExternal,
} = this.state
} = this.state;
const LiveSelection = {
selectedRowKeys: _.pluck(selectLive, 'liveCourseId'),
onSelect: this.selectLiveList,
onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = []
let _list = [];
if (selected) {
_list = _.uniq(selectLive.concat(changeRows), false, (item) => item.liveCourseId)
_list = _.uniq(selectLive.concat(changeRows), false, (item) => item.liveCourseId);
} else {
_list = _.reject(selectLive, (item) => _.find(changeRows, (data) => data.liveCourseId === item.liveCourseId))
_list = _.reject(selectLive, (item) => _.find(changeRows, (data) => data.liveCourseId === item.liveCourseId));
}
this.setState({ selectLive: _list })
this.setState({ selectLive: _list });
},
}
};
const VideoSelection = {
selectedRowKeys: _.pluck(selectVideo[videoCourseDivision], 'id'),
onSelect: this.selectVideoList,
onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = []
let _list = [];
if (selected) {
_list = _.uniq(selectVideo[videoCourseDivision].concat(changeRows), false, (item) => item.id)
_list = _.uniq(selectVideo[videoCourseDivision].concat(changeRows), false, (item) => item.id);
} else {
_list = _.reject(selectVideo[videoCourseDivision], (item) => _.find(changeRows, (data) => data.id === item.id))
_list = _.reject(selectVideo[videoCourseDivision], (item) => _.find(changeRows, (data) => data.id === item.id));
}
this.setState({
selectVideo: {
...selectVideo,
[videoCourseDivision]: _list,
},
})
});
},
}
};
const PictureSelection = {
selectedRowKeys: _.pluck(selectPicture, 'id'),
onSelect: this.selectPictureList,
onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = []
let _list = [];
if (selected) {
_list = _.uniq(selectPicture.concat(changeRows), false, (item) => item.id)
_list = _.uniq(selectPicture.concat(changeRows), false, (item) => item.id);
} else {
_list = _.reject(selectPicture, (item) => _.find(changeRows, (data) => data.id === item.id))
_list = _.reject(selectPicture, (item) => _.find(changeRows, (data) => data.id === item.id));
}
this.setState({ selectPicture: _list })
this.setState({ selectPicture: _list });
},
}
};
return (
<Modal visible={true} width={800} title='新增课程' footer={this.renderFooter()} onCancel={this.props.onClose} className='add-course-modal'>
......@@ -801,7 +798,7 @@ class AddCourse extends React.Component {
style={{ width: 'calc(100% - 75px)' }}
placeholder='搜索课程名称'
onSearch={(value) => {
this.handleChangLiveFilter('courseName', value)
this.handleChangLiveFilter('courseName', value);
}}
enterButton={<span className='icon iconfont'>&#xe832;</span>}
/>
......@@ -817,7 +814,7 @@ class AddCourse extends React.Component {
placeholder='请选择课程类型'
allowClear
onChange={(value) => {
this.handleChangLiveFilter('categoryId', value)
this.handleChangLiveFilter('categoryId', value);
}}
/>
</div>
......@@ -833,7 +830,7 @@ class AddCourse extends React.Component {
},
selectLive: [],
selectPicture: [],
})
});
}}
/>
<Table
......@@ -854,15 +851,15 @@ class AddCourse extends React.Component {
pageSize={liveSize}
total={parseInt(liveTotalCount)}
toPage={(page) => {
const _query = { ...liveQuery, current: page + 1 }
const _query = { ...liveQuery, current: page + 1 };
this.setState(
{
liveQuery: _query,
},
() => {
this.handleFetchLiveList()
}
)
this.handleFetchLiveList();
},
);
}}
onShowSizeChange={this.onShowLiveSizeChange}
/>
......@@ -886,7 +883,7 @@ class AddCourse extends React.Component {
placeholder='搜索课程名称'
onChange={this.handleChangVideoCourseName}
onSearch={(value) => {
this.handleChangVideoFilter('courseName', value)
this.handleChangVideoFilter('courseName', value);
}}
enterButton={<span className='icon iconfont'>&#xe832;</span>}
/>
......@@ -897,13 +894,14 @@ class AddCourse extends React.Component {
treeNodeFilterProp='categoryName'
showSearch
style={{ minWidth: 'calc(100% - 75px)' }}
value={videoQuery[videoCourseDivision].categoryId || null}
dropdownMatchSelectWidth={false}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
treeData={videoCourseDivision === 'internal' ? categoryList : categoryListExternal}
placeholder='请选择课程类型'
allowClear
onChange={(value) => {
this.handleChangVideoFilter('categoryId', value)
this.handleChangVideoFilter('categoryId', value);
}}
/>
</div>
......@@ -919,7 +917,7 @@ class AddCourse extends React.Component {
},
selectLive: [],
selectPicture: [],
})
});
}}
/>
<Table
......@@ -941,8 +939,8 @@ class AddCourse extends React.Component {
pageSize={videoSize[videoCourseDivision]}
total={videoTotalCount[videoCourseDivision]}
toPage={(page) => {
const _query = { ...videoQuery[videoCourseDivision], current: page + 1 }
console.log('_query', _query)
const _query = { ...videoQuery[videoCourseDivision], current: page + 1 };
console.log('_query', _query);
this.setState(
{
videoQuery: {
......@@ -951,9 +949,9 @@ class AddCourse extends React.Component {
},
},
() => {
this.handleFetchVideoList()
}
)
this.handleFetchVideoList();
},
);
}}
onShowSizeChange={this.onShowVideoSizeChange}
/>
......@@ -972,7 +970,7 @@ class AddCourse extends React.Component {
style={{ width: 'calc(100% - 75px)' }}
placeholder='搜索课程名称'
onSearch={(value) => {
this.handleChangPictureFilter('courseName', value)
this.handleChangPictureFilter('courseName', value);
}}
enterButton={<span className='icon iconfont'>&#xe832;</span>}
/>
......@@ -988,7 +986,7 @@ class AddCourse extends React.Component {
placeholder='请选择课程类型'
allowClear
onChange={(value) => {
this.handleChangPictureFilter('categoryId', value)
this.handleChangPictureFilter('categoryId', value);
}}
/>
</div>
......@@ -1004,7 +1002,7 @@ class AddCourse extends React.Component {
},
selectLive: [],
selectPicture: [],
})
});
}}
/>
<Table
......@@ -1025,15 +1023,15 @@ class AddCourse extends React.Component {
pageSize={pictureSize}
total={parseInt(pictureTotalCount)}
toPage={(page) => {
const _query = { ...pictureQuery, current: page + 1 }
const _query = { ...pictureQuery, current: page + 1 };
this.setState(
{
pictureQuery: _query,
},
() => {
this.handleFetchPictureList()
}
)
this.handleFetchPictureList();
},
);
}}
onShowSizeChange={this.onShowPictureSizeChange}
/>
......@@ -1043,7 +1041,7 @@ class AddCourse extends React.Component {
</TabPane>
</Tabs>
</Modal>
)
);
}
}
export default AddCourse
export default AddCourse;
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