import React, { useEffect, useState } from 'react'
import styles from './index.module.scss'
import { rowArrTemp } from '@/pages/Zother/data'
import { getPanDianListFu } from '../../G1accident/data'
import { G2moreList } from '../data'
import { InfoProvider } from '@/pages/Zother/InfoContext'
import EditTop from '@/pages/Zother/EditTop'
import { G2_APIgetClueList, G2API_obj } from '@/store/action/Gmaintain/G2actuality'
import FileArchive from '@/pages/Zother/FileArchive'
import EditBtn from '@/pages/Zother/EditBtn'

const rowArr = [
  {
    name: `现状登记`,
    type: 'txt'
  },
  ...rowArrTemp('登记', undefined, '现状登记').slice(1)
]

function G2edit() {
  const [info, setInfo] = useState<any>({ list: [], loding: false })

  useEffect(() => {
    getPanDianListFu(
      list => {
        setInfo({ list, loding: true })
      },
      list => G2moreList(list)
    )
  }, [])

  return (
    <>
      {info.loding ? (
        <InfoProvider>
          <div className={styles.G2edit} id='editBox'>
            <div className='editMain'>
              {/* 顶部 */}
              <EditTop
                pageTxt='现状登记'
                rowArr={rowArr}
                APIobj={G2API_obj}
                fileUpInfo={{ myUrl: 'cms/orderCurrent/upload', dirCode: 'actuality' }}
                // 第二个模块
                moreDom={{
                  txt: '现状报告',
                  API: G2_APIgetClueList,
                  domList: info.list,
                  myUrl: 'cms/orderCurrent/son/upload',
                  dirCode: 'actualitySon'
                }}
              />

              {/* 附件归档 */}
              <FileArchive />

              {/* 底部按钮 */}
              <EditBtn
                path='/actuality'
                APIobj={G2API_obj}
                checkListTxt='请选择关联藏品'
                isTow={true}
              />
            </div>
          </div>
        </InfoProvider>
      ) : null}
    </>
  )
}

const MemoG2edit = React.memo(G2edit)

export default MemoG2edit
