提交 e8a67704 authored 作者: 钟是志's avatar 钟是志

附件上传的预览图片组件修改

上级 ad18dfa9
/**
* web端文件预览功能
*/
import React, { Component } from 'react';
import { Modal, Popconfirm } from 'antd';
import { checkIsImage } from '@/webPublic/one_stop_public/libs/UploadCom';
import React, {Component} from 'react';
import {Modal, Popconfirm} from 'antd';
import {checkIsImage} from '@/webPublic/one_stop_public/libs/UploadCom';
const FileViewer = CLIENT_TYPE == 'mobile' ? null : require('react-file-viewer');
......@@ -13,6 +13,7 @@ export default class index extends Component {
this.state = {
visible: false,
};
this.imageDom = null;
}
showModal = () => {
......@@ -33,13 +34,13 @@ export default class index extends Component {
});
};
download = () => {
let { path, pathName } = this.props;
let {path, pathName} = this.props;
window.open(path, '_blank');
};
render() {
let { path, pathName, width, height } = this.props;
const { visible } = this.state;
let {path, pathName, width, height} = this.props;
const {visible} = this.state;
let isShow = false;
let type;
let isImg = checkIsImage(pathName);
......@@ -53,7 +54,7 @@ export default class index extends Component {
isShow = true;
}
}
if(isShow){
if (isShow) {
type = pathName.split('.');
type = Array.isArray(type) && type.length && type[type.length - 1];
}
......@@ -69,6 +70,7 @@ export default class index extends Component {
cancelText='预览'>
{isImg ? (
<img
ref={(node)=>{ this.imageDom = node;}}
style={{
width: width ? width : '100px',
height: height ? height : 'auto',
......@@ -93,6 +95,8 @@ export default class index extends Component {
visible={visible}
width={1200}
destroyOnClose
getContainer={false}
centered={true}
onOk={this.handleOk}
onCancel={this.handleCancel}>
{type === 'pdf' ? (
......@@ -106,8 +110,11 @@ export default class index extends Component {
) : (
<div
style={{
height: 600,
height: 650,
}}>
<a target={'_blank'} href={path}>
下载文件
</a>
{FileViewer && (
<FileViewer
fileType={type}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论