import React, { useCallback, useMemo, useState } from 'react' import { Upload, Button, UploadProps, Select } from 'antd' import { InboxOutlined } from '@ant-design/icons' import { MessageFu } from '@/utils/message' import styles from './index.module.scss' import { B1Xtype } from '@/pages/B_enterTibet/B1collect/data' import { baseURL } from '@/utils/http' import { fileTypeRes } from '@/store/action/layout' import { getTokenFu } from '@/utils/storage' import history from '@/utils/history' import { API_C2dels } from '@/store/action/C2files' import MyPopconfirm from '../MyPopconfirm' import { DeleteOutlined } from '@ant-design/icons' const { Dragger } = Upload type Props = { tableList: B1Xtype[] moduleId: number isShow: boolean closeFu: () => void succFu: (obj: any) => void } function ZupFile({ tableList, moduleId, isShow, closeFu, succFu }: Props) { // 附件列表 const [fileList, setFileList] = useState([]) // const timeRef = useRef(-1) const FileProps: UploadProps = { name: 'file', // 支持上传文件夹 directory: true, multiple: true, action: baseURL + 'cms/orderCollect/upload', headers: { token: getTokenFu() }, // 上传的额外参数 data: file => ({ dirCode: 'collectUpFiles', isDb: 'true', type: fileTypeRes(file.name), moduleId, isCompress: 'true' }), fileList, onChange(info: any) { setFileList([...info.fileList]) const { status } = info.file // 检查请求状态 const response = info.file.response || {} if (status !== 'uploading') { if (response.code !== 0) { setFileList(info.fileList.filter((v: any) => v.uid !== info.file.uid)) MessageFu.error(`${info.file.name} 上传失败;${response.msg}`) } if (response.code === 5001 || response.code === 5002) { MessageFu.warning('登录失效!') history.push('/login') return false } // console.log(info.file, info.fileList); } if (status === 'done' && response.code === 0) { // console.log("-----", info); setFileList( info.fileList.map((v: any) => ({ ...v, mySelect: info.file.uid === v.uid ? { id: info.file.response.data.id, goodsId: undefined, name: info.file.name } : v.mySelect })) ) } else if (status === 'error') { MessageFu.error(`${info.file.name} 上传失败.`) // 去掉列表中的失败状态文件 setFileList(info.fileList.filter((v: any) => v.uid !== info.file.uid)) } }, // 自定义列表 itemRender: (originNode, file: any) => { const obj = file.mySelect || { goodsId: undefined } return ( {originNode} {file.status === 'done' ? ( <>