Commit 8bde2114 by zhujian

'feat:试卷改造'

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