Commit 9df2307f by zhangleyuan

feat:创建课程条助教选项改为多选

parent 6bb59f47
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Modal, Button } from 'antd'; import { Modal, Button } from 'antd';
import UploadOss from '@/core/upload'; import Service from '@/common/js/service';
import User from '@/common/js/user';
let cutFlag = false; let cutFlag = false;
class ImgCutModalNew extends React.Component { class ImgCutModalNew extends React.Component {
...@@ -41,7 +41,7 @@ class ImgCutModalNew extends React.Component { ...@@ -41,7 +41,7 @@ class ImgCutModalNew extends React.Component {
dataUrl = this.getBase64Size(dataUrl) > compressSizeByte ? await this.handleCompressImg(dataUrl, compressSizeByte, cutWidth) : dataUrl; dataUrl = this.getBase64Size(dataUrl) > compressSizeByte ? await this.handleCompressImg(dataUrl, compressSizeByte, cutWidth) : dataUrl;
} }
const cutImage = this.convertBase64UrlToBlob(dataUrl); const cutImage = this.convertBase64UrlToBlob(dataUrl);
window.axios.Apollo("public/apollo/commonOssAuthority", params).then((res) => { Service.Hades('public/hades/commonOssAuthority', param).then((res) => {
const { resourceId, accessId, policy, callback, signature,key, host } = res.result; const { resourceId, accessId, policy, callback, signature,key, host } = res.result;
const localUrl = URL.createObjectURL(cutImage); const localUrl = URL.createObjectURL(cutImage);
// 构建上传的表单 // 构建上传的表单
......
...@@ -20,7 +20,7 @@ import PreviewCourseModal from './modal/PreviewCourseModal'; ...@@ -20,7 +20,7 @@ import PreviewCourseModal from './modal/PreviewCourseModal';
import CourseService from "@/domains/course-domain/CourseService"; import CourseService from "@/domains/course-domain/CourseService";
import moment from 'moment'; import moment from 'moment';
import User from '@/common/js/user'; import User from '@/common/js/user';
import _ from "underscore";
import './AddLive.less'; import './AddLive.less';
const defaultCover = 'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png'; const defaultCover = 'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png';
...@@ -28,15 +28,15 @@ const defaultBasicInfo = { ...@@ -28,15 +28,15 @@ const defaultBasicInfo = {
courseName: null, // 课程名称 courseName: null, // 课程名称
coverId: null, coverId: null,
coverUrl: defaultCover, coverUrl: defaultCover,
parentCatalogId:'', parentCatalogId:null,
parentCatalogName:'', sonCatalogId:null,
sonCatalogId:'', categoryId:null,
sonCatalogName:'' categoryName:null
}; };
const defaultClassInfo = { const defaultClassInfo = {
teacherId: null, //讲师的Id teacherId: null, //讲师的Id
adminId:null, //助教的Id assistant:[], //助教
teacherName: null, teacherName: null,
liveDate: null, liveDate: null,
timeHorizonStart: null, timeHorizonStart: null,
...@@ -73,15 +73,17 @@ class AddLive extends React.Component { ...@@ -73,15 +73,17 @@ class AddLive extends React.Component {
courseName: null, // 课程名称 courseName: null, // 课程名称
coverId: null, coverId: null,
coverUrl: defaultCover, coverUrl: defaultCover,
parentCatalogId:'', parentCatalogId:null,
sonCatalogId:'' sonCatalogId:null,
categoryId:null,
categoryName:null
}, },
// 直播课上课信息 // 直播课上课信息
addLiveClassInfo: { addLiveClassInfo: {
teacherId: null, teacherId: null,
teacherName: null, teacherName: null,
adminId:null, assistant:[],
liveDate: null, liveDate: null,
timeHorizonStart: null, timeHorizonStart: null,
timeHorizonEnd: null, timeHorizonEnd: null,
...@@ -129,8 +131,11 @@ class AddLive extends React.Component { ...@@ -129,8 +131,11 @@ class AddLive extends React.Component {
needRecord, needRecord,
whetherVisitorsJoin, whetherVisitorsJoin,
warmMedia, warmMedia,
categoryId,
categoryName,
admins
} = res.result; } = res.result;
courseMediaVOS.map((item) => { courseMediaVOS.map((item) => {
item.key = window.random_string(16); item.key = window.random_string(16);
return item; return item;
...@@ -140,12 +145,17 @@ class AddLive extends React.Component { ...@@ -140,12 +145,17 @@ class AddLive extends React.Component {
courseName, courseName,
coverId, coverId,
coverUrl: coverUrl || defaultCover, coverUrl: coverUrl || defaultCover,
categoryId,
categoryName
}; };
const liveDate = startTime; const liveDate = startTime;
const timeHorizonStart = startTime; const timeHorizonStart = startTime;
const timeHorizonEnd = endTime; const timeHorizonEnd = endTime;
const assistant = _.pluck(admins, "adminId");
console.log('assistant',assistant);
const addLiveClassInfo = { const addLiveClassInfo = {
assistant,
liveDate, liveDate,
nickname, nickname,
teacherId, teacherId,
...@@ -154,6 +164,7 @@ class AddLive extends React.Component { ...@@ -154,6 +164,7 @@ class AddLive extends React.Component {
startTime, startTime,
endTime, endTime,
} }
const liveCourseMediaRequests = courseMediaVOS.length const liveCourseMediaRequests = courseMediaVOS.length
? [...courseMediaVOS] ? [...courseMediaVOS]
: [{ contentType:"INTRO",mediaType: 'TEXT', mediaContent: '', key: window.random_string(16) }, ...courseMediaVOS]; : [{ contentType:"INTRO",mediaType: 'TEXT', mediaContent: '', key: window.random_string(16) }, ...courseMediaVOS];
...@@ -164,6 +175,7 @@ class AddLive extends React.Component { ...@@ -164,6 +175,7 @@ class AddLive extends React.Component {
whetherVisitorsJoin, whetherVisitorsJoin,
liveCourseMediaRequests, liveCourseMediaRequests,
} }
// 晚于开课前30分钟 // 晚于开课前30分钟
if(new Date().getTime() > startTime - 1800000) { if(new Date().getTime() > startTime - 1800000) {
isEdit = false isEdit = false
...@@ -247,11 +259,11 @@ class AddLive extends React.Component { ...@@ -247,11 +259,11 @@ class AddLive extends React.Component {
this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit).then((res) => { this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit).then((res) => {
if (!res) return; if (!res) return;
const { type } = this.state; const { type } = this.state;
const { courseName, coverId, coverUrl,parentCatalogId} = addLiveBasicInfo; const { courseName, coverId, coverUrl,parentCatalogId,sonCatalogId,categoryId} = addLiveBasicInfo;
const { const {
liveDate, liveDate,
teacherId, teacherId,
adminId, assistant,
timeHorizonEnd, timeHorizonEnd,
timeHorizonStart, timeHorizonStart,
calendarTime, calendarTime,
...@@ -259,6 +271,7 @@ class AddLive extends React.Component { ...@@ -259,6 +271,7 @@ class AddLive extends React.Component {
let { startTime, endTime } = addLiveClassInfo; let { startTime, endTime } = addLiveClassInfo;
const { liveCourseMediaRequests, needRecord,whetherVisitorsJoin,liveCourseWarmMedia} = addLiveIntroInfo; const { liveCourseMediaRequests, needRecord,whetherVisitorsJoin,liveCourseWarmMedia} = addLiveIntroInfo;
if(type === 'add') { if(type === 'add') {
startTime = startTime; startTime = startTime;
endTime = endTime; endTime = endTime;
...@@ -270,9 +283,9 @@ class AddLive extends React.Component { ...@@ -270,9 +283,9 @@ class AddLive extends React.Component {
endTime = moment(_liveDate + ' ' + _timeHorizonEnd).format('x'); endTime = moment(_liveDate + ' ' + _timeHorizonEnd).format('x');
} }
const commonParams = { const commonParams = {
adminIds:[adminId], adminIds:assistant,
calendarTime, calendarTime,
categoryId:parentCatalogId, categoryId,
endTime, endTime,
needRecord, needRecord,
startTime, startTime,
...@@ -280,13 +293,13 @@ class AddLive extends React.Component { ...@@ -280,13 +293,13 @@ class AddLive extends React.Component {
storeId:User.getStoreId(), storeId:User.getStoreId(),
teacherId:teacherId, teacherId:teacherId,
whetherVisitorsJoin, whetherVisitorsJoin,
scheduleMediaRequests:[...liveCourseMediaRequests] // scheduleMediaRequests:[...liveCourseMediaRequests]
} }
if (type === 'add') { if (type === 'add') {
const params = { const params = {
...commonParams, ...commonParams,
operatorId:User.getUserId(), operatorId:User.getUserId(),
} }
CourseService.createLiveCloudCourse(params).then((res) => { CourseService.createLiveCloudCourse(params).then((res) => {
...@@ -317,23 +330,25 @@ class AddLive extends React.Component { ...@@ -317,23 +330,25 @@ class AddLive extends React.Component {
handleValidate = (addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit) => { handleValidate = (addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit) => {
return new Promise((resolve) => { return new Promise((resolve) => {
const { type } = this.state; const { type } = this.state;
const { courseName,parentCatalogId} = addLiveBasicInfo; const { courseName,parentCatalogId,categoryId} = addLiveBasicInfo;
const { const {
liveDate, timeHorizonStart, timeHorizonEnd, teacherId, calendarTime liveDate, timeHorizonStart, timeHorizonEnd, teacherId, calendarTime
} = addLiveClassInfo; } = addLiveClassInfo;
const { liveCourseMediaRequests } = addLiveIntroInfo; const { liveCourseMediaRequests } = addLiveIntroInfo;
const currentTime = +new Date(); const currentTime = +new Date();
if(!courseName) { if(!courseName) {
message.warning('请输入课程名称'); message.warning('请输入课程名称');
resolve(false); resolve(false);
return; return;
} }
if(!parentCatalogId){
if(!categoryId){
message.warning('请选择课程分类'); message.warning('请选择课程分类');
resolve(false); resolve(false);
return; return;
} }
if(type === 'add') { if(type === 'add') {
const { startTime, endTime } = addLiveClassInfo; const { startTime, endTime } = addLiveClassInfo;
if(calendarTime.length && calendarTime.length === 0) { if(calendarTime.length && calendarTime.length === 0) {
...@@ -494,6 +509,7 @@ class AddLive extends React.Component { ...@@ -494,6 +509,7 @@ class AddLive extends React.Component {
<div className="title">基本信息</div> <div className="title">基本信息</div>
<AddLiveBasic <AddLiveBasic
isEdit={isEdit} isEdit={isEdit}
pageType={type}
data={addLiveBasicInfo} data={addLiveBasicInfo}
onChange={this.handleChangeBasicInfo} onChange={this.handleChangeBasicInfo}
/> />
......
/*
* @Author: 吴文洁
* @Date: 2020-07-15 17:29:12
* @Last Modified by: 吴文洁
* @Last Modified time: 2020-07-15 18:16:05
* @Description: 新建/编辑直播课-基本信息
*/
import React from 'react';
import { Input, Button, message ,Cascader } from 'antd';
import UploadOss from "@/core/upload";
import { ImgCutModalNew } from '@/components';
import StoreService from "@/domains/store-domain/storeService";
import './AddLiveBasic.less';
const defaultCover = 'https://image.xiaomaiketang.com/xm/YNfi45JwFA.png';
const fieldNames = { label: 'categoryName', value: 'id', children: 'sonCategoryList' };
class AddLiveBasic extends React.Component {
constructor(props) {
super(props);
this.state = {
imageFile: null,
showCutModal: false,
courseCatalogList:[]
}
}
componentWillUnmount() {
}
componentDidMount(){
this.getCourseCatalogList();
}
getCourseCatalogList = ()=>{
StoreService.getCourseCatalogList({current:1,size:1000}).then((res) => {
this.setState({
courseCatalogList:res.result.records
})
});
}
// 上传封面图
handleShowImgCutModal = (event) => {
const imageFile = event.target.files[0];
if (!imageFile) return;
this.setState({
imageFile,
showCutModal: true,
});
}
// 使用默认封面图
handleResetCoverUrl = () => {
const { data: { coverUrl } } = this.props;
const isDefaultCover = coverUrl === defaultCover;
// 如果已经是默认图的话,不做任何任何处理
if (isDefaultCover) return;
message.success('已替换为默认图');
this.props.onChange('coverId', null, defaultCover);
}
catalogChange= (value) => {
const changeValueLength = value.length;
switch (changeValueLength){
case 1:
this.props.onChange('parentCatalogId',value[0]);
break;
case 2:
this.props.onChange('parentCatalogId',value[0]);
setTimeout(()=>{
this.props.onChange('sonCatalogId',value[1]);
},1000)
break;
default:
break;
}
}
render() {
const { showCutModal, imageFile,courseCatalogList} = this.state;
const { data} = this.props;
const { courseName, coverUrl} = data;
const fileName = '';
// 当前是否使用的是默认图片
const isDefaultCover = coverUrl === defaultCover;
return (
<div className="add-live__basic-info">
<div className="course-name">
<span className="label"><span className="require">*</span>课程名称:</span>
<Input
value={courseName}
placeholder="请输入直播名称(40字以内)"
maxLength={40}
style={{ width: 240 }}
onChange={(e) => { this.props.onChange('courseName', e.target.value)}}
/>
</div>
<div className="course-cover">
<span className="label">封面图:</span>
<div className="course-cover__wrap">
<div className="img-content">
{
isDefaultCover && <span className="tag">默认图</span>
}
<img src={coverUrl} />
</div>
<div className="opt-btns">
<input
type="file"
value={fileName} // 避免选择同一文件 value不改变 不触发onChange事件
accept="image/png, image/jpeg, image/bmp, image/jpg"
ref="stagePicInputFile"
style={{display: 'none'}}
onChange={(event) => { this.handleShowImgCutModal(event) }}
/>
<Button onClick={() => {
this.setState({
currentInputFile: this.refs.stagePicInputFile
});
this.refs.stagePicInputFile.click();
}}>上传图片</Button>
<span
className={`default-btn ${isDefaultCover ? 'disabled' : ''}`}
onClick={this.handleResetCoverUrl}
>使用默认图</span>
<div className="tips">建议尺寸690*398像素,图片支持jpg、jpeg、png格式。</div>
</div>
</div>
</div>
<div className="course-catalog">
<span className="label"><span className="require">*</span>课程分类:</span>
<Cascader options={courseCatalogList} displayRender={ label => label.join('-')} fieldNames={fieldNames} onChange={this.catalogChange} style={{ width: 240 }} placeholder="请选择课程分类" />
</div>
<ImgCutModalNew
title="裁剪"
width={550}
cutWidth={500}
cutHeight={282}
cutContentWidth={500}
cutContentHeight={300}
visible={showCutModal}
imageFile={imageFile}
bizCode='LIVE_COURSE_MEDIA'
onOk={(urlStr, resourceId) => {
this.setState({ showCutModal: false });
this.props.onChange('coverId', resourceId, urlStr);
this.state.currentInputFile.value = '';
}}
onClose={() => this.setState({ showCutModal: false })}
reUpload={() => { this.state.currentInputFile.click() }}
/>
</div>
)
}
}
export default AddLiveBasic;
\ No newline at end of file
...@@ -172,17 +172,16 @@ class LiveCourseList extends React.Component { ...@@ -172,17 +172,16 @@ class LiveCourseList extends React.Component {
<div className="course-name">{record.courseName}</div> <div className="course-name">{record.courseName}</div>
<div> <div>
<span className="course-time">{formatDate("YYYY-MM-DD H:i",parseInt(record.startTime))}~{formatDate("H:i", parseInt(record.endTime))}</span> <span className="course-time">{formatDate("YYYY-MM-DD H:i",parseInt(record.startTime))}~{formatDate("H:i", parseInt(record.endTime))}</span>
<span>{courseStateShow[record.courseState].title}</span> <span className="course-status" style={{color:courseStateShow[record.courseState].color,border:`1px solid ${courseStateShow[record.courseState].color}`}}>{courseStateShow[record.courseState].title}</span>
</div> </div>
<div> <div>
<span>讲师:{record.teacherName}</span> <span className="teacher">讲师:{record.teacherName}</span>
<span> | </span> <span className="split"> | </span>
<span>助教: <span className="assistant">助教:
{ record.admins.map((item,index)=>{ { record.admins.map((item,index)=>{
return <span>{item.adminName}</span> return <span>{item.adminName} { (index < record.admins.length-1)&&(<span></span>)} </span>
}) })
} }
</span> </span>
...@@ -199,7 +198,7 @@ class LiveCourseList extends React.Component { ...@@ -199,7 +198,7 @@ class LiveCourseList extends React.Component {
dataIndex: "couseCatalog", dataIndex: "couseCatalog",
render: (val, item) => { render: (val, item) => {
return ( return (
<div>{item.categoryName}</div> <div className="categoryName">{item.categoryName}</div>
) )
}, },
}, },
...@@ -210,7 +209,7 @@ class LiveCourseList extends React.Component { ...@@ -210,7 +209,7 @@ class LiveCourseList extends React.Component {
dataIndex: "courseware", dataIndex: "courseware",
render: (val, item) => { render: (val, item) => {
return ( return (
<span>{item.courseDocumentCount}</span> <span className="courseware">{item.courseDocumentCount}</span>
); );
}, },
}, },
...@@ -221,7 +220,7 @@ class LiveCourseList extends React.Component { ...@@ -221,7 +220,7 @@ class LiveCourseList extends React.Component {
dataIndex: "quota", dataIndex: "quota",
render: (val, item) => { render: (val, item) => {
return ( return (
<span className="iconfont icon data-icon" onClick={() => { <span className="iconfont icon quota-icon" onClick={() => {
this.handleLinkToClassData(item) this.handleLinkToClassData(item)
}}>&#xe7d6;</span> }}>&#xe7d6;</span>
); );
......
.live-course-list {
margin-top: 16px;
.record__item {
display: flex;
align-items: center;
}
.operate {
display: flex;
align-items: center;
flex-wrap: wrap;
.operate__item {
color: #ff7519;
cursor: pointer;
&.split {
margin: 0 8px;
color: #BFBFBF;
}
}
}
.operate-text {
color: #ff7519;
cursor: pointer;
}
.course-cover {
min-width: 90px;
max-width: 90px;
height: 50px;
border-radius: 2px;
margin-right: 8px;
}
.course-status {
display: flex;
.badge {
transform: none !important;
display: flex;
align-items: center;
.ant-badge-status-dot {
top: 0;
}
.ant-badge-status-text {
white-space: nowrap;
}
}
}
.course-start-end {
margin-left: 16px;
width: 78px;
height: 20px;
border-radius: 2px;
border: 1px solid rgba(204, 204, 204, 1);
display: flex;
align-items: center;
cursor: pointer;
white-space: nowrap;
.start-icon {
color: #3296fa;
font-size: 12px;
transform: scale(0.8);
margin: 0 5px;
}
.end-icon {
color: #00d700;
font-size: 12px;
transform: scale(0.8);
margin: 0 5px;
}
.start-end-text {
font-size: 12px;
}
}
}
.live-course-more-menu {
background: white;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
border-radius: 4px;
div {
line-height: 30px;
padding: 0 15px;
cursor: pointer;
&:hover {
background: #f3f6fa;
}
}
}
.tipTitle {
.type {
font-weight: 700;
}
}
\ No newline at end of file
...@@ -27,7 +27,7 @@ import ScanFileModal from '../modal/ScanFileModal'; ...@@ -27,7 +27,7 @@ import ScanFileModal from '../modal/ScanFileModal';
import CreateFolderModal from '../modal/CreateFolderModal'; import CreateFolderModal from '../modal/CreateFolderModal';
const DEL_FOLDER_URL_MAP = { const DEL_FOLDER_URL_MAP = {
'MYSELF': 'public/apollo/delFolder', 'MYSELF': 'public/hadesStore/delFolder',
'COMMON': 'public/apollo/delCommonFolder' 'COMMON': 'public/apollo/delCommonFolder'
} }
...@@ -163,7 +163,7 @@ class FolderList extends React.Component { ...@@ -163,7 +163,7 @@ class FolderList extends React.Component {
disk: currentRootDisk.disk, disk: currentRootDisk.disk,
} }
Service.Hades('public/apollo/folderPath', params).then((res) => { Service.Hades('public/hadesStore/folderPath', params).then((res) => {
const { result = [] } = res; const { result = [] } = res;
this.props.onChangeFolderPath(result, false); this.props.onChangeFolderPath(result, false);
}) })
...@@ -347,7 +347,7 @@ class FolderList extends React.Component { ...@@ -347,7 +347,7 @@ class FolderList extends React.Component {
return; return;
} }
Service.Hades('public/apollo/renameFolder', { Service.Hades('public/hadesStore/renameFolder', {
id: renameModalData.id, id: renameModalData.id,
name: folderName name: folderName
}).then(() => { }).then(() => {
...@@ -371,7 +371,7 @@ class FolderList extends React.Component { ...@@ -371,7 +371,7 @@ class FolderList extends React.Component {
folderType: 'FOLDER', folderType: 'FOLDER',
} }
const res = await Service.Hades('public/apollo/sameNameFile', params); const res = await Service.Hades('public/hadesStore/sameNameFile', params);
const { result } = res; const { result } = res;
return result; return result;
} }
......
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