index.tsx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. import React, { useCallback, useEffect, useRef, useState } from 'react'
  2. import styles from './index.module.scss'
  3. import { useParams } from 'react-router-dom'
  4. import TopCom from '@/components/TopCom'
  5. import { Button, Form, FormInstance, Input } from 'antd'
  6. import ZinfoPop from '@/components/ZinfoPop'
  7. import history from '@/utils/history'
  8. import TextArea from 'antd/es/input/TextArea'
  9. import { CloudUploadOutlined, EyeOutlined, CloseOutlined } from '@ant-design/icons'
  10. import MyPopconfirm from '@/components/MyPopconfirm'
  11. import { ImageViewer } from 'antd-mobile'
  12. function A8proof() {
  13. const urlObj: any = useParams()
  14. const canRef = useRef('')
  15. useEffect(() => {
  16. if (urlObj.id) {
  17. canRef.current =
  18. urlObj.id === '1' ? '横琴粤澳深度合作区民生事务局' : '澳门街坊会联合总会广东办事处'
  19. }
  20. }, [urlObj.id])
  21. useEffect(() => {
  22. FormBoxRef.current?.setFieldsValue({
  23. name: '王大锤',
  24. phone: '18702025091',
  25. danwei: '阿三大苏打'
  26. })
  27. }, [])
  28. // 表单的ref
  29. const FormBoxRef = useRef<FormInstance>(null)
  30. // 没有通过校验
  31. const onFinishFailed = useCallback(() => {}, [])
  32. // 通过校验点击确定
  33. const onFinish = useCallback(async (values: any) => {
  34. setTitPop('succ')
  35. }, [])
  36. // 打开提示弹窗
  37. const [titPop, setTitPop] = useState('')
  38. const [fileArr, setFileArr] = useState([
  39. {
  40. id: 1,
  41. name: '啊实打实大苏打实打实大苏打啊实打实大苏打实打实大苏打啊实打实大苏打实打实大苏打.jpg',
  42. src: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
  43. },
  44. {
  45. id: 2,
  46. name: 'cccc.pdf',
  47. src: '//cccc.pdf'
  48. }
  49. ])
  50. return (
  51. <div className={styles.A8proof}>
  52. <TopCom txt='团体认证' />
  53. <div className='A8main'>
  54. <div className='A8Center'>
  55. <Form
  56. ref={FormBoxRef}
  57. name='basic'
  58. // labelCol={{ span: 3 }}
  59. onFinish={onFinish}
  60. onFinishFailed={onFinishFailed}
  61. autoComplete='off'
  62. scrollToFirstError
  63. >
  64. {/* 第一个卡片 */}
  65. <div className='A8lKa'>
  66. <div className='A8tit'>负责人信息</div>
  67. <Form.Item
  68. label='负责人姓名'
  69. name='name'
  70. rules={[{ required: true, message: '请输入负责人姓名!' }]}
  71. getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
  72. >
  73. <Input placeholder='请输入内容,不超过6个字' maxLength={6} />
  74. </Form.Item>
  75. <Form.Item
  76. label='联系方式'
  77. name='phone'
  78. rules={[
  79. { required: true, message: '请输入联系方式!' },
  80. {
  81. pattern: /^1[3-9][0-9]{9}$/,
  82. message: '请输入正确格式的手机号!'
  83. }
  84. ]}
  85. >
  86. <Input placeholder='请输入11位数字' maxLength={11} />
  87. </Form.Item>
  88. <Form.Item
  89. className='A8Text'
  90. label='单位名称'
  91. name='danwei'
  92. rules={[{ required: true, message: '请输入单位名称!' }]}
  93. // getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
  94. >
  95. <TextArea placeholder='请输入内容,不超过50个字' maxLength={50} />
  96. </Form.Item>
  97. </div>
  98. {/* 第二个卡片 */}
  99. <div className='A8lKa A8lKa2'>
  100. <div className='A8lKa2Top'>
  101. <div className='A8K2ll'>
  102. <div className='A8K2ll_1'>
  103. <span>* </span>上传授权或同意文件
  104. </div>
  105. <div className='A8K2ll_2'>仅限PDF,jpg,png格式;大小不超过5M;最多3个文件</div>
  106. </div>
  107. <div
  108. className='A8K2rr'
  109. style={{
  110. opacity: fileArr.length >= 3 ? '0' : '1',
  111. pointerEvents: fileArr.length >= 3 ? 'none' : 'auto'
  112. }}
  113. >
  114. <CloudUploadOutlined />
  115. 上传
  116. </div>
  117. </div>
  118. {fileArr.length ? (
  119. <div className='A8lKa2File'>
  120. {fileArr.map(item => (
  121. <div key={item.id} className='A8Frow'>
  122. <div className='A8Frowll'>{item.name}</div>
  123. <div className='A8Frowrr'>
  124. {item.name.includes('.pdf') || item.name.includes('.PDF') ? null : (
  125. <EyeOutlined onClick={() => ImageViewer.show({ image: item.src })} />
  126. )}
  127. <MyPopconfirm
  128. txtK='删除'
  129. onConfirm={() => setFileArr(fileArr.filter(v => v.id !== item.id))}
  130. Dom={<CloseOutlined className='clearCover' />}
  131. />
  132. </div>
  133. </div>
  134. ))}
  135. </div>
  136. ) : null}
  137. </div>
  138. <Button className='A8btn' type='primary' htmlType='submit'>
  139. 提交
  140. </Button>
  141. </Form>
  142. </div>
  143. </div>
  144. {/* 预约成功的弹窗 */}
  145. {titPop ? (
  146. <ZinfoPop proof={true} type={titPop as 'succ'} callFu={() => history.push('/my?m=1')} />
  147. ) : null}
  148. </div>
  149. )
  150. }
  151. const MemoA8proof = React.memo(A8proof)
  152. export default MemoA8proof