Commit 6a156684 by yuananting

Merge branch 'feature/yuananting/20210327/test-paper' of…

Merge branch 'feature/yuananting/20210327/test-paper' of https://xmgit.ixm5.cn/xiaomai-cloud-class/xiaomai-cloud-class-web into feature/yuananting/20210327/test-paper
parents cc685626 b8bb7783
import React, { useState, useRef, useEffect, useContext } from 'react' import React, { useState, useRef, useEffect, useContext } from 'react'
import Breadcrumbs from "@/components/Breadcrumbs"; import Breadcrumbs from "@/components/Breadcrumbs";
import { Form, Alert, Input, Button, InputNumber, DatePicker, Switch, Radio } from 'antd'; import { Form, Alert, Input, Button, InputNumber, DatePicker, Switch, Radio, message, Modal } from 'antd';
import { Route, withRouter } from 'react-router-dom'; import { Route, withRouter } from 'react-router-dom';
import User from "@/common/js/user"; import User from "@/common/js/user";
import moment from 'moment' import moment from 'moment'
...@@ -30,6 +30,9 @@ function AddExam(props: any) { ...@@ -30,6 +30,9 @@ function AddExam(props: any) {
const [resultShow, setResultShow] = useState('IMMEDIATELY'); const [resultShow, setResultShow] = useState('IMMEDIATELY');
const [examDesc, setExamDesc] = useState(''); const [examDesc, setExamDesc] = useState('');
const [passScore, setPassScore] = useState(100); const [passScore, setPassScore] = useState(100);
const [desclen, setDescLen] = useState(0);
const [check, setCheck] = useState(false);
const [examDuration, setExamDuration] = useState(0); const [examDuration, setExamDuration] = useState(0);
useEffect(() => { useEffect(() => {
...@@ -51,10 +54,11 @@ function AddExam(props: any) { ...@@ -51,10 +54,11 @@ function AddExam(props: any) {
function handleSave() { function handleSave() {
setCheck(true);
const param = { const param = {
paperId, paperId,
startTime:examStartTime, startTime: examStartTime,
endTime:examEndTime, endTime: examEndTime,
examName, examName,
passRate, passRate,
examStartTime, examStartTime,
...@@ -70,8 +74,46 @@ function AddExam(props: any) { ...@@ -70,8 +74,46 @@ function AddExam(props: any) {
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
source: 0 source: 0
} }
Service.Hades("public/hades/createExam", param).then((res) => {
if (!param.examName) {
message.warning('请输入考试名称');
return
}
if (!paperId) {
message.warning('请选择试卷');
return
}
if (!passRate) {
message.warning('请输入及格线');
return
}
if (!examStartTime || !examEndTime) {
message.warning('请选择考试起止时间');
return
}
if (Number(examStartTime) < moment().valueOf()) {
message.warning('开始时间不能早于现在');
return
}
if (!examDuration) {
message.warning('请输入考试时长');
return
}
if (desclen > 1000) {
message.warning('内容过长,不能超过1000字');
return
}
Service.Hades("public/hades/createExam", param).then((res) => {
message.success('创建成功');
props.history.goBack();
}) })
} }
...@@ -108,8 +150,21 @@ function AddExam(props: any) { ...@@ -108,8 +150,21 @@ function AddExam(props: any) {
}; };
} }
function handleGoBack() {
Modal.confirm({
title: '确定要返回吗?',
content: '返回后,本次编辑的内容将不被保存',
okText: '确认返回',
cancelText: '留在本页',
icon: <span className="icon iconfont default-confirm-icon">&#xe6f4;</span>,
onOk: () => {
props.history.goBack();
}
})
}
return <div className="page examPage"> return <div className="page examPage">
<Breadcrumbs navList={"新建考试"} goBack={() => props.history.goBack()} /> <Breadcrumbs navList={"新建考试"} goBack={handleGoBack} />
<div className="box"> <div className="box">
<Alert message="请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企培保有依据国家规定及平台规则进行处理的权利" type="info" showIcon /> <Alert message="请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企培保有依据国家规定及平台规则进行处理的权利" type="info" showIcon />
...@@ -120,15 +175,21 @@ function AddExam(props: any) { ...@@ -120,15 +175,21 @@ function AddExam(props: any) {
wrapperCol={{ span: 14 }} wrapperCol={{ span: 14 }}
layout="horizontal" layout="horizontal"
> >
<Form.Item label="考试名称" required> <Form.Item label="考试名称"
validateStatus={(check && !examName) ? 'error' : ''}
help={check && !examName && '请选择课程'}
required>
<Input placeholder='请输入试卷名称(40字以内)' value={examName} onChange={(e) => { <Input placeholder='请输入试卷名称(40字以内)' maxLength={40} value={examName} onChange={(e) => {
console.log(e.target.value) console.log(e.target.value)
setExamName(e.target.value) setExamName(e.target.value)
}} style={{ width: 300 }} /> }} style={{ width: 300 }} />
</Form.Item> </Form.Item>
<Form.Item label="选择试卷" required> <Form.Item label="选择试卷"
validateStatus={(check && !paperId) ? 'error' : ''}
help={check && !paperId && '请选择试卷'}
required>
<span style={{ marginRight: 12, lineHeight: '32px' }}>{paperInfo.paperName}</span> <Button onClick={() => { setShowModal(true) }} >{paperInfo.paperId ? '重新选择' : '选择试卷'}</Button> <span style={{ marginRight: 12, lineHeight: '32px' }}>{paperInfo.paperName}</span> <Button onClick={() => { setShowModal(true) }} >{paperInfo.paperId ? '重新选择' : '选择试卷'}</Button>
...@@ -164,7 +225,11 @@ function AddExam(props: any) { ...@@ -164,7 +225,11 @@ function AddExam(props: any) {
} }
<Form.Item label="及格线" style={{marginTop:24}} required> <Form.Item label="及格线"
style={{ marginTop: 24 }}
validateStatus={(check && !passRate) ? 'error' : ''}
help={check && !passRate && '请输入及格线'}
required>
<InputNumber value={passRate} onChange={(value: any) => { setPassRate(value) }} style={{ width: 100 }} /> <InputNumber value={passRate} onChange={(value: any) => { setPassRate(value) }} style={{ width: 100 }} />
<span style={{ marginLeft: 4 }}>% <span style={{ marginLeft: 4 }}>%
</span> </span>
...@@ -172,7 +237,10 @@ function AddExam(props: any) { ...@@ -172,7 +237,10 @@ function AddExam(props: any) {
{` 总分(${paperInfo.totalScore || 0})*及格线(${passRate || 0}%)=及格分数(${passScore})`}</span> {` 总分(${paperInfo.totalScore || 0})*及格线(${passRate || 0}%)=及格分数(${passScore})`}</span>
</Form.Item> </Form.Item>
<Form.Item label="考试有效期" required> <Form.Item label="考试有效期"
validateStatus={(check && !examStartTime) ? 'error' : ''}
help={check && !examStartTime && '请选择考试起止时间'}
required>
<RangePicker <RangePicker
ranges={{ ranges={{
'近七天': [moment(), moment().add(6, 'day').endOf('day')], '近七天': [moment(), moment().add(6, 'day').endOf('day')],
...@@ -188,13 +256,16 @@ function AddExam(props: any) { ...@@ -188,13 +256,16 @@ function AddExam(props: any) {
showTime showTime
format="YYYY/MM/DD HH:mm" format="YYYY/MM/DD HH:mm"
onChange={(date: any) => { onChange={(date: any) => {
setStartTime(date && date[0]?.startOf('day').valueOf()); setStartTime(date && date[0]?.valueOf());
setExamEndTime(date && date[1]?.endOf('day').valueOf()); setExamEndTime(date && date[1]?.valueOf());
}} }}
/> />
</Form.Item> </Form.Item>
<Form.Item label="考试时长" required> <Form.Item label="考试时长"
validateStatus={(check && !examDuration) ? 'error' : ''}
help={check && !examDuration && '请输入考试时长'}
required>
<InputNumber value={examDuration} max={1440} min={1} onChange={(value: any) => { setExamDuration(value) }} style={{ width: 100 }} /> <InputNumber value={examDuration} max={1440} min={1} onChange={(value: any) => { setExamDuration(value) }} style={{ width: 100 }} />
<span style={{ marginLeft: 4 }}>分钟 <span style={{ marginLeft: 4 }}>分钟
</span> </span>
...@@ -209,7 +280,7 @@ function AddExam(props: any) { ...@@ -209,7 +280,7 @@ function AddExam(props: any) {
detail={{ detail={{
content: examDesc content: examDesc
}} }}
onChange={(val: any) => { setExamDesc(val) }} onChange={(val: any, len: any) => { setExamDesc(val); setDescLen(len) }}
/> />
</Form.Item> </Form.Item>
<div className="title" style={{ marginTop: 40 }}>考试设置</div> <div className="title" style={{ marginTop: 40 }}>考试设置</div>
...@@ -274,10 +345,12 @@ function AddExam(props: any) { ...@@ -274,10 +345,12 @@ function AddExam(props: any) {
}} paperInfo={paperInfo} close={() => { setShowModal(false) }}></SelectPaperModal> }} paperInfo={paperInfo} close={() => { setShowModal(false) }}></SelectPaperModal>
} }
<div className="footer"> <div className="footer">
<Button onClick={() => { }}>取消</Button> <Button onClick={handleGoBack}>取消</Button>
<Button onClick={() => { }}>预览</Button> <Button onClick={() => { }}>预览</Button>
<Button type="primary" onClick={_.debounce(() => { handleSave() }, 3000, true)}>保存</Button> <Button type="primary" onClick={_.debounce(() => { handleSave() }, 3000, true)}>保存</Button>
</div> </div>
</div> </div>
} }
......
import React, { useState, useRef, useEffect, useContext } from 'react' import React, { useState, useRef, useEffect, useContext } from 'react'
import { Row, Input, Select, DatePicker, Tooltip, Button, Table, Dropdown, Menu } from 'antd'; import { Row, Input, Select, DatePicker, Tooltip, Button, Table, Dropdown, Menu, Modal } from 'antd';
import TeacherSelect from '@/modules/common/TeacherSelect'; import TeacherSelect from '@/modules/common/TeacherSelect';
import { Route, withRouter } from 'react-router-dom'; import { Route, withRouter } from 'react-router-dom';
import Service from "@/common/js/service"; import Service from "@/common/js/service";
...@@ -32,7 +32,7 @@ function ExaminationManager(props: any) { ...@@ -32,7 +32,7 @@ function ExaminationManager(props: any) {
const [total, setTotal] = useState(0); const [total, setTotal] = useState(0);
const [list, setList] = useState([]); const [list, setList] = useState([]);
const [questionCntSort, setQuestionCntSort] = useState(sortState) const [questionCntSort, setQuestionCntSort] = useState(sortState)
const queryRef = useRef(null); const queryRef = useRef({});
const columns = [ const columns = [
...@@ -105,7 +105,7 @@ function ExaminationManager(props: any) { ...@@ -105,7 +105,7 @@ function ExaminationManager(props: any) {
</div> </div>
{ {
(ctx.xmState?.userPermission?.AddExam() || ctx.xmState?.userPermission?.DelExam()) && [<span className="operate__item split" > | </span>, <Dropdown overlay={getOpe(record)}> ((ctx.xmState?.userPermission?.AddExam() && (moment().valueOf() < record.examStartTime)) || (ctx.xmState?.userPermission?.DelExam() && (moment().valueOf() + 30 * 60 * 1000 < record.examStartTime))) && [<span className="operate__item split" > | </span>, <Dropdown overlay={getOpe(record)}>
<span className='more'>更多</span> <span className='more'>更多</span>
</Dropdown>] </Dropdown>]
} }
...@@ -121,10 +121,18 @@ function ExaminationManager(props: any) { ...@@ -121,10 +121,18 @@ function ExaminationManager(props: any) {
function getOpe(item: any) { function getOpe(item: any) {
return <Menu> return <Menu>
{ {
ctx.xmState?.userPermission?.AddExam() && <Menu.Item key="0"> ctx.xmState?.userPermission?.AddExam() && (moment().valueOf() < item.examStartTime) && <Menu.Item key="0">
<span <span
onClick={() => { onClick={() => {
if (moment().valueOf() + 5 * 60 * 1000 < item.examStartTime) {
Modal.info({
title: '无法编辑',
content: '离考试开始时间小于5分钟,为保证答题数据的准确性,不能再进行编辑了',
})
} else {
}
}} }}
> >
编辑 编辑
...@@ -133,10 +141,10 @@ function ExaminationManager(props: any) { ...@@ -133,10 +141,10 @@ function ExaminationManager(props: any) {
} }
{ {
ctx.xmState?.userPermission?.DelExam() && <Menu.Item key="1"> ctx.xmState?.userPermission?.DelExam() && (moment().valueOf() + 30 * 60 * 1000 < item.examStartTime) && <Menu.Item key="1">
<span <span
onClick={() => { onClick={() => {
deleteExam(item)
}} }}
> >
删除 删除
...@@ -149,6 +157,28 @@ function ExaminationManager(props: any) { ...@@ -149,6 +157,28 @@ function ExaminationManager(props: any) {
} }
function deleteExam(item: any) {
Modal.confirm({
title: '删除考试',
content: '确定删除该考试吗?',
okText: '删除',
cancelText: '取消',
icon: <span className="icon iconfont default-confirm-icon">&#xe6f4;</span>,
onOk: () => {
Service.Hades("public/hades/deleteExam", {
"examId": item.paperId,
userId: User.getStoreUserId(),
tenantId: User.getStoreId(),
source: 0
}).then(() => {
getList()
})
}
})
}
function getList() { function getList() {
Service.Hades("public/hades/queryExamPageList", { Service.Hades("public/hades/queryExamPageList", {
...query, userId: User.getStoreUserId(), ...query, userId: User.getStoreUserId(),
...@@ -156,6 +186,7 @@ function ExaminationManager(props: any) { ...@@ -156,6 +186,7 @@ function ExaminationManager(props: any) {
source: 0 source: 0
}).then((res) => { }).then((res) => {
setList(res.result?.records || []) setList(res.result?.records || [])
setTotal(parseInt(res.result.total))
}) })
} }
...@@ -213,22 +244,25 @@ function ExaminationManager(props: any) { ...@@ -213,22 +244,25 @@ function ExaminationManager(props: any) {
}} /> }} />
</div> </div>
<div className="search-condition__item"> {
<span className="search-name">创建时间:</span> !!expandFilter && <div className="search-condition__item">
<RangePicker <span className="search-name">创建时间:</span>
className='search-input' <RangePicker
value={[ className='search-input'
query.createStartTime ? moment(Number(query.createStartTime)) : null, value={[
query.createStartTime ? moment(Number(query.createEndTime)) : null query.createStartTime ? moment(Number(query.createStartTime)) : null,
]} query.createStartTime ? moment(Number(query.createEndTime)) : null
onChange={(date: any) => { ]}
const _query = { ...query } onChange={(date: any) => {
_query.createStartTime = date && date[0]?.startOf('day').valueOf(); const _query = { ...query }
_query.createEndTime = date && date[1]?.endOf('day').valueOf(); _query.createStartTime = date && date[0]?.startOf('day').valueOf();
setQuery(_query); _query.createEndTime = date && date[1]?.endOf('day').valueOf();
setQuery(_query);
}} />
</div>
}
}} />
</div>
</div> </div>
<div className="reset-fold-area"> <div className="reset-fold-area">
<Tooltip title="清空筛选"><span className="resetBtn iconfont icon" onClick={() => { <Tooltip title="清空筛选"><span className="resetBtn iconfont icon" onClick={() => {
...@@ -241,10 +275,10 @@ function ExaminationManager(props: any) { ...@@ -241,10 +275,10 @@ function ExaminationManager(props: any) {
</div> </div>
</div> </div>
{ {
ctx.xmState?.userPermission?.AddExam() && <Button type='primary' onClick={()=>{ ctx.xmState?.userPermission?.AddExam() && <Button type='primary' onClick={() => {
props.history.push({ props.history.push({
pathname: `${match.url}/add` pathname: `${match.url}/add`
}) })
}} style={{ margin: '12px 0' }}>新建考试</Button> }} style={{ margin: '12px 0' }}>新建考试</Button>
} }
...@@ -269,8 +303,9 @@ function ExaminationManager(props: any) { ...@@ -269,8 +303,9 @@ function ExaminationManager(props: any) {
total={total} total={total}
onShowSizeChange={onShowSizeChange} onShowSizeChange={onShowSizeChange}
toPage={(page: any) => { toPage={(page: any) => {
let _query: any = { ...query.current }; console.log(page)
_query.current = page; let _query: any = { ...queryRef.current };
_query.current = page + 1;
setQuery(_query) setQuery(_query)
}} }}
/> />
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yuananting * @Author: yuananting
* @Date: 2021-02-25 11:23:47 * @Date: 2021-02-25 11:23:47
* @LastEditors: yuananting * @LastEditors: yuananting
* @LastEditTime: 2021-04-07 15:30:00 * @LastEditTime: 2021-04-07 15:33:33
* @Description: 助学工具-题库-试卷列表数据 * @Description: 助学工具-题库-试卷列表数据
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/ */
...@@ -22,12 +22,12 @@ import { ...@@ -22,12 +22,12 @@ import {
} from "antd"; } from "antd";
import { PageControl } from "@/components"; import { PageControl } from "@/components";
import "./PaperList.less"; import "./PaperList.less";
import { Route, withRouter } from 'react-router-dom';
import OperatePaper from "@/modules/teach-tool/paper-manage/OperatePaper";
import User from "@/common/js/user"; import User from "@/common/js/user";
import AidToolService from "@/domains/aid-tool-domain/AidToolService"; import AidToolService from "@/domains/aid-tool-domain/AidToolService";
import _ from "underscore"; import _ from "underscore";
import PaperPreviewModal from "../modal/PreviewPaperModal"; import PaperPreviewModal from "../modal/PreviewPaperModal";
import { Route, withRouter } from 'react-router-dom';
import OperatePaper from "../OperatePaper";
import Bus from "@/core/bus"; import Bus from "@/core/bus";
const { Search } = Input; const { Search } = Input;
...@@ -112,6 +112,8 @@ class PaperList extends Component { ...@@ -112,6 +112,8 @@ class PaperList extends Component {
// 编辑试卷 // 编辑试卷
editPaper = (record) => { editPaper = (record) => {
const { match } = this.props;
if (record.relatedExam === 0) { if (record.relatedExam === 0) {
const { categoryId } = this.state.query; const { categoryId } = this.state.query;
const { match } = this.props; const { match } = this.props;
...@@ -256,7 +258,7 @@ class PaperList extends Component { ...@@ -256,7 +258,7 @@ class PaperList extends Component {
> >
预览 预览
</div> </div>
{isPermiss && <span className="record-operate__item split"> | </span> } {isPermiss && <span className="record-operate__item split"> | </span>}
{isPermiss && <div {isPermiss && <div
className="record-operate__item" className="record-operate__item"
onClick={() => this.copyPaper(record)} onClick={() => this.copyPaper(record)}
......
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