import React, { useMemo } from 'react'
import styles from './index.module.scss'
import { TypetableAuditList } from '../data'
import { Button } from 'antd'
import MyTable from '@/components/MyTable'

type Props = {
  list: TypetableAuditList[]
  closeFu: () => void
}

function AuditList({ list, closeFu }: Props) {
  const tableLastBtn = useMemo(() => {
    return [
      {
        title: '审批结果',
        render: (item: TypetableAuditList) => {
          let txt1 = item.status === 1 ? '同意' : item.status === 2 ? '不同意' : '待处理'
          if (item.isUse === 0) txt1 = '（空）'
          const txt2 = item.isAuto === 1 ? '（自动）' : ''
          return txt1 + txt2
        }
      },
      {
        title: '审批日期',
        render: (item: TypetableAuditList) => item.auditTime || '（空）'
      },
      {
        title: '审批意见',
        render: (item: TypetableAuditList) => item.rtfOpinion || '（空）'
      }
    ]
  }, [])

  return (
    <div className={styles.AuditList}>
      <div className='ALbox'>
        <div className='ALtit'>
          <div>申请记录</div>
          <Button onClick={closeFu}>关闭</Button>
        </div>
        {/* 表格 */}
        <MyTable
          yHeight={650}
          classKey='AuditListTable'
          list={list}
          columnsTemp={[
            ['txt', '节点名称', 'name'],
            ['txt', '提交日期', 'createTime'],
            ['txt', '处理人', 'handler']
          ]}
          lastBtn={tableLastBtn}
          pagingInfo={false}
        />
      </div>
    </div>
  )
}

const MemoAuditList = React.memo(AuditList)

export default MemoAuditList
