/*
 * @Author: yuananting
 * @Date: 2021-02-21 17:51:01
 * @LastEditors: yuananting
 * @LastEditTime: 2021-03-05 13:41:32
 * @Description: 助学工具-题库-题库主页面
 * @Copyrigh: © 2020 杭州杰竞科技有限公司 版权所有
 */

import React, { Component } from "react";
import { Layout } from "antd";
import "./QuestionBankIndex.less";
import QuestionBankSider from "./components/QuestionBankSider";
import QuestionManageFilter from "./components/QuestionManageFilter";
import QuestionManageOpt from "./components/QuestionManageOpt";
import QuestionManageList from "./components/QuestionManageList";

class QuestionBankIndex extends Component {
  constructor(props) {
    super(props);
    this.state = {
      query: {
        current: 1,
        size: 10,
      },
      loading: true,
      dataSource: [], // 题库列表数据
      totalCount: 1, // 题库数据总条数
    };
  }

  componentDidMount() {
    // TODO
    // 接口请求 初始化数据
    this.getQuestionBankList();
  }

  getQuestionBankList = (_query = {}) => {
    const query = {
      ...this.state.query,
      ..._query,
    };

    // 更新请求参数
    this.setState({ query });

    // CourseService.videoSchedulePage(query).then((res) => {
    //   const { result = {} } = res || {};
    //   const { records = [], total = 0 } = result;
    //   this.setState({
    //     dataSource: records,
    //     totalCount: Number(total)
    //   });
    // });
  };

  render() {
    const { query, dataSource, totalCount } = this.state;
    return (
      <div className="question-bank-index page">
        <div className="content-header">题目</div>
        <div className="box content-body">
          <div className="sider">
            <QuestionBankSider />
          </div>
          <div className="content">
            <QuestionManageFilter />
            <QuestionManageOpt />
            <QuestionManageList
              query={query}
              dataSource={dataSource}
              totalCount={totalCount}
              onChange={this.getQuestionList}
            />
          </div>
        </div>
      </div>
    );
  }
}

export default QuestionBankIndex;
