Commit 833adc93 by chenshu

feat:初始化

parent 8f54e0eb
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, message, Modal } from 'antd'; import { Form, Alert, Input, Button, InputNumber, DatePicker, Switch, Radio, message, Modal, Tooltip } 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'
...@@ -41,7 +41,7 @@ function AddExam(props: any) { ...@@ -41,7 +41,7 @@ function AddExam(props: any) {
const [examDuration, setExamDuration] = useState(undefined); const [examDuration, setExamDuration] = useState(undefined);
useEffect(() => { useEffect(() => {
if (props.type === 'edit') { if (props.type === 'edit' || props.type === 'copy') {
queryExamDetail() queryExamDetail()
} }
}, []) }, [])
...@@ -73,9 +73,9 @@ function AddExam(props: any) { ...@@ -73,9 +73,9 @@ function AddExam(props: any) {
const { result } = res const { result } = res
setPaperInfo(result.examPaper) setPaperInfo(result.examPaper)
setPaperId(result.examPaper.paperId) setPaperId(result.examPaper.paperId)
setStartTime(result.examStartTime) setStartTime(props.type === 'edit' ? result.examStartTime : '')
setExamEndTime(result.examEndTime) setExamEndTime(props.type === 'edit' ? result.examEndTime : '')
setExamName(result.examName) setExamName(props.type === 'edit' ? result.examName : `${result.examName}(复制)`)
setPassRate(result.passRate * 100) setPassRate(result.passRate * 100)
setNeedPhone(result.needPhone) setNeedPhone(result.needPhone)
setExamDesc(result.examDesc) setExamDesc(result.examDesc)
...@@ -225,9 +225,22 @@ function AddExam(props: any) { ...@@ -225,9 +225,22 @@ function AddExam(props: any) {
}) })
} }
let title = '';
switch (props.type) {
case 'add':
title = '新建考试';
break;
case 'edit':
title = '编辑考试';
break;
case 'copy':
title = '复制考试';
break;
default:
break;
}
return <div className="page examPage"> return <div className="page examPage">
<Breadcrumbs navList={props.type === 'edit' ? "编辑考试" : "新建考试"} goBack={handleGoBack} /> <Breadcrumbs navList={title} goBack={handleGoBack} />
<div className="box"> <div className="box">
<Alert message="请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企学院保有依据国家规定及平台规则进行处理的权利" type="info" showIcon /> <Alert message="请遵守国家相关规定,切勿上传低俗色情、暴力恐怖、谣言诈骗、侵权盗版等相关内容,小麦企学院保有依据国家规定及平台规则进行处理的权利" type="info" showIcon />
...@@ -293,11 +306,18 @@ function AddExam(props: any) { ...@@ -293,11 +306,18 @@ function AddExam(props: any) {
<Form.Item label="及格线" <Form.Item
label={<div>
<span>及格线</span>
<Tooltip title="默认为选中试卷所设置的及格线,可修改">
<span className="icon iconfont" style={{ color: '#BFBFBF', marginLeft: 4 }}>&#xe61d;</span>
</Tooltip>
</div>}
style={{ marginTop: 24 }} style={{ marginTop: 24 }}
validateStatus={(check && !passRate) ? 'error' : ''} validateStatus={(check && !passRate) ? 'error' : ''}
help={check && !passRate && '请输入及格线'} help={check && !passRate && '请输入及格线'}
required> required
>
<InputNumber value={passRate} min={0} max={100} onChange={(value: any) => { setPassRate(parseInt(value)) }} style={{ width: 100 }} /> <InputNumber value={passRate} min={0} max={100} onChange={(value: any) => { setPassRate(parseInt(value)) }} style={{ width: 100 }} />
<span style={{ marginLeft: 4 }}>% <span style={{ marginLeft: 4 }}>%
</span> </span>
...@@ -347,7 +367,7 @@ function AddExam(props: any) { ...@@ -347,7 +367,7 @@ function AddExam(props: any) {
help={check && (desclen > 1000) && '最多只能输入1000个字'} help={check && (desclen > 1000) && '最多只能输入1000个字'}
> >
{ {
(getData || (props.type !== 'edit')) && <GraphicsEditor (getData || (props.type === 'add')) && <GraphicsEditor
maxLimit={1000} maxLimit={1000}
isIntro={true} isIntro={true}
detail={{ detail={{
......
...@@ -10,6 +10,7 @@ import User from "@/common/js/user"; ...@@ -10,6 +10,7 @@ import User from "@/common/js/user";
import { XMContext } from "@/store/context"; import { XMContext } from "@/store/context";
import ExamShareModal from './ExamShareModal' import ExamShareModal from './ExamShareModal'
import DataAnalysic from './DataAnalysic' import DataAnalysic from './DataAnalysic'
import PreviewModal from './PreviewModal'
import './index.less' import './index.less'
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
const { Search } = Input; const { Search } = Input;
...@@ -53,6 +54,8 @@ function ExaminationManager(props: any) { ...@@ -53,6 +54,8 @@ function ExaminationManager(props: any) {
const [order, setOrder] = useState(sortStatus.type); const [order, setOrder] = useState(sortStatus.type);
const [modal, setModal] = useState(null); const [modal, setModal] = useState(null);
const [questionCntSort, setQuestionCntSort] = useState(sortState) const [questionCntSort, setQuestionCntSort] = useState(sortState)
const [openPreviewModal, setOpenPreviewModal] = useState(false);
const [info, setInfo] = useState({});
const queryRef = useRef({}); const queryRef = useRef({});
const orderEnum = { const orderEnum = {
...@@ -161,13 +164,11 @@ function ExaminationManager(props: any) { ...@@ -161,13 +164,11 @@ function ExaminationManager(props: any) {
onClick={() => { shareModal(record) }} onClick={() => { shareModal(record) }}
> >
分享 分享
</div> </div>
<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>]
}
...@@ -176,6 +177,18 @@ function ExaminationManager(props: any) { ...@@ -176,6 +177,18 @@ function ExaminationManager(props: any) {
]; ];
function queryExamDetail(examId: string) {
Service.Hades("public/hades/queryExamDetail", {
examId,
tenantId: User.getStoreId(),
userId: User.getStoreUserId(),
source: 0
}).then((res) => {
setInfo(res.result);
setOpenPreviewModal(true);
});
}
function shareModal(record: any) { function shareModal(record: any) {
const modal = <ExamShareModal const modal = <ExamShareModal
...@@ -189,8 +202,14 @@ function ExaminationManager(props: any) { ...@@ -189,8 +202,14 @@ function ExaminationManager(props: any) {
function getOpe(item: any) { function getOpe(item: any) {
return <Menu> return <Menu>
<Menu.Item
key="1"
onClick={() => {
queryExamDetail(item.examId);
}}
>预览</Menu.Item>
{ {
ctx.xmState?.userPermission?.AddExam() && (moment().valueOf() < item.examStartTime) && <Menu.Item key="0"> ctx.xmState?.userPermission?.AddExam() && (moment().valueOf() < item.examStartTime) && <Menu.Item key="2">
<span <span
onClick={() => { onClick={() => {
if (moment().valueOf() + 5 * 60 * 1000 > item.examStartTime) { if (moment().valueOf() + 5 * 60 * 1000 > item.examStartTime) {
...@@ -212,8 +231,11 @@ function ExaminationManager(props: any) { ...@@ -212,8 +231,11 @@ function ExaminationManager(props: any) {
</Menu.Item> </Menu.Item>
} }
{ctx.xmState?.userPermission?.AddExam() &&
<Menu.Item key="3" onClick={() => props.history.push(`${match.url}/copy/${item.examId}`)}>复制</Menu.Item>
}
{ {
ctx.xmState?.userPermission?.DelExam() && (moment().valueOf() + 30 * 60 * 1000 < item.examStartTime) && <Menu.Item key="1"> ctx.xmState?.userPermission?.DelExam() && (moment().valueOf() + 30 * 60 * 1000 < item.examStartTime) && <Menu.Item key="4">
<span <span
onClick={() => { onClick={() => {
deleteExam(item) deleteExam(item)
...@@ -408,8 +430,14 @@ function ExaminationManager(props: any) { ...@@ -408,8 +430,14 @@ function ExaminationManager(props: any) {
} }
</div> </div>
</div> </div>
{openPreviewModal &&
<PreviewModal
info={info}
onClose={() => { setOpenPreviewModal(false) }}
/>
}
<Route path={`${match.url}/add`} render={() => { <Route path={`${match.url}/add`} render={() => {
return <AddExam freshList={() => { return <AddExam type="add" freshList={() => {
let _query: any = { ...queryRef.current }; let _query: any = { ...queryRef.current };
if (_query.current != 1) { if (_query.current != 1) {
_query.current = 1; _query.current = 1;
...@@ -426,6 +454,11 @@ function ExaminationManager(props: any) { ...@@ -426,6 +454,11 @@ function ExaminationManager(props: any) {
getList() getList()
}} />; }} />;
}} /> }} />
<Route path={`${match.url}/copy/:id`} render={() => {
return <AddExam type='copy' freshList={() => {
getList()
}} />;
}} />
<Route path={`${match.url}/analysic/:id`} render={() => { <Route path={`${match.url}/analysic/:id`} render={() => {
return <DataAnalysic />; return <DataAnalysic />;
......
...@@ -21,6 +21,7 @@ import { ...@@ -21,6 +21,7 @@ import {
message, message,
Menu, Menu,
Dropdown, Dropdown,
DatePicker,
} from "antd"; } from "antd";
import _ from "underscore"; import _ from "underscore";
import { Route, withRouter } from "react-router-dom"; import { Route, withRouter } from "react-router-dom";
...@@ -32,11 +33,12 @@ import PreviewQuestionModal from "../modal/PreviewQuestionModal"; ...@@ -32,11 +33,12 @@ import PreviewQuestionModal from "../modal/PreviewQuestionModal";
import BatchImportQuestionModal from "../modal/BatchImportQuestionModal"; import BatchImportQuestionModal from "../modal/BatchImportQuestionModal";
import OperateQuestion from "../OperateQuestion"; import OperateQuestion from "../OperateQuestion";
import Bus from "@/core/bus"; import Bus from "@/core/bus";
import moment from 'moment';
import Service from "@/common/js/service"; import Service from "@/common/js/service";
import MoveModal from '../../modal/MoveModal'; import MoveModal from '../../modal/MoveModal';
import "./QuestionList.less"; import "./QuestionList.less";
import { data } from "jquery";
const { RangePicker } = DatePicker;
const { Search } = Input; const { Search } = Input;
const questionTypeEnum = { const questionTypeEnum = {
...@@ -250,6 +252,15 @@ class QuestionList extends Component { ...@@ -250,6 +252,15 @@ class QuestionList extends Component {
); );
const columns = [ const columns = [
{ {
title: "题型",
key: "questionTypeEnum",
dataIndex: "questionTypeEnum",
width: "16%",
render: (val) => {
return questionTypeEnum[val];
},
},
{
title: "题目", title: "题目",
key: "questionStem", key: "questionStem",
dataIndex: "questionStem", dataIndex: "questionStem",
...@@ -287,15 +298,6 @@ class QuestionList extends Component { ...@@ -287,15 +298,6 @@ class QuestionList extends Component {
}, },
}, },
{ {
title: "题型",
key: "questionTypeEnum",
dataIndex: "questionTypeEnum",
width: "16%",
render: (val) => {
return questionTypeEnum[val];
},
},
{
title: "正确率", title: "正确率",
key: "accuracy", key: "accuracy",
dataIndex: "accuracy", dataIndex: "accuracy",
...@@ -603,7 +605,7 @@ class QuestionList extends Component { ...@@ -603,7 +605,7 @@ class QuestionList extends Component {
<Search <Search
placeholder="搜索题目名称" placeholder="搜索题目名称"
value={questionName} value={questionName}
style={{ width: 178 }} style={{ width: '100%' }}
onChange={(e) => { onChange={(e) => {
this.handleChangeQuery("questionName", e.target.value); this.handleChangeQuery("questionName", e.target.value);
}} }}
...@@ -619,7 +621,7 @@ class QuestionList extends Component { ...@@ -619,7 +621,7 @@ class QuestionList extends Component {
<Select <Select
placeholder="请选择题目类型" placeholder="请选择题目类型"
value={questionType} value={questionType}
style={{ width: 178 }} style={{ width: '100%' }}
showSearch showSearch
allowClear allowClear
enterButton={<span className="icon iconfont">&#xe832;</span>} enterButton={<span className="icon iconfont">&#xe832;</span>}
...@@ -644,6 +646,25 @@ class QuestionList extends Component { ...@@ -644,6 +646,25 @@ class QuestionList extends Component {
})} })}
</Select> </Select>
</div> </div>
<div className="search-condition__item">
<span className="search-label">更新时间:</span>
<RangePicker
value={
query.updateDateStart
? [moment(query.updateDateStart), moment(query.updateDateEnd)]
: null
}
style={{ width: '100%' }}
format={"YYYY-MM-DD"}
onChange={(dates) => {
const _query = _.clone(query);
_query.updateDateStart = dates ? dates[0].startOf("day").valueOf() : null;
_query.updateDateEnd = dates ? dates[1].endOf("day").valueOf() : null;
_query.current = 0;
this.setState({ query: _query }, () => this.queryQuestionPageList());
}}
/>
</div>
</div> </div>
<div className="reset-fold-area"> <div className="reset-fold-area">
......
...@@ -8,13 +8,16 @@ ...@@ -8,13 +8,16 @@
flex-wrap: wrap; flex-wrap: wrap;
&__item { &__item {
display: flex;
margin-right: 3%; margin-right: 3%;
margin-bottom: 16px; margin-bottom: 16px;
width: 30%;
.search-label { .search-label {
vertical-align: middle; vertical-align: middle;
display: inline-block; display: inline-block;
height: 32px; height: 32px;
line-height: 32px; line-height: 32px;
flex-shrink: 0;
} }
} }
} }
......
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