Commit a4d52d69 by yuananting

feat:添加新建培训任务校验

parent 4f7e0407
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-07-29 13:57:03 * @Date: 2021-07-29 13:57:03
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-08-02 17:25:17 * @LastEditTime: 2021-08-04 17:47:51
* @Description: 任务中心-培训任务-新建页面 * @Description: 任务中心-培训任务-新建页面
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
...@@ -21,35 +21,48 @@ import './AddTrainTask.less'; ...@@ -21,35 +21,48 @@ import './AddTrainTask.less';
import Bus from '@/core/bus'; import Bus from '@/core/bus';
const { TabPane } = Tabs; const { TabPane } = Tabs;
const defaultCover = 'https://image.xiaomaiketang.com/xm/rEAetaTEh3.png';
const DEFAULT_BASIC_INFO = { const DEFAULT_BASIC_INFO = {
planName: '', taskName: '', // 培训任务名称
coverUrl: defaultCover, // createId: User.getStoreUserId(), // 创建人id
coverId: null, // storeId: User.getStoreId(), // 学院id
durationType: 'NEVER_EXPIRES', // issueState: 'YES', // 是否发布此计划(底部按钮区分)
learnType: 'FREEDOM', // scheduleMediaRequests: [], // 封面图-(简介待定)
enableState: 'YES', coverUrl: '',
selectOperatorList: [], trainingStageList: [], // 培训内容
instro: '', helpStoreUserIds: [], // 指定协同者id
operateType: 'All_Operate', timeType: 'VALIDITY', // 培训时间,默认永久有效
percentCompleteLive: 80, startTime: null, // 固定时间段-开始时间
percentCompleteVideo: 80, endTime: null, // 固定时间段-结束时间
percentCompletePicture: 100, learnType: 'FREEDOM', // 学习模式,默认自由学习
assignList: [], // 指派列表-assignId assignType
instro: null, // 培训目的
}; };
const DEFAULT_TASK_LIST = [ const DEFAULT_STAGE_LIST = [
{ {
taskName: '阶段一', stageName: '阶段一',
courseList: [], contentList: [],
check: false,
}, },
]; ];
const DEFAULT_FINISH_STANDARD = {
percentCompleteLive: 80,
percentCompleteVideo: 80, // 线上课完成百分比
percentCompletePicture: 80, // 图文课完成百分比
};
function AddTrainTask() { function AddTrainTask() {
const type = getParameterByName('type'); const type = getParameterByName('type');
const [activeStep, setActiveStep] = useState('BASIC_INFO'); const [activeStep, setActiveStep] = useState('BASIC_INFO');
const [basicInfo, setBasicInfo] = useState(DEFAULT_BASIC_INFO); const [basicInfo, setBasicInfo] = useState(DEFAULT_BASIC_INFO);
const [taskList, setTaskList] = useState(DEFAULT_TASK_LIST); const [stageList, setStageList] = useState(DEFAULT_STAGE_LIST);
const [finishStandard, setFinishStandard] = useState(DEFAULT_FINISH_STANDARD); // 完成百分比
const [startCheck, setStartCheck] = useState(false); // 是否启动校验
useEffect(() => {
console.log('basicInfo:', basicInfo);
}, [basicInfo]);
function renderFooter() { function renderFooter() {
return ( return (
...@@ -57,7 +70,7 @@ function AddTrainTask() { ...@@ -57,7 +70,7 @@ function AddTrainTask() {
<When condition={activeStep === 'BASIC_INFO'}> <When condition={activeStep === 'BASIC_INFO'}>
<div className='footer shrink-footer'> <div className='footer shrink-footer'>
<Button onClick={handleGoBack}>取消</Button> <Button onClick={handleGoBack}>取消</Button>
<Button onClick={() => console.log('提交')}>保存</Button> <Button onClick={handleSubmit}>保存</Button>
<Button type='primary' onClick={() => console.log('下一步')}> <Button type='primary' onClick={() => console.log('下一步')}>
下一步 下一步
</Button> </Button>
...@@ -68,7 +81,7 @@ function AddTrainTask() { ...@@ -68,7 +81,7 @@ function AddTrainTask() {
<div className='footer shrink-footer'> <div className='footer shrink-footer'>
<Button onClick={handleGoBack}>取消</Button> <Button onClick={handleGoBack}>取消</Button>
<Button onClick={() => console.log('上一步')}>上一步</Button> <Button onClick={() => console.log('上一步')}>上一步</Button>
<Button onClick={() => console.log('提交')}>保存</Button> <Button onClick={handleSubmit}>保存</Button>
<Button type='primary' onClick={() => console.log('提交')}> <Button type='primary' onClick={() => console.log('提交')}>
保存并发布 保存并发布
</Button> </Button>
...@@ -79,19 +92,44 @@ function AddTrainTask() { ...@@ -79,19 +92,44 @@ function AddTrainTask() {
); );
} }
function handleSubmit() {
setStartCheck(true);
if (stageList.length === 0) {
return message.warning('请添加阶段');
}
}
function handleGoBack() { function handleGoBack() {
window.RCHistory.goBack(); window.RCHistory.goBack();
} }
function handleChangeBasicInfo(field, value) { function handleChangeBasicInfo(field, value) {
if (field === 'trainDate') {
// 固定培训时间,设置起始
setBasicInfo({
...basicInfo,
startTime: value && value[0]?.valueOf(),
endTime: value && value[1]?.valueOf(),
});
} else {
setBasicInfo({ setBasicInfo({
...basicInfo, ...basicInfo,
[field]: value, [field]: value,
startTime: null,
endTime: null,
}); });
} }
}
function handleChangeTaskInfo(value) { function handleChangeStageInfo(field, value) {
setTaskList(value); if (field === 'stageList') {
setStageList(value);
} else {
setFinishStandard({
...finishStandard,
[field]: value,
});
}
} }
return ( return (
...@@ -118,8 +156,10 @@ function AddTrainTask() { ...@@ -118,8 +156,10 @@ function AddTrainTask() {
</span> </span>
</span> </span>
</div> </div>
{activeStep === 'BASIC_INFO' && <BasicInfo data={basicInfo} onChange={handleChangeBasicInfo} />} {activeStep === 'BASIC_INFO' && <BasicInfo basicInfo={basicInfo} startCheck={startCheck} onChange={handleChangeBasicInfo} />}
{activeStep === 'TRAIN_CONTENT' && <TrainContent data={taskList} onChange={handleChangeTaskInfo} />} {activeStep === 'TRAIN_CONTENT' && (
<TrainContent stageList={stageList} startCheck={startCheck} finishStandard={finishStandard} onChange={handleChangeStageInfo} />
)}
</div> </div>
{renderFooter()} {renderFooter()}
</div> </div>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
&.disabled { &.disabled {
color: #ccc; color: #ccc;
cursor: not-allowed; cursor: not-allowed;
pointer-events: none;
} }
} }
.tips { .tips {
...@@ -57,6 +58,9 @@ ...@@ -57,6 +58,9 @@
.picker-box { .picker-box {
display: inline-block; display: inline-block;
margin-left: 16px; margin-left: 16px;
.ant-form-item {
margin-bottom: 0 !important;
}
} }
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-08-01 17:28:30 * @Date: 2021-08-01 17:28:30
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-08-02 14:26:43 * @LastEditTime: 2021-08-04 16:13:46
* @Description: 新建培训任务-关联课程抽屉 * @Description: 新建培训任务-关联课程抽屉
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
...@@ -99,7 +99,7 @@ class RelatedCourseDrawer extends Component { ...@@ -99,7 +99,7 @@ class RelatedCourseDrawer extends Component {
const _data = [...this.props.data]; const _data = [...this.props.data];
let currentLiveCourseListData = []; let currentLiveCourseListData = [];
_data.map((item) => { _data.map((item) => {
item.courseList.map((childItem, childIndex) => { item.contentList.map((childItem, childIndex) => {
if (childItem.courseType === 'LIVE') { if (childItem.courseType === 'LIVE') {
currentLiveCourseListData.push(childItem.courseId); currentLiveCourseListData.push(childItem.courseId);
} }
...@@ -130,7 +130,7 @@ class RelatedCourseDrawer extends Component { ...@@ -130,7 +130,7 @@ class RelatedCourseDrawer extends Component {
const _data = [...this.props.data]; const _data = [...this.props.data];
let currentVideoCourseListData = []; let currentVideoCourseListData = [];
_data.map((item, index) => { _data.map((item, index) => {
item.courseList.map((childItem, childIndex) => { item.contentList.map((childItem, childIndex) => {
if (childItem.courseType === 'VOICE') { if (childItem.courseType === 'VOICE') {
currentVideoCourseListData.push(childItem.courseId); currentVideoCourseListData.push(childItem.courseId);
} }
...@@ -168,7 +168,7 @@ class RelatedCourseDrawer extends Component { ...@@ -168,7 +168,7 @@ class RelatedCourseDrawer extends Component {
const _data = [...this.props.data]; const _data = [...this.props.data];
let currentPictureCourseListData = []; let currentPictureCourseListData = [];
_data.map((item, index) => { _data.map((item, index) => {
item.courseList.map((childItem, childIndex) => { item.contentList.map((childItem, childIndex) => {
if (childItem.courseType === 'PICTURE') { if (childItem.courseType === 'PICTURE') {
currentPictureCourseListData.push(childItem.courseId); currentPictureCourseListData.push(childItem.courseId);
} }
......
...@@ -2,17 +2,18 @@ ...@@ -2,17 +2,18 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-08-03 17:05:32 * @Date: 2021-08-03 17:05:32
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-08-03 20:02:27 * @LastEditTime: 2021-08-04 10:40:11
* @Description: 新建培训任务-关联考试抽屉 * @Description: 新建培训任务-关联考试抽屉
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
* @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @@Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
import React, { useState, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { Drawer, Form, Input, Button, Tooltip, Switch, Radio, InputNumber } from 'antd'; import { Drawer, Form, Input, Button, Tooltip, Switch, Radio, InputNumber, message } from 'antd';
import GraphicsEditor from '@/modules/course-manage/components/GraphicsEditor'; import GraphicsEditor from '@/modules/course-manage/components/GraphicsEditor';
import moment from 'moment'; import moment from 'moment';
import './RelatedExamDrawer.less'; import './RelatedExamDrawer.less';
import SelectPaperModal from '@/modules/teach-tool/examination-manager/SelectPaperModal'; import SelectPaperModal from '@/modules/teach-tool/examination-manager/SelectPaperModal';
import User from '@/common/js/user';
function RelatedExamDrawer(props) { function RelatedExamDrawer(props) {
const paperInfoInit = { passScore: 60 }; const paperInfoInit = { passScore: 60 };
...@@ -32,8 +33,6 @@ function RelatedExamDrawer(props) { ...@@ -32,8 +33,6 @@ function RelatedExamDrawer(props) {
const [passScore, setPassScore] = useState(100); const [passScore, setPassScore] = useState(100);
const [desclen, setDescLen] = useState(0); const [desclen, setDescLen] = useState(0);
const [check, setCheck] = useState(false); const [check, setCheck] = useState(false);
const [getData, setGetData] = useState(false);
const [preview, setPreview] = useState(false);
const [examTotal, setExamTotal] = useState(0); const [examTotal, setExamTotal] = useState(0);
const [examList, setExamList] = useState([]); const [examList, setExamList] = useState([]);
const request = useRef(false); const request = useRef(false);
...@@ -41,52 +40,22 @@ function RelatedExamDrawer(props) { ...@@ -41,52 +40,22 @@ function RelatedExamDrawer(props) {
const [examDuration, setExamDuration] = useState(undefined); const [examDuration, setExamDuration] = useState(undefined);
useEffect(() => {
setPaperId(paperInfo.paperId);
setPassRate(paperInfo.passRate);
setExamName(paperInfo.paperName);
}, [paperInfo.paperId]);
useEffect(() => {
setPassScore(Math.round(((paperInfo.totalScore || 0) * (passRate || 0)) / 100));
setExamTotal(paperInfo.singleChoiceCnt + paperInfo.multiChoiceCnt + paperInfo.judgeCnt + paperInfo.gapFillingCnt + paperInfo.indefiniteChoiceCnt || 0);
}, [paperInfo.paperId, passRate]);
function disabledDate(current) { function disabledDate(current) {
// Can not select days before today and today // Can not select days before today and today
return current && current < moment().startOf('day'); return current && current < moment().startOf('day');
} }
function queryExamList() {
let param = {
current: 1,
size: 9999,
order: 'EXAM_START_TIME_DESC',
userId: User.getStoreUserId(),
tenantId: User.getStoreId(),
source: 0,
};
Service.Hades('public/hades/queryExamPageList', param).then((res) => {
const { result = {} } = res;
setExamList(result.records || []);
});
}
function queryExamDetail() {
Service.Hades('public/hades/queryExamDetail', {
examId: match.params.id,
tenantId: User.getStoreId(),
userId: User.getStoreUserId(),
source: 0,
}).then((res) => {
const { result } = res;
setPaperInfo(result.examPaper);
setPaperId(result.examPaper.paperId);
setStartTime(props.type === 'edit' ? result.examStartTime : '');
setExamEndTime(props.type === 'edit' ? result.examEndTime : '');
setExamName(props.type === 'edit' ? result.examName : `${result.examName}(复制)`);
setPassRate(result.passRate * 100);
setNeedPhone(result.needPhone);
setExamDesc(result.examDesc);
setExamDuration(result.examDuration / 60 / 1000);
setAnswerAnalysis(result.answerAnalysis);
setNeedOptionDisorder(result.needOptionDisorder);
setPassScore(result.passScore);
setResultContent(result.resultContent);
setResultShow(result.resultShow);
setGetData(true);
});
}
function handleSave() { function handleSave() {
if (request.current) { if (request.current) {
return; return;
...@@ -222,19 +191,6 @@ function RelatedExamDrawer(props) { ...@@ -222,19 +191,6 @@ function RelatedExamDrawer(props) {
}; };
} }
function handleGoBack() {
Modal.confirm({
title: '确定要返回吗?',
content: '返回后,本次编辑的内容将不被保存',
okText: '确认返回',
cancelText: '留在本页',
icon: <span className='icon iconfont default-confirm-icon'>&#xe6f4;</span>,
onOk: () => {
window.RCHistory.push('/examination-manage-index');
},
});
}
// 校验考试名称是否存在 // 校验考试名称是否存在
function checkExist(examName) { function checkExist(examName) {
var result = null; var result = null;
...@@ -385,6 +341,16 @@ function RelatedExamDrawer(props) { ...@@ -385,6 +341,16 @@ function RelatedExamDrawer(props) {
</div> </div>
</div> </div>
</Form.Item> </Form.Item>
<Form.Item label='考试结果查看' required>
<Radio.Group
onChange={(e) => {
setResultShow(e.target.value);
}}
value={resultShow}>
<Radio value={'IMMEDIATELY'}>交卷后立即显示考试结果</Radio>
<Radio value={'AFTER_EXAM_END'}>到达考试截止日期才显示结果</Radio>
</Radio.Group>
</Form.Item>
<Form.Item label='考试结果内容' required> <Form.Item label='考试结果内容' required>
<Radio.Group <Radio.Group
...@@ -412,7 +378,7 @@ function RelatedExamDrawer(props) { ...@@ -412,7 +378,7 @@ function RelatedExamDrawer(props) {
</Form> </Form>
<div className='footer shrink-footer'> <div className='footer shrink-footer'>
<Button onClick={props.onClose}>取消</Button> <Button onClick={props.onClose}>取消</Button>
<Button type='primary' onClick={() => console.log('提交')}> <Button type='primary' onClick={handleSave}>
确定 确定
</Button> </Button>
</div> </div>
......
...@@ -68,6 +68,9 @@ ...@@ -68,6 +68,9 @@
.graphics-editor-container { .graphics-editor-container {
width: 550px; width: 550px;
height: 130px; height: 130px;
.editor-warning {
top: 130px !important;
}
} }
} }
} }
...@@ -53,8 +53,10 @@ ...@@ -53,8 +53,10 @@
color: #333333; color: #333333;
vertical-align: middle; vertical-align: middle;
margin-bottom: 20px; margin-bottom: 20px;
* { .ant-form-item {
vertical-align: middle; display: inline-block;
margin-bottom: 0 !important;
vertical-align: baseline;
} }
img { img {
width: 20px; width: 20px;
...@@ -185,6 +187,11 @@ ...@@ -185,6 +187,11 @@
padding: 16px; padding: 16px;
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;
&.disabled {
color: #ccc;
cursor: not-allowed;
pointer-events: none;
}
} }
.ant-collapse-content { .ant-collapse-content {
......
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