You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/public/react/src/modules/testpaper/component/Contentpart.js

457 lines
11 KiB

import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl,queryString} from 'educoder';
import axios from 'axios';
import {
notification,
Spin,
Table,
Pagination,
Tabs,
Input,
Popover
} from "antd";
import './../testioncss/testioncss.css';
import NoneDatas from '../component/NoneDatas';
import Contentquestionbank from "./Contentquestionbank";
import LoadingSpin from '../../../common/LoadingSpin';
import Listjihe from "./Listjihe";
import Certifiedprofessional from "../../modals/Certifiedprofessional";
const { TabPane } = Tabs;
const Search = Input.Search;
class Contentpart extends Component {
constructor(props) {
super(props);
this.state = {
page:1,
defaultActiveKeyss:"0",
mydisplay:false,
occupation:2,
isysladmins:false,
}
}
//初始化
componentDidMount(){
const query = this.props.location.search;
const parsed = queryString.parse(query);
console.log("Contentpart");
console.log(parsed);
if(JSON.stringify(parsed)==="{}"){
this.setState({
defaultActiveKeyss:"0",
})
}else {
if(parsed.defaultActiveKey==="0"){
this.setState({
defaultActiveKeyss:"0",
})
}else{
this.setState({
defaultActiveKeyss:"1",
})
}
}
let isysladmins=false;
if(this.props){
if(this.props.current_user){
if(this.props.current_user.admin){
isysladmins=true;
}
else if(this.props.current_user.business){
isysladmins=true;
}
}
}
this.setState({
isysladmins:isysladmins
})
}
//跳转人工组卷
Mantegeneration=()=>{
this.props.history.push('/question');
}
componentDidUpdate(prevProps) {
if(prevProps.current_user !== this.props.current_user) {
let isysladmins=false;
let is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false;
const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false;
let {defaultActiveKey} = this.props;
let defaultActiveKeys=defaultActiveKey;
try {
if(this.props){
if(this.props.current_user){
if(this.props.current_user.admin){
isysladmins=true;
}
else if(this.props.current_user.business){
isysladmins=true;
}
}
}
if(is_teacher===false){
if(this.props.current_user.user_identity !=="学生"){
//专业人士
is_teacher=true
}
}
}catch (e) {
}
if(isysladmins===true||(is_teacher===true&&professional_certification===true)){
defaultActiveKeys="0"
}else{
defaultActiveKeys="1"
}
try {
if(this.props.defaultActiveKeybool===false){
if (this.state.defaultActiveKeyss==="0"){
defaultActiveKeys="0"
} else {
defaultActiveKeys="1"
}
}
}catch (e) {
}
this.props.callback(defaultActiveKeys,false);
}
}
HideAddcoursestypess=(i)=>{
console.log("调用了");
this.setState({
mydisplay:true,
occupation:i,
})
}
mydisplayHidedel=()=>{
this.setState({
mydisplay:false,
})
}
xinzenw=(url)=>{
//只限制了教师
if(this.props.current_user.professional_certification===false&&this.state.isysladmins===false){
this.HideAddcoursestypess(2);
return
}
this.props.history.push(url);
}
HideAddcoursestypess=(i)=>{
console.log("调用了");
this.setState({
mydisplay:true,
occupation:i,
})
}
mydisplayHidedel=()=>{
this.setState({
mydisplay:false,
})
}
Testpapereditor=(e)=>{
if(this.props.current_user.professional_certification===false&&this.state.isysladmins===false){
this.HideAddcoursestypess(2);
return
}
this.props.Testpapereditor(e)
}
showmodels=(e)=>{
if(this.props.current_user.professional_certification===false&&this.state.isysladmins===false){
this.HideAddcoursestypess(2);
return
}
this.props.showmodels(e)
}
showmodelysl=(e)=>{
if(this.props.current_user.professional_certification===false&&this.state.isysladmins===false){
this.HideAddcoursestypess(2);
return
}
this.props.showmodelysl(e)
}
showmodelsInaudit=(e)=>{
if(this.props.current_user.professional_certification===false&&this.state.isysladmins===false){
this.HideAddcoursestypess(2);
return
}
this.props.showmodelsInaudit(e)
}
render() {
let {page,defaultActiveKeyss,mydisplay}=this.state;
let {defaultActiveKey,defaultActiveKeybool}=this.props;
let defaultActiveKeys=defaultActiveKey+'';
let isysladmins=false;
let is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false;
const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false;
try {
if(this.props){
if(this.props.current_user){
if(this.props.current_user.admin){
isysladmins=true;
}
else if(this.props.current_user.business){
isysladmins=true;
}
}
}
if(is_teacher===false){
if(this.props.current_user.user_identity !=="学生"){
//专业人士
is_teacher=true
}
}
}catch (e) {
}
const contents = (
<div className="questiontypes" style={{
width:'93px',
height:'160px',
}}>
<p className="questiontype " onClick={()=>this.props.setdifficulty(null)}>全部</p>
<p className="questiontypeheng"></p>
<p className="questiontype " onClick={()=>this.props.setdifficulty(1)}>简单</p>
<p className="questiontypeheng"></p>
<p className="questiontype " onClick={()=>this.props.setdifficulty(2)}>适中</p>
<p className="questiontypeheng"></p>
<p className="questiontype " onClick={()=>this.props.setdifficulty(3)}>困难</p>
<p className="questiontypeheng"></p>
</div>
);
if(defaultActiveKeybool===false){
if(defaultActiveKeyss==="0"){
defaultActiveKeys="0";
}else {
defaultActiveKeys="1";
}
}
return (
<div className=" clearfix mt25">
<div className="educontent mt10 pb20 w1200s">
{
mydisplay===true?
<Certifiedprofessional {...this.props} {...this.state} ModalCancelsy={this.mydisplayHidedel} />
:""
}
{
mydisplay===true?
<style>
{
`
body{
overflow:hidden!important;
}
`
}
</style>
:""
}
<div className="w1200ms contentparttit" style={{
position: "relative",
}}>
<style>
{
`
.contentparttit .ant-tabs-bar{
margin: 0px 0px 0px 0px !important;
}
.contentparttit .ant-tabs-nav .ant-tabs-tab{
margin: 10px 10px 10px 0 !important;
}
.contentparttit .ant-tabs-nav .ant-tabs-ink-bar{
width: 31px !important;
left: 14px;
}
.ant-tabs-nav{
z-index: 1000;
}
`
}
</style>
{
isysladmins===true||is_teacher===true?
<Tabs activeKey={defaultActiveKeys} onChange={(e)=>this.props.callback(e,true)}>
<TabPane tab="公共" key="1">
</TabPane>
<TabPane tab="我的" key="0">
</TabPane>
</Tabs>
:
<Tabs activeKey={"1"} onChange={(e)=>this.props.callback(e,true)}>
<TabPane tab="公共" key="1">
</TabPane>
</Tabs>
}
<div className=" mt19" style={{
position:"absolute",
top: "0px",
paddingLeft: "170px",
width: "100%",
}}>
<style>
{
`
.sortinxdirection .ant-input-group-addon{
width: 48px !important;
}
.sortinxdirection .ant-input-lg {
height: 41px;}
.sortinxdirection .ant-popover{
top: 348px !important;
}
`
}
</style>
<div className={isysladmins===true||is_teacher===true?"sortinxdirection":"xaxisreverseorder"}>
<Search
style={{ width: "347px",marginRight:"60px",}}
placeholder="请输入题目名称、内容"
enterButton
size="large"
onInput={(e)=>this.props.setdatafunsval(e)}
onSearch={ (value)=>this.props.setdatafuns(value)}
value={this.props.keyword}
/>
{
isysladmins===true||is_teacher===true?
<div className="xaxisreverseorder" style={{
width:"50%"
}}>
<a onClick={()=>this.xinzenw('/Integeneration')}>
<div className="newbutoonss">
<p className="newbutoontess" >智能组卷</p>
</div>
</a>
<a onClick={()=>this.xinzenw('/question')}>
<div className="newbutoons mr39">
<p className="newbutoontess" >人工组卷</p>
</div>
</a>
</div>
:""
}
</div>
</div>
</div>
{/*内容*/}
{
this.props.Contentdata.exams === undefined ||this.props.Contentdata.exams === null||this.props.Contentdata.exams.length===0 ?
<div className=" w100s mb10"></div>
:
<div className=" w100s mb10" style={
{
position:"relative",
}
}>
{
defaultActiveKey===1||defaultActiveKey==="1"?
<Contentquestionbank {...this.props} {...this.state} ></Contentquestionbank>
:""
}
{
defaultActiveKey===0||defaultActiveKey==="0"?
<Contentquestionbank {...this.props} {...this.state} ></Contentquestionbank>
:""
}
</div>
}
<div className="minheight">
{/*列表集合*/}
<div className=" w100s">
{
this.props.booljupyterurls===true?
<LoadingSpin></LoadingSpin>
:
this.props.Contentdata.exams === undefined ||this.props.Contentdata.exams === null||this.props.Contentdata.exams.length===0?
<NoneDatas></NoneDatas>
: this.props.Contentdata.exams.map((object, index) => {
return (
<Listjihe {...this.state} {...this.props} items={object} key={index}
Testpapereditor={(e)=>this.Testpapereditor(e)}
showmodels={(e)=>this.showmodels(e)}
showmodelysl={(e)=>this.showmodelysl(e)}
Isitapopup={this.props.Isitapopup}
showmodelsInaudit={(e)=>this.props.showmodelsInaudit(e)}
>
</Listjihe>
)
})}
</div>
</div>
</div>
</div>
)
}
}
export default Contentpart