Commit fd3041ba by yuananting

fix:培训计划文案调整,编辑器文本长度字段修改

parent 81eb1a9c
......@@ -114,9 +114,9 @@ class AddLive extends React.Component {
if (type === 'edit') {
this.getCourseDetail();
}
Bus.bind('editorLimit', (textLength) => {
Bus.bind('editorLimit', (editorTextLength) => {
this.setState({
textLength,
editorTextLength,
});
});
}
......@@ -284,7 +284,7 @@ class AddLive extends React.Component {
});
return;
}
const { addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, id, isEdit, type } = this.state;
const { addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, id, isEdit, type, editorTextLength } = this.state;
const { liveDate, timeHorizonStart } = addLiveClassInfo;
const _liveDate = moment(liveDate).format('YYYY-MM-DD');
const _timeHorizonStart = moment(timeHorizonStart).format('HH:mm');
......@@ -301,7 +301,7 @@ class AddLive extends React.Component {
});
return;
}
this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit).then((res) => {
this.handleValidate(addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit, editorTextLength).then((res) => {
if (!res) return;
Upload.uploadTextToOSS(
addLiveIntroInfo.introduce,
......@@ -393,9 +393,9 @@ class AddLive extends React.Component {
}
};
handleValidate = (addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit) => {
handleValidate = (addLiveBasicInfo, addLiveClassInfo, addLiveIntroInfo, isEdit, editorTextLength) => {
return new Promise((resolve) => {
const { type, textLength } = this.state;
const { type } = this.state;
const { courseName, categoryId } = addLiveBasicInfo;
const { liveDate, timeHorizonStart, timeHorizonEnd, teacherId, calendarTime } = addLiveClassInfo;
const { liveCourseMediaRequests } = addLiveIntroInfo;
......@@ -480,7 +480,7 @@ class AddLive extends React.Component {
return;
}
if (textLength > 1000) {
if (editorTextLength > 1000) {
message.warning('课程简介超过字数限定');
resolve(false);
return;
......
......@@ -2,7 +2,7 @@
* @Author: 吴文洁
* @Date: 2020-08-05 10:07:47
* @LastEditors: yuananting
* @LastEditTime: 2021-07-06 18:26:14
* @LastEditTime: 2021-07-07 14:49:24
* @Description: 图文课新增/编辑页
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
......@@ -73,9 +73,9 @@ class AddGraphicsCourse extends React.Component {
if (pageType === 'edit') {
this.handleFetchScheudleDetail(id);
}
Bus.bind('editorLimit', (textLength, editorType) => {
Bus.bind('editorLimit', (editorTextLength, editorType) => {
this.setState({
[editorType]: textLength,
[editorType]: editorTextLength,
});
});
}
......
......@@ -2,7 +2,7 @@
* @Author: 吴文洁
* @Date: 2020-08-05 10:07:47
* @LastEditors: yuananting
* @LastEditTime: 2021-07-07 10:55:41
* @LastEditTime: 2021-07-07 14:51:41
* @Description: 线下课新增/编辑页
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
......@@ -98,9 +98,9 @@ class AddOfflineCourse extends React.Component {
if (pageType === 'edit') {
this.handleFetchScheudleDetail(courseId);
}
Bus.bind('editorLimit', (textLength) => {
Bus.bind('editorLimit', (editorTextLength) => {
this.setState({
textLength,
editorTextLength,
});
});
}
......@@ -500,6 +500,7 @@ class AddOfflineCourse extends React.Component {
signOutEndTimeNum,
signOutEndTimeUnit,
// isMore,
editorTextLength,
} = this.state;
let coverObj = {
......@@ -532,6 +533,7 @@ class AddOfflineCourse extends React.Component {
startTime,
endTime,
calendarTime,
editorTextLength,
// isMore,
};
......@@ -603,7 +605,6 @@ class AddOfflineCourse extends React.Component {
};
handleValidate = (data) => {
const { textLength } = this.state;
return new Promise((resolve) => {
if (!data.courseName) {
message.warning('请输入课程名称');
......@@ -647,7 +648,7 @@ class AddOfflineCourse extends React.Component {
} else if (data.whetherSetSignOut === 'YES' && ((data.signOutType === 'START_LATER' && !data.signOutStartTimeNum) || !data.signOutEndTimeNum)) {
message.warning('请输入签退时间');
resolve(false);
} else if (textLength > 1000) {
} else if (data.editorTextLength > 1000) {
message.warning('课程简介超过字数限定');
resolve(false);
} else {
......
......@@ -2,7 +2,7 @@
* @Author: 吴文洁
* @Date: 2020-08-05 10:07:47
* @LastEditors: yuananting
* @LastEditTime: 2021-07-07 12:05:07
* @LastEditTime: 2021-07-07 15:01:40
* @Description: 线上课新增/编辑页
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
......@@ -94,9 +94,9 @@ class AddVideoCourse extends React.Component {
if (pageType === 'edit') {
this.handleFetchScheudleDetail(id)
}
Bus.bind('editorLimit', (textLength) => {
Bus.bind('editorLimit', (editorTextLength) => {
this.setState({
textLength,
editorTextLength,
});
});
}
......@@ -402,7 +402,7 @@ class AddVideoCourse extends React.Component {
whetherVisitorsJoin,
introduce,
courseChapterList,
textLength,
editorTextLength,
} = this.state
const commonParams = {
......@@ -420,7 +420,7 @@ class AddVideoCourse extends React.Component {
courseChapterList
}
// 校验必填字段:课程名称, 课程视频
this.handleValidate(courseName, courseChapterList, categoryId, scheduleMedia, textLength).then((res) => {
this.handleValidate(courseName, courseChapterList, categoryId, scheduleMedia, editorTextLength).then((res) => {
if (!res) return
Upload.uploadTextToOSS(introduce, `${randomString()}.txt`, (introduceId) => {
this.submitRemote({ id, pageType, commonParams: { ...commonParams, introduceId } })
......@@ -452,7 +452,7 @@ class AddVideoCourse extends React.Component {
}
}
handleValidate = (courseName, courseChapterList, categoryId, scheduleMedia, textLength) => {
handleValidate = (courseName, courseChapterList, categoryId, scheduleMedia, editorTextLength) => {
return new Promise((resolve) => {
if (!courseName) {
message.warning('请输入课程名称')
......@@ -469,7 +469,7 @@ class AddVideoCourse extends React.Component {
resolve(false)
return false
}
if (textLength > 1000) {
if (editorTextLength > 1000) {
message.warning('课程简介超过字数限定');
resolve(false);
return;
......
/*
* @Author: zhangleyuan
* @Date: 2021-02-20 16:13:39
* @LastEditors: wufan
* @LastEditTime: 2021-05-30 20:39:16
* @LastEditors: yuananting
* @LastEditTime: 2021-07-07 14:59:59
* @Description: 描述一下
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import React, { useEffect, useState } from 'react'
import { Button, message, Modal } from 'antd'
import ShowTips from '@/components/ShowTips'
import Breadcrumbs from '@/components/Breadcrumbs'
import BasicInfo from './components/BasicInfo'
import TrainingTask from './components/TrainingTask'
import ExpiredCourseList from './components/ExpiredCourseList'
import PlanService from '@/domains/plan-domain/planService'
import User from '@/common/js/user'
import _ from 'underscore'
import './AddPlan.less'
import React, { useEffect, useState } from 'react';
import { Button, message, Modal } from 'antd';
import ShowTips from '@/components/ShowTips';
import Breadcrumbs from '@/components/Breadcrumbs';
import BasicInfo from './components/BasicInfo';
import TrainingTask from './components/TrainingTask';
import ExpiredCourseList from './components/ExpiredCourseList';
import PlanService from '@/domains/plan-domain/planService';
import User from '@/common/js/user';
import _ from 'underscore';
import './AddPlan.less';
import bus from '@/core/bus';
const defaultCover = 'https://image.xiaomaiketang.com/xm/rEAetaTEh3.png';
const defaultBasicData = {
planName: '',
......@@ -28,35 +29,39 @@ const defaultBasicData = {
operateType: 'All_Operate',
percentCompleteLive: 80,
percentCompleteVideo: 80,
percentCompletePicture: 100
}
const defaultTaskList = []
percentCompletePicture: 100,
};
const defaultTaskList = [];
function AddPlan() {
const id = getParameterByName('id')
const type = getParameterByName('type')
const [basicData, setBasicData] = useState(defaultBasicData)
const [taskList, setTaskList] = useState(defaultTaskList)
const [expiredCourseList, setExpiredCourseList] = useState([])
const [hasGetDetail, setHasGetDetail] = useState(false)
const [submitDisabled, setSubmitDisabled] = useState(false)
const id = getParameterByName('id');
const type = getParameterByName('type');
const [basicData, setBasicData] = useState(defaultBasicData);
const [taskList, setTaskList] = useState(defaultTaskList);
const [expiredCourseList, setExpiredCourseList] = useState([]);
const [hasGetDetail, setHasGetDetail] = useState(false);
const [editorTextLength, setEditorTextLength] = useState(0);
useEffect(() => {
if (type === 'edit') {
getPlanDetail()
getPlanCustomerState()
getPlanDetail();
getPlanCustomerState();
}
}, id)
Bus.bind('editorLimit', (editorTextLength) => {
setEditorTextLength(editorTextLength);
});
}, id);
function getPlanCustomerState() {
PlanService.getTrainingCourseAutoCancel({
planId: id
planId: id,
}).then((res) => {
const expiredCourseList = res.result
setExpiredCourseList(expiredCourseList)
})
const expiredCourseList = res.result;
setExpiredCourseList(expiredCourseList);
});
}
function getPlanDetail() {
PlanService.getTrainingPlanDetail({
planId: id
planId: id,
}).then((res) => {
const {
planName,
......@@ -67,34 +72,34 @@ function AddPlan() {
percentCompleteVideo,
percentCompletePicture,
courseMediaVOS,
trainingTaskList
} = res.result
let coverId
let coverUrl
let instro
trainingTaskList,
} = res.result;
let coverId;
let coverUrl;
let instro;
courseMediaVOS.map((item) => {
switch (item.contentType) {
case 'COVER':
coverId = item.mediaContent
coverUrl = item.mediaUrl
break
coverId = item.mediaContent;
coverUrl = item.mediaUrl;
break;
case 'INTRO':
instro = item.mediaContent
break
instro = item.mediaContent;
break;
default:
break
break;
}
return item
})
let _selectOperatorList = []
return item;
});
let _selectOperatorList = [];
if (operateIds) {
_selectOperatorList = operateIds.map((item, index) => {
let _item = {}
_item.id = item
return _item
})
let _item = {};
_item.id = item;
return _item;
});
}
setTaskList(trainingTaskList)
setTaskList(trainingTaskList);
setBasicData({
planName,
coverUrl: coverUrl || defaultCover,
......@@ -105,20 +110,20 @@ function AddPlan() {
operateType,
percentCompleteLive,
percentCompleteVideo,
percentCompletePicture
})
setHasGetDetail(true)
})
percentCompletePicture,
});
setHasGetDetail(true);
});
}
function handleChangeBasicInfo(field, value, option) {
setBasicData({
...basicData,
[field]: value
})
[field]: value,
});
}
function handleChangeTaskInfo(value) {
setTaskList(value)
setTaskList(value);
}
function submitInfo() {
......@@ -132,37 +137,37 @@ function AddPlan() {
percentCompleteVideo,
percentCompletePicture,
coverId,
coverUrl
} = basicData
let input = /^[\s]*$/
coverUrl,
} = basicData;
let input = /^[\s]*$/;
if (!planName || input.test(planName)) {
message.warning('请输入的培训计划名称')
return
message.warning('请输入的培训计划名称');
return;
}
if (operateType === 'Assign_Operate' && selectOperatorList.length === 0) {
message.warning('请选择指定运营师')
return
message.warning('请选择指定运营师');
return;
}
if (!percentCompleteLive && percentCompleteLive !== 0) {
message.warning('请输入完成标准')
return
message.warning('请输入完成标准');
return;
}
if (!percentCompleteVideo && percentCompleteVideo !== 0) {
message.warning('请输入完成标准')
return
message.warning('请输入完成标准');
return;
}
if (!percentCompletePicture && percentCompletePicture !== 0) {
message.warning('请输入完成标准')
return
message.warning('请输入完成标准');
return;
}
if (taskList.length === 0) {
message.warning('请输入培训计划内容')
return
message.warning('请输入培训计划内容');
return;
}
for (let i = 0; i < taskList.length; i++) {
if (input.test(taskList[i].taskName)) {
message.warning('培训任务名称不能为空')
return false
message.warning('培训任务名称不能为空');
return false;
}
if (taskList[i].courseList.length === 0) {
Modal.confirm({
......@@ -170,28 +175,33 @@ function AddPlan() {
content: '每个任务下至少关联一个课程',
okText: '确定',
cancelText: '取消',
icon: <span className='icon iconfont default-confirm-icon'>&#xe6f4;</span>
})
return false
icon: <span className='icon iconfont default-confirm-icon'>&#xe6f4;</span>,
});
return false;
}
}
if (editorTextLength > 1000) {
message.warning('简介超过字数限定');
return;
}
let scheduleMediaRequests = []
let scheduleMediaRequests = [];
let coverObj = {
contentType: 'COVER',
mediaContent: coverId,
mediaType: 'PICTURE',
mediaUrl: coverUrl
}
mediaUrl: coverUrl,
};
if (coverId) {
scheduleMediaRequests = [...scheduleMediaRequests, coverObj]
scheduleMediaRequests = [...scheduleMediaRequests, coverObj];
}
let instroObj = {
contentType: 'INTRO',
mediaType: 'TEXT',
mediaContent: instro
}
mediaContent: instro,
};
if (instro) {
scheduleMediaRequests = [...scheduleMediaRequests, instroObj]
scheduleMediaRequests = [...scheduleMediaRequests, instroObj];
}
const params = {
......@@ -205,43 +215,43 @@ function AddPlan() {
planName,
scheduleMediaRequests,
storeId: User.getStoreId(),
trainingTaskList: handleSubmitTaskData(taskList)
}
trainingTaskList: handleSubmitTaskData(taskList),
};
if (type === 'add') {
PlanService.createTrainingPlan(params).then((res) => {
if (res.success) {
message.success('新建成功')
setSubmitDisabled(true)
window.RCHistory.goBack()
message.success('新建成功');
setSubmitDisabled(true);
window.RCHistory.goBack();
}
})
});
} else {
const _params = {
...params,
id
}
id,
};
PlanService.updateTrainingPlan(_params).then((res) => {
if (res.success) {
message.success('更新成功')
window.RCHistory.goBack()
message.success('更新成功');
window.RCHistory.goBack();
}
})
});
}
}
function handleSubmitTaskData(taskData) {
return taskData.map((item, index) => {
let _item = {}
_item.taskId = item.taskId
_item.taskName = item.taskName
let _item = {};
_item.taskId = item.taskId;
_item.taskName = item.taskName;
_item.courseList = item.courseList.map((childItem, index) => {
let _childItem = {}
_childItem.courseId = childItem.courseId
_childItem.courseName = childItem.courseName
_childItem.courseType = childItem.courseType
return _childItem
})
return _item
})
let _childItem = {};
_childItem.courseId = childItem.courseId;
_childItem.courseName = childItem.courseName;
_childItem.courseType = childItem.courseType;
return _childItem;
});
return _item;
});
}
// 取消编辑并返回上一级路由
function handleGoBack() {
......@@ -253,11 +263,11 @@ function AddPlan() {
cancelText: '留在本页',
icon: <span className='icon iconfont default-confirm-icon'>&#xe6f4;</span>,
onOk: () => {
window.RCHistory.goBack()
}
})
window.RCHistory.goBack();
},
});
} else {
window.RCHistory.goBack()
window.RCHistory.goBack();
}
}
......@@ -293,6 +303,6 @@ function AddPlan() {
</Button>
</div>
</div>
)
);
}
export default AddPlan
export default AddPlan;
......@@ -2,7 +2,7 @@
* @Author: yuananting
* @Date: 2021-07-05 10:48:08
* @LastEditors: yuananting
* @LastEditTime: 2021-07-06 19:49:14
* @LastEditTime: 2021-07-07 15:00:20
* @Description: 描述一下咯
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
......@@ -260,7 +260,7 @@ class BasicInfo extends React.Component {
</div>
</div>
<div className='introduction'>
<span className='label'>课程简介:</span>
<span className='label'>简介:</span>
{/* <TextArea
placeholder='请输入培训计划简介'
maxLength={200}
......
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