A2timeFlag.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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) return MessageFu.info(`当前已经是${info.num ? '' : '不'}可预约状态!`)
  27. closeFu(val as 0)
  28. },
  29. [closeFu, info.num]
  30. )
  31. return (
  32. <Modal
  33. wrapClassName={styles.A2timeFlag}
  34. open={true}
  35. title=''
  36. onCancel={() => closeFu(null)}
  37. footer={
  38. [] // 设置footer为空,去掉 取消 确定默认按钮
  39. }
  40. >
  41. {info.num !== null ? (
  42. <div className='A2Tmain'>
  43. {info.time}:&emsp;
  44. {arr.map(v => (
  45. <Button
  46. onClick={() => btnClick(v.num)}
  47. key={v.name}
  48. type={v.num === info.num ? 'primary' : 'default'}
  49. >
  50. {v.name}
  51. </Button>
  52. ))}
  53. </div>
  54. ) : null}
  55. </Modal>
  56. )
  57. }
  58. const MemoA2timeFlag = React.memo(A2timeFlag)
  59. export default MemoA2timeFlag