A2xuZhi.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import React, { useCallback, useEffect, useRef } from 'react'
  2. import styles from './index.module.scss'
  3. import { Button, Modal } from 'antd'
  4. import MyPopconfirm from '@/components/MyPopconfirm'
  5. import ZRichTexts from '@/components/ZRichTexts'
  6. import { A2_APIgetConfig, A2_APIsetConfig } from '@/store/action/A2orderSet'
  7. import { MessageFu } from '@/utils/message'
  8. import { A2getConfigType, A2NolistIdType, A2setConfigType } from './type'
  9. type Props = {
  10. closeFu: () => void
  11. getSrc: A2getConfigType
  12. setSrc: A2setConfigType
  13. sId: A2NolistIdType
  14. }
  15. function A2xuZhi({ closeFu, getSrc, setSrc, sId }: Props) {
  16. // 富文本的ref
  17. const ZRichTextRef = useRef<any>(null)
  18. // 获取设置
  19. const getEMfu = useCallback(async () => {
  20. const res = await A2_APIgetConfig(getSrc, sId)
  21. if (res.code === 0) {
  22. // 设置富文本
  23. ZRichTextRef.current?.ritxtShowFu(JSON.parse(res.data.rtf || '{}'))
  24. }
  25. }, [getSrc, sId])
  26. useEffect(() => {
  27. getEMfu()
  28. }, [getEMfu])
  29. // 点击提交
  30. const btnOk = useCallback(async () => {
  31. // 富文本校验不通过
  32. const rtf = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
  33. const res = await A2_APIsetConfig(setSrc, { id: sId, rtf: rtf.val || '' })
  34. if (res.code === 0) {
  35. MessageFu.success('设置预约须知成功!')
  36. closeFu()
  37. }
  38. }, [closeFu, sId, setSrc])
  39. return (
  40. <Modal
  41. wrapClassName={styles.A2xuZhi}
  42. open={true}
  43. title='预约须知'
  44. footer={
  45. [] // 设置footer为空,去掉 取消 确定默认按钮
  46. }
  47. >
  48. <div className='formRow'>
  49. <ZRichTexts
  50. check={false}
  51. dirCode={'A2xuZhiText'}
  52. isLook={false}
  53. ref={ZRichTextRef}
  54. myUrl='cms/book/upload'
  55. isOne={true}
  56. upAudioBtnNone={true}
  57. otherArr={[{ key: 'moduleName', value: 'config' }]}
  58. />
  59. </div>
  60. <div className='A2Xbtn'>
  61. <MyPopconfirm txtK='取消' onConfirm={closeFu} />
  62. &emsp;
  63. <Button type='primary' onClick={btnOk}>
  64. 提交
  65. </Button>
  66. </div>
  67. </Modal>
  68. )
  69. }
  70. const MemoA2xuZhi = React.memo(A2xuZhi)
  71. export default MemoA2xuZhi