A2timeFlag.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React, { useCallback } from 'react'
  2. import styles from './index.module.scss'
  3. import { Button, Modal } from 'antd'
  4. import { MessageFu } from '@/utils/message'
  5. export type A2TcanType = {
  6. time: string
  7. num: null | 0 | 1
  8. }
  9. type Props = {
  10. info: A2TcanType
  11. closeFu: (val: 0 | 1 | null) => void
  12. }
  13. const arr = [
  14. {
  15. name: '不可预约',
  16. num: 1
  17. },
  18. {
  19. name: '可预约',
  20. num: 0
  21. }
  22. ]
  23. function A2timeFlag({ info, closeFu }: Props) {
  24. const btnClick = useCallback(
  25. (val: number) => {
  26. if (val === info.num)
  27. return MessageFu.info(`当前已经是${info.num ? '' : '不'}可预约状态!`)
  28. closeFu(val as 0)
  29. },
  30. [closeFu, info.num]
  31. )
  32. return (
  33. <Modal
  34. wrapClassName={styles.A2timeFlag}
  35. open={true}
  36. title=''
  37. onCancel={() => closeFu(null)}
  38. footer={
  39. [] // 设置footer为空,去掉 取消 确定默认按钮
  40. }
  41. >
  42. {info.num !== null ? (
  43. <div className='A2Tmain'>
  44. {info.time}:&emsp;
  45. {arr.map(v => (
  46. <Button
  47. onClick={() => btnClick(v.num)}
  48. key={v.name}
  49. type={v.num === info.num ? 'primary' : 'default'}
  50. >
  51. {v.name}
  52. </Button>
  53. ))}
  54. </div>
  55. ) : null}
  56. </Modal>
  57. )
  58. }
  59. const MemoA2timeFlag = React.memo(A2timeFlag)
  60. export default MemoA2timeFlag