import React from 'react'; import config from "../../config"; import { connect } from 'dva'; import { checkImg } from "../../utils/common"; import FileViewer from 'react-file-viewer'; //传入附件提供查看功能 //弹窗 listFiles showFile 多附件与单附件查看 class FileViewerShow extends React.Component { constructor(props) { super(props) this.state = { idRadim: '', isPageCenter: true, data: [] } }; componentDidMount() { if (this.props.data?.listFiles || this.props.data?.showFile) this.initInfo(this.props.data); } componentWillReceiveProps(NextProps) { if (NextProps.data?.key && this.props.data?.key != NextProps.data?.key) { if (NextProps.data?.listFiles || NextProps.data?.showFile) { this.initInfo(NextProps.data); } } } initInfo(paramInt) { if (!paramInt.listFiles && paramInt.showFile) { paramInt.listFiles = [] paramInt.listFiles.push(paramInt.showFile) } if (paramInt.listFiles && paramInt.listFiles.length > 0) { var isPageCenter = true var fileName = paramInt.listFiles[0].Nav_ImgFile.FILE_NAME if (fileName.indexOf('.doc') > -1 || fileName.indexOf('.docx') > -1 || fileName.indexOf('.xls') > -1 || fileName.indexOf('.xlsx') > -1) { isPageCenter = false } this.setState({ data: paramInt.listFiles, isPageCenter: isPageCenter }); } else { //去数据库查找对应的信息 //暂时不处理 } } //显示附件查看 showFilesView = (listFile, imgHost) => {//FileViewer, var result = [] if (listFile == null || listFile.length < 1) { return result } var listfilesPath = [] var listfilesType = [] var listfilesIsImage = [] var percent = 0.75 if (window.screen.height < 1000) { percent = 0.65 } var height = window.screen.height * percent listFile.forEach(e => { listfilesIsImage.push(checkImg(e.Nav_ImgFile.FILE_NAME)) listfilesPath.push(e.Nav_ImgFile.FILE_PATH) if (e.Nav_ImgFile.FILE_TYPE.indexOf('application/msword') > -1 || e.Nav_ImgFile.FILE_TYPE.indexOf('application/vnd.openxmlformats-officedocument') > -1 || e.Nav_ImgFile.FILE_TYPE.indexOf('application/vnd.ms-excel') > -1 || e.Nav_ImgFile.FILE_TYPE.indexOf('application/vnd.openxmlformats') > -1 || e.Nav_ImgFile.FILE_TYPE.indexOf('application/xml') > -1 || e.Nav_ImgFile.FILE_TYPE.indexOf('text/') > -1) { listfilesType.push(e.Nav_ImgFile.FILE_PATH.split('.')[1]) } else { listfilesType.push(e.Nav_ImgFile.FILE_TYPE.split('/')[1]) } }); if (listfilesPath == null || listfilesPath.length < 1) return result // mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/130.0.0.0 safari/537.36 edg/130.0.0.0 // mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/109.0.0.0 safari/537.36 // mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/122.0.6261.95 safari/537.36 var ua = navigator.userAgent.toLowerCase(); var isShowdox = true if (ua.indexOf('edg') > -1) { isShowdox = false } // 显示思路 图片 img txt iframe 文件 FileViewer 其他 a listfilesPath.forEach((item, i) => { try { result.push(
) if (listfilesIsImage[i] == true) { result.push(