index.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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.replace('-', '年').replace('-', '月') + '日')
  43. str = arr.join(',')
  44. }
  45. const res = await A2_APIsetConfig('cms/configExhibition/setConfig', {
  46. id: 15,
  47. rtf: str
  48. })
  49. if (res.code === 0) {
  50. MessageFu.success('设置不可预约日期成功!')
  51. getNoListFu()
  52. setNoTxt('')
  53. }
  54. },
  55. [getNoListFu]
  56. )
  57. // 1111111111111不可预约日期--------------结束
  58. // 2222222222------------- 预约须知---------开始
  59. const [xuZhi, setXuZhi] = useState(false)
  60. // 2222222222------------- 预约须知---------结束
  61. return (
  62. <div className={styles.B1exhibit}>
  63. <div className='pageTitle'>展馆预约设置{edit ? ' - 编辑' : null}</div>
  64. <div className='B1top'>
  65. <Button type='primary' onClick={() => setNoTxt(noListRef.current || '空')}>
  66. 设置不可预约日期
  67. </Button>
  68. &emsp;
  69. <Button type='primary' onClick={() => setXuZhi(true)}>
  70. 设置预约需知
  71. </Button>
  72. &emsp;
  73. <Button type='primary' onClick={() => setEdit(true)}>
  74. 编辑
  75. </Button>
  76. </div>
  77. <MyTable list={list} columnsTemp={B1tableC} pagingInfo={false} isNull='闭馆' />
  78. {/* 编辑 */}
  79. {edit ? (
  80. <B1edit list={list} closeFu={() => setEdit(false)} editTableFu={getListFu} />
  81. ) : null}
  82. {/* 不可预约日期设置 */}
  83. {noTxt ? (
  84. <A2NoTime
  85. num={20}
  86. baseTime={noTxt}
  87. editFu={val => A2NoBtn(val)}
  88. closeFu={() => setNoTxt('')}
  89. />
  90. ) : null}
  91. {/*预约须知 */}
  92. {xuZhi ? (
  93. <A2xuZhi
  94. setSrc='cms/configExhibition/setConfig'
  95. getSrc='cms/configExhibition/getConfig'
  96. sId={16}
  97. closeFu={() => setXuZhi(false)}
  98. />
  99. ) : null}
  100. </div>
  101. )
  102. }
  103. const MemoB1exhibit = React.memo(B1exhibit)
  104. export default MemoB1exhibit