import React, { Component } from 'react'
import {
  Card,
  Tooltip,
  message,
  Button,
  Tabs,
  Spin,
  Table,
  Tag,
  Collapse,
  Input,
  Modal,
  Form,
  Select,
  InputNumber,
  Popover,
  Pagination,
  Anchor,
  Icon,
  Badge,
  Menu,
  Dropdown,
} from 'antd'
import WrappedIframe from '../../../components/iframePdb'
import { request } from '../../../utils/request'
import Molstar from 'molstar-react'
import { Jsme } from 'jsme-react'
import qs from 'qs'
import './index.css'
const { Panel } = Collapse
const { TabPane } = Tabs
const { Option } = Select
const { Link } = Anchor
let id = 0

@Form.create()
export default class SearchDetails extends Component {
  state = {
    name: '',
    dataOne: qs.parse(this.props.location.search.slice(1)),
    visible: false,
    pdbId: '6f6s',
    smile: 'c',
    DetailsData: {
      smiles: null,
      Structure: [],
      Bioassay: [],
      Target: [],
      Indication: [],
      synonyms: [],
    },
    panelList: {},
    loading: true,
    getStructureList: {
      ligand_up_list: [],
      ligand_list: [],
      chain: [],
      References: [],
    },
    listData: {
      pdb_code: '',
      ligand: '',
      resolution: 0,
    },
    fileData: {
      filestring: '',
      type: 'pdb',
    },

    targetsDetail: {
      Target: [],

      Structure: [],
    },
    Biological_propeties: {},
    Calculated_propeties: {},
    BioassaySearch: {
      page: 1,
      page_size: 10,
      dataid: qs.parse(this.props.location.search.slice(1)).dataid,
    },
    TargetSearch: {
      page: 1,
      page_size: 10,
      dataid: qs.parse(this.props.location.search.slice(1)).dataid,
    },
    IndicationSearch: {
      page: 1,
      page_size: 10,
      dataid: qs.parse(this.props.location.search.slice(1)).dataid,
    },
    pdbLink: '',
    pdbLink2: '',
    addList: ['super', 'align'],
    sum: 0,
    // superpositionData: [
    //   {
    //     chainID: "R",
    //     pdbID: "7tyn",
    //   },
    //   {
    //     chainID: "R",
    //     pdbID: "7tyi",
    //     method: "super",
    //     cutoff: 2.0,
    //     cycles: 5,
    //   },
    //   {
    //     chainID: "R",
    //     pdbID: "7vuj",
    //     method: "align",
    //     cutoff: 3.0,
    //     cycles: 4,
    //   },
    // ],
    superpositionData: [
      {
        chainID: '',
        pdbID: '',
      },
      {
        chainID: '',
        pdbID: '',
        method: '',
        cutoff: 0,
        cycles: 0,
      },
      {
        chainID: '',
        pdbID: '',
        method: '',
        cutoff: 0,
        cycles: 0,
      },
    ],

    total_num: 0,
    total_num2: 0,
    total_num3: 0,
    aciveKey: '',
    directoryState: false,
  }
  componentDidMount () {
    this.getDetails()
  }
  getDetails () {
    // this.setState({loading:true})
    this.setState({ loading: true })
    request
      .post('kinase/drug_detail', qs.parse(this.props.location.search.slice(1)))
      .then((res) => {
        this.setState({ loading: false })
        if (res.data.code === 200) {
          let data = res.data.data
          console.log(data)
          this.setState({
            DetailsData: data,
          })
          this.setState({ Calculated_propeties: data.Calculated_propeties })
          this.setState({ Biological_propeties: data.biological_propeties })

          this.setState({ loading: false })

          let StructureList = data.Structure
          if (StructureList.length > 0) {
            this.getStructure(StructureList[0].pdb)
            this.setState({
              aciveKey: StructureList[0].pdb,
            })
          }
          this.getBioassayList()
          this.getTargetList()
          this.getIndicationList()
        } else {
          message.error(res.data.msg)
        }
      })
      .catch((err) => {
        console.error(err)
      })
  }
  getStructure = (e) => {
    console.log(e)
    request
      .post(
        '/search_pdb_data',
        qs.stringify({
          pdb: e,
        })
      )
      .then((res) => {
        this.setState({ loading: false })
        if (res.data.code === 200) {
          this.setState({ getStructureList: res.data.data })
          let listData = this.state.listData
          listData.pdb_code = res.data.data.name
          listData.ligand = ''
          listData.resolution = 0
          this.setState({ listData })

          let pdbLink =
            'http://52.83.169.190:3004/?id=' + JSON.stringify(listData)
          this.setState({
            pdbLink,
          })
        } else {
          message.error(res.data.msg)
        }
      })
      .catch((err) => {
        console.error(err)
      })
  }
  ChangeTabs = (e) => {
    this.setState({
      aciveKey: e,
    })
    this.setState({
      pdbLink: '',
    })
    let listData = this.state.listData
    listData.ligand = ''
    listData.resolution = 0
    if (listData.pdbList) {
      delete listData.pdbList
    }
    this.setState({
      listData: listData,
      pdbLink: '',
    })
    this.getStructure(e)
  }
  getPdid (e) {
    console.log(e)
    this.setState({ visible: true })
    this.setState({ pdbId: e })
  }
  getTag = (e) => {
    let listData = this.state.listData
    listData.pdb_code = e
    listData.ligand = ''
    listData.resolution = 0
    this.setState({ listData })
    let pdbLink2 = 'http://52.83.169.190:3004/?id=' + JSON.stringify(listData)
    this.setState({
      pdbLink2,
    })
    this.setState({ visible: true })
    this.setState({ pdbId: e })
  }
  getReferences = (e) => {
    window.open(`https://pubmed.ncbi.nlm.nih.gov/${e}`)
  }
  getReferences2 = (e) => {
    window.open(e)
  }
  getList = () => {
    console.log('getList')
    if (this.state.listData.ligand === '') {
      message.warning('输入查询条件')
      return
    }
    JSON.stringify(this.state.listData)
    let listData = this.state.listData
    listData.pdbList = this.state.pdbList
    let pdbLink = 'http://52.83.169.190:3004/?id=' + JSON.stringify(listData)
    this.setState({
      pdbLink,
    })
  }
  getResolutionData = (e) => {
    let listData = this.state.listData
    listData.resolution = e
    this.setState({
      listData,
    })
  }
  LigandChange = (e) => {
    let listData = this.state.listData
    listData.ligand = e
    this.setState({
      listData,
    })
  }

  callback () { }
  getOne (e) {
    console.log(e)
    const { dataid } = e
    let data = {
      dataid,
    }

    this.props.history.push({
      pathname: '/kinase/TargetDetails',
      search: qs.stringify(data),
    })
  }
  getBioassayList = () => {
    console.log(this.state.dataOne)
    const { dataid } = this.state.dataOne
    this.setState({ loading: true })
    request
      .post('kinase/drug_detail/bioassay', this.state.BioassaySearch)
      .then((res) => {
        this.setState({ loading: false })
        if (res) {
          console.log(res)
          let DetailsData = this.state.DetailsData
          DetailsData.Bioassay = res.data.data
          this.setState({ total_num2: res.data.total_num })
          this.setState({
            DetailsData: DetailsData,
          })
        }
      })
      .catch((err) => {
        console.error(err)
      })
  }
  getTargetList = () => {
    console.log(this.state.dataOne)
    const { dataid } = this.state.dataOne
    this.setState({ loading: true })
    request
      .post('kinase/drug_detail/target', this.state.TargetSearch)
      .then((res) => {
        this.setState({ loading: false })
        if (res) {
          console.log(res)
          let DetailsData = this.state.DetailsData
          DetailsData.Target = res.data.data
          this.setState({ total_num: res.data.total_num })
          this.setState({
            DetailsData: DetailsData,
          })
        }
      })
      .catch((err) => {
        console.error(err)
      })
  }
  getIndicationList = () => {
    console.log(this.state.dataOne)
    const { dataid } = this.state.dataOne
    this.setState({ loading: true })
    request
      .post('kinase/drug_detail/indication', this.state.IndicationSearch)
      .then((res) => {
        this.setState({ loading: false })
        if (res) {
          console.log(res)
          let DetailsData = this.state.DetailsData
          DetailsData.Indication = res.data.data
          this.setState({ total_num3: res.data.total_num })
          this.setState({
            DetailsData: DetailsData,
          })
        }
      })
      .catch((err) => {
        console.error(err)
      })
  }
  onShowSizeChange = (current, pageSize) => {
    let BioassaySearch = this.state.BioassaySearch
    BioassaySearch.page = current
    BioassaySearch.page_size = pageSize
    this.setState({
      BioassaySearch,
    })
    this.getBioassayList()
  }
  onChange = (current, pageSize) => {
    let BioassaySearch = this.state.BioassaySearch
    BioassaySearch.page = current
    BioassaySearch.page_size = pageSize
    this.setState({
      BioassaySearch,
    })

    this.getBioassayList()
  }
  onShowSizeChange2 = (current, pageSize) => {
    console.log(current, pageSize)
    let TargetSearch = this.state.TargetSearch
    TargetSearch.page = current
    TargetSearch.page_size = pageSize
    this.setState({
      TargetSearch,
    })
    this.getTargetList()
  }
  onChange2 = (current, pageSize) => {
    console.log(current, pageSize)
    let TargetSearch = this.state.TargetSearch
    TargetSearch.page = current
    TargetSearch.page_size = pageSize
    this.setState({
      TargetSearch,
    })
    this.getTargetList()
  }
  onShowSizeChange3 = (current, pageSize) => {
    console.log(current, pageSize)
    let IndicationSearch = this.state.IndicationSearch
    IndicationSearch.page = current
    IndicationSearch.page_size = pageSize
    this.setState({
      IndicationSearch,
    })
    this.getIndicationList()
  }
  onChange3 = (current, pageSize) => {
    console.log(current, pageSize)
    let IndicationSearch = this.state.IndicationSearch
    IndicationSearch.page = current
    IndicationSearch.page_size = pageSize
    this.setState({
      IndicationSearch,
    })
    this.getIndicationList()
  }
  handleAnchorClick = (e) => {
    e.preventDefault()
  }
  getValue = (e) => {
    const { value } = e.target
    let superpositionData = this.state.superpositionData
    superpositionData[0].chainID = value
    this.setState(() => ({ superpositionData: superpositionData }))
  }
  SelectValue = (e) => {
    console.log(e)
    let superpositionData = this.state.superpositionData
    superpositionData[0].pdbID = e
    this.setState(() => ({ superpositionData: superpositionData }))
  }
  onChangeGroup = (e) => {
    console.log(e)
    this.setState({
      pdbList: e,
    })
  }
  remove = (k) => {
    const { form } = this.props
    // can use data-binding to get
    const keys = form.getFieldValue('keys')
    // We need at least one passenger
    if (keys.length === 1) {
      return
    }

    this.setState({
      sum: keys.length - 1,
    })

    // can use data-binding to set
    form.setFieldsValue({
      keys: keys.filter((key) => key !== k),
    })
  }

  add = () => {
    const { form } = this.props
    // can use data-binding to get
    const keys = form.getFieldValue('keys')
    console.log(keys)
    const nextKeys = keys.concat(id++)
    // can use data-binding to set
    // important! notify form to detect changes
    form.setFieldsValue({
      keys: nextKeys,
    })
    this.setState({
      sum: keys.length + 1,
    })
  }

  handleSubmit = (e) => {
    // console.log(e);
    // e.preventDefault();
    this.props.form.validateFields((err, values) => {
      console.log(values)
      const {
        keys,
        pdbList,
        chainList,
        methodList,
        cutoffList,
        cyclesList,
      } = values
      console.log('Received values of form: ', values)
      // console.log('Merged values:', keys.map(key => names[key]))
      // let names = keys.map(key => names[key])

      for (let index = 0; index < pdbList.length; index++) {
        var element = pdbList[index]
        if (element == undefined) {
          pdbList[index] = ''
        }
      }
      let newArr = pdbList.filter((i) => i && i.trim())
      for (let index = 0; index < chainList.length; index++) {
        var element = chainList[index]
        if (element == undefined) {
          chainList[index] = ''
        }
      }
      let newArr2 = chainList.filter((i) => i && i.trim())
      for (let index = 0; index < methodList.length; index++) {
        var element = methodList[index]
        if (element == undefined) {
          methodList[index] = ''
        }
      }
      let newArr3 = methodList.filter((i) => i && i.trim())
      for (let index = 0; index < cutoffList.length; index++) {
        var element = cutoffList[index]
        if (element == undefined) {
          cutoffList[index] = ''
        }
      }
      let newArr4 = cutoffList.filter((i) => i && i.trim())
      for (let index = 0; index < cyclesList.length; index++) {
        var element = cyclesList[index]
        if (element == undefined) {
          cyclesList[index] = ''
        }
      }
      let newArr5 = cyclesList.filter((i) => i && i.trim())
      console.log(newArr2)
      let superpositionData = this.state.superpositionData
      superpositionData[1].pdbID = newArr[0] === undefined ? '' : newArr[0]
      superpositionData[1].chainID = newArr2[0] === undefined ? '' : newArr2[0]
      superpositionData[1].method = newArr3[0] === undefined ? '' : newArr3[0]
      superpositionData[1].cutoff =
        newArr4[0] === undefined ? '' : parseInt(newArr4[0])
      superpositionData[1].cycles =
        newArr5[0] === undefined ? '' : parseInt(newArr5[0])
      superpositionData[2].pdbID = newArr[1] === undefined ? '' : newArr[1]
      superpositionData[2].chainID = newArr2[1] === undefined ? '' : newArr2[1]
      superpositionData[2].method = newArr3[1] === undefined ? '' : newArr3[1]
        ; (superpositionData[2].cutoff =
          newArr4[1] === undefined ? '' : parseInt(newArr4[1])),
          (superpositionData[2].cycles =
            newArr5[1] === undefined ? '' : parseInt(newArr5[1]))
      this.setState(() => ({ superpositionData: superpositionData }))
      console.log(this.state.superpositionData)
      let listData = this.state.listData
      listData.pdbList = this.state.superpositionData
      let pdbLink = 'http://52.83.169.190:3004/?id=' + JSON.stringify(listData)
      this.setState({ listData })
      this.setState({ pdbLink })
      console.log(this.state.pdbLink)
    })
  }
  render () {
    const {
      visible,
      panelList,
      name,
      pdbId,
      DetailsData,
      getStructureList,
      targetsDetail,
      total_num,
      total_num2,
      total_num3,
      Calculated_propeties,
      Biological_propeties,
      pdbLink,
      pdbLink2,
      addList,
      sum,
      directoryState,
    } = this.state
    const formItemLayout = {
      labelCol: { span: 8 },
      wrapperCol: { span: 12 },
    }
    const columns = [
      {
        title: 'Target name',
        dataIndex: 'Target name',
        key: 'Target name',
        render: (item, record) => (
          <Tag
            color="blue"
            onClick={() => {
              this.getOne(record)
            }}>
            {record.Target_name}
          </Tag>
        ),
      },
   
      {
        title: "Uniport id",
        dataIndex: "Uniport_id",
        key: "Uniport_id",
      },
      {
        title: "Group",
        dataIndex: "Group",
        key: "Group",
      },
      {
        title: "Family",
        dataIndex: "Family",
        key: "Family",
      },
      {
        title: 'PDB',
        dataIndex: 'PDB',
        render: (PDB) => (
          <span>
            {PDB.map((item, index) => {
              return (
                <Tag
                  color="blue"
                  key={index}
                  onClick={() => {
                    this.getTag(item)
                  }}>
                  {item.toUpperCase()}
                </Tag>
              )
            })}
          </span>
        ),
      },
      {
        title: 'sequence',
        dataIndex: 'sequence',
        key: 'sequence',
        render: (sequence) => (
          <span>
            {
              <Tooltip placement="topLeft" title={sequence}>
                <Button>Sequence</Button>
              </Tooltip>
            }
          </span>
        ),
      },
    ]
    const columns2 = [
      {
        title: 'Indication',
        dataIndex: 'Indication',
        key: 'Indication',
      },
      {
        title: 'Synonyms',
        dataIndex: 'Synonyms',
        key: 'Synonyms',
        render: (Synonyms) => (
          <span>
            {Synonyms != null &&
              Synonyms.map((item, index) => {
                return <span key={index}>{item.toUpperCase()},</span>
              })}
          </span>
        ),
      },
      {
        title: 'Status',
        dataIndex: 'Status',
        key: 'Status',
        render: (Status) => (
          <span>
            {Status.map((item, index) => {
              return <Tag key={index}>{item.toUpperCase()}</Tag>
            })}
          </span>
        ),
      },
      {
        title: 'Clinical phase',
        dataIndex: 'Clinical_phase',
        key: 'Clinical_phase',
      },
      {
        title: 'Clinical status',
        dataIndex: 'Clinical_status',
        key: 'Clinical_status',
      },
      {
        title: 'Purpose',
        dataIndex: 'Purpose',
        key: 'Purpose',
      },
      {
        title: 'reference',
        dataIndex: 'reference',
        render: (reference) => (
          <span>
            {reference != 'Null' &&
              reference.map((item, index) => {
                return (
                  <Tag
                    color="blue"
                    key={index}
                    onClick={() => {
                      this.getReferences2(item)
                    }}>
                    {item.toUpperCase()}
                  </Tag>
                )
              })}
          </span>
        ),
      },
    ]
    const menu = (
      <Menu>
        <Menu.Item>Action 1</Menu.Item>
        <Menu.Item>Action 2</Menu.Item>
      </Menu>
    )
    const expandedRowRender = (e) => {
      console.log(e)
      const { standards } = e
      const columns = [
        {
          title: 'Standard Type',
          dataIndex: 'Standard Type',
          key: 'Standard Type',
        },
        {
          title: 'Standard Relation',
          dataIndex: 'Standard Relation',
          key: 'Standard Relation',
        },
        {
          title: 'Standard Value',
          dataIndex: 'Standard Value',
          key: 'Standard Value',
        },
        {
          title: 'Standard Units',
          dataIndex: 'Standard Units',
          key: 'Standard Units',
        },
        {
          title: 'reference',
          dataIndex: 'reference',
          key: 'reference',
          render: (reference) => (
            <span>
              {
                <Tag
                  color="blue"
                  onClick={() => {
                    this.getReferences2(reference)
                  }}>
                  {reference}
                </Tag>
              }
            </span>
          ),
        },
      ]
      return (
        <Table columns={columns} dataSource={standards} pagination={false} />
      )
    }

    const columns3 = [
      {
        title: 'Target',
        dataIndex: 'Target',
        render: (item, record) => (
          <Tag
            color="blue"
            onClick={() => {
              this.getOne(record)
            }}>
            {record.Target_name}
          </Tag>
        ),
      },

      // {
      //   title: 'Reference',
      //   dataIndex: 'reference',
      //   key: 'reference',
      //   render: (reference) => (
      //     <span>
      //       {reference &&
      //         reference.map((item, index) => {
      //           return (
      //             <Tag
      //               color="blue"
      //               key={index}
      //               onClick={() => {
      //                 this.getReferences(item)
      //               }}>
      //               {item.toUpperCase()}
      //             </Tag>
      //           )
      //         })}
      //     </span>
      //   ),
      // },
    ]
    const columnsChain = [
      {
        title: 'Chain_name',
        dataIndex: 'Chain_name',
        key: 'Chain_name',
      },
      {
        title: 'Chain_ID',
        dataIndex: 'Chain_ID',
        key: 'Chain_ID',
      },

      {
        title: 'code',
        dataIndex: 'code',
        key: 'code',
      },
      {
        title: 'code_type',
        dataIndex: 'code_type',
        key: 'code_type',
      },
      {
        title: 'res_start',
        dataIndex: 'res_start',
        key: 'res_start',
      },
      {
        title: 'res_end',
        dataIndex: 'res_end',
        key: 'res_end',
      },
    ]
    const { getFieldDecorator, getFieldValue } = this.props.form
    const formItemLayoutWithOutLabel = {
      wrapperCol: {
        xs: { span: 24, offset: 0 },
        sm: { span: 20, offset: 4 },
      },
    }
    const formItemLayout2 = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 4 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 20 },
      },
    }
    getFieldDecorator('keys', { initialValue: [] })
    const keys = getFieldValue('keys')
    const formItems = keys.map((k, index) => (
      <Form.Item
        {...(index === 0 ? formItemLayout2 : formItemLayoutWithOutLabel)}
        label={index === 0 ? 'SelectPDB: ' : ''}
        required={false}
        key={k}>
        <div style={{ display: 'flex ', alignItems: 'center ' }}>
          {getFieldDecorator(`pdbList[${k}]`)(
            <Select style={{ width: '100px' }}>
              {DetailsData.Structure.map((item, index) => {
                return (
                  <Option key={index.pdb} value={item.pdb.toLowerCase()}>
                    {item.pdb.toLowerCase()}
                  </Option>
                )
              })}
            </Select>
          )}
          <div>
            <Form.Item style={{ margin: '0px' }}>
              {getFieldDecorator(`chainList[${k}]`)(
                <Input
                  placeholder="请输入Chain"
                  style={{ width: '100px', marginRight: 8 }}
                />
              )}
            </Form.Item>
          </div>
          <div>
            <Form.Item style={{ margin: '0px' }} help="The information is being validated...">
              {getFieldDecorator(`methodList[${k}]`)(
                <Select style={{ width: '100px' }}>
                  {addList.map((item, index) => {
                    return (
                      <Option key={index} value={item}>
                        {item}
                      </Option>
                    )
                  })}
                </Select>
              )}
            </Form.Item>
          </div>
          <div>
            <Form.Item style={{ margin: '0px' }}>
              {getFieldDecorator(`cutoffList[${k}]`)(
                <Input
                  placeholder="Cutoff"
                  style={{ width: '100px', marginRight: 8 }}
                />
              )}
            </Form.Item>
          </div>
          <div>
            <Form.Item style={{ margin: '0px' }}>
              {getFieldDecorator(`cyclesList[${k}]`)(
                <Input
                  placeholder="Cycles"
                  style={{ width: '100px', marginRight: 8 }}
                />
              )}
              {keys.length > 1 ? (
                <Icon
                  className="dynamic-delete-button"
                  type="minus-circle-o"
                  onClick={() => this.remove(k)}
                  style={{ marginLeft: '10px' }}
                />
              ) : null}
            </Form.Item>
          </div>
        </div>
      </Form.Item>
    ))
    return (
      <div className="search-details-div">
        <Modal
          footer={null}
          closable={false}
          width={850}
          visible={visible}
          wrapClassName="vertical-center-modal"
          onCancel={() => this.setState({ visible: false })}>
          <div className="Molstar-div">
            {/* <Molstar file={this.state.fileData} /> */}
            <iframe
              src={pdbLink2}
              height={'500px'}
              width={'100%'}
              name="iframe-video"
            />
          </div>
        </Modal>
        <Spin tip="Loading..." size="large" spinning={this.state.loading}>
          <div className="Anchor-div">
            {directoryState && (
              <Button type="primary" style={{ width: '100%' }} onClick={() => this.setState({ directoryState: false })}>
                收起目录
              </Button>
            )}
            {!directoryState && (
              <Button type="primary" style={{ width: '100%' }} onClick={() => this.setState({ directoryState: true })}>

                展开目录
              </Button>
            )}

            {directoryState && (
              <div>
                <Anchor onClick={this.handleAnchorClick}>
                  <Link href="#card" title="Title" />
                  <Link href="#Indication" title="Indication" />
                  <Link href="#Target" title="Target" />
                  <Link
                    href="#BiologicalPropeties"
                    title="Biological Propeties"
                  />
                  <Link href="#Bioassay" title="Bioassay" />
                  <Link
                    href="#CalculatedPropeties"
                    title="Calculated Propeties"
                  />
                  <Link href="#Structure" title="Structure" />
                </Anchor>
              </div>
            )}
          </div>
          <Card hoverable id="card">
            <div>
              <div className="title-div">{name}</div>
              <div className="title-div-top">
                <div className="DataList-left">
                  <div>
                    <div className="title-div">{DetailsData.name}</div>
                    <div className="title-div-top">
                      <div className="DataList-left">
                        <div>
                          <div className="div-list">
                            <div className="list-one">
                              <div className="left-title">Synonyms</div>

                              <div className="Synonyms-div">
                                <div> </div>
                                {DetailsData.synonyms.map((item, index) => {
                                  return <Tag>{item}</Tag>
                                })}
                              </div>
                            </div>
                            <div className="list-one">
                              <div className="left-title">Drug Type</div>
                              <div />
                              {DetailsData.datatype}
                            </div>
                            <div className="list-one">
                              <div className="left-title">Smiles</div>
                              <div />
                              {DetailsData.smiles}
                            </div>
                          </div>
                        </div>
                      </div>
                      <div className="Jsme-div">
                        {DetailsData.smiles && (
                          <Jsme
                            height="300px"
                            width="300px"
                            options="depict,useopenchemlib"
                            smiles={DetailsData.smiles}
                          />
                        )}
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </Card>
          <Collapse
            defaultActiveKey={['1', '2', '3', '4', '5', '6']}
            onChange={this.callback}>
            <Panel header="Indication" id="Indication" key="6">
              <Table
                bordered
                rowKey="dataid"
                dataSource={DetailsData.Indication}
                pagination={false}
                columns={columns2}
              />
              <Pagination
                showSizeChanger
                onShowSizeChange={this.onShowSizeChange3}
                onChange={this.onChange3}
                total={total_num3}
              />
            </Panel>
            <Panel header="Target" key="1" id="Target">
              <Table
                bordered
                rowKey="index"
                dataSource={DetailsData.Target}
                pagination={false}
                columns={columns}
              />
              <Pagination
                showSizeChanger
                onShowSizeChange={this.onShowSizeChange2}
                onChange={this.onChange2}
                total={total_num}
              />
            </Panel>
            <Panel
              header="Biological Propeties"
              id="BiologicalPropeties"
              key="5">
              <div className="Calcilated">
                <div className="div-list">
                  <div className="list-one">
                    <div>Absorption:</div>
                    <div />
                    {Biological_propeties.absorption}
                  </div>
                  <div className="list-one">
                    <div>Clearance:</div>
                    <div />
                    {Biological_propeties.clearance}
                  </div>
                  <div className="list-one">
                    <div>Distribution: </div>
                    <div />
                    {Biological_propeties.distribution}
                  </div>
                  <div className="list-one">
                    <div>Elimination:</div>
                    <div />
                    {Biological_propeties.elimination}
                  </div>
                  <div className="list-one">
                    <div>Half Life: </div>
                    <div />
                    {Biological_propeties.half_life}
                  </div>
                  <div className="list-one">
                    <div>metabolism: </div>
                    <div />
                    {Biological_propeties.metabolism}
                  </div>
                  <div className="list-one">
                    <div>Toxicity: </div>
                    <div />
                    {Biological_propeties.toxicity}
                  </div>
                </div>
              </div>
            </Panel>

            <Panel header="Bioassay" key="2" id="Bioassay">
              <Table
                bordered
                rowKey="dataid"
                dataSource={DetailsData.Bioassay}
                pagination={false}
                columns={columns3}
                expandedRowRender={expandedRowRender}
              />
              <Pagination
                showSizeChanger
                onShowSizeChange={this.onShowSizeChange}
                onChange={this.onChange}
                total={total_num2}
              />
            </Panel>
            <Panel
              header="Calculated Propeties"
              key="3"
              id="CalculatedPropeties">
              <div>
                <div className="Calcilated">
                  <div className="list-one2">
                    <div>Molecular weight:</div>
                    <div />
                    {Calculated_propeties.Molecular_weight}
                  </div>
                  <div className="list-one2">
                    <div>LogP:</div>
                    <div />
                    {Calculated_propeties.logP}
                  </div>
                  <div className="list-one2">
                    <div>Hydrogen bond donor: </div>
                    <div />
                    {Calculated_propeties.Hydrogen_bond_donor}
                  </div>
                  <div className="list-one2">
                    <div>Hydrogen bond acceptor:</div>
                    <div />
                    {Calculated_propeties.Hydrogen_bond_acceptor}
                  </div>
                  <div className="list-one2">
                    <div>Rotatable bond: </div>
                    <div />
                    {Calculated_propeties.Rotatable_bond}
                  </div>
                  <div className="list-one2">
                    <div>sp3 Carbon: </div>
                    <div />
                    {Calculated_propeties.sp3_Carbon}
                  </div>
                  <div className="list-one2">
                    <div>tPSA: </div>
                    <div />
                    {Calculated_propeties.tPSA}
                  </div>
                </div>
              </div>
            </Panel>
            <Panel header="Structure" key="4" id="Structure">
              <Tabs
                defaultActiveKey="0"
                // type="card"
                style={{ height: 1000 }}
                tabPosition="left"
                onChange={this.ChangeTabs}>
                {DetailsData.Structure.map((item, index) => {
                  return (
                    <TabPane id={item.pdb} tab={item.pdb} key={item.pdb}>
                      <div className="TabPane-center">
                        <div className="Molstar-div2">
                          {this.state.aciveKey == item.pdb && (
                            <WrappedIframe pdbLink={this.state.pdbLink} />
                          )}
                        </div>
                        <div className="Structure-right">
                          <Form layout="horizontal">
                            <Form.Item label="详情" {...formItemLayout}>
                              <div>method: {getStructureList.method}</div>
                              <div>name: {getStructureList.name}</div>
                              <div>
                                pdb_datatime: {getStructureList.pdb_datatime}
                              </div>
                              <div>
                                resolution: {getStructureList.resolution}
                              </div>
                            </Form.Item>
                            <Form.Item label="References " {...formItemLayout}>
                              {getStructureList.References &&
                                getStructureList.References.map(
                                  (item, index) => {
                                    return (
                                      <Button
                                        type="primary"
                                        onClick={() => {
                                          this.getReferences(item)
                                        }}
                                        key={index}
                                        style={{ marginRight: '5px' }}>
                                        {item}
                                      </Button>
                                    )
                                  }
                                )}
                            </Form.Item>
                          </Form>
                          <Collapse accordion>
                            <Panel header="对齐" key="1">
                              <div className="form-div">
                                <Form
                                  onSubmit={this.handleSubmit}
                                  className="login-form">
                                  <Form.Item
                                    label="Ref.PDB"
                                    {...formItemLayout2}>
                                    <div>
                                      <Select
                                        style={{ width: '100px' }}
                                        value={
                                          this.state.superpositionData[0].pdbID
                                        }
                                        onChange={this.SelectValue}>
                                        {DetailsData.Structure.map(
                                          (item, index) => {
                                            return (
                                              <Option
                                                key={index.pdb}
                                                value={item.pdb.toLowerCase()}>
                                                {item.pdb.toLowerCase()}
                                              </Option>
                                            )
                                          }
                                        )}
                                      </Select>
                                      <Input
                                        placeholder="请输入Chain"
                                        onChange={this.getValue}
                                        value={
                                          this.state.superpositionData[0]
                                            .chainID
                                        }
                                        style={{
                                          width: '100px',
                                        }}
                                      />
                                    </div>
                                  </Form.Item>
                                  {formItems}
                                  <Form.Item {...formItemLayoutWithOutLabel}>
                                    {sum < 2 && (
                                      <Button
                                        type="dashed"
                                        onClick={this.add}
                                        style={{ width: '60%' }}>
                                        <Icon type="plus" /> Add field
                                      </Button>
                                    )}
                                  </Form.Item>
                                  <Form.Item {...formItemLayoutWithOutLabel}>
                                    <Button type="primary" htmlType="submit">
                                      对齐
                                    </Button>
                                  </Form.Item>
                                </Form>
                              </div>
                            </Panel>
                            <Panel header="抽取配体" key="2">
                              <Form layout="horizontal">
                                <Form.Item label="配体列表" {...formItemLayout}>
                                  {getStructureList.ligand_up_list &&
                                    getStructureList.ligand_up_list.map(
                                      (item, index) => {
                                        return (
                                          <Popover
                                            content={
                                              <div>
                                                <div
                                                  key={index}
                                                  style={{
                                                    width: '100px',
                                                    wordWrap: 'break-word',
                                                    wordBreak: 'normal',
                                                  }}>
                                                  {item.comp_name}
                                                </div>

                                                <Jsme
                                                  height="100px"
                                                  width="100px"
                                                  options="depict,useopenchemlib"
                                                  smiles={item.smiles}
                                                />
                                              </div>
                                            }>
                                            {
                                              <Button
                                                type="primary"
                                                style={{ marginRight: '5px' }}>
                                                {item.name}
                                              </Button>
                                            }
                                          </Popover>
                                        )
                                      }
                                    )}
                                </Form.Item>
                                <Form.Item label="配体选择" {...formItemLayout}>
                                  <Select
                                    style={{ width: 250 }}
                                    value={this.state.listData.ligand}
                                    size="large"
                                    onChange={this.LigandChange}>
                                    {getStructureList.ligand_list &&
                                      getStructureList.ligand_list.map(
                                        (item, index) => {
                                          return (
                                            <Option key={index} value={item}>
                                              {item}
                                            </Option>
                                          )
                                        }
                                      )}
                                  </Select>
                                </Form.Item>
                                <Form.Item label="搜索半径" {...formItemLayout}>
                                  <InputNumber
                                    style={{ width: 250 }}
                                    min={getStructureList.resolution}
                                    max={10}
                                    placeholder={'请输入大于resolutiond数字'}
                                    step={0.1}
                                    size="large"
                                    onChange={this.getResolutionData}
                                  />
                                </Form.Item>
                                <Form.Item label="Search" {...formItemLayout}>
                                  <Button
                                    type="primary"
                                    style={{ marginLeft: 50, width: 150 }}
                                    size="large"
                                    loading={this.state.loading}
                                    disabled={
                                      getStructureList.ligand_list.length === 0
                                    }
                                    onClick={this.getList}>
                                    Search
                                  </Button>
                                </Form.Item>
                              </Form>
                            </Panel>
                          </Collapse>
                        </div>
                      </div>
                      <Table
                        bordered
                        rowKey="item"
                        dataSource={getStructureList.chain}
                        pagination={false}
                        columns={columnsChain}
                      />
                    </TabPane>
                  )
                })}
              </Tabs>
            </Panel>
          </Collapse>
        </Spin>
      </div>
    )
  }
}
