index.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import React, { useCallback, useEffect, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { Button } from 'antd'
  4. import MyTable from '@/components/MyTable'
  5. import { useDispatch, useSelector } from 'react-redux'
  6. import { RootState } from '@/store'
  7. import { B1_APIgetList } from '@/store/action/B1exhibit'
  8. import { B1tableC } from '@/utils/tableData'
  9. import B1edit from './B1edit'
  10. import { A2_APIgetConfig, A2_APIsetConfig } from '@/store/action/A2orderSet'
  11. import { MessageFu } from '@/utils/message'
  12. import A2NoTime from '../A2orderSet/A2NoTime'
  13. import A2xuZhi from '../A2orderSet/A2xuZhi'
  14. function B1exhibit() {
  15. const dispatch = useDispatch()
  16. const getListFu = useCallback(() => {
  17. dispatch(B1_APIgetList())
  18. }, [dispatch])
  19. useEffect(() => {
  20. getListFu()
  21. }, [getListFu])
  22. const { list } = useSelector((state: RootState) => state.B1exhibit)
  23. // 编辑
  24. const [edit, setEdit] = useState(false)
  25. // 1111111111111不可预约日期--------------开始
  26. const noListRef = useRef('')
  27. const getNoListFu = useCallback(async () => {
  28. const res = await A2_APIgetConfig('cms/configExhibition/getConfig', 15)
  29. if (res.code === 0) {
  30. noListRef.current = res.data.rtf
  31. }
  32. }, [])
  33. useEffect(() => {
  34. getNoListFu()
  35. }, [getNoListFu])
  36. const [noTxt, setNoTxt] = useState('')
  37. // 点击提交或者取消
  38. const A2NoBtn = useCallback(
  39. async (val: string[] | null) => {
  40. let str = ''
  41. if (val) {
  42. const arr = val.map(v => v.replaceAll('-', '月') + '日')
  43. str = arr.join(',')
  44. }
  45. const res = await A2_APIsetConfig('cms/configExhibition/setConfig', { id: 15, rtf: str })
  46. if (res.code === 0) {
  47. MessageFu.success('设置不可预约日期成功!')
  48. getNoListFu()
  49. setNoTxt('')
  50. }
  51. },
  52. [getNoListFu]
  53. )
  54. // 1111111111111不可预约日期--------------结束
  55. // 2222222222------------- 预约须知---------开始
  56. const [xuZhi, setXuZhi] = useState(false)
  57. // 2222222222------------- 预约须知---------结束
  58. return (
  59. <div className={styles.B1exhibit}>
  60. <div className='pageTitle'>展馆预约设置{edit ? ' - 编辑' : null}</div>
  61. <div className='B1top'>
  62. <Button type='primary' onClick={() => setNoTxt(noListRef.current || '空')}>
  63. 设置不可预约日期
  64. </Button>
  65. &emsp;
  66. <Button type='primary' onClick={() => setXuZhi(true)}>
  67. 设置预约需知
  68. </Button>
  69. &emsp;
  70. <Button type='primary' onClick={() => setEdit(true)}>
  71. 编辑
  72. </Button>
  73. </div>
  74. <MyTable list={list} columnsTemp={B1tableC} pagingInfo={false} isNull='闭馆' />
  75. {/* 编辑 */}
  76. {edit ? <B1edit list={list} closeFu={() => setEdit(false)} editTableFu={getListFu} /> : null}
  77. {/* 不可预约日期设置 */}
  78. {noTxt ? (
  79. <A2NoTime
  80. num={20}
  81. baseTime={noTxt}
  82. editFu={val => A2NoBtn(val)}
  83. closeFu={() => setNoTxt('')}
  84. />
  85. ) : null}
  86. {/*预约须知 */}
  87. {xuZhi ? (
  88. <A2xuZhi
  89. setSrc='cms/configExhibition/setConfig'
  90. getSrc='cms/configExhibition/getConfig'
  91. sId={16}
  92. closeFu={() => setXuZhi(false)}
  93. />
  94. ) : null}
  95. </div>
  96. )
  97. }
  98. const MemoB1exhibit = React.memo(B1exhibit)
  99. export default MemoB1exhibit