|
@@ -9,6 +9,11 @@ import TextArea from 'antd/es/input/TextArea'
|
|
import { CloudUploadOutlined, EyeOutlined, CloseOutlined } from '@ant-design/icons'
|
|
import { CloudUploadOutlined, EyeOutlined, CloseOutlined } from '@ant-design/icons'
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
import MyPopconfirm from '@/components/MyPopconfirm'
|
|
import { ImageViewer } from 'antd-mobile'
|
|
import { ImageViewer } from 'antd-mobile'
|
|
|
|
+import { MessageFu } from '@/utils/message'
|
|
|
|
+import { A8_APIsave, API_upFile } from '@/store/action/all'
|
|
|
|
+import { fileDomInitialFu } from '@/utils/domShow'
|
|
|
|
+import { FileType } from '@/types'
|
|
|
|
+import { baseURL } from '@/utils/http'
|
|
|
|
|
|
function A8proof() {
|
|
function A8proof() {
|
|
const urlObj: any = useParams()
|
|
const urlObj: any = useParams()
|
|
@@ -16,19 +21,21 @@ function A8proof() {
|
|
const canRef = useRef('')
|
|
const canRef = useRef('')
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
- if (urlObj.id) {
|
|
|
|
- canRef.current =
|
|
|
|
- urlObj.id === '1' ? '横琴粤澳深度合作区民生事务局' : '澳门街坊会联合总会广东办事处'
|
|
|
|
|
|
+ if (urlObj.val) {
|
|
|
|
+ canRef.current = urlObj.val
|
|
}
|
|
}
|
|
- }, [urlObj.id])
|
|
|
|
|
|
+ }, [urlObj.val])
|
|
|
|
|
|
- useEffect(() => {
|
|
|
|
- FormBoxRef.current?.setFieldsValue({
|
|
|
|
- name: '王大锤',
|
|
|
|
- phone: '18702025091',
|
|
|
|
- danwei: '阿三大苏打'
|
|
|
|
- })
|
|
|
|
- }, [])
|
|
|
|
|
|
+ // useEffect(() => {
|
|
|
|
+ // FormBoxRef.current?.setFieldsValue({
|
|
|
|
+ // name: '王大锤',
|
|
|
|
+ // phone: '18702025091',
|
|
|
|
+ // unit: '阿三大苏打'
|
|
|
|
+ // })
|
|
|
|
+ // }, [])
|
|
|
|
+
|
|
|
|
+ // 附件列表
|
|
|
|
+ const [fileArr, setFileArr] = useState<FileType[]>([])
|
|
|
|
|
|
// 表单的ref
|
|
// 表单的ref
|
|
const FormBoxRef = useRef<FormInstance>(null)
|
|
const FormBoxRef = useRef<FormInstance>(null)
|
|
@@ -37,28 +44,94 @@ function A8proof() {
|
|
const onFinishFailed = useCallback(() => {}, [])
|
|
const onFinishFailed = useCallback(() => {}, [])
|
|
|
|
|
|
// 通过校验点击确定
|
|
// 通过校验点击确定
|
|
- const onFinish = useCallback(async (values: any) => {
|
|
|
|
- setTitPop('succ')
|
|
|
|
- }, [])
|
|
|
|
|
|
+ const onFinish = useCallback(
|
|
|
|
+ async (values: any) => {
|
|
|
|
+ if (fileArr.length <= 0) return MessageFu.warning('请上传授权或同意文件!')
|
|
|
|
+
|
|
|
|
+ let fileIds = ''
|
|
|
|
+ fileIds = fileArr.map(v => v.id).join(',')
|
|
|
|
+ const obj = {
|
|
|
|
+ ...values,
|
|
|
|
+ fileIds,
|
|
|
|
+ type: canRef.current
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const res = await A8_APIsave(obj)
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ setTitPop('succ')
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ [fileArr]
|
|
|
|
+ )
|
|
|
|
|
|
// 打开提示弹窗
|
|
// 打开提示弹窗
|
|
const [titPop, setTitPop] = useState('')
|
|
const [titPop, setTitPop] = useState('')
|
|
|
|
|
|
- const [fileArr, setFileArr] = useState([
|
|
|
|
- {
|
|
|
|
- id: 1,
|
|
|
|
- name: '啊实打实大苏打实打实大苏打啊实打实大苏打实打实大苏打啊实打实大苏打实打实大苏打.jpg',
|
|
|
|
- src: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png'
|
|
|
|
|
|
+ const myInput = useRef<HTMLInputElement>(null)
|
|
|
|
+
|
|
|
|
+ // 上传
|
|
|
|
+ const handeUpPhoto = useCallback(
|
|
|
|
+ async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
+ if (e.target.files) {
|
|
|
|
+ // 拿到files信息
|
|
|
|
+ const filesInfo = e.target.files[0]
|
|
|
|
+ // console.log("-----", filesInfo.type);
|
|
|
|
+
|
|
|
|
+ // 校验格式
|
|
|
|
+ const type = ['image/jpeg', 'image/png', 'application/pdf']
|
|
|
|
+
|
|
|
|
+ if (!type.includes(filesInfo.type)) {
|
|
|
|
+ e.target.value = ''
|
|
|
|
+ return MessageFu.warning(`只支持.pdf,.jpg,.png格式!`)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const size = 5
|
|
|
|
+
|
|
|
|
+ // 校验大小
|
|
|
|
+ if (filesInfo.size > size * 1024 * 1024) {
|
|
|
|
+ e.target.value = ''
|
|
|
|
+ return MessageFu.warning(`最大支持${size}M!`)
|
|
|
|
+ }
|
|
|
|
+ // 创建FormData对象
|
|
|
|
+ const fd = new FormData()
|
|
|
|
+ fd.append('type', 'doc')
|
|
|
|
+ fd.append('dirCode', 'ProofDoc')
|
|
|
|
+ fd.append('moduleName', 'auth')
|
|
|
|
+ fd.append('isDb', 'true')
|
|
|
|
+ fd.append('file', filesInfo)
|
|
|
|
+
|
|
|
|
+ // if (filesInfo.size > 1 * 1024 * 1024) {
|
|
|
|
+ // // 开启压缩图片
|
|
|
|
+ // fd.append('isCompress', 'true')
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ e.target.value = ''
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ const res = await API_upFile(fd, 'wx/upload')
|
|
|
|
+ if (res.code === 0) {
|
|
|
|
+ MessageFu.success('上传成功!')
|
|
|
|
+ setFileArr([...fileArr, res.data])
|
|
|
|
+ }
|
|
|
|
+ fileDomInitialFu()
|
|
|
|
+ } catch (error) {
|
|
|
|
+ fileDomInitialFu()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- {
|
|
|
|
- id: 2,
|
|
|
|
- name: 'cccc.pdf',
|
|
|
|
- src: '//cccc.pdf'
|
|
|
|
- }
|
|
|
|
- ])
|
|
|
|
|
|
+ [fileArr]
|
|
|
|
+ )
|
|
|
|
|
|
return (
|
|
return (
|
|
<div className={styles.A8proof}>
|
|
<div className={styles.A8proof}>
|
|
|
|
+ <input
|
|
|
|
+ id='upInput'
|
|
|
|
+ type='file'
|
|
|
|
+ accept='.pdf,.jpg,.png'
|
|
|
|
+ ref={myInput}
|
|
|
|
+ onChange={e => handeUpPhoto(e)}
|
|
|
|
+ />
|
|
|
|
+
|
|
<TopCom txt='团体认证' />
|
|
<TopCom txt='团体认证' />
|
|
<div className='A8main'>
|
|
<div className='A8main'>
|
|
<div className='A8Center'>
|
|
<div className='A8Center'>
|
|
@@ -101,7 +174,7 @@ function A8proof() {
|
|
<Form.Item
|
|
<Form.Item
|
|
className='A8Text'
|
|
className='A8Text'
|
|
label='单位名称'
|
|
label='单位名称'
|
|
- name='danwei'
|
|
|
|
|
|
+ name='unit'
|
|
rules={[{ required: true, message: '请输入单位名称!' }]}
|
|
rules={[{ required: true, message: '请输入单位名称!' }]}
|
|
// getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
// getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
>
|
|
>
|
|
@@ -119,6 +192,7 @@ function A8proof() {
|
|
<div className='A8K2ll_2'>仅限PDF,jpg,png格式;大小不超过5M;最多3个文件</div>
|
|
<div className='A8K2ll_2'>仅限PDF,jpg,png格式;大小不超过5M;最多3个文件</div>
|
|
</div>
|
|
</div>
|
|
<div
|
|
<div
|
|
|
|
+ onClick={() => myInput.current?.click()}
|
|
className='A8K2rr'
|
|
className='A8K2rr'
|
|
style={{
|
|
style={{
|
|
opacity: fileArr.length >= 3 ? '0' : '1',
|
|
opacity: fileArr.length >= 3 ? '0' : '1',
|
|
@@ -131,17 +205,19 @@ function A8proof() {
|
|
</div>
|
|
</div>
|
|
{fileArr.length ? (
|
|
{fileArr.length ? (
|
|
<div className='A8lKa2File'>
|
|
<div className='A8lKa2File'>
|
|
- {fileArr.map(item => (
|
|
|
|
|
|
+ {fileArr.map((item, index) => (
|
|
<div key={item.id} className='A8Frow'>
|
|
<div key={item.id} className='A8Frow'>
|
|
- <div className='A8Frowll'>{item.name}</div>
|
|
|
|
|
|
+ <div className='A8Frowll'>{item.fileName}</div>
|
|
<div className='A8Frowrr'>
|
|
<div className='A8Frowrr'>
|
|
- {item.name.includes('.pdf') || item.name.includes('.PDF') ? null : (
|
|
|
|
- <EyeOutlined onClick={() => ImageViewer.show({ image: item.src })} />
|
|
|
|
|
|
+ {item.fileName.endsWith('.pdf') || item.fileName.endsWith('.PDF') ? null : (
|
|
|
|
+ <EyeOutlined
|
|
|
|
+ onClick={() => ImageViewer.show({ image: baseURL + item.filePath })}
|
|
|
|
+ />
|
|
)}
|
|
)}
|
|
|
|
|
|
<MyPopconfirm
|
|
<MyPopconfirm
|
|
txtK='删除'
|
|
txtK='删除'
|
|
- onConfirm={() => setFileArr(fileArr.filter(v => v.id !== item.id))}
|
|
|
|
|
|
+ onConfirm={() => setFileArr(fileArr.filter((v, i) => i !== index))}
|
|
Dom={<CloseOutlined className='clearCover' />}
|
|
Dom={<CloseOutlined className='clearCover' />}
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|