import React, { useEffect, useState } from 'react'
import styles from './index.module.scss'
import { rowArrTemp } from '@/pages/Zother/data'
import { getPanDianListFu } from '../../G1accident/data'
import { G3moreList } from '../data'
import { InfoProvider } from '@/pages/Zother/InfoContext'
import EditTop from '@/pages/Zother/EditTop'
import { G3_APIgetClueList, G3API_obj } from '@/store/action/Gmaintain/G3repair'
import FileArchive from '@/pages/Zother/FileArchive'
import EditBtn from '@/pages/Zother/EditBtn'

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

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

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

  return (
    <>
      {info.loding ? (
        <InfoProvider>
          <div className={styles.G3edit} id='editBox'>
            <div className='editMain'>
              {/* 顶部 */}
              <EditTop
                pageTxt='修复登记'
                rowArr={rowArr}
                APIobj={G3API_obj}
                fileUpInfo={{ myUrl: 'cms/orderFix/upload', dirCode: 'repair' }}
                // 第二个模块
                moreDom={{
                  txt: '修复报告',
                  API: G3_APIgetClueList,
                  domList: info.list,
                  myUrl: 'cms/orderFix/son/upload',
                  dirCode: 'repairSon'
                }}
              />

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

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

const MemoG3edit = React.memo(G3edit)

export default MemoG3edit
