From d316a52a0f195ee0589fe8a2a73cf72417ab11c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 4 Sep 2019 15:09:04 +0800 Subject: [PATCH] bd --- .../questionbank/Generaljobbankdetails.js | 229 +++++------------- .../src/modules/user/usersInfo/InfosTopics.js | 4 +- .../modules/user/usersInfo/banks/banksMenu.js | 28 ++- 3 files changed, 93 insertions(+), 168 deletions(-) diff --git a/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js b/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js index 0817f5122..ee5956d7d 100644 --- a/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js +++ b/public/react/src/modules/courses/questionbank/Generaljobbankdetails.js @@ -1,23 +1,27 @@ import React, {Component} from "react"; -import {Link, NavLink} from 'react-router-dom'; +import {BrowserRouter as Router,Route,Switch,Link, NavLin} from 'react-router-dom'; import {WordsBtn, ActionBtn,getImageUrl} from 'educoder'; import { Input,Checkbox,Table, Pagination, Modal,Menu, Tooltip,Spin,Button,Form } from "antd"; import axios from 'axios'; -import { - notification -} from "antd"; -import CoursesListType from '../coursesPublic/CoursesListType'; -import Generaljobdetails from './Generaljobdetails'; -import Generaljobanswer from './Generaljobanswer'; -import SendTopics from '../../modals/SendTopics'; -import Modals from '../../modals/Modals'; +import BanksMenu from '../../user/usersInfo/banks/banksMenu' +import Loadable from 'react-loadable'; +import Loading from '../../../Loading'; import '../css/members.css'; import "../common/formCommon.css"; import '../css/Courses.css'; import '../css/busyWork.css'; import '../poll/pollStyle.css'; - +// 问卷内容 +const Generaljobdetails = Loadable({ + loader: () => import('./Generaljobdetails'), + loading: Loading, +}) +// 试卷详情 +const Generaljobanswer = Loadable({ + loader: () => import('./Generaljobanswer'), + loading: Loading, +}); class Generaljobbankdetails extends Component { //普通作业内容详情 constructor(props) { @@ -28,42 +32,12 @@ class Generaljobbankdetails extends Component { workid:1, isSpin:false, datas:[], - visible:false - } - - } - - //切换tab - ChangeTab = (e) => { - // console.log(e); - this.setState({ - tab: e - }) - try { - var currenturl = window.location.href; - var newUrl = (currenturl.split("?"))[0]; - window.history.pushState('','',newUrl+'?tab='+e); - }catch (e) { - console.log(e); - console.log("44"); + visible:false, + banksMenu:undefined } - this.getonedata(); } - componentDidMount() { - // console.log("父组件加载框"); - const query = this.props.location.search; - const type = query.split('?tab='); - // let sum = [] - // sum.push(type[1]) - // console.log("componentDidMountcomponentDidMount"); - // console.log(type); - this.setState({ - tab: type[1], - }); - console.log("Generaljobbankdetails"); - console.log(this.props); this.getonedata(); } @@ -102,7 +76,20 @@ class Generaljobbankdetails extends Component { crumbArray:[ {content:'详情'} ] + }; + const menuData={ + tab:'0',//tab选中的index + menuArray:[//tab以及tab路由 + {to:`/banks/normal/${workids}/${this.props.match.params.type}/details`,content:'内容详情'}, + {to:`/banks/normal/${workids}/${this.props.match.params.type}/answer`,content:'参考答案'} + ], + category:'normal',//毕设选题 + tos:`/banks/normal/${workids}/edit/${this.props.match.params.type}`, + id:workids, } + this.setState({ + banksMenu:menuData + }) this.props.initPublic(crumbData); }catch (e) { @@ -130,132 +117,50 @@ class Generaljobbankdetails extends Component { isSpin:false, }) }); - } - -//发送至相关 - sendTopics=()=>{ - this.setState({ - visible:true - }) - } - - topicscancelmodel=()=>{ - this.setState({ - Modalstype:false, - Loadtype:false, - visible:false, - Modalstopval:"", - ModalCancel:"", - ModalSave:"", - checkBoxValues:[], - checkedtype:false - }) - } - - //删除相关 - - deletecheckBoxValues=()=>{ - - this.setState({ - Modalstype:true, - Modalstopval:"是否确认删除?", - ModalCancel:this.topicscancelmodel, - ModalSave:this.topicssavedelete, - }) - - } - - topicssavedelete=()=>{ - - const url = `/question_banks/multi_delete.json`; - axios.delete(url, { data: { - object_id: [this.props.match.params.workid], - object_type:"normal" - }}) - .then((response) => { - if(response.data.status===0){ - this.props.showNotification(response.data.message) - window.location.href=`/users/${this.props.current_user.login}/topics/personal`; - }else{ - this.props.showNotification(response.data.message) - } - }) - .catch(function (error) { - console.log(error); - }); - this.topicscancelmodel() - } + }; + // initPublic = (crumbData,menuData) =>{ + // this.setState({ + // banksMenu:menuData + // }) + // this.props.initPublic(crumbData); + // } render() { let {tab,datas,visible} = this.state; - - let user_id=this.props.current_user&&this.props.current_user.user_id; - let user_type=this.props.current_user&&this.props.current_user.user_identity; - let targetuserid=this.props.data&&this.props.data.id; - - + let{ + banksMenu + }=this.state + // + // const common={ + // initPublic:this.initPublic, + // } return ( -
- - {this.state.Modalstype&&this.state.Modalstype===true?:""} - {/*发送至弹窗*/} - { - visible&&visible===true? - + { + banksMenu && + this.topicscancelmodel()} - />:"" - } -
- - {/*
*/} - {/*

*/} - {/* 题库*/} - {/* >*/} - {/* 详情*/} - {/*

*/} - {/*
*/} - {/*
*/} - {/*

*/} - {/* {datas&&datas.name}*/} - {/*

*/} - {/* */} - {/*
*/} - - - - {parseInt(tab) === 0 ? :""} - {parseInt(tab) === 1 ? :""} - -
-
+ {...this.state} + > + } + + { + return () + } + }> + { + return () + } + }> + + + ) } } diff --git a/public/react/src/modules/user/usersInfo/InfosTopics.js b/public/react/src/modules/user/usersInfo/InfosTopics.js index 7dcd3bfe5..0cca22b46 100644 --- a/public/react/src/modules/user/usersInfo/InfosTopics.js +++ b/public/react/src/modules/user/usersInfo/InfosTopics.js @@ -488,8 +488,8 @@ class InfosTopics extends Component{ 55?item.name:""} className="ml10 fl mt3 font-16 color-dark maxwidth900" href={ - category==="normal"?`/banks/normal/${item.id}/${types}?tab=0`: - category==="group"?`/banks/group/${item.id}/${types}?tab=0`: + category==="normal"?`/banks/normal/${item.id}/${types}/details`: + category==="group"?`/banks/group/${item.id}/${types}/tab=0`: category==="poll"?`/banks/poll/${item.id}/${types}`: category==="exercise"?`/banks/exercise/${item.id}/${types}`: category==="gtask"?`/banks/gtask/${item.id}/${types}`: diff --git a/public/react/src/modules/user/usersInfo/banks/banksMenu.js b/public/react/src/modules/user/usersInfo/banks/banksMenu.js index 7680dc748..acc4c1c71 100644 --- a/public/react/src/modules/user/usersInfo/banks/banksMenu.js +++ b/public/react/src/modules/user/usersInfo/banks/banksMenu.js @@ -13,7 +13,8 @@ class BanksMenu extends Component{ constructor(props){ super(props); this.state={ - visible:false + visible:false, + tab:['0'], } } @@ -23,6 +24,12 @@ class BanksMenu extends Component{ visible:true }) } + componentDidMount() { + let { banksMenu} = this.props; + this.setState({ + tab:banksMenu && banksMenu.tab?[String(banksMenu.tab)]:['0'], + }) + } topicscancelmodel=()=>{ this.setState({ @@ -78,10 +85,21 @@ class BanksMenu extends Component{ }); this.topicscancelmodel() } - + changeTab=(e)=>{ + this.setState({ + tab:e.key + }) + console.log(e.key); + // if(e.key === 0){ + // + // }else{ + // + // + // } + } render(){ let { banksMenu} = this.props; - let {visible}=this.state; + let {visible,tab}=this.state; // console.log("问卷预览"); // console.log(visible); let user_id=this.props.current_user&&this.props.current_user.user_id; @@ -112,9 +130,11 @@ class BanksMenu extends Component{ { banksMenu &&
- + { banksMenu.menuArray && banksMenu.menuArray.map((item,key)=>{ + console.log("BanksMenu"); + console.log(item); return( {item.content} )