|
|
|
@ -5,7 +5,7 @@ import { PageContainer } from '@ant-design/pro-layout';
|
|
|
|
|
import { useParams, useRequest } from 'umi';
|
|
|
|
|
import { useEffect, useRef, useState } from 'react';
|
|
|
|
|
const { Text, Link } = Typography;
|
|
|
|
|
import { getRulesPaper, getPaperQuestionList, finishExamination } from '../service';
|
|
|
|
|
import { getRulesPaper, getPaperQuestionList, finishExamination, getCurrentDate } from '../service';
|
|
|
|
|
import type { CardListItemDataType } from '../data';
|
|
|
|
|
import styles from './style.less';
|
|
|
|
|
import cookie from 'react-cookies';
|
|
|
|
@ -15,8 +15,59 @@ const CheckboxGroup = Checkbox.Group;
|
|
|
|
|
|
|
|
|
|
const { Paragraph } = Typography;
|
|
|
|
|
|
|
|
|
|
// 秒数转化为时分秒
|
|
|
|
|
const formatSeconds = (value) => {
|
|
|
|
|
// 秒
|
|
|
|
|
let second = parseInt(value)
|
|
|
|
|
// 分
|
|
|
|
|
let minute = 0
|
|
|
|
|
// 小时
|
|
|
|
|
let hour = 0
|
|
|
|
|
// 天
|
|
|
|
|
// let day = 0
|
|
|
|
|
// 如果秒数大于60,将秒数转换成整数
|
|
|
|
|
if (second > 60) {
|
|
|
|
|
// 获取分钟,除以60取整数,得到整数分钟
|
|
|
|
|
minute = parseInt(second / 60)
|
|
|
|
|
// 获取秒数,秒数取佘,得到整数秒数
|
|
|
|
|
second = parseInt(second % 60)
|
|
|
|
|
// 如果分钟大于60,将分钟转换成小时
|
|
|
|
|
if (minute > 60) {
|
|
|
|
|
// 获取小时,获取分钟除以60,得到整数小时
|
|
|
|
|
hour = parseInt(minute / 60)
|
|
|
|
|
// 获取小时后取佘的分,获取分钟除以60取佘的分
|
|
|
|
|
minute = parseInt(minute % 60)
|
|
|
|
|
// 如果小时大于24,将小时转换成天
|
|
|
|
|
// if (hour > 23) {
|
|
|
|
|
// // 获取天数,获取小时除以24,得到整天数
|
|
|
|
|
// day = parseInt(hour / 24)
|
|
|
|
|
// // 获取天数后取余的小时,获取小时除以24取余的小时
|
|
|
|
|
// hour = parseInt(hour % 24)
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let result = '' + parseInt(second) + ' 秒 '
|
|
|
|
|
if (minute > 0) {
|
|
|
|
|
result = '' + parseInt(minute) + ' 分 ' + result
|
|
|
|
|
}
|
|
|
|
|
if (hour > 0) {
|
|
|
|
|
result = '' + parseInt(hour) + ' 小时 ' + result
|
|
|
|
|
}
|
|
|
|
|
// if (day > 0) {
|
|
|
|
|
// result = '' + parseInt(day) + '天' + result
|
|
|
|
|
// }
|
|
|
|
|
console.log('result:', result)
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CardList = () => {
|
|
|
|
|
const formRef = useRef<ActionType>();
|
|
|
|
|
const params = useParams();
|
|
|
|
|
|
|
|
|
|
// 组卷详情查询
|
|
|
|
|
const [rulesPaperInfo, setRulesPaperInfo] = useState([]);
|
|
|
|
@ -37,11 +88,31 @@ const CardList = () => {
|
|
|
|
|
const [questionNowNum, setQuestionNowNum] = useState(0)
|
|
|
|
|
const [questionNum, setQuestioNum] = useState(0)
|
|
|
|
|
|
|
|
|
|
const [timeData, setTimeData] = useState(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let secondValue = params.rules_time * 60; // 秒 截至时间 - 服务器当前时间
|
|
|
|
|
setTimeData(secondValue)
|
|
|
|
|
console.log(secondValue);
|
|
|
|
|
|
|
|
|
|
const timer = setInterval(() => { //
|
|
|
|
|
setTimeData((secondValue >= 1) ? secondValue-- : 0);
|
|
|
|
|
}, 1000);
|
|
|
|
|
return () => {
|
|
|
|
|
clearInterval(timer) // 清理计算器
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params = useParams();
|
|
|
|
|
const { loading, data } = useRequest(() => {
|
|
|
|
|
return getRulesPaper({
|
|
|
|
|
rules_id: params.rules_id
|
|
|
|
@ -122,7 +193,12 @@ const CardList = () => {
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (result, params) => {
|
|
|
|
|
console.log(result, 'questionFinish server', params)
|
|
|
|
|
|
|
|
|
|
if (result.success) {
|
|
|
|
|
console.log(result, 'questionFinish server', params)
|
|
|
|
|
history.push(`/mockExamination/index/paper/${record.id}/${record.examination_time}`);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -273,7 +349,7 @@ const CardList = () => {
|
|
|
|
|
<Form
|
|
|
|
|
ref={formRef} name="control-ref"
|
|
|
|
|
>
|
|
|
|
|
<Form.Item name="note" label="Note" rules={[{ required: true }]}>
|
|
|
|
|
<Form.Item name="note" rules={[{ required: true }]}>
|
|
|
|
|
|
|
|
|
|
{questionNow.question_type === 0 ?
|
|
|
|
|
|
|
|
|
@ -400,7 +476,7 @@ const CardList = () => {
|
|
|
|
|
<div style={{ background: '#ffffff', padding: 24 }}>
|
|
|
|
|
<Space direction="vertical" style={{ width: '100%' }}>
|
|
|
|
|
<strong>剩余时间</strong>
|
|
|
|
|
<Typography>6分14秒</Typography>
|
|
|
|
|
<Typography>{formatSeconds(timeData)}</Typography>
|
|
|
|
|
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
|
|
|
|
|
<strong>答题序号</strong>
|
|
|
|
|
<Typography>{questionNowNum}/{questionNum}</Typography>
|
|
|
|
|