Commit 435c83c7 by wufan

Merge branch 'hotfix/pangguoming/20210601/plan_list_add_cover' into 'master'

Hotfix/pangguoming/20210601/plan list add cover

See merge request !32
parents 4098f112 e340da37
...@@ -3,50 +3,50 @@ ...@@ -3,50 +3,50 @@
* @Author: zangsuyun * @Author: zangsuyun
* @Date: 2021-03-13 09:54:26 * @Date: 2021-03-13 09:54:26
* @LastEditors: fusanqiasng * @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-30 23:59:36 * @LastEditTime: 2021-06-01 10:26:46
* @Copyright: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyright: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React from 'react' import React from 'react';
import { Row, Modal, Button, message, Radio, Table, Input, Tabs, Tooltip, TreeSelect } from 'antd' import { Row, Modal, Button, message, Radio, Table, Input, Tabs, Tooltip, TreeSelect } from 'antd';
import { PageControl } from '@/components' import { PageControl } from '@/components';
import TableSelectedData from '@/components/TableSelectedData' import TableSelectedData from '@/components/TableSelectedData';
import KnowledgeAPI from '@/data-source/knowledge/request-api' import KnowledgeAPI from '@/data-source/knowledge/request-api';
import AidToolService from '@/domains/aid-tool-domain/AidToolService' import AidToolService from '@/domains/aid-tool-domain/AidToolService';
import User from '@/common/js/user' import User from '@/common/js/user';
import './LiveList.less' import './LiveList.less';
import _ from 'underscore' import _ from 'underscore';
import dealTimeDuration from '../../course-manage/utils/dealTimeDuration' import dealTimeDuration from '../../course-manage/utils/dealTimeDuration';
const { Search } = Input const { Search } = Input;
const { TabPane } = Tabs const { TabPane } = Tabs;
const courseStateShow = { const courseStateShow = {
UN_START: { UN_START: {
code: 1, code: 1,
title: '待开课', title: '待开课',
color: '#FFB129' color: '#FFB129',
}, },
STARTING: { STARTING: {
code: 2, code: 2,
title: '上课中', title: '上课中',
color: '#238FFF' color: '#238FFF',
}, },
FINISH: { FINISH: {
code: 3, code: 3,
title: '已完成', title: '已完成',
color: '#3BBDAA' color: '#3BBDAA',
}, },
EXPIRED: { EXPIRED: {
code: 4, code: 4,
title: '未成功开课', title: '未成功开课',
color: '#999' color: '#999',
} },
} };
class AddCourse extends React.Component { class AddCourse extends React.Component {
constructor(props) { constructor(props) {
super(props) super(props);
this.state = { this.state = {
liveDataSource: [], liveDataSource: [],
liveSize: 10, liveSize: 10,
...@@ -55,7 +55,7 @@ class AddCourse extends React.Component { ...@@ -55,7 +55,7 @@ class AddCourse extends React.Component {
excludeUsed: true, excludeUsed: true,
courseType: 'LIVE', courseType: 'LIVE',
storeId: User.getStoreId(), storeId: User.getStoreId(),
toRefKnowledgeCategoryId: this.props.categoryId toRefKnowledgeCategoryId: this.props.categoryId,
}, },
liveTotalCount: 0, liveTotalCount: 0,
selectLive: [], //弹窗内已选择的直播课程 selectLive: [], //弹窗内已选择的直播课程
...@@ -63,21 +63,21 @@ class AddCourse extends React.Component { ...@@ -63,21 +63,21 @@ class AddCourse extends React.Component {
videoCourseDivision: 'internal', videoCourseDivision: 'internal',
videoDataSource: { videoDataSource: {
external: [], external: [],
internal: [] internal: [],
}, },
videoSize: { videoSize: {
external: 10, external: 10,
internal: 10 internal: 10,
}, },
videoSearchDefalt: { videoSearchDefalt: {
external: { external: {
categoryId: '', categoryId: '',
courseName: '' courseName: '',
}, },
internal: { internal: {
categoryId: '', categoryId: '',
courseName: '' courseName: '',
} },
}, },
videoQuery: { videoQuery: {
...@@ -88,7 +88,7 @@ class AddCourse extends React.Component { ...@@ -88,7 +88,7 @@ class AddCourse extends React.Component {
courseType: 'VOICE', courseType: 'VOICE',
excludeUsed: true, excludeUsed: true,
storeId: User.getStoreId(), storeId: User.getStoreId(),
toRefKnowledgeCategoryId: this.props.categoryId toRefKnowledgeCategoryId: this.props.categoryId,
}, },
internal: { internal: {
categoryId: '', categoryId: '',
...@@ -97,20 +97,20 @@ class AddCourse extends React.Component { ...@@ -97,20 +97,20 @@ class AddCourse extends React.Component {
courseType: 'VOICE', courseType: 'VOICE',
excludeUsed: true, excludeUsed: true,
storeId: User.getStoreId(), storeId: User.getStoreId(),
toRefKnowledgeCategoryId: this.props.categoryId toRefKnowledgeCategoryId: this.props.categoryId,
} },
}, },
videoTotalCount: { videoTotalCount: {
external: 0, external: 0,
internal: 0 internal: 0,
}, },
selectVideo: { selectVideo: {
external: [], external: [],
internal: [] internal: [],
}, //弹窗内已选择的视频课程 }, //弹窗内已选择的视频课程
currentVideoCourseListData: { currentVideoCourseListData: {
external: [], external: [],
internal: [] internal: [],
}, //页面中已关联的视频课程 }, //页面中已关联的视频课程
pictureDataSource: [], pictureDataSource: [],
...@@ -120,47 +120,47 @@ class AddCourse extends React.Component { ...@@ -120,47 +120,47 @@ class AddCourse extends React.Component {
excludeUsed: true, excludeUsed: true,
courseType: 'PICTURE', courseType: 'PICTURE',
storeId: User.getStoreId(), storeId: User.getStoreId(),
toRefKnowledgeCategoryId: this.props.categoryId toRefKnowledgeCategoryId: this.props.categoryId,
}, },
pictureTotalCount: 0, pictureTotalCount: 0,
selectPicture: [], //弹窗内已选择的图文课程 selectPicture: [], //弹窗内已选择的图文课程
categoryList: [], //内部分类列表 categoryList: [], //内部分类列表
categoryListExternal: [] //外部分类列表 categoryListExternal: [], //外部分类列表
} };
} }
componentDidMount() { componentDidMount() {
this.handleFetchLiveList() this.handleFetchLiveList();
this.handleFetchVideoList() this.handleFetchVideoList();
this.handleFetchPictureList() this.handleFetchPictureList();
this.queryCategoryTree() this.queryCategoryTree();
} }
// 查询分类树 // 查询分类树
queryCategoryTree = (categoryName) => { queryCategoryTree = (categoryName) => {
let query = { let query = {
storeId: User.getStoreId(), storeId: User.getStoreId(),
withCount: false withCount: false,
} };
let queryInternal = { let queryInternal = {
bizType: 'QUESTION', bizType: 'QUESTION',
source: 2, source: 2,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
count: false count: false,
} };
AidToolService.queryExternalCategoryTree(queryInternal).then((res) => { AidToolService.queryExternalCategoryTree(queryInternal).then((res) => {
const { categoryList = [] } = res.result const { categoryList = [] } = res.result;
this.setState({ this.setState({
categoryListExternal: this.renderTreeNodes(categoryList) categoryListExternal: this.renderTreeNodes(categoryList),
}) });
}) });
KnowledgeAPI.getCategoryTree(query).then((res) => { KnowledgeAPI.getCategoryTree(query).then((res) => {
const { categoryList = [] } = res.result const { categoryList = [] } = res.result;
this.setState({ this.setState({
categoryList: this.renderTreeNodes(categoryList) categoryList: this.renderTreeNodes(categoryList),
}) });
}) });
} };
renderTreeNodes = (data) => { renderTreeNodes = (data) => {
let newTreeData = data.map((item) => { let newTreeData = data.map((item) => {
...@@ -171,124 +171,124 @@ class AddCourse extends React.Component { ...@@ -171,124 +171,124 @@ class AddCourse extends React.Component {
</span> </span>
{item.categoryName} {item.categoryName}
</span> </span>
) );
item.key = item.id item.key = item.id;
if (item.sonCategoryList) { if (item.sonCategoryList) {
item.children = this.renderTreeNodes(item.sonCategoryList) item.children = this.renderTreeNodes(item.sonCategoryList);
}
return item
})
return newTreeData
} }
return item;
});
return newTreeData;
};
// 获取直播课列表 // 获取直播课列表
handleFetchLiveList = () => { handleFetchLiveList = () => {
const { liveQuery, liveSize } = this.state const { liveQuery, liveSize } = this.state;
const params = { const params = {
...liveQuery, ...liveQuery,
size: liveSize size: liveSize,
} };
// CourseService.getLiveCloudCoursePage(params).then((res) => { // CourseService.getLiveCloudCoursePage(params).then((res) => {
KnowledgeAPI.knowledgeLiveCoursePage(params).then((res) => { KnowledgeAPI.knowledgeLiveCoursePage(params).then((res) => {
const { result = {} } = res const { result = {} } = res;
const { records = [], total = 0 } = result const { records = [], total = 0 } = result;
this.setState({ this.setState({
liveDataSource: records, liveDataSource: records,
liveTotalCount: Number(total) liveTotalCount: Number(total),
}) });
}) });
} };
// 获取视频课列表 // 获取视频课列表
handleFetchVideoList = () => { handleFetchVideoList = () => {
const { videoQuery, videoSize, videoCourseDivision, videoDataSource, videoTotalCount } = this.state const { videoQuery, videoSize, videoCourseDivision, videoDataSource, videoTotalCount } = this.state;
const params = { const params = {
...videoQuery[videoCourseDivision], ...videoQuery[videoCourseDivision],
size: videoSize[videoCourseDivision], size: videoSize[videoCourseDivision],
courseDivision: videoCourseDivision === 'internal' ? 'INTERNAL' : 'EXTERNAL' courseDivision: videoCourseDivision === 'internal' ? 'INTERNAL' : 'EXTERNAL',
} };
// CourseService.videoSchedulePage(query).then((res) => { // CourseService.videoSchedulePage(query).then((res) => {
KnowledgeAPI.knowledgeMediaCoursePage(params).then((res) => { KnowledgeAPI.knowledgeMediaCoursePage(params).then((res) => {
const { result = {} } = res || {} const { result = {} } = res || {};
const { records = [], total = 0 } = result const { records = [], total = 0 } = result;
this.setState({ this.setState({
videoDataSource: { videoDataSource: {
...videoDataSource, ...videoDataSource,
[videoCourseDivision]: records [videoCourseDivision]: records,
}, },
videoTotalCount: { videoTotalCount: {
...videoTotalCount, ...videoTotalCount,
[videoCourseDivision]: Number(total) [videoCourseDivision]: Number(total),
} },
}) });
}) });
} };
// 获取图文课列表 // 获取图文课列表
handleFetchPictureList = () => { handleFetchPictureList = () => {
const { pictureQuery, pictureSize } = this.state const { pictureQuery, pictureSize } = this.state;
const params = { const params = {
...pictureQuery, ...pictureQuery,
size: pictureSize size: pictureSize,
} };
// CourseService.pictureSchedulePage(query).then((res) => { // CourseService.pictureSchedulePage(query).then((res) => {
KnowledgeAPI.knowledgeMediaCoursePage(params).then((res) => { KnowledgeAPI.knowledgeMediaCoursePage(params).then((res) => {
const { result = {} } = res || {} const { result = {} } = res || {};
const { records = [], total = 0 } = result const { records = [], total = 0 } = result;
this.setState({ this.setState({
pictureDataSource: records, pictureDataSource: records,
pictureTotalCount: Number(total) pictureTotalCount: Number(total),
}) });
}) });
} };
onShowLiveSizeChange = (current, size) => { onShowLiveSizeChange = (current, size) => {
if (current === size) { if (current === size) {
return return;
} }
this.setState( this.setState(
{ {
liveSize: size liveSize: size,
}, },
() => { () => {
this.handleFetchLiveList() this.handleFetchLiveList();
}
)
} }
);
};
onShowVideoSizeChange = (current, size) => { onShowVideoSizeChange = (current, size) => {
if (current === size) { if (current === size) {
return return;
} }
this.setState( this.setState(
{ {
videoSize: size videoSize: size,
}, },
() => { () => {
this.handleFetchVideoList() this.handleFetchVideoList();
}
)
} }
);
};
onShowPictureSizeChange = (current, size) => { onShowPictureSizeChange = (current, size) => {
if (current === size) { if (current === size) {
return return;
} }
this.setState( this.setState(
{ {
pictureSize: size pictureSize: size,
}, },
() => { () => {
this.handleFetchPictureList() this.handleFetchPictureList();
}
)
} }
);
};
liveColumns = () => { liveColumns = () => {
const columns = [ const columns = [
...@@ -304,7 +304,7 @@ class AddCourse extends React.Component { ...@@ -304,7 +304,7 @@ class AddCourse extends React.Component {
cursor: 'pointer', cursor: 'pointer',
color: '#bfbfbf', color: '#bfbfbf',
fontSize: '14px', fontSize: '14px',
fontWeight: '400' fontWeight: '400',
}}> }}>
&#xe61d; &#xe61d;
</i> </i>
...@@ -315,13 +315,13 @@ class AddCourse extends React.Component { ...@@ -315,13 +315,13 @@ class AddCourse extends React.Component {
key: 'course', key: 'course',
dataIndex: 'courseName', dataIndex: 'courseName',
render: (val, record) => { render: (val, record) => {
let hasCover = false let hasCover = false;
return ( return (
<div className='record__item'> <div className='record__item'>
{record.courseMediaVOS.map((item) => { {record.courseMediaVOS.map((item) => {
if (item.contentType === 'COVER') { if (item.contentType === 'COVER') {
hasCover = true hasCover = true;
return <img className='course-cover' src={item.mediaUrl} alt='' /> return <img className='course-cover' src={item.mediaUrl} alt='' />;
} }
})} })}
{!hasCover && <img className='course-cover' src={'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'} alt='' />} {!hasCover && <img className='course-cover' src={'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'} alt='' />}
...@@ -341,15 +341,15 @@ class AddCourse extends React.Component { ...@@ -341,15 +341,15 @@ class AddCourse extends React.Component {
className='course-status' className='course-status'
style={{ style={{
color: courseStateShow[record.courseState].color, color: courseStateShow[record.courseState].color,
border: `1px solid ${courseStateShow[record.courseState].color}` border: `1px solid ${courseStateShow[record.courseState].color}`,
}}> }}>
{courseStateShow[record.courseState].title} {courseStateShow[record.courseState].title}
</span> </span>
</div> </div>
</div> </div>
</div> </div>
) );
} },
}, },
{ {
title: '上课时间', title: '上课时间',
...@@ -362,8 +362,8 @@ class AddCourse extends React.Component { ...@@ -362,8 +362,8 @@ class AddCourse extends React.Component {
{formatDate('YYYY-MM-DD', parseInt(item.startTime))} <br></br> {formatDate('YYYY-MM-DD', parseInt(item.startTime))} <br></br>
{formatDate('H:i', parseInt(item.startTime))}~{formatDate('H:i', parseInt(item.endTime))} {formatDate('H:i', parseInt(item.startTime))}~{formatDate('H:i', parseInt(item.endTime))}
</span> </span>
) );
} },
}, },
{ {
...@@ -377,16 +377,16 @@ class AddCourse extends React.Component { ...@@ -377,16 +377,16 @@ class AddCourse extends React.Component {
{record.categoryOneName} {record.categoryOneName}
{record.categoryTwoName ? `-${record.categoryTwoName}` : ''} {record.categoryTwoName ? `-${record.categoryTwoName}` : ''}
</div> </div>
) );
} },
} },
] ];
return columns return columns;
} };
videoColumns = () => { videoColumns = () => {
const { videoCourseDivision } = this.state const { videoCourseDivision } = this.state;
const columns = [ const columns = [
{ {
title: ( title: (
...@@ -400,7 +400,7 @@ class AddCourse extends React.Component { ...@@ -400,7 +400,7 @@ class AddCourse extends React.Component {
cursor: 'pointer', cursor: 'pointer',
color: '#bfbfbf', color: '#bfbfbf',
fontSize: '14px', fontSize: '14px',
fontWeight: '400' fontWeight: '400',
}}> }}>
&#xe61d; &#xe61d;
</i> </i>
...@@ -411,7 +411,7 @@ class AddCourse extends React.Component { ...@@ -411,7 +411,7 @@ class AddCourse extends React.Component {
dataIndex: 'scheduleName', dataIndex: 'scheduleName',
width: 300, width: 300,
render: (val, record) => { render: (val, record) => {
const { coverUrl, mediaCourseUrl } = record const { coverUrl, mediaCourseUrl } = record;
return ( return (
<div className='record__item'> <div className='record__item'>
{/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */} {/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */}
...@@ -436,8 +436,8 @@ class AddCourse extends React.Component { ...@@ -436,8 +436,8 @@ class AddCourse extends React.Component {
</Otherwise> </Otherwise>
</Choose> </Choose>
</div> </div>
) );
} },
}, },
{ {
title: '课程时长', title: '课程时长',
...@@ -445,8 +445,8 @@ class AddCourse extends React.Component { ...@@ -445,8 +445,8 @@ class AddCourse extends React.Component {
width: 80, width: 80,
dataIndex: 'videoDuration', dataIndex: 'videoDuration',
render: (text, item) => { render: (text, item) => {
return <span>{text ? dealTimeDuration(text) : '-'}</span> return <span>{text ? dealTimeDuration(text) : '-'}</span>;
} },
}, },
{ {
...@@ -466,12 +466,12 @@ class AddCourse extends React.Component { ...@@ -466,12 +466,12 @@ class AddCourse extends React.Component {
<div className='record__item'>{record.categorySonName}</div> <div className='record__item'>{record.categorySonName}</div>
</Otherwise> </Otherwise>
</Choose> </Choose>
) );
} },
} },
] ];
return columns return columns;
} };
pictureColumns = () => { pictureColumns = () => {
const columns = [ const columns = [
...@@ -487,7 +487,7 @@ class AddCourse extends React.Component { ...@@ -487,7 +487,7 @@ class AddCourse extends React.Component {
cursor: 'pointer', cursor: 'pointer',
color: '#bfbfbf', color: '#bfbfbf',
fontSize: '14px', fontSize: '14px',
fontWeight: '400' fontWeight: '400',
}}> }}>
&#xe61d; &#xe61d;
</i> </i>
...@@ -498,7 +498,7 @@ class AddCourse extends React.Component { ...@@ -498,7 +498,7 @@ class AddCourse extends React.Component {
dataIndex: 'scheduleName', dataIndex: 'scheduleName',
width: 371, width: 371,
render: (val, record) => { render: (val, record) => {
const { coverUrl } = record const { coverUrl } = record;
return ( return (
<div className='record__item'> <div className='record__item'>
{/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */} {/* 上传了封面的话就用上传的封面, 没有的话就取视频的第一帧 */}
...@@ -514,8 +514,8 @@ class AddCourse extends React.Component { ...@@ -514,8 +514,8 @@ class AddCourse extends React.Component {
</Otherwise> </Otherwise>
</Choose> </Choose>
</div> </div>
) );
} },
}, },
{ {
title: '课程分类', title: '课程分类',
...@@ -527,122 +527,122 @@ class AddCourse extends React.Component { ...@@ -527,122 +527,122 @@ class AddCourse extends React.Component {
{record.categoryOneName} {record.categoryOneName}
{record.categoryTwoName ? `-${record.categoryTwoName}` : ''} {record.categoryTwoName ? `-${record.categoryTwoName}` : ''}
</div> </div>
) );
} },
} },
] ];
return columns return columns;
} };
selectLiveList = (record, selected) => { selectLiveList = (record, selected) => {
let { selectLive } = this.state let { 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);
}
this.setState({ selectLive: _list })
} }
this.setState({ selectLive: _list });
};
selectVideoList = (record, selected) => { 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)) { 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 { } else {
_list = _.reject(selectList, (item) => item.id === record.id) _list = _.reject(selectList, (item) => item.id === record.id);
} }
this.setState({ this.setState({
selectVideo: { selectVideo: {
...selectVideo, ...selectVideo,
[videoCourseDivision]: _list [videoCourseDivision]: _list,
} },
}) });
} };
selectPictureList = (record, selected) => { selectPictureList = (record, selected) => {
console.log(record) console.log(record);
let { selectPicture } = this.state let { selectPicture } = this.state;
let _list = [] let _list = [];
if (selected || !_.find(selectPicture, (item) => item.id == record.id)) { 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 { } 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) { callback(key) {
console.log(key) console.log(key);
} }
handleChangVideoFilter = (key, value) => { handleChangVideoFilter = (key, value) => {
const { videoQuery, videoCourseDivision, videoSearchDefalt } = this.state const { videoQuery, videoCourseDivision, videoSearchDefalt } = this.state;
videoQuery[videoCourseDivision][key] = value videoQuery[videoCourseDivision][key] = value;
videoSearchDefalt[videoCourseDivision][key] = value videoSearchDefalt[videoCourseDivision][key] = value;
videoQuery[videoCourseDivision].current = 1 videoQuery[videoCourseDivision].current = 1;
this.setState( this.setState(
{ {
videoQuery, videoQuery,
videoSearchDefalt videoSearchDefalt,
}, },
() => { () => {
this.handleFetchVideoList() this.handleFetchVideoList();
}
)
} }
);
};
handleChangVideoCourseName = (e) => { handleChangVideoCourseName = (e) => {
const { videoSearchDefalt, videoCourseDivision } = this.state const { videoSearchDefalt, videoCourseDivision } = this.state;
videoSearchDefalt[videoCourseDivision].courseName = e.target.value videoSearchDefalt[videoCourseDivision].courseName = e.target.value;
this.setState({ this.setState({
videoSearchDefalt videoSearchDefalt,
}) });
} };
handleChangLiveFilter = (key, value) => { handleChangLiveFilter = (key, value) => {
const { liveQuery } = this.state const { liveQuery } = this.state;
liveQuery[key] = value liveQuery[key] = value;
liveQuery.current = 1 liveQuery.current = 1;
this.setState( this.setState(
{ {
liveQuery liveQuery,
}, },
() => { () => {
this.handleFetchLiveList() this.handleFetchLiveList();
}
)
} }
);
};
handleChangPictureFilter = (key, value) => { handleChangPictureFilter = (key, value) => {
const { pictureQuery } = this.state const { pictureQuery } = this.state;
pictureQuery[key] = value pictureQuery[key] = value;
pictureQuery.current = 1 pictureQuery.current = 1;
this.setState( this.setState(
{ {
pictureQuery pictureQuery,
}, },
() => { () => {
this.handleFetchPictureList() this.handleFetchPictureList();
}
)
} }
);
};
handAddCourse = () => { handAddCourse = () => {
const { selectVideo, selectLive, selectPicture } = this.state const { selectVideo, selectLive, selectPicture } = this.state;
const batchAddList = [] const batchAddList = [];
if (selectVideo.external.length) { if (selectVideo.external.length) {
batchAddList.push({ batchAddList.push({
categoryId: this.props.categoryId, categoryId: this.props.categoryId,
refIds: _.pluck(selectVideo.external, 'id'), refIds: _.pluck(selectVideo.external, 'id'),
storeId: User.getStoreId(), storeId: User.getStoreId(),
type: 'VOICE', type: 'VOICE',
createId: User.getStoreUserId() createId: User.getStoreUserId(),
}) });
} }
if (selectVideo.internal.length) { if (selectVideo.internal.length) {
batchAddList.push({ batchAddList.push({
...@@ -650,8 +650,8 @@ class AddCourse extends React.Component { ...@@ -650,8 +650,8 @@ class AddCourse extends React.Component {
refIds: _.pluck(selectVideo.internal, 'id'), refIds: _.pluck(selectVideo.internal, 'id'),
storeId: User.getStoreId(), storeId: User.getStoreId(),
type: 'VOICE', type: 'VOICE',
createId: User.getStoreUserId() createId: User.getStoreUserId(),
}) });
} }
if (selectLive.length) { if (selectLive.length) {
batchAddList.push({ batchAddList.push({
...@@ -659,8 +659,8 @@ class AddCourse extends React.Component { ...@@ -659,8 +659,8 @@ class AddCourse extends React.Component {
refIds: _.pluck(selectLive, 'liveCourseId'), refIds: _.pluck(selectLive, 'liveCourseId'),
storeId: User.getStoreId(), storeId: User.getStoreId(),
type: 'LIVE', type: 'LIVE',
createId: User.getStoreUserId() createId: User.getStoreUserId(),
}) });
} }
if (selectPicture.length) { if (selectPicture.length) {
batchAddList.push({ batchAddList.push({
...@@ -668,21 +668,21 @@ class AddCourse extends React.Component { ...@@ -668,21 +668,21 @@ class AddCourse extends React.Component {
refIds: _.pluck(selectPicture, 'id'), refIds: _.pluck(selectPicture, 'id'),
storeId: User.getStoreId(), storeId: User.getStoreId(),
type: 'PICTURE', type: 'PICTURE',
createId: User.getStoreUserId() createId: User.getStoreUserId(),
}) });
} }
KnowledgeAPI.addDifTypeKnowledge({ batchAddList }).then(({ success }) => { KnowledgeAPI.addDifTypeKnowledge({ batchAddList }).then(({ success }) => {
if (success) { if (success) {
message.success('新增成功') message.success('新增成功');
this.props.onClose() this.props.onClose();
this.props.onChange() this.props.onChange();
this.props.updateCategoryTree() this.props.updateCategoryTree();
}
})
} }
});
};
videoCourseDivisionChange = (e) => { videoCourseDivisionChange = (e) => {
const { videoQuery, videoSearchDefalt } = this.state const { videoQuery, videoSearchDefalt } = this.state;
this.setState( this.setState(
{ {
videoCourseDivision: e.target.value, videoCourseDivision: e.target.value,
...@@ -690,18 +690,18 @@ class AddCourse extends React.Component { ...@@ -690,18 +690,18 @@ class AddCourse extends React.Component {
...videoSearchDefalt, ...videoSearchDefalt,
[e.target.value]: { [e.target.value]: {
courseName: videoQuery[e.target.value].courseName, courseName: videoQuery[e.target.value].courseName,
categoryId: videoQuery[e.target.value].categoryId categoryId: videoQuery[e.target.value].categoryId,
} },
} },
}, },
() => { () => {
this.handleFetchVideoList() this.handleFetchVideoList();
}
)
} }
);
};
renderFooter = () => { renderFooter = () => {
const { selectVideo, selectPicture, selectLive } = this.state const { selectVideo, selectPicture, selectLive } = this.state;
return ( return (
<div> <div>
<Button onClick={this.props.onClose}>取消</Button> <Button onClick={this.props.onClose}>取消</Button>
...@@ -712,8 +712,8 @@ class AddCourse extends React.Component { ...@@ -712,8 +712,8 @@ class AddCourse extends React.Component {
确定 确定
</Button> </Button>
</div> </div>
) );
} };
render() { render() {
const { const {
...@@ -735,55 +735,55 @@ class AddCourse extends React.Component { ...@@ -735,55 +735,55 @@ class AddCourse extends React.Component {
selectPicture, selectPicture,
videoSearchDefalt, videoSearchDefalt,
categoryList, categoryList,
categoryListExternal categoryListExternal,
} = this.state } = this.state;
const LiveSelection = { const LiveSelection = {
selectedRowKeys: _.pluck(selectLive, 'liveCourseId'), selectedRowKeys: _.pluck(selectLive, 'liveCourseId'),
onSelect: this.selectLiveList, onSelect: this.selectLiveList,
onSelectAll: (selected, _selectedRows, changeRows) => { onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = [] let _list = [];
if (selected) { if (selected) {
_list = _.uniq(selectLive.concat(changeRows), false, (item) => item.liveCourseId) _list = _.uniq(selectLive.concat(changeRows), false, (item) => item.liveCourseId);
} else { } 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 = { const VideoSelection = {
selectedRowKeys: _.pluck(selectVideo[videoCourseDivision], 'id'), selectedRowKeys: _.pluck(selectVideo[videoCourseDivision], 'id'),
onSelect: this.selectVideoList, onSelect: this.selectVideoList,
onSelectAll: (selected, _selectedRows, changeRows) => { onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = [] let _list = [];
if (selected) { if (selected) {
_list = _.uniq(selectVideo[videoCourseDivision].concat(changeRows), false, (item) => item.id) _list = _.uniq(selectVideo[videoCourseDivision].concat(changeRows), false, (item) => item.id);
} else { } 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({ this.setState({
selectVideo: { selectVideo: {
...selectVideo, ...selectVideo,
[videoCourseDivision]: _list [videoCourseDivision]: _list,
} },
}) });
} },
} };
const PictureSelection = { const PictureSelection = {
selectedRowKeys: _.pluck(selectPicture, 'id'), selectedRowKeys: _.pluck(selectPicture, 'id'),
onSelect: this.selectPictureList, onSelect: this.selectPictureList,
onSelectAll: (selected, _selectedRows, changeRows) => { onSelectAll: (selected, _selectedRows, changeRows) => {
let _list = [] let _list = [];
if (selected) { if (selected) {
_list = _.uniq(selectPicture.concat(changeRows), false, (item) => item.id) _list = _.uniq(selectPicture.concat(changeRows), false, (item) => item.id);
} else { } 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 ( return (
<Modal visible={true} width={800} title='新增课程' footer={this.renderFooter()} onCancel={this.props.onClose} className='add-course-modal'> <Modal visible={true} width={800} title='新增课程' footer={this.renderFooter()} onCancel={this.props.onClose} className='add-course-modal'>
...@@ -798,7 +798,7 @@ class AddCourse extends React.Component { ...@@ -798,7 +798,7 @@ class AddCourse extends React.Component {
style={{ width: 'calc(100% - 75px)' }} style={{ width: 'calc(100% - 75px)' }}
placeholder='搜索课程名称' placeholder='搜索课程名称'
onSearch={(value) => { onSearch={(value) => {
this.handleChangLiveFilter('courseName', value) this.handleChangLiveFilter('courseName', value);
}} }}
enterButton={<span className='icon iconfont'>&#xe832;</span>} enterButton={<span className='icon iconfont'>&#xe832;</span>}
/> />
...@@ -814,7 +814,7 @@ class AddCourse extends React.Component { ...@@ -814,7 +814,7 @@ class AddCourse extends React.Component {
placeholder='请选择课程类型' placeholder='请选择课程类型'
allowClear allowClear
onChange={(value) => { onChange={(value) => {
this.handleChangLiveFilter('categoryId', value) this.handleChangLiveFilter('categoryId', value);
}} }}
/> />
</div> </div>
...@@ -826,11 +826,11 @@ class AddCourse extends React.Component { ...@@ -826,11 +826,11 @@ class AddCourse extends React.Component {
this.setState({ this.setState({
selectVideo: { selectVideo: {
internal: [], internal: [],
external: [] external: [],
}, },
selectLive: [], selectLive: [],
selectPicture: [] selectPicture: [],
}) });
}} }}
/> />
<Table <Table
...@@ -851,15 +851,15 @@ class AddCourse extends React.Component { ...@@ -851,15 +851,15 @@ class AddCourse extends React.Component {
pageSize={liveSize} pageSize={liveSize}
total={parseInt(liveTotalCount)} total={parseInt(liveTotalCount)}
toPage={(page) => { toPage={(page) => {
const _query = { ...liveQuery, current: page + 1 } const _query = { ...liveQuery, current: page + 1 };
this.setState( this.setState(
{ {
liveQuery: _query liveQuery: _query,
}, },
() => { () => {
this.handleFetchLiveList() this.handleFetchLiveList();
} }
) );
}} }}
onShowSizeChange={this.onShowLiveSizeChange} onShowSizeChange={this.onShowLiveSizeChange}
/> />
...@@ -883,7 +883,7 @@ class AddCourse extends React.Component { ...@@ -883,7 +883,7 @@ class AddCourse extends React.Component {
placeholder='搜索课程名称' placeholder='搜索课程名称'
onChange={this.handleChangVideoCourseName} onChange={this.handleChangVideoCourseName}
onSearch={(value) => { onSearch={(value) => {
this.handleChangVideoFilter('courseName', value) this.handleChangVideoFilter('courseName', value);
}} }}
enterButton={<span className='icon iconfont'>&#xe832;</span>} enterButton={<span className='icon iconfont'>&#xe832;</span>}
/> />
...@@ -893,7 +893,7 @@ class AddCourse extends React.Component { ...@@ -893,7 +893,7 @@ class AddCourse extends React.Component {
<TreeSelect <TreeSelect
treeNodeFilterProp='categoryName' treeNodeFilterProp='categoryName'
showSearch showSearch
value={videoQuery[videoCourseDivision].categoryId} value={videoQuery[videoCourseDivision].categoryId || null}
style={{ minWidth: 'calc(100% - 75px)' }} style={{ minWidth: 'calc(100% - 75px)' }}
dropdownMatchSelectWidth={false} dropdownMatchSelectWidth={false}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }} dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
...@@ -901,7 +901,7 @@ class AddCourse extends React.Component { ...@@ -901,7 +901,7 @@ class AddCourse extends React.Component {
placeholder='请选择课程类型' placeholder='请选择课程类型'
allowClear allowClear
onChange={(value) => { onChange={(value) => {
this.handleChangVideoFilter('categoryId', value) this.handleChangVideoFilter('categoryId', value);
}} }}
/> />
</div> </div>
...@@ -913,11 +913,11 @@ class AddCourse extends React.Component { ...@@ -913,11 +913,11 @@ class AddCourse extends React.Component {
this.setState({ this.setState({
selectVideo: { selectVideo: {
internal: [], internal: [],
external: [] external: [],
}, },
selectLive: [], selectLive: [],
selectPicture: [] selectPicture: [],
}) });
}} }}
/> />
<Table <Table
...@@ -939,19 +939,19 @@ class AddCourse extends React.Component { ...@@ -939,19 +939,19 @@ class AddCourse extends React.Component {
pageSize={videoSize[videoCourseDivision]} pageSize={videoSize[videoCourseDivision]}
total={videoTotalCount[videoCourseDivision]} total={videoTotalCount[videoCourseDivision]}
toPage={(page) => { toPage={(page) => {
const _query = { ...videoQuery[videoCourseDivision], current: page + 1 } const _query = { ...videoQuery[videoCourseDivision], current: page + 1 };
console.log('_query', _query) console.log('_query', _query);
this.setState( this.setState(
{ {
videoQuery: { videoQuery: {
...videoQuery, ...videoQuery,
[videoCourseDivision]: _query [videoCourseDivision]: _query,
} },
}, },
() => { () => {
this.handleFetchVideoList() this.handleFetchVideoList();
} }
) );
}} }}
onShowSizeChange={this.onShowVideoSizeChange} onShowSizeChange={this.onShowVideoSizeChange}
/> />
...@@ -970,7 +970,7 @@ class AddCourse extends React.Component { ...@@ -970,7 +970,7 @@ class AddCourse extends React.Component {
style={{ width: 'calc(100% - 75px)' }} style={{ width: 'calc(100% - 75px)' }}
placeholder='搜索课程名称' placeholder='搜索课程名称'
onSearch={(value) => { onSearch={(value) => {
this.handleChangPictureFilter('courseName', value) this.handleChangPictureFilter('courseName', value);
}} }}
enterButton={<span className='icon iconfont'>&#xe832;</span>} enterButton={<span className='icon iconfont'>&#xe832;</span>}
/> />
...@@ -986,7 +986,7 @@ class AddCourse extends React.Component { ...@@ -986,7 +986,7 @@ class AddCourse extends React.Component {
placeholder='请选择课程类型' placeholder='请选择课程类型'
allowClear allowClear
onChange={(value) => { onChange={(value) => {
this.handleChangPictureFilter('categoryId', value) this.handleChangPictureFilter('categoryId', value);
}} }}
/> />
</div> </div>
...@@ -998,11 +998,11 @@ class AddCourse extends React.Component { ...@@ -998,11 +998,11 @@ class AddCourse extends React.Component {
this.setState({ this.setState({
selectVideo: { selectVideo: {
internal: [], internal: [],
external: [] external: [],
}, },
selectLive: [], selectLive: [],
selectPicture: [] selectPicture: [],
}) });
}} }}
/> />
<Table <Table
...@@ -1023,15 +1023,15 @@ class AddCourse extends React.Component { ...@@ -1023,15 +1023,15 @@ class AddCourse extends React.Component {
pageSize={pictureSize} pageSize={pictureSize}
total={parseInt(pictureTotalCount)} total={parseInt(pictureTotalCount)}
toPage={(page) => { toPage={(page) => {
const _query = { ...pictureQuery, current: page + 1 } const _query = { ...pictureQuery, current: page + 1 };
this.setState( this.setState(
{ {
pictureQuery: _query pictureQuery: _query,
}, },
() => { () => {
this.handleFetchPictureList() this.handleFetchPictureList();
} }
) );
}} }}
onShowSizeChange={this.onShowPictureSizeChange} onShowSizeChange={this.onShowPictureSizeChange}
/> />
...@@ -1041,7 +1041,7 @@ class AddCourse extends React.Component { ...@@ -1041,7 +1041,7 @@ class AddCourse extends React.Component {
</TabPane> </TabPane>
</Tabs> </Tabs>
</Modal> </Modal>
) );
} }
} }
export default AddCourse export default AddCourse;
/* /*
* @Author: zhangleyuan * @Author: zhangleyuan
* @Date: 2021-02-20 16:45:51 * @Date: 2021-02-20 16:45:51
* @LastEditors: wufan * @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-13 16:36:26 * @LastEditTime: 2021-06-01 15:20:33
* @Description: 描述一下 * @Description: 描述一下
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React from 'react'; import React from 'react';
import { Button,Input,Switch,Radio,Row,Col,Modal,message,Tooltip} from 'antd'; import { Button, Input, Switch, Radio, Row, Col, Modal, message, Tooltip } from 'antd';
import { withRouter } from 'react-router-dom'; import { withRouter } from 'react-router-dom';
import SelectOperatorModal from '../modal/SelectOperatorModal'; import SelectOperatorModal from '../modal/SelectOperatorModal';
import { ImgCutModalNew } from '@/components';
import SelectPrepareFileModal from '@/modules/prepare-lesson/modal/SelectPrepareFileModal'; import SelectPrepareFileModal from '@/modules/prepare-lesson/modal/SelectPrepareFileModal';
import Upload from '@/core/upload'; import Upload from '@/core/upload';
// import PhotoClip from 'photoclip' // import PhotoClip from 'photoclip'
import './BasicInfo.less'; import './BasicInfo.less';
const { TextArea } = Input; const { TextArea } = Input;
const defaultCover = 'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'; const defaultCover = 'https://image.xiaomaiketang.com/xm/rEAetaTEh3.png';
let cutFlag = false; let cutFlag = false;
let timer = null class BasicInfo extends React.Component {
class BasicInfo extends React.Component{
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
operatorModalVisible: false, operatorModalVisible: false,
showSelectFileModal:false, showSelectFileModal: false,
cutImageBlob: null cutImageBlob: null,
}; };
} }
handleShowSelectOperatorModal = () => {
handleShowSelectOperatorModal = () =>{
this.setState({ this.setState({
operatorModalVisible:true operatorModalVisible: true,
}) });
} };
handleCloseSelectOperatorMOdal = ()=>{ handleCloseSelectOperatorMOdal = () => {
this.setState({ this.setState({
operatorModalVisible:false operatorModalVisible: false,
}) });
} };
handleConfirmSelectOperator = (selectOperatorList)=> { handleConfirmSelectOperator = (selectOperatorList) => {
if(selectOperatorList.length === 0){ if (selectOperatorList.length === 0) {
message.warning('请选择运营师') message.warning('请选择运营师');
return; return;
} }
this.props.onChange('selectOperatorList',selectOperatorList); this.props.onChange('selectOperatorList', selectOperatorList);
this.setState({ this.setState({
operatorModalVisible:false operatorModalVisible: false,
}) });
} };
enableStateChange = ()=> { enableStateChange = () => {
if(this.props.data.enableState==="NO"){ if (this.props.data.enableState === 'NO') {
this.props.onChange('enableState','YES') this.props.onChange('enableState', 'YES');
}else{ } else {
this.props.onChange('enableState','NO') this.props.onChange('enableState', 'NO');
}
} }
};
// 使用默认封面图 // 使用默认封面图
handleResetCoverUrl = ()=> { handleResetCoverUrl = () => {
const { data: { coverUrl } } = this.props; const {
data: { coverUrl },
} = this.props;
const isDefaultCover = coverUrl === defaultCover; const isDefaultCover = coverUrl === defaultCover;
// 如果已经是默认图的话,不做任何任何处理 // 如果已经是默认图的话,不做任何任何处理
if (isDefaultCover) return; if (isDefaultCover) return;
message.success('已替换为默认图'); message.success('已替换为默认图');
this.props.onChange('coverUrl',defaultCover); this.props.onChange('coverUrl', defaultCover);
setTimeout(()=>{ setTimeout(() => {
this.props.onChange('coverId', null); this.props.onChange('coverId', null);
},1000) }, 1000);
} };
handleSelectCover = (file)=> { handleSelectCover = (file) => {
this.uploadImage(file); this.uploadImage(file);
} };
//上传图片 //上传图片
uploadImage = (imageFile) => { uploadImage = (imageFile) => {
const { folderName } = imageFile;
const fileName = window.random_string(16) + folderName.slice(folderName.lastIndexOf("."));
const self = this; const self = this;
this.setState( this.setState(
{ {
...@@ -87,57 +83,55 @@ class BasicInfo extends React.Component{ ...@@ -87,57 +83,55 @@ class BasicInfo extends React.Component{
}, },
() => { () => {
setTimeout(() => { setTimeout(() => {
const okBtnDom = document.querySelector("#headPicModal"); const okBtnDom = document.querySelector('#headPicModal');
const options = { const options = {
size: [500, 282], size: [500, 282],
ok: okBtnDom, ok: okBtnDom,
maxZoom: 3, maxZoom: 3,
style: { style: {
jpgFillColor: "transparent", jpgFillColor: 'transparent',
}, },
done: function (dataUrl) { done: function (dataUrl) {
clearTimeout(self.timer); clearTimeout(self.timer);
self.timer = setTimeout(() => { self.timer = setTimeout(() => {
if ((self.state.rotate != this.rotate()) || (self.state.scale != this.scale())) { if (self.state.rotate !== this.rotate() || self.state.scale !== this.scale()) {
console.log(this.scale(), 'scale') console.log(this.scale(), 'scale');
const _dataUrl = this.clip() const _dataUrl = this.clip();
const cutImageBlob = self.convertBase64UrlToBlob(_dataUrl); const cutImageBlob = self.convertBase64UrlToBlob(_dataUrl);
self.setState({ self.setState({
cutImageBlob, cutImageBlob,
dataUrl: _dataUrl, dataUrl: _dataUrl,
rotate: this.rotate(), rotate: this.rotate(),
scale: this.scale() scale: this.scale(),
}) });
} }
}, 500);
}, 500)
const cutImageBlob = self.convertBase64UrlToBlob(dataUrl); const cutImageBlob = self.convertBase64UrlToBlob(dataUrl);
self.setState({ self.setState({
cutImageBlob, cutImageBlob,
dataUrl dataUrl,
}) });
setTimeout(() => { setTimeout(() => {
cutFlag = false; cutFlag = false;
}, 2000); }, 2000);
}, },
fail: (failInfo) => { fail: (failInfo) => {
message.error("图片上传失败了,请重新上传"); message.error('图片上传失败了,请重新上传');
}, },
loadComplete: function (img) { loadComplete: function (img) {
setTimeout(() => { setTimeout(() => {
const _dataUrl = this.clip() const _dataUrl = this.clip();
self.setState({ self.setState({
dataUrl: _dataUrl, dataUrl: _dataUrl,
hasImgReady: true hasImgReady: true,
}) });
}, 100) }, 100);
}, },
}; };
const imgUrl = `${imageFile.ossUrl}?${new Date().getTime()}` const imgUrl = `${imageFile.ossUrl}?${new Date().getTime()}`;
if (!this.state.photoclip) { if (!this.state.photoclip) {
const _photoclip = new PhotoClip("#headPicModal", options); const _photoclip = new PhotoClip('#headPicModal', options);
_photoclip.load(imgUrl); _photoclip.load(imgUrl);
this.setState({ this.setState({
photoclip: _photoclip, photoclip: _photoclip,
...@@ -146,7 +140,6 @@ class BasicInfo extends React.Component{ ...@@ -146,7 +140,6 @@ class BasicInfo extends React.Component{
this.state.photoclip.clear(); this.state.photoclip.clear();
this.state.photoclip.load(imgUrl); this.state.photoclip.load(imgUrl);
} }
}, 200); }, 200);
} }
); );
...@@ -154,251 +147,283 @@ class BasicInfo extends React.Component{ ...@@ -154,251 +147,283 @@ class BasicInfo extends React.Component{
//获取resourceId //获取resourceId
getSignature = (blob, fileName) => { getSignature = (blob, fileName) => {
Upload.uploadBlobToOSS(blob, 'cover' + (new Date()).valueOf(),null,'signInfo').then((signInfo) => { Upload.uploadBlobToOSS(blob, 'cover' + new Date().valueOf(), null, 'signInfo').then((signInfo) => {
this.setState({ this.setState(
coverClicpPath:signInfo.fileUrl, {
coverId:signInfo.resourceId, coverClicpPath: signInfo.fileUrl,
visible: false coverId: signInfo.resourceId,
},()=>this.updateCover()) visible: false,
},
() => this.updateCover()
);
}); });
}; };
updateCover = () =>{ updateCover = () => {
const {coverClicpPath,coverId} = this.state const { coverClicpPath, coverId } = this.state;
this.setState({ this.setState({
showSelectFileModal: false showSelectFileModal: false,
}) });
this.props.onChange('coverUrl', coverClicpPath); this.props.onChange('coverUrl', coverClicpPath);
setTimeout(()=>{ setTimeout(() => {
this.props.onChange('coverId', coverId); this.props.onChange('coverId', coverId);
},1000) }, 1000);
} };
// base64转换成blob // base64转换成blob
convertBase64UrlToBlob = (urlData) => { convertBase64UrlToBlob = (urlData) => {
const bytes = window.atob(urlData.split(",")[1]); const bytes = window.atob(urlData.split(',')[1]);
const ab = new ArrayBuffer(bytes.length); const ab = new ArrayBuffer(bytes.length);
const ia = new Uint8Array(ab); const ia = new Uint8Array(ab);
for (let i = 0; i < bytes.length; i++) { for (let i = 0; i < bytes.length; i++) {
ia[i] = bytes.charCodeAt(i); ia[i] = bytes.charCodeAt(i);
} }
return new Blob([ab], { type: "image/png" }); return new Blob([ab], { type: 'image/png' });
}; };
limitNumber = value => { limitNumber = (value) => {
if (typeof value === 'string') { if (typeof value === 'string') {
return !isNaN(Number(value)) ? value.replace(/^(0+)|[^\d]/g, '') : '' return !isNaN(Number(value)) ? value.replace(/^(0+)|[^\d]/g, '') : '';
} else if (typeof value === 'number') { } else if (typeof value === 'number') {
return !isNaN(value) ? String(value).replace(/^(0+)|[^\d]/g, '') : '' return !isNaN(value) ? String(value).replace(/^(0+)|[^\d]/g, '') : '';
} else { } else {
return '' return '';
}
} }
percentCompleteBlur = (e,field) =>{ };
percentCompleteBlur = (e, field) => {
let _percentCompleteLive; let _percentCompleteLive;
const { value } = e.target; const { value } = e.target;
if(value > 100){ if (value > 100) {
_percentCompleteLive = 100; _percentCompleteLive = 100;
}else{ } else {
if(value < 0){ if (value < 0) {
_percentCompleteLive = 0; _percentCompleteLive = 0;
}else{ } else {
_percentCompleteLive = value; _percentCompleteLive = value;
} }
} }
this.props.onChange(field,_percentCompleteLive) this.props.onChange(field, _percentCompleteLive);
} };
render(){ render() {
const { operatorModalVisible ,showSelectFileModal,visible,hasImgReady,cutImageBlob} = this.state; const { operatorModalVisible, showSelectFileModal, visible, hasImgReady, cutImageBlob } = this.state;
const { data} = this.props; const { data } = this.props;
const { planName,coverUrl,instro,enableState,operateType,selectOperatorList,percentCompleteLive,percentCompleteVideo,percentCompletePicture} = data; const { planName, coverUrl, instro, enableState, operateType, selectOperatorList, percentCompleteLive, percentCompleteVideo, percentCompletePicture } =
data;
// 当前是否使用的是默认图片 // 当前是否使用的是默认图片
const isDefaultCover = coverUrl === defaultCover; const isDefaultCover = coverUrl === defaultCover;
return ( return (
<div className="plan-basic-info"> <div className='plan-basic-info'>
<div className="plan-name"> <div className='plan-name'>
<span className="label"><span className="require">*</span>培训计划名称:</span> <span className='label'>
<span className='require'>*</span>培训计划名称:
</span>
<Input <Input
value={planName} value={planName}
placeholder="请输入培训计划名称(20字以内)" placeholder='请输入培训计划名称(20字以内)'
maxLength={20} maxLength={20}
style={{ width: 240 }} style={{ width: 240 }}
onChange={(e)=>this.props.onChange('planName', e.target.value)} onChange={(e) => this.props.onChange('planName', e.target.value)}
/> />
</div> </div>
<div className="cover"> <div className='cover'>
<span className="label">封面图:</span> <span className='label'>封面图:</span>
<div className="cover__wrap"> <div className='cover__wrap'>
<div className="img-content"> <div className='img-content'>
{ isDefaultCover && {isDefaultCover && <span className='tag'>默认图</span>}
<span className="tag">默认图</span> <img src={coverUrl} width='690' alt='' />
}
<img src={coverUrl} width="690"/>
</div> </div>
<div className="opt-btns"> <div className='opt-btns'>
<Button onClick={() => { <Button
onClick={() => {
this.setState({ this.setState({
showSelectFileModal:true showSelectFileModal: true,
}) });
}}>上传图片</Button> }}>
<span 上传图片
className={`default-btn ${isDefaultCover ? 'disabled' : ''}`} </Button>
onClick={this.handleResetCoverUrl} <span className={`default-btn ${isDefaultCover ? 'disabled' : ''}`} onClick={this.handleResetCoverUrl}>
>使用默认图</span> 使用默认图
<div className="tips">建议尺寸1280*720px或16:9。封面图最大5M,支持jpg、jpeg和png。</div> </span>
<div className='tips'>建议尺寸1280*720px或16:9。封面图最大5M,支持jpg、jpeg和png。</div>
</div> </div>
</div> </div>
</div> </div>
<div className="introduction"> <div className='introduction'>
<span className="label">简介:</span> <span className='label'>简介:</span>
<TextArea <TextArea
placeholder="请输入培训计划简介" placeholder='请输入培训计划简介'
maxLength={200} maxLength={200}
style={{ width: '552px',height:'110px'}} style={{ width: '552px', height: '110px' }}
className="instro-textarea" className='instro-textarea'
value={instro} value={instro}
onChange={(e)=>this.props.onChange('instro', e.target.value)} onChange={(e) => this.props.onChange('instro', e.target.value)}
/> />
</div> </div>
<div className="wether-use"> <div className='wether-use'>
<span className="label">是否启用:</span> <span className='label'>是否启用:</span>
<div className="content"> <div className='content'>
<div> <div>
<Switch checked={enableState==="YES"? true:false} onChange={()=> {this.enableStateChange()}}/> <Switch
checked={enableState === 'YES' ? true : false}
onChange={() => {
this.enableStateChange();
}}
/>
</div> </div>
<div> <div>
<div className="instro-text"> <div className='instro-text'>
<div>开启:此培训计划可以分享给学员进行学习</div> <div>开启:此培训计划可以分享给学员进行学习</div>
<div>关闭:此培训计划暂不可分享给学员进行学习,后续可开启</div> <div>关闭:此培训计划暂不可分享给学员进行学习,后续可开启</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div className="view-range" > <div className='view-range'>
<span className="label"> <span className='label'>
<span className="require">*</span> <span className='require'>*</span>
可见范围 可见范围
<Tooltip <Tooltip title='学院管理员、管理员默认都可见'>
title="学院管理员、管理员默认都可见"> <span className='iconfont'>&#xe61d;</span>
<span className="iconfont">&#xe61d;</span> </Tooltip>
</Tooltip></span>
<div className="content"> </span>
<Radio.Group value={operateType} onChange={(e) => { this.props.onChange('operateType', e.target.value) }}> <div className='content'>
<Radio.Group
value={operateType}
onChange={(e) => {
this.props.onChange('operateType', e.target.value);
}}>
<Row style={{ marginBottom: '5px' }}> <Row style={{ marginBottom: '5px' }}>
<Col span={24}> <Col span={24}>
<Radio value="All_Operate"> <Radio value='All_Operate'>
所有运营师 所有运营师
<span className="playback__text">后续新增的运营师都有权限可见</span> <span className='playback__text'>后续新增的运营师都有权限可见</span>
</Radio> </Radio>
</Col> </Col>
</Row> </Row>
<Row> <Row>
<Col span={24}> <Col span={24}>
<Radio value="Assign_Operate"> <Radio value='Assign_Operate'>
指定运营师 指定运营师
<span className="playback__text">仅被选择的运营师有权限可见</span> <span className='playback__text'>仅被选择的运营师有权限可见</span>
</Radio> </Radio>
</Col> </Col>
</Row> </Row>
</Radio.Group> </Radio.Group>
{operateType==="Assign_Operate" && {operateType === 'Assign_Operate' && (
<div className="choose-business"> <div className='choose-business'>
<Button onClick={()=>{this.handleShowSelectOperatorModal()}}>选择运营师</Button> <Button
<span>已选择<span>{selectOperatorList.length}</span>名运营师</span> onClick={() => {
this.handleShowSelectOperatorModal();
}}>
选择运营师
</Button>
<span>
已选择<span>{selectOperatorList.length}</span>名运营师
</span>
</div> </div>
} )}
</div> </div>
</div> </div>
<div className="done-standard"> <div className='done-standard'>
<span className="label standard-label"><span className="require">*</span>完成标准:</span> <span className='label standard-label'>
<span className='require'>*</span>完成标准:
</span>
<div> <div>
<div className="live-standard-info"> <div className='live-standard-info'>
<span className="icon iconfont">&#xe865;</span> <span className='icon iconfont'>&#xe865;</span>
<span className="instro">直播课单个课程,学员学习进度达到 <span className='instro'>
直播课单个课程,学员学习进度达到
<Input <Input
width="40" width='40'
value={percentCompleteLive} value={percentCompleteLive}
onChange={(e) => { this.props.onChange('percentCompleteLive', e.target.value.replace(/\D/g,'')) }} onChange={(e) => {
onBlur={(e)=>this.percentCompleteBlur(e,'percentCompleteLive')} this.props.onChange('percentCompleteLive', e.target.value.replace(/\D/g, ''));
className="input-box" }}
/>%,即视为"已完成"学习 onBlur={(e) => this.percentCompleteBlur(e, 'percentCompleteLive')}
className='input-box'
/>
%,即视为"已完成"学习
</span> </span>
</div> </div>
<div className="live-standard-info"> <div className='live-standard-info'>
<span className="icon iconfont">&#xe864;</span> <span className='icon iconfont'>&#xe864;</span>
<span className="instro">视频课单个课程,学员学习进度达到 <span className='instro'>
视频课单个课程,学员学习进度达到
<Input <Input
width="40" width='40'
value={percentCompleteVideo} value={percentCompleteVideo}
onChange={(e) => { this.props.onChange('percentCompleteVideo', e.target.value.replace(/\D/g,'')) }} onChange={(e) => {
onBlur={(e)=>this.percentCompleteBlur(e,'percentCompleteVideo')} this.props.onChange('percentCompleteVideo', e.target.value.replace(/\D/g, ''));
className="input-box" }}
onBlur={(e) => this.percentCompleteBlur(e, 'percentCompleteVideo')}
className='input-box'
/> />
%,即视为"已完成"学习 %,即视为"已完成"学习
</span> </span>
</div> </div>
<div className="live-standard-info"> <div className='live-standard-info'>
<span className="icon iconfont">&#xe601;</span> <span className='icon iconfont'>&#xe601;</span>
<span className="instro">图文课单个课程,学员学习进度达到 <span className='instro'>
图文课单个课程,学员学习进度达到
<Input <Input
width="40" width='40'
value={percentCompletePicture} value={percentCompletePicture}
onChange={(e) => { this.props.onChange('percentCompletePicture', e.target.value.replace(/\D/g,'')) }} onChange={(e) => {
onBlur={(e)=>this.percentCompleteBlur(e,'percentCompletePicture')} this.props.onChange('percentCompletePicture', e.target.value.replace(/\D/g, ''));
className="input-box" }}
onBlur={(e) => this.percentCompleteBlur(e, 'percentCompletePicture')}
className='input-box'
/> />
%,即视为"已完成"学习 %,即视为"已完成"学习
</span> </span>
</div> </div>
</div> </div>
</div> </div>
{ operatorModalVisible && {operatorModalVisible && (
<SelectOperatorModal <SelectOperatorModal
visible={operatorModalVisible} visible={operatorModalVisible}
onClose={this.handleCloseSelectOperatorMOdal} onClose={this.handleCloseSelectOperatorMOdal}
selectOperatorList={selectOperatorList} selectOperatorList={selectOperatorList}
onSelect={this.handleConfirmSelectOperator} onSelect={this.handleConfirmSelectOperator}
/> />
} )}
{showSelectFileModal && {showSelectFileModal && (
<SelectPrepareFileModal <SelectPrepareFileModal
key="basic" key='basic'
operateType="select" operateType='select'
multiple={false} multiple={false}
accept="image/jpeg,image/png,image/jpg" accept='image/jpeg,image/png,image/jpg'
selectTypeList={['JPG', 'JPEG', 'PNG']} selectTypeList={['JPG', 'JPEG', 'PNG']}
tooltip='支持文件类型:jpg、jpeg、png' tooltip='支持文件类型:jpg、jpeg、png'
isOpen={showSelectFileModal} isOpen={showSelectFileModal}
onClose={() => { onClose={() => {
this.setState({ this.setState({
showSelectFileModal:false showSelectFileModal: false,
}) });
}} }}
onSelect={this.handleSelectCover} onSelect={this.handleSelectCover}
/> />
} )}
<Modal <Modal
title="设置图片" title='设置图片'
width={1080} width={1080}
visible={visible} visible={visible}
maskClosable={false} maskClosable={false}
closeIcon={<span className="icon iconfont modal-close-icon">&#xe6ef;</span>} closeIcon={<span className='icon iconfont modal-close-icon'>&#xe6ef;</span>}
onCancel={() => { onCancel={() => {
this.setState({ visible: false }); this.setState({ visible: false });
}} }}
zIndex={10001} zIndex={10001}
footer={[ footer={[
<Button <Button
key="back" key='back'
onClick={() => { onClick={() => {
this.setState({ visible: false }); this.setState({ visible: false });
}} }}>
>
重新上传 重新上传
</Button>, </Button>,
<Button <Button
key="submit" key='submit'
type="primary" type='primary'
disabled={!hasImgReady} disabled={!hasImgReady}
onClick={() => { onClick={() => {
if (!cutFlag) { if (!cutFlag) {
...@@ -406,32 +431,29 @@ class BasicInfo extends React.Component{ ...@@ -406,32 +431,29 @@ class BasicInfo extends React.Component{
this.refs.hiddenBtn.click(); this.refs.hiddenBtn.click();
} }
this.getSignature(cutImageBlob); this.getSignature(cutImageBlob);
}} }}>
>
确定 确定
</Button>, </Button>,
]} ]}>
> <div className='clip-box'>
<div className="clip-box">
<div <div
id="headPicModal" id='headPicModal'
ref="headPicModal" ref='headPicModal'
style={{ style={{
width: "500px", width: '500px',
height: "430px", height: '430px',
marginBottom: 0, marginBottom: 0,
}} }}></div>
></div> <div id='clipBtn' style={{ display: 'none' }} ref='hiddenBtn'></div>
<div id="clipBtn" style={{ display: "none" }} ref="hiddenBtn"></div> <div className='preview-img'>
<div className="preview-img"> <div className='title'>效果预览</div>
<div className="title">效果预览</div> <div id='preview-url-box' style={{ width: 500, height: 282 }}>
<div id="preview-url-box" style={{width:500,height:282}}> <img src={this.state.dataUrl} style={{ width: '100%' }} alt='' />
<img src={this.state.dataUrl} style={{ width: '100%' }} alt="" />
</div> </div>
<div className="tip-box"> <div className='tip-box'>
<div className="tip">温馨提示</div> <div className='tip'>温馨提示</div>
<div className="tip">①预览效果图时可能存在延迟,单击左侧图片刷新即可</div> <div className='tip'>①预览效果图时可能存在延迟,单击左侧图片刷新即可</div>
<div className="tip">②设置图片时双击可旋转图片,滚动可放大或缩小图片</div> <div className='tip'>②设置图片时双击可旋转图片,滚动可放大或缩小图片</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -440,4 +462,4 @@ class BasicInfo extends React.Component{ ...@@ -440,4 +462,4 @@ class BasicInfo extends React.Component{
); );
} }
} }
export default withRouter(BasicInfo) export default withRouter(BasicInfo);
/* /*
* @Author: zhangleyuan * @Author: zhangleyuan
* @Date: 2021-02-20 16:46:46 * @Date: 2021-02-20 16:46:46
* @LastEditors: wufan * @LastEditors: fusanqiasng
* @LastEditTime: 2021-05-14 18:12:50 * @LastEditTime: 2021-06-01 11:45:34
* @Description: 描述一下 * @Description: 描述一下
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React, { useState, useRef, useEffect } from 'react'; import React, { useState } from 'react';
import { Table, Modal, message , Tooltip,Switch,Dropdown} from 'antd'; import { Table, Modal, message, Tooltip, Switch, Dropdown } from 'antd';
import { withRouter } from 'react-router-dom'; import { withRouter } from 'react-router-dom';
import { PageControl } from "@/components"; import { PageControl } from '@/components';
import PlanService from "@/domains/plan-domain/planService"; import PlanService from '@/domains/plan-domain/planService';
import SharePlanModal from '../modal/SharePlanModal'; import SharePlanModal from '../modal/SharePlanModal';
import {LIVE_SHARE} from '@/domains/course-domain/constants'; import { LIVE_SHARE } from '@/domains/course-domain/constants';
import User from '@/common/js/user'; import User from '@/common/js/user';
import './PlanList.less'; import './PlanList.less';
const { confirm } = Modal; const { confirm } = Modal;
const userRole = User.getUserRole();
function PlanList(props) { function PlanList(props) {
const [sharePlanModal, setSharePlanModal] = useState(null); const [sharePlanModal, setSharePlanModal] = useState(null);
function parseColumns(){ function parseColumns() {
const columns = [ const columns = [
{ {
title: '培训计划', title: '培训计划',
key: 'planName', key: 'planName',
dataIndex: 'planName', dataIndex: 'planName',
width:'18%', width: '18%',
render: (val, record) => { render: (val, record) => {
return ( return (
<div className="plan-name"> <div className='plan_name_item'>
{val} <img className='plan-cover' src={record.coverUrl || 'https://image.xiaomaiketang.com/xm/rEAetaTEh3.png'} alt='' />
<Choose>
<When condition={record.planName.length > 25}>
<Tooltip title={record.planName}>
<div className='plan-name'>{val}</div>
</Tooltip>
</When>
<Otherwise>
<div className='plan-name'>{val}</div>
</Otherwise>
</Choose>
</div> </div>
) );
} },
}, },
{ {
title: '课程总数量', title: '课程总数量',
...@@ -43,21 +53,21 @@ function PlanList(props) { ...@@ -43,21 +53,21 @@ function PlanList(props) {
dataIndex: 'courseNum', dataIndex: 'courseNum',
width: 110, width: 110,
render: (val, record) => { render: (val, record) => {
return ( return <div className='course-number'>{val}</div>;
<div className="course-number"> },
{val}
</div>
)
}
}, },
{ {
title: '当前状态', title: '当前状态',
width: '10%', width: '10%',
dataIndex: "status", dataIndex: 'status',
render: (val, item, index) => { render: (val, item, index) => {
return ( return (
<Switch checked={item.enableState==="NO"?false:true} onChange={()=>changeEnableState(item)} disabled={(User.getUserRole() === "CloudManager" || User.getUserRole() === "StoreManager")?false:true}/> <Switch
) checked={item.enableState === 'NO' ? false : true}
onChange={() => changeEnableState(item)}
disabled={User.getUserRole() === 'CloudManager' || User.getUserRole() === 'StoreManager' ? false : true}
/>
);
}, },
}, },
{ {
...@@ -66,46 +76,38 @@ function PlanList(props) { ...@@ -66,46 +76,38 @@ function PlanList(props) {
dataIndex: 'createName', dataIndex: 'createName',
width: '10%', width: '10%',
render: (val) => { render: (val) => {
return ( return <div className='create-name'>{val}</div>;
<div className="create-name"> },
{val}
</div>
)
}
}, },
{ {
title: '创建时间', title: '创建时间',
width: "12.5%", width: '12.5%',
key: 'created', key: 'created',
dataIndex: 'created', dataIndex: 'created',
sorter: true, sorter: true,
render: (val) => { render: (val) => {
return formatDate('YYYY-MM-DD H:i', val) return window.formatDate('YYYY-MM-DD H:i', val);
} },
}, },
{ {
title: '更新时间', title: '更新时间',
width: "10%", width: '10%',
key: 'updated', key: 'updated',
dataIndex: 'updated', dataIndex: 'updated',
sorter: true, sorter: true,
render: (val) => { render: (val) => {
return formatDate('YYYY-MM-DD H:i', val) return window.formatDate('YYYY-MM-DD H:i', val);
} },
}, },
{ {
title: '参培人数', title: '参培人数',
width:76, width: 76,
key: 'cultureCustomerNum', key: 'cultureCustomerNum',
dataIndex: 'cultureCustomerNum', dataIndex: 'cultureCustomerNum',
sorter: true, sorter: true,
render: (val) => { render: (val) => {
return ( return <div className='join-number'>{val}</div>;
<div className="join-number"> },
{val}
</div>
)
}
}, },
{ {
title: '操作', title: '操作',
...@@ -115,201 +117,221 @@ function PlanList(props) { ...@@ -115,201 +117,221 @@ function PlanList(props) {
width: 176, width: 176,
render: (val, record) => { render: (val, record) => {
return ( return (
<div className="operate"> <div className='operate'>
<div className="operate__item" onClick={()=>toLearningDataPage(record)}>学习数据</div> <div className='operate__item' onClick={() => toLearningDataPage(record)}>
{record.enableState==="YES" && 学习数据
</div>
{record.enableState === 'YES' && (
<> <>
<span className="operate__item split"> | </span> <span className='operate__item split'> | </span>
<div className="operate__item" onClick={() => {handleShowShareModal(record); }}>分享</div> <div
className='operate__item'
onClick={() => {
handleShowShareModal(record);
}}>
分享
</div>
</> </>
} )}
{(User.getUserRole() === "CloudManager" || User.getUserRole() === "StoreManager") && {(User.getUserRole() === 'CloudManager' || User.getUserRole() === 'StoreManager') && (
<> <>
<span className="operate__item split"> | </span> <span className='operate__item split'> | </span>
<Dropdown overlay={renderMoreOperate(record)}> <Dropdown overlay={renderMoreOperate(record)}>
<span className="more-operate"> <span className='more-operate'>
<span className="operate-text">更多</span> <span className='operate-text'>更多</span>
<span <span className='iconfont icon' style={{ color: '#2966FF' }}>
className="iconfont icon"
style={{ color: "#2966FF" }}
>
&#xe824; &#xe824;
</span> </span>
</span> </span>
</Dropdown> </Dropdown>
</> </>
} )}
</div> </div>
) );
} },
} },
]; ];
return columns; return columns;
} }
function renderMoreOperate(item){ function renderMoreOperate(item) {
return ( return (
<div className="live-course-more-menu"> <div className='live-course-more-menu'>
<div className='operate__item' onClick={() => toEditPlanPage(item)}>
<div className="operate__item" 编辑
onClick={()=>toEditPlanPage(item)}
>编辑</div>
<div
className="operate__item" onClick={()=>handleDelete(item)}
>删除</div>
</div> </div>
) <div className='operate__item' onClick={() => handleDelete(item)}>
删除
</div>
</div>
);
} }
function handleChangeTable(pagination, filters, sorter){ function handleChangeTable(pagination, filters, sorter) {
const { columnKey, order } = sorter; const { columnKey, order } = sorter;
const { query } = props; const { query } = props;
let _columnKey; let _columnKey;
let _order; let _order;
// 按创建时间升序排序 // 按创建时间升序排序
if (columnKey === 'created' && order === 'ascend') {_columnKey="CREATED"; _order = 'SORT_ASC'; } if (columnKey === 'created' && order === 'ascend') {
_columnKey = 'CREATED';
_order = 'SORT_ASC';
}
// 按创建时间降序排序 // 按创建时间降序排序
if (columnKey === 'created' && order === 'descend') { _columnKey="CREATED"; _order = 'SORT_DESC';} if (columnKey === 'created' && order === 'descend') {
_columnKey = 'CREATED';
_order = 'SORT_DESC';
}
// 按更新时间升序排序 // 按更新时间升序排序
if (columnKey === 'updated' && order === 'ascend') { _columnKey="UPDATED"; _order = 'SORT_ASC'; } if (columnKey === 'updated' && order === 'ascend') {
_columnKey = 'UPDATED';
_order = 'SORT_ASC';
}
// 按更新时间降序排序 // 按更新时间降序排序
if (columnKey === 'updated' && order === 'descend') { _columnKey="UPDATED"; _order = 'SORT_DESC'; } if (columnKey === 'updated' && order === 'descend') {
_columnKey = 'UPDATED';
_order = 'SORT_DESC';
}
// 按更新时间升序排序 // 按更新时间升序排序
if (columnKey === 'cultureCustomerNum' && order === 'ascend') { _columnKey="CUSTOMER_NUM"; _order = 'SORT_ASC'; } if (columnKey === 'cultureCustomerNum' && order === 'ascend') {
_columnKey = 'CUSTOMER_NUM';
_order = 'SORT_ASC';
}
// 按更新时间降序排序 // 按更新时间降序排序
if (columnKey === 'cultureCustomerNum' && order === 'descend') { _columnKey="CUSTOMER_NUM"; _order = 'SORT_DESC'; } if (columnKey === 'cultureCustomerNum' && order === 'descend') {
_columnKey = 'CUSTOMER_NUM';
_order = 'SORT_DESC';
}
const _query = { const _query = {
...query, ...query,
sortMap:{} sortMap: {},
}; };
_query.sortMap[_columnKey]=_order; _query.sortMap[_columnKey] = _order;
props.onChange(_query); props.onChange(_query);
} }
// 显示分享弹窗 // 显示分享弹窗
function handleShowShareModal(item) { function handleShowShareModal(item) {
const htmlUrl = `${LIVE_SHARE}training_plan_detail/${item.planId}?id=${User.getStoreId()}&storeUserId=${User.getStoreUserId()}`; const htmlUrl = `${LIVE_SHARE}training_plan_detail/${item.planId}?id=${User.getStoreId()}&storeUserId=${User.getStoreUserId()}`;
const longUrl = htmlUrl const longUrl = htmlUrl;
const shareData = { ...item, longUrl }; const shareData = { ...item, longUrl };
const sharePlanModal = ( const sharePlanModal = (
<SharePlanModal <SharePlanModal
data={shareData} data={shareData}
type="liveClass" type='liveClass'
close={() => { close={() => {
setSharePlanModal(null) setSharePlanModal(null);
}} }}
/> />
) );
setSharePlanModal(sharePlanModal) setSharePlanModal(sharePlanModal);
} }
//改变上架状态 //改变上架状态
function changeEnableState(item){ function changeEnableState(item) {
let _enableState = item.enableState let _enableState = item.enableState;
if(_enableState==='NO'){ if (_enableState === 'NO') {
_enableState = "YES"; _enableState = 'YES';
item.enableState = "YES" item.enableState = 'YES';
}else{ } else {
_enableState = "NO" _enableState = 'NO';
item.enableState = "NO" item.enableState = 'NO';
}
const params={
"planId": item.planId,
"enableState":_enableState
} }
PlanService.updateStateTrainingPlan(params).then((res)=>{ const params = {
if(res.success){ planId: item.planId,
if(_enableState === "YES"){ enableState: _enableState,
message.success("已启用此计划"); };
}else{ PlanService.updateStateTrainingPlan(params).then((res) => {
message.success("已禁用此计划"); if (res.success) {
if (_enableState === 'YES') {
message.success('已启用此计划');
} else {
message.success('已禁用此计划');
} }
props.onChange(); props.onChange();
} }
}) });
} }
function toEditPlanPage(item){ function toEditPlanPage(item) {
window.RCHistory.push({ window.RCHistory.push({
pathname: `/create-plan?type=edit&id=${item.planId}`, pathname: `/create-plan?type=edit&id=${item.planId}`,
}) });
} }
function toLearningDataPage(item){ function toLearningDataPage(item) {
window.RCHistory.push({ window.RCHistory.push({
pathname: `/learning-data?id=${item.planId}`, pathname: `/learning-data?id=${item.planId}`,
}) });
} }
function handleDelete(record){ function handleDelete(record) {
return confirm({ return confirm({
title: '你确定要删除吗?', title: '你确定要删除吗?',
content: '删除后,此培训计划的学员将无法继续学习,所有学习数据将同步删除不可恢复', content: '删除后,此培训计划的学员将无法继续学习,所有学习数据将同步删除不可恢复',
icon: <span className="icon iconfont default-confirm-icon">&#xe839; </span>, icon: <span className='icon iconfont default-confirm-icon'>&#xe839; </span>,
okText: '删除', okText: '删除',
okType: 'danger', okType: 'danger',
cancelText: '取消', cancelText: '取消',
width:440, width: 440,
height:188, height: 188,
onOk: () => { onOk: () => {
if(record.enableState === "YES"){ if (record.enableState === 'YES') {
Modal.warning({ Modal.warning({
title: '无法删除', title: '无法删除',
content: '培训计划启用中,无法直接删除', content: '培训计划启用中,无法直接删除',
}); });
}else{ } else {
deleteConfirm(record); deleteConfirm(record);
} }
},
} });
})
}
function deleteConfirm(item){
const params={
"planId": item.planId,
} }
PlanService.deleteTrainingPlan(params).then((res)=>{ function deleteConfirm(item) {
if(res.success){ const params = {
message.success("删除成功"); planId: item.planId,
};
PlanService.deleteTrainingPlan(params).then((res) => {
if (res.success) {
message.success('删除成功');
props.onChange(); props.onChange();
} }
}) });
} }
function onShowSizeChange(current, size){ function onShowSizeChange(current, size) {
if (current === size) { if (current === size) {
return return;
} }
let _query = props.query let _query = props.query;
_query.size = size; _query.size = size;
props.onChange(_query) props.onChange(_query);
} }
return ( return (
<div className="plan-list"> <div className='plan-list'>
<Table <Table
rowKey={record => record.id} rowKey={(record) => record.id}
showSorterTooltip={false} showSorterTooltip={false}
dataSource={props.planListData} dataSource={props.planListData}
columns={ parseColumns() } columns={parseColumns()}
pagination={false} pagination={false}
onChange={handleChangeTable} onChange={handleChangeTable}
bordered bordered
size="middle" size='middle'
scroll={{ x: 1400}} scroll={{ x: 1400 }}
className="plan-list-table" className='plan-list-table'
/> />
<div className="box-footer"> <div className='box-footer'>
<PageControl <PageControl
current={props.query.current - 1} current={props.query.current - 1}
pageSize={props.query.size} pageSize={props.query.size}
total={props.totalCount} total={props.totalCount}
toPage={(page) => { toPage={(page) => {
const _query = {...props.query, current: page + 1}; const _query = { ...props.query, current: page + 1 };
props.onChange(_query) props.onChange(_query);
}} }}
onShowSizeChange={onShowSizeChange} onShowSizeChange={onShowSizeChange}
/> />
</div> </div>
{sharePlanModal } {sharePlanModal}
</div> </div>
) );
} }
export default withRouter(PlanList); export default withRouter(PlanList);
\ No newline at end of file
.plan-list{ .plan-list {
margin-top:12px; margin-top: 12px;
.course-number{ .course-number {
text-align:right; text-align: right;
margin-right:45px; margin-right: 45px;
}
.plan-list-table {
thead.ant-table-thead {
tr {
th {
padding: 10px 12px;
}
}
} }
.plan-list-table{
tbody { tbody {
tr{ tr {
&:nth-child(even){ td.ant-table-cell {
background: transparent !important; padding: 16px 12px;
td{ color: #333;
background:#FFF !important; }
&:nth-child(even) {
background: transparent;
td {
background: #fff;
} }
} }
&:nth-child(odd){ &:nth-child(odd) {
background: #FAFAFA !important; background: #fafafa;
td{ td {
background: #FAFAFA !important; background: #fafafa;
} }
} }
&:hover{ &:hover {
td{ td {
background:#F3f6fa !important; background: #f3f6fa;
} }
} }
} }
} }
} }
.plan-name{ .plan_name_item {
text-overflow: -o-ellipsis-lastline; display: flex;
align-items: center;
.plan-cover {
width: 106px;
height: 60px;
border-radius: 2px;
margin-right: 8px;
}
.plan-name {
width: 188px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
-webkit-line-clamp: 2; -webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
height: 40px;
}
} }
.operate-text { .operate-text {
color: #2966FF; color: #2966ff;
cursor: pointer; cursor: pointer;
} }
.operate { .operate {
display: flex; display: flex;
&__item { &__item {
color: #2966FF; color: #2966ff;
cursor: pointer; cursor: pointer;
&.split { &.split {
margin: 0 8px; margin: 0 8px;
color: #BFBFBF; color: #bfbfbf;
} }
} }
} }
.join-number{ .join-number {
text-align:right; text-align: right;
margin-right:12px; margin-right: 12px;
} }
.more-operate{ .more-operate {
line-height:20px; line-height: 20px;
} }
} }
...@@ -2,54 +2,57 @@ ...@@ -2,54 +2,57 @@
.ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn { .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn {
font-weight: 500; font-weight: 500;
} }
.link-create-course{ .ant-modal-footer {
color:#666666; display: flex;
font-size:14px; }
width:638px; .link-create-course {
text-align:left; color: #666666;
display:inline-block; font-size: 14px;
span{ width: 638px;
color:#2966FF; text-align: left;
} display: inline-block;
} span {
.search-container{ color: #2966ff;
margin-bottom:16px; }
} }
.select-area{ .search-container {
margin-bottom:12px; margin-bottom: 16px;
display:flex; }
justify-content:space-between; .select-area {
.select-box{ margin-bottom: 12px;
display:inline-box; display: flex;
justify-content: space-between;
.select-box {
display: inline-box;
width: 186px; width: 186px;
background: #E9EFFF; background: #e9efff;
border-radius: 4px; border-radius: 4px;
padding:6px 16px; padding: 6px 16px;
margin-right:8px; margin-right: 8px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
.tip-icon{ .tip-icon {
color:#2966FF; color: #2966ff;
font-size:14px; font-size: 14px;
margin-right:4px; margin-right: 4px;
} }
.select-num{ .select-num {
color:#666666; color: #666666;
font-size:14px; font-size: 14px;
} }
.clear-btn{ .clear-btn {
text-align:right; text-align: right;
color:#2966FF; color: #2966ff;
font-size:14px; font-size: 14px;
} }
} }
.related-box{ .related-box {
padding:6px 16px; padding: 6px 16px;
background: #E9EFFF; background: #e9efff;
border-radius: 4px; border-radius: 4px;
flex:1; flex: 1;
color:#666666; color: #666666;
font-size:14px; font-size: 14px;
} }
} }
.search-container { .search-container {
......
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