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

Merge remote-tracking branch 'origin/master'

/**
* 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}
......
......@@ -169,6 +169,8 @@ export default class TableSelect extends React.Component {
dataSource,
disabled,
} = this.props;
// console.log(JSON.stringify(columns?.map((g) => g.width) ));
let { valueName, labelName } = this.props.json;
if (optionType == 'reference' && referenceObjId) {
valueName = this.props.dataColumn.referenceCodeName;
......@@ -329,7 +331,7 @@ export default class TableSelect extends React.Component {
size="small"
dataSource={dataSource.list}
columns={columns3}
scroll={{ x: allWidth }}
scroll={{ x: this.props.get === 'mobile' ? 'max-content' : allWidth }}
/>
</>
)}
......
......@@ -24,6 +24,19 @@ export default function index(props) {
}
}
/**
*
* otherProps: {
* limitImageSize: {
* width: number// 限制上传的图片的最小宽度
* height: number// 限制上传的图片的最小高度
* widthMinusHeight: number// 限制必须宽度大于高度 且 宽度 - 高度 >= widthMinusHeight
* }
* limitWarnningMessage: string// 当图片不满足限制条件时 提示语句
* limitImageInfo: string// 在上传按钮旁展示的提示语句
* }
* */
class UploadCom extends React.Component {
constructor(props) {
super(props);
......@@ -65,11 +78,17 @@ class UploadCom extends React.Component {
isSize = file => {
const {limitWarnningMessage} = this.otherProps;
return new Promise((resolve, reject) => {
let {width, height} = this.otherProps.limitImageSize;
let {width, height, widthMinusHeight} = this.otherProps.limitImageSize;
let _URL = window.URL || window.webkitURL;
let img = new Image();
img.onload = function () {
let valid = img.width >= width && img.height >= height;
if(!!widthMinusHeight && valid){
if((img.width - img.height) < widthMinusHeight){
// widthMinusHeight: number// 限制必须宽度大于高度 且 宽度 - 高度 >= widthMinusHeight
valid = false;
}
}
valid ? resolve() : reject();
};
img.src = _URL.createObjectURL(file);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论