|
|
|
@ -14,7 +14,51 @@ import ProCard from '@ant-design/pro-card';
|
|
|
|
|
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>();
|
|
|
|
|
|
|
|
|
@ -39,8 +83,20 @@ const CardList = () => {
|
|
|
|
|
const [questionNowNum, setQuestionNowNum] = useState(0)
|
|
|
|
|
const [questionNum, setQuestioNum] = useState(0)
|
|
|
|
|
|
|
|
|
|
const [timeData, setTimeData] = useState(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let secondValue = params.time; // 秒 截至时间 - 服务器当前时间
|
|
|
|
|
setTimeData(secondValue)
|
|
|
|
|
// console.log(secondValue);
|
|
|
|
|
|
|
|
|
|
const timer = setInterval(() => { //
|
|
|
|
|
setTimeData((secondValue >= 1) ? secondValue-- : 0);
|
|
|
|
|
}, 1000);
|
|
|
|
|
return () => {
|
|
|
|
|
clearInterval(timer) // 清理计算器
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const params = useParams();
|
|
|
|
@ -148,7 +204,10 @@ const CardList = () => {
|
|
|
|
|
},
|
|
|
|
|
onSuccess: (result, params) => {
|
|
|
|
|
if(result.success){
|
|
|
|
|
history.push(`/dashboard/qualification/result/${result.data.pass_score}/${result.data.score}/${result.data.sum_score}/${params.examination_id}/${params.examination_name}`);
|
|
|
|
|
const time=new Date(timeData).getTime();
|
|
|
|
|
const timeDiff=params.duration/1000-time;
|
|
|
|
|
// console.log('timeDiff',timeDiff)
|
|
|
|
|
history.push(`/dashboard/qualification/result/${result.data.pass_score}/${result.data.score}/${result.data.sum_score}/${params.examination_id}/${params.examination_name}/${timeDiff}`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -157,6 +216,7 @@ const CardList = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// 已选择题目回显
|
|
|
|
|
formRef?.current?.setFieldsValue({ note: questionNow.answerId });
|
|
|
|
@ -426,7 +486,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>
|
|
|
|
@ -501,9 +561,9 @@ const CardList = () => {
|
|
|
|
|
person_id: cookie.load('person_id'),
|
|
|
|
|
paper_id: rulesPaperInfo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// console.log(questionFinish, 'questionFinish', rulesPaperInfo)
|
|
|
|
|
runFinishExamination(questionFinish)
|
|
|
|
|
// console.log(paperInfo)
|
|
|
|
|
// console.log(questionTypeList)
|
|
|
|
|
// console.log(questionNow)
|
|
|
|
|
|
|
|
|
|