|  | @@ -30,6 +30,7 @@ export default function FileModal(props: iFileModalProps) {
 | 
	
		
			
				|  |  |    const { dataId = "", visible = false, onCancel, dataType = 1, showUpload = false, uploadCallBack } = props
 | 
	
		
			
				|  |  |    const [ files, setFiles ] = useState<Array<iFileModalState>>([])
 | 
	
		
			
				|  |  |    const [ total, setTotal ] = useState<number>(0)
 | 
	
		
			
				|  |  | +  const [ fileList, setFileList ] = useState<UploadFile[]>([])
 | 
	
		
			
				|  |  |    const [ OSSData, setOssData ] = useState<iOSSData>({
 | 
	
		
			
				|  |  |      dir: '',
 | 
	
		
			
				|  |  |      expire: '',
 | 
	
	
		
			
				|  | @@ -38,6 +39,7 @@ export default function FileModal(props: iFileModalProps) {
 | 
	
		
			
				|  |  |      policy: '',
 | 
	
		
			
				|  |  |      signature: ''
 | 
	
		
			
				|  |  |    })
 | 
	
		
			
				|  |  | +  let curFileIndex = 0
 | 
	
		
			
				|  |  |    useEffect(() => {
 | 
	
		
			
				|  |  |      if (props.visible) {
 | 
	
		
			
				|  |  |        initOssData()
 | 
	
	
		
			
				|  | @@ -52,30 +54,42 @@ export default function FileModal(props: iFileModalProps) {
 | 
	
		
			
				|  |  |        setTotal(total)
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  const saveFiles = async (newFileList: iFile[]) => {
 | 
	
		
			
				|  |  | +    console.log(newFileList)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    const { code = -1 } = await apiSaveFileInfo(newFileList, consts.DATA_TYPE.RETURN, dataId)
 | 
	
		
			
				|  |  | +    if (code === consts.RET_CODE.SUCCESS) {
 | 
	
		
			
				|  |  | +      initData()
 | 
	
		
			
				|  |  | +      uploadCallBack && uploadCallBack()
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    // 上传文件改变时的状态
 | 
	
		
			
				|  |  | -  const onChange = async (info: UploadChangeParam) => {
 | 
	
		
			
				|  |  | +  const onChange = (info: UploadChangeParam) => {
 | 
	
		
			
				|  |  |      const { status } = info.file
 | 
	
		
			
				|  |  | -    if (status !== 'uploading') {
 | 
	
		
			
				|  |  | -      // console.log(info.file, info.fileList)
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | +    // if (status !== 'uploading') {
 | 
	
		
			
				|  |  | +    // }
 | 
	
		
			
				|  |  |      if (status === 'done') {
 | 
	
		
			
				|  |  | -      // message.success(`${info.file.name} 上传成功`)
 | 
	
		
			
				|  |  | -      const newFileList: iFile[] = [
 | 
	
		
			
				|  |  | -        {
 | 
	
		
			
				|  |  | +      curFileIndex++
 | 
	
		
			
				|  |  | +      if (curFileIndex === info.fileList.length) {
 | 
	
		
			
				|  |  | +        const newFileList: iFile[] = info.fileList.map(item => ({
 | 
	
		
			
				|  |  |            createTime: new Date(),
 | 
	
		
			
				|  |  | -          filepath: info.file.url,
 | 
	
		
			
				|  |  | -          filename: info.file.name
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -      ]
 | 
	
		
			
				|  |  | -      const { code = -1 } = await apiSaveFileInfo(newFileList, consts.DATA_TYPE.RETURN, dataId)
 | 
	
		
			
				|  |  | -      if (code === consts.RET_CODE.SUCCESS) {
 | 
	
		
			
				|  |  | -        initData()
 | 
	
		
			
				|  |  | -        uploadCallBack && uploadCallBack()
 | 
	
		
			
				|  |  | +            filepath: item.url,
 | 
	
		
			
				|  |  | +            filename: item.name
 | 
	
		
			
				|  |  | +        }))
 | 
	
		
			
				|  |  | +        saveFiles(newFileList)
 | 
	
		
			
				|  |  | +        setFileList([])
 | 
	
		
			
				|  |  | +      } else {
 | 
	
		
			
				|  |  | +        setFileList(info.fileList)
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      } else if (status === 'error') {
 | 
	
		
			
				|  |  |        message.error(`${info.file.name} 上传失败`)
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    // 初始化、获取签名
 | 
	
		
			
				|  |  |    const initOssData = async () => {
 | 
	
		
			
				|  |  |      try {
 | 
	
	
		
			
				|  | @@ -175,6 +189,7 @@ export default function FileModal(props: iFileModalProps) {
 | 
	
		
			
				|  |  |            <div className="pi-mg-bottom-10">
 | 
	
		
			
				|  |  |              <Dragger
 | 
	
		
			
				|  |  |                name="file"
 | 
	
		
			
				|  |  | +              fileList={fileList}
 | 
	
		
			
				|  |  |                action={OSSData.host}
 | 
	
		
			
				|  |  |                multiple={true}
 | 
	
		
			
				|  |  |                onChange={onChange}
 |