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