import React, { useEffect, useState } from 'react';
import { Tabs } from 'antd';
import First from './components/first';
import FirstMain from './components/firstMain';
import Detailed from './components/detailed';
import DetailedMain from './components/detailedMain';
import { getURLInformation } from '@/utils/CommonUtils'
import { getBizInfo } from './service'
import './style.less';


const Config: React.FC<{}> = () => {
  const { TabPane } = Tabs;
  //控制展示页
  const callback = (key: string) => {
    showSet(key)
  }
  const [method, methodSet] = useState<any>(false)// true  false 不显示
  const [show, showSet] = useState<any>('1')//
  useEffect(() => {
    let bizId = ''
    let commonId: any = "";
    if (getURLInformation("id") != null) {
      commonId = getURLInformation("id")
    }
    let secId: any = '';
    if (getURLInformation("secId") != null) {
      secId = getURLInformation("secId");
      bizId = secId;
    }
    let roomType: any = '';
    if (getURLInformation("roomType") != null) {
      roomType = getURLInformation("roomType");
    }
    //查评分办法和采购方式
    getBizInfo(bizId).then((res) => {
      let methodT = false;
      if (res.code == 200) {
        const data = res.data;
        console.log("data",data)
        if (roomType == '2') {
          data.evalMethodDict === 'eval_method_2' ? methodT = true : null;//评分办法 1最低价 2综合评估
        }
        data.ptcpMode === 'ptcp_mode_2' ? methodT = true : null;//采购方式  1合格制 2有限数量制
      }
      methodSet(methodT);
    });

  }, [])
  return (
    <div key='confogDiv1'>
      <Tabs defaultActiveKey="1" onChange={callback} size={"large"} className='configDiv'>
        <TabPane tab="初审设置" key="1" >
          {show == '1' && <FirstMain show={show} />}
        </TabPane>
        {
          method &&
          <TabPane tab="详审设置" key="2">
            {show == '2' && <DetailedMain show={show} />}
          </TabPane>
        }
      </Tabs>
    </div>
  )
}
export default Config;