Commit 8bde2114 by zhujian

'feat:试卷改造'

parent a24eaa07
......@@ -219,7 +219,7 @@ class CourseCategorySiderTree extends Component {
enterButton={<span className="icon iconfont">&#xe832;</span>}
/>
{["QUESTION_INDEX", "PAPER_INDEX"].includes(this.props.fromModule) &&
User.getUserRole() !== "CloudLecturer" && (
User.getUserRole() !== "CloudLecturer" && (this.props.type !== 'modal-select') && (
<div className="sider-btn">
<Button
onClick={() => {
......
......@@ -26,7 +26,7 @@ function AddExam(props: any) {
</Form.Item>
<Form.Item label="选择试卷" name="size" required>
<Button onClick={()=>{setShowModal(true)}} >选择试卷</Button>
<Button onClick={() => { setShowModal(true) }} >选择试卷</Button>
</Form.Item>
......@@ -36,7 +36,7 @@ function AddExam(props: any) {
</div>
{
showModal && <SelectPaperModal></SelectPaperModal>
showModal && <SelectPaperModal close={() => { setShowModal(false) }}></SelectPaperModal>
}
</div>
......
import React, { useState, useRef, useEffect, useContext } from 'react'
import { Modal } from 'antd';
import { withRouter } from 'react-router-dom';
import ExaminationPaperIndex from '../examination-paper/ExaminationPaperIndex'
import ExaminationPaperContent from '../examination-paper/ExaminationPaperContent'
import './AddExam.less';
function SelectPaperModal(props: any) {
const [item, setItem] = useState({paperId:''});
useEffect(() => {
console.log(item)
}, [item])
return <Modal
width={800}
width={900}
title="选择试卷"
visible={true}
onOk={() => { }
}
onCancel={() => { }}
onCancel={() => { props.close() }}
>
<ExaminationPaperIndex></ExaminationPaperIndex>
<ExaminationPaperContent paperId={item.paperId} onSelect={(item: any) => { setItem(item) }} type='modal-select'></ExaminationPaperContent>
</Modal >
}
......
/*
* @Author: yuananting
* @Date: 2021-03-27 14:55:14
* @LastEditors: yuananting
* @LastEditTime: 2021-04-01 14:00:47
* @Description: 助学工具-试卷主页面
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
import React, { Component } from "react";
import "./ExaminationPaperIndex.less";
import CourseCategorySiderTree from "../components/CourseCategorySiderTree";
import ExaminationPaperContent from "./components/ExaminationPaperContent";
class ExaminationPaperIndex extends Component {
constructor(props) {
super(props);
this.state = {};
}
getCategoryIdFromSider = (selectedCategoryId) => {
if (selectedCategoryId && selectedCategoryId.length > 0) {
this.setState({ selectedCategoryId: selectedCategoryId[0] });
}
};
updatedSiderTreeFromList = (currentTotal, updatedCategoryId) => {
this.setState({ currentTotal, updatedCategoryId });
};
render() {
return (
<div className='examination-paper-content'>
<div
style={{ borderRight: "0.5px solid #EEEEEE", paddingRight: "4px" }}
>
<div className="sider">
<CourseCategorySiderTree
type={this.props.type}
fromModule="PAPER_INDEX"
getSelectedCategoryId={this.getCategoryIdFromSider.bind(this)}
currentTotal={this.state.currentTotal}
updatedCategoryId={this.state.updatedCategoryId}
/>
</div>
</div>
<div className="content">
<ExaminationPaperContent
paperId={this.props.paperId}
onSelect={this.props.onSelect}
type={this.props.type}
updatedSiderTree={this.updatedSiderTreeFromList.bind(this)}
selectedCategoryId={this.state.selectedCategoryId}
/>
</div>
</div>
);
}
}
export default ExaminationPaperIndex;
......@@ -8,8 +8,7 @@
*/
import React, { Component } from "react";
import "./ExaminationPaperIndex.less";
import CourseCategorySiderTree from "../components/CourseCategorySiderTree";
import ExaminationPaperContent from "./components/ExaminationPaperContent";
import ExaminationPaperContent from "./ExaminationPaperContent";
class ExaminationPaperIndex extends Component {
constructor(props) {
......@@ -17,39 +16,13 @@ class ExaminationPaperIndex extends Component {
this.state = {};
}
getCategoryIdFromSider = (selectedCategoryId) => {
if (selectedCategoryId && selectedCategoryId.length > 0) {
this.setState({ selectedCategoryId: selectedCategoryId[0] });
}
};
updatedSiderTreeFromList = (currentTotal, updatedCategoryId) => {
this.setState({ currentTotal, updatedCategoryId });
};
render() {
return (
<div className="examination-paper-index page">
<div className="content-header">试卷</div>
<div className="box content-body">
<div
style={{ borderRight: "0.5px solid #EEEEEE", paddingRight: "4px" }}
>
<div className="sider">
<CourseCategorySiderTree
fromModule="PAPER_INDEX"
getSelectedCategoryId={this.getCategoryIdFromSider.bind(this)}
currentTotal={this.state.currentTotal}
updatedCategoryId={this.state.updatedCategoryId}
/>
</div>
</div>
<div className="content">
<ExaminationPaperContent
updatedSiderTree={this.updatedSiderTreeFromList.bind(this)}
selectedCategoryId={this.state.selectedCategoryId}
/>
</div>
<ExaminationPaperContent type=''></ExaminationPaperContent>
</div>
</div>
);
......
.examination-paper-index {
.content-body {
display: flex;
.site-layout-background {
background: #fff;
}
.sider {
min-width: 244px;
}
.content {
width: 100%;
margin-left: 24px;
height: calc(100vh - 160px);
}
.examination-paper-content{
display: flex;
.site-layout-background {
background: #fff;
}
.sider {
min-width: 244px;
}
.content {
width: 100%;
margin-left: 24px;
height: calc(100vh - 160px);
}
}
......@@ -40,6 +40,7 @@ class ExaminationPaperContent extends Component {
tenantId: User.getStoreId(),
userId: User.getStoreUserId(),
},
selectedRowKeys: [this.props.paperId],
dataSource: [],
paperPreviewModal: null, // 试卷预览模态框
};
......@@ -86,7 +87,7 @@ class ExaminationPaperContent extends Component {
};
// 复制试卷
copyPaper = (record) => {};
copyPaper = (record) => { };
// 编辑试卷
editPaper = (record) => {
......@@ -139,9 +140,9 @@ class ExaminationPaperContent extends Component {
title: "试卷",
key: "paperName",
dataIndex: "paperName",
ellipsis: {
showTitle: false,
},
// ellipsis: {
// showTitle: false,
// },
render: (val, record) => {
var handleVal = val;
handleVal = handleVal.replace(/<(?!img|input).*?>/g, "");
......@@ -165,7 +166,7 @@ class ExaminationPaperContent extends Component {
title: "及格分/总分",
key: "score",
dataIndex: "score",
width: "16%",
render: (val, record) => {
return (
<span>
......@@ -178,15 +179,18 @@ class ExaminationPaperContent extends Component {
title: "题目数量",
key: "questionCnt",
dataIndex: "questionCnt",
width: "14%",
},
{
title: "关联考试数",
key: "relatedExam",
dataIndex: "relatedExam",
width: "14%",
},
{
];
if ((this.props.type !== 'modal-select')) {
columns.push({
title: "操作",
key: "operate",
dataIndex: "operate",
......@@ -216,8 +220,8 @@ class ExaminationPaperContent extends Component {
</div>
);
},
},
];
})
}
return columns;
};
......@@ -245,11 +249,26 @@ class ExaminationPaperContent extends Component {
this.setState({ query: _query }, () => this.queryPaperPageList());
};
onSelectChange = (selectedRowKeys, selectedRows) => {
console.log(selectedRowKeys, selectedRows)
this.setState({
selectedRowKeys
})
this.props.onSelect(selectedRows)
}
render() {
const { dataSource = [], total, query, paperPreviewModal } = this.state;
const { dataSource = [], total, query, paperPreviewModal, selectedRowKeys } = this.state;
const { current, size, categoryId, paperName } = query;
const rowSelection = {
type: 'radio',
selectedRowKeys,
onChange: this.onSelectChange,
};
return (
<div className="question-manage-content">
<div className={"question-manage-content " + this.props.type}>
<div className="question-manage-filter">
<Row type="flex" justify="space-between" align="top">
<div className="search-condition">
......@@ -258,7 +277,7 @@ class ExaminationPaperContent extends Component {
<Search
placeholder="搜索试卷名称"
value={paperName}
style={{ width: "calc(100% - 100px)" }}
style={{ width: 200 }}
onChange={(e) => {
this.setState({
query: {
......@@ -277,25 +296,42 @@ class ExaminationPaperContent extends Component {
</div>
</Row>
</div>
<Button
type="primary"
onClick={() => {
window.RCHistory.push({
pathname: `/new-examination-paper?categoryId=${categoryId}`,
});
}}
>
新建试卷
</Button>
{
(this.props.type !== 'modal-select') && <Button
type="primary"
onClick={() => {
window.RCHistory.push({
pathname: `/new-examination-paper?categoryId=${categoryId}`,
});
}}
>
新建试卷
</Button>
}
<div className="question-manage-list">
<Table
{(this.props.type !== 'modal-select') ? < Table
rowKey={(record) => record.id}
dataSource={dataSource}
columns={this.parseColumns()}
pagination={false}
bordered
onChange={this.handleChangeTable}
/>
/> :
<Table
rowKey={(record) => record.id}
dataSource={dataSource}
rowKey={(item) => {
return item.paperId
}}
rowSelection={rowSelection}
columns={this.parseColumns()}
pagination={false}
bordered
onChange={this.handleChangeTable}
/>
}
{total > 0 && (
<div className="box-footer">
<PageControl
......
......@@ -7,8 +7,10 @@
* @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
*/
.question-manage-content {
.question-manage-filter {
position: relative;
.search-condition {
width: calc(100% - 80px);
display: flex;
......@@ -75,6 +77,18 @@
}
}
}
&.modal-select{
.search-condition {
width: calc(100% - 80px);
display: flex;
align-items: center;
flex-wrap: wrap;
&__item {
width: auto;
}
}
}
}
.tool-list {
.ant-tooltip-inner {
......
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