Commit 51719bb9 by zhujian

'fix;

parent 6a156684
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -32,11 +32,19 @@ function AddExam(props: any) { ...@@ -32,11 +32,19 @@ function AddExam(props: any) {
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 timer = useRef({});
const request = useRef(false);
const { match } = props;
const [examDuration, setExamDuration] = useState(undefined);
useEffect(() => {
if (props.type === 'edit') {
queryExamDetail()
}
}, [])
const [examDuration, setExamDuration] = useState(0);
useEffect(() => { useEffect(() => {
console.log(paperInfo)
setPaperId(paperInfo.paperId) setPaperId(paperInfo.paperId)
setPassRate(paperInfo.passScore) setPassRate(paperInfo.passScore)
...@@ -52,15 +60,44 @@ function AddExam(props: any) { ...@@ -52,15 +60,44 @@ function AddExam(props: any) {
return current && current < moment().startOf('day'); return current && current < moment().startOf('day');
} }
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(result.examStartTime)
setExamEndTime(result.examEndTime)
setExamName(result.examName)
setPassRate(result.passRate * 100)
setNeedPhone(result.needPhone)
setExamDesc(result.examDesc)
setExamDuration(result.examDuration)
setAnswerAnalysis(result.answerAnalysis)
setNeedOptionDisorder(result.needOptionDisorder)
setPassScore(result.passScore)
setResultContent(result.resultContent)
setResultShow(result.resultShow)
})
}
function handleSave() { function handleSave() {
if (request.current) {
return
}
setCheck(true); setCheck(true);
const param = { const param = {
paperId, paperId,
startTime: examStartTime, startTime: examStartTime,
endTime: examEndTime, endTime: examEndTime,
examName, examName,
passRate, passRate: passRate / 100,
examStartTime, examStartTime,
examEndTime, examEndTime,
examDesc, examDesc,
...@@ -72,7 +109,9 @@ function AddExam(props: any) { ...@@ -72,7 +109,9 @@ function AddExam(props: any) {
examDuration, examDuration,
passScore, passScore,
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
source: 0 userId: User.getStoreUserId(),
source: 0,
examId: ''
} }
if (!param.examName) { if (!param.examName) {
...@@ -106,13 +145,30 @@ function AddExam(props: any) { ...@@ -106,13 +145,30 @@ function AddExam(props: any) {
} }
if (examStartTime + (examDuration as any) * 60 * 1000 > examEndTime) {
message.warning('考试时长不得超过考试有效期时长');
return
}
if (desclen > 1000) { if (desclen > 1000) {
message.warning('内容过长,不能超过1000字'); message.warning('内容过长,不能超过1000字');
return return
} }
Service.Hades("public/hades/createExam", param).then((res) => {
message.success('创建成功'); request.current = true;
setTimeout(() => {
request.current = false
}, 2000)
if (props.type === 'edit') {
param.examId = match.params.id;
}
Service.Hades(props.type === 'edit' ? 'public/hades/editExam' : "public/hades/createExam", param).then((res) => {
message.success(props.type === 'edit' ? '编辑成功' : '创建成功');
props.freshList()
props.history.goBack(); props.history.goBack();
}) })
} }
...@@ -181,7 +237,6 @@ function AddExam(props: any) { ...@@ -181,7 +237,6 @@ function AddExam(props: any) {
required> required>
<Input placeholder='请输入试卷名称(40字以内)' maxLength={40} value={examName} onChange={(e) => { <Input placeholder='请输入试卷名称(40字以内)' maxLength={40} value={examName} onChange={(e) => {
console.log(e.target.value)
setExamName(e.target.value) setExamName(e.target.value)
}} style={{ width: 300 }} /> }} style={{ width: 300 }} />
</Form.Item> </Form.Item>
...@@ -273,9 +328,9 @@ function AddExam(props: any) { ...@@ -273,9 +328,9 @@ function AddExam(props: any) {
{` 时长不能超过1440分钟(24小时)`}</span> {` 时长不能超过1440分钟(24小时)`}</span>
</Form.Item> </Form.Item>
<Form.Item label="考试说明" required> <Form.Item label="考试说明" >
<GraphicsEditor <GraphicsEditor
maxLimit={1000}
isIntro={true} isIntro={true}
detail={{ detail={{
content: examDesc content: examDesc
...@@ -340,14 +395,13 @@ function AddExam(props: any) { ...@@ -340,14 +395,13 @@ function AddExam(props: any) {
</div> </div>
{ {
showModal && <SelectPaperModal onSelect={(info: any) => { showModal && <SelectPaperModal onSelect={(info: any) => {
console.log(info, 'jkhjkhjk')
setPaperInfo(info) setPaperInfo(info)
}} paperInfo={paperInfo} close={() => { setShowModal(false) }}></SelectPaperModal> }} paperInfo={paperInfo} close={() => { setShowModal(false) }}></SelectPaperModal>
} }
<div className="footer"> <div className="footer">
<Button onClick={handleGoBack}>取消</Button> <Button onClick={handleGoBack}>取消</Button>
<Button onClick={() => { }}>预览</Button> <Button onClick={() => { }}>预览</Button>
<Button type="primary" onClick={_.debounce(() => { handleSave() }, 3000, true)}>保存</Button> <Button type="primary" onClick={handleSave}>保存</Button>
</div> </div>
......
import React, { useState, useRef, useEffect, useContext } from 'react'
import { Route, withRouter } from 'react-router-dom';
import './dataAnalysic.less'
function DataAnalysic() {
return <div className="page dataAnalysic">
</div>
}
export default withRouter(DataAnalysic);
\ No newline at end of file
...@@ -14,26 +14,52 @@ const { RangePicker } = DatePicker; ...@@ -14,26 +14,52 @@ const { RangePicker } = DatePicker;
const { Search } = Input; const { Search } = Input;
const { Option } = Select; const { Option } = Select;
interface sortType {
type: "ascend" | "descend" | null | undefined
}
function ExaminationManager(props: any) { function ExaminationManager(props: any) {
const queryInit: any = { const queryInit: any = {
examName: '', examName: '',
current: 1, size: 10, order: 'PASS_CNT_DESC' current: 1, size: 10, order: 'EXAM_START_TIME_DESC'
}
const sortStatus: sortType = {
type: undefined
} }
const examStatus = {
EXAM_INIT: '未开始', EXAM_STARTED: '进行中', EXAM_FINISHED: '已结束'
const sortEnum = {
} }
const { match } = props; const { match } = props;
const sortState: any = false; const sortState: any = false;
const ctx: any = useContext(XMContext); const ctx: any = useContext(XMContext);
console.log(ctx)
const [query, setQuery] = useState(queryInit); const [query, setQuery] = useState(queryInit);
const [expandFilter, setExpandFilter] = useState(false); const [expandFilter, setExpandFilter] = useState(false);
const [total, setTotal] = useState(0); const [total, setTotal] = useState(0);
const [list, setList] = useState([]); const [list, setList] = useState([]);
const [field, setfield] = useState('');
const [order, setOrder] = useState(sortStatus.type);
const [questionCntSort, setQuestionCntSort] = useState(sortState) const [questionCntSort, setQuestionCntSort] = useState(sortState)
const queryRef = useRef({}); const queryRef = useRef({});
const orderEnum = {
userCnt: {
ascend: 'USER_CNT_ASC',
descend: 'USER_CNT_DESC'
},
passCnt: {
ascend: 'PASS_CNT_ASC',
descend: 'PASS_CNT_DESC'
},
examCreateTime: {
ascend: 'EXAM_START_TIME_ASC',
descend: 'EXAM_START_TIME_DESC'
}
}
const columns = [ const columns = [
{ {
...@@ -41,11 +67,22 @@ function ExaminationManager(props: any) { ...@@ -41,11 +67,22 @@ function ExaminationManager(props: any) {
// fixed:'left', // fixed:'left',
// width:350, // width:350,
dataIndex: "examName", dataIndex: "examName",
render: (text: any, record: any) => <div style={{ width: 330 }}> render: (text: any, record: any) => {
<div className='oneLineText' style={{ width: 330 }} >{text}</div> var _text = '未开始', _color = 'rgba(255, 183, 20, 1)';
<div>{moment(record.examStartTime).format("YYYY-MM-DD HH:mm")}~{moment(record.examEndTime).format("YYYY-MM-DD HH:mm")} <div className="status">{(examStatus as any)[record.examState]}</div></div> if (moment().valueOf() > record.examEndTime) {
<div>创建人:{record.examCreator}</div> _text = '已结束';
</div>, _color = 'rgba(153, 153, 153, 1)';
} else if (moment().valueOf() > record.examStartTime) {
_text = '进行中';
_color = 'rgba(59, 189, 170, 1)';
}
return <div style={{ width: 330 }}>
<div className='oneLineText' style={{ width: 330 }} >{text}</div>
<div>{moment(record.examStartTime).format("YYYY-MM-DD HH:mm")}~{moment(record.examEndTime).format("YYYY-MM-DD HH:mm")} <div className="status" style={{ border: `1px solid ${_color}`, color: _color }}>{_text}</div></div>
<div>创建人:{record.examCreator}</div>
</div>
},
}, },
{ {
title: "考试时长", title: "考试时长",
...@@ -66,19 +103,23 @@ function ExaminationManager(props: any) { ...@@ -66,19 +103,23 @@ function ExaminationManager(props: any) {
title: "参与人数", title: "参与人数",
dataIndex: "userCnt", dataIndex: "userCnt",
sorter: true, sorter: true,
// sortDirections: ['USER_CNT_DESC', 'USER_CNT_ASC'], sortOrder: field === "userCnt" ? order : sortStatus.type,
sortOrder: null,
}, },
{ {
title: "及格数", title: "及格数",
dataIndex: "userCnt", dataIndex: "passCnt",
sorter: true,
sortOrder: field === "passCnt" ? order : sortStatus.type,
}, },
{ {
title: "创建时间", title: "创建时间",
dataIndex: "examCreateTime", dataIndex: "examCreateTime",
sorter: true,
sortOrder: field === "examCreateTime" ? order : sortStatus.type,
render: (text: any, record: any) => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>, render: (text: any, record: any) => <span>{moment(text).format("YYYY-MM-DD HH:mm")}</span>,
}, },
{ {
title: "操作", title: "操作",
...@@ -124,14 +165,17 @@ function ExaminationManager(props: any) { ...@@ -124,14 +165,17 @@ function ExaminationManager(props: any) {
ctx.xmState?.userPermission?.AddExam() && (moment().valueOf() < item.examStartTime) && <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) { if (moment().valueOf() + 5 * 60 * 1000 > item.examStartTime) {
Modal.info({ Modal.info({
title: '无法编辑', title: '无法编辑',
content: '离考试开始时间小于5分钟,为保证答题数据的准确性,不能再进行编辑了', content: '离考试开始时间小于5分钟,为保证答题数据的准确性,不能再进行编辑了',
}) })
} else { } else {
props.history.push({
pathname: `${match.url}/edit/${item.examId}`
})
} }
}} }}
> >
...@@ -167,7 +211,7 @@ function ExaminationManager(props: any) { ...@@ -167,7 +211,7 @@ function ExaminationManager(props: any) {
icon: <span className="icon iconfont default-confirm-icon">&#xe6f4;</span>, icon: <span className="icon iconfont default-confirm-icon">&#xe6f4;</span>,
onOk: () => { onOk: () => {
Service.Hades("public/hades/deleteExam", { Service.Hades("public/hades/deleteExam", {
"examId": item.paperId, "examId": item.examId,
userId: User.getStoreUserId(), userId: User.getStoreUserId(),
tenantId: User.getStoreId(), tenantId: User.getStoreId(),
source: 0 source: 0
...@@ -196,7 +240,17 @@ function ExaminationManager(props: any) { ...@@ -196,7 +240,17 @@ function ExaminationManager(props: any) {
}, [query]) }, [query])
function onShowSizeChange(current: any, size: any) { function onShowSizeChange(current: any, size: any) {
setQuery({ current: 1, size, order: 'PASS_CNT_DESC' }) setQuery({ current: 1, size })
}
function onChange(pagination: any, filters: any, sorter: any, extra: any) {
setfield(sorter.field);
setOrder(sorter.order)
console.log(sorter.field, sorter.order, (orderEnum as any)[sorter.field])
let _query: any = { ...queryRef.current };
_query.order = (orderEnum as any)[sorter.field][sorter.order] || 'EXAM_START_TIME_DESC'
setQuery(_query)
} }
return <div className="page examination-manager"> return <div className="page examination-manager">
...@@ -266,7 +320,7 @@ function ExaminationManager(props: any) { ...@@ -266,7 +320,7 @@ function ExaminationManager(props: any) {
</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={() => {
setQuery({ current: 1, size: 10, order: 'PASS_CNT_DESC' }); setQuery({ current: 1, size: 10, order: 'EXAM_START_TIME_DESC' });
}}>&#xe61b; </span></Tooltip> }}>&#xe61b; </span></Tooltip>
<span style={{ cursor: 'pointer' }} className="fold-btn" onClick={() => { <span style={{ cursor: 'pointer' }} className="fold-btn" onClick={() => {
setExpandFilter(!expandFilter) setExpandFilter(!expandFilter)
...@@ -290,10 +344,11 @@ function ExaminationManager(props: any) { ...@@ -290,10 +344,11 @@ function ExaminationManager(props: any) {
size="small" size="small"
columns={columns} columns={columns}
dataSource={list} dataSource={list}
onChange={() => { }}
scroll={{ x: 1100 }} scroll={{ x: 1100 }}
onChange={onChange}
pagination={false} pagination={false}
style={{ margin: '16px 0' }}> style={{ margin: '0px 0 16px' }}
>
</Table> </Table>
{total > 0 && {total > 0 &&
<PageControl <PageControl
...@@ -312,7 +367,16 @@ function ExaminationManager(props: any) { ...@@ -312,7 +367,16 @@ function ExaminationManager(props: any) {
} }
</div> </div>
</div> </div>
<Route path={`${match.url}/add`} component={AddExam} /> <Route path={`${match.url}/add`} render={() => {
return <AddExam freshList={() => {
getList()
}} />;
}} />
<Route path={`${match.url}/edit/:id`} render={() => {
return <AddExam type='edit' freshList={() => {
getList()
}} />;
}} />
</div> </div>
} }
......
.dataAnalysic{
}
\ No newline at end of file
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