import React, {Component} from "react";
import {Link, NavLink} from 'react-router-dom';
import {WordsBtn, ActionBtn,SnackbarHOC,getImageUrl} from 'educoder';
import axios from 'axios';
import {
	notification,
	Spin,
	Table,
	Pagination,
	Tabs,
	Input,
	Popover
} from "antd";
import './../questioncss/questioncom.css';
import NoneDatas from '../component/NoneDatas';
import LoadingSpin from '../../../common/LoadingSpin';
import Contentquestionbank from "./Contentquestionbank";
import Listjihe from "./Listjihe";
const { TabPane } = Tabs;
const Search = Input.Search;
class Contentpart extends Component {
	constructor(props) {
		super(props);
		this.state = {
			page:1,
			chakanjiexibool:false,
			chakanjiexiboolindex:"无",
		}
	}
	//初始化
	componentDidMount(){


	}

	chakanjiexibool=(index)=>{
		debugger
		if(this.state.chakanjiexiboolindex===index){
			this.setState({
				chakanjiexiboolindex:"无",
			})
			return
		}
			this.setState({
				chakanjiexiboolindex:index,
			})
	}

	render() {
		let {page}=this.state;
		let {defaultActiveKey}=this.props;
		const content = (
			<div className="questiontypes" style={{
				width:'93px',
				height:'200px',
			}}>
				<p className="questiontype " onClick={()=>this.props.setitem_types(null)}>全部</p>
				<p className="questiontypeheng" ></p>
				<p className="questiontype " onClick={()=>this.props.setitem_types("SINGLE")}>单选题</p>
				<p className="questiontypeheng" ></p>
				<p className="questiontype "  onClick={()=>this.props.setitem_types("MULTIPLE")}>多选题</p>
				<p className="questiontypeheng"></p>
				<p className="questiontype "  onClick={()=>this.props.setitem_types("JUDGMENT")}>判断题</p>
				<p className="questiontypeheng"></p>
				<p className="questiontype "  onClick={()=>this.props.setitem_types("PROGRAM")}>编程题</p>
				<p className="questiontypeheng"></p>

			</div>
		);
		const contents = (
			<div  className="questiontypes" style={{
				width:'93px',
				height:'161px',
			}}>
				<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>
		);

		const buttonWidth = 70;
		//console.log("Contentpart");
		//console.log(this.props);
		return (
			<div className=" clearfix mt40">
				<div className="educontent mt10 pb20 w1200s">
					<div className="w1200ms contentparttit" style={{
						position: "relative",
					}}>
						<style>
							{
								`
								.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;
								}
								`
							}
						</style>
						<Tabs defaultActiveKey={defaultActiveKey} onChange={(e)=>this.props.callback(e)}>
							<TabPane tab="公共" key="1">
							</TabPane>
							<TabPane tab="我的" key="0">
							</TabPane>
						</Tabs>

						<div className=" mt19" style={{
							position:"absolute",
							top: "0px",
							right:" 0px",
							paddingRight: "20px",
						}}>
							<style>
								{
									`
									.xaxisreverseorder .ant-input-group-addon{
									width: 60px !important;
									
									}
									
									.xaxisreverseorder .ant-input-lg {
    height: 41px;}
                 
                  .xaxisreverseorder .ant-popover{
                       top: 30px !important;
                   }
                   
                   
                   .ant-popover-inner-content {
                   padding:0px !important;
                   }
   
									`
								}
							</style>
						 <div className="xaxisreverseorder">
							 {
								 defaultActiveKey===0||defaultActiveKey==="0"?
									 <a href={'/question/newitem'}>
									 <div className="newbutoon">
										 <p className="newbutoontes" >新增</p>
									 </div>
									 </a>
									 :""
							 }
							 <Popover getPopupContainer={trigger => trigger.parentNode}  placement="bottom" trigger="hover" content={contents}   onVisibleChange={()=>this.props.handleVisibleChange(true)}>
							 <div className=" sortinxdirection mr10">

							 <div className="subjecttit">
								 难度
							 </div>
								 <i className="iconfont icon-sanjiaoxing-down font-12 lg ml7 icondowncolor"></i>
							 </div>
							 </Popover>



							 <Popover getPopupContainer={trigger => trigger.parentNode}  placement="bottom" trigger="hover" content={content}   onVisibleChange={()=>this.props.handleVisibleChanges(true)}>
							 <div className="sortinxdirection mr40">
							 <div className="subjecttit">
								 题型
							 </div>
								 <i className="iconfont icon-sanjiaoxing-down font-12 lg ml7 icondowncolor"></i>
							 </div>
							 </Popover>
							 <Search
								 style={{ width: "347px",marginRight:"60px",}}
								 placeholder="请输入题目名称、内容"
								 enterButton
								 size="large"
								 onInput={(e)=>this.props.setdatafunsval(e)}
								 onSearch={ (value)=>this.props.setdatafuns(value)} />
						 </div>

						</div>
					</div>
					{/*内容*/}
					{
						this.props.Contentdata.items === undefined ||this.props.Contentdata.items === null||this.props.Contentdata.items.length===0 ?
							<div className=" w100s mb10"></div>
							:
							<div className=" w100s mb10">
								{
									defaultActiveKey===1||defaultActiveKey==="1"?
										<Contentquestionbank {...this.props} {...this.state}  selectallquestionsonthispage={()=>this.props.selectallquestionsonthispage()} ></Contentquestionbank>
										:""
								}
								{
									defaultActiveKey===0||defaultActiveKey==="0"?
										<Contentquestionbank {...this.props} {...this.state} selectallquestionsonthispage={()=>this.props.selectallquestionsonthispage()}></Contentquestionbank>
										:""
								}
							</div>
					}

					<div className="minheight">
					{/*列表集合*/}
					<div className=" w100s">
						{
							this.props.booljupyterurls===true?
								<LoadingSpin></LoadingSpin>
								:
							this.props.Contentdata.items === undefined ||this.props.Contentdata.items === null||this.props.Contentdata.items.length===0?
							 <NoneDatas></NoneDatas>


							: this.props.Contentdata.items.map((object, index) => {
							return (
								<Listjihe {...this.state} {...this.props}
													chakanjiexibool={(keindex)=>this.chakanjiexibool(keindex)}
													listjihe={index+1}
													keindex={index}
													items={object}
													key={index}
													getitem_basketss={(id)=>this.props.getitem_basketss(id)}
													getitem_baskets={(e)=>this.props.getitem_baskets(e)}
													showmodels={(e)=>this.props.showmodels(e)}
													showmodelysl={(e)=>this.props.showmodelysl(e)}>

								</Listjihe>
							)
						})}



					</div>

					</div>










				</div>


			</div>
		)

	}



}
export default Contentpart
