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

Merge remote-tracking branch 'origin/master'

/** /**
* web端文件预览功能 * web端文件预览功能
*/ */
import React, { Component } from 'react'; import React, {Component} from 'react';
import { Modal, Popconfirm } from 'antd'; import {Modal, Popconfirm} from 'antd';
import { checkIsImage } from '@/webPublic/one_stop_public/libs/UploadCom'; import {checkIsImage} from '@/webPublic/one_stop_public/libs/UploadCom';
const FileViewer = CLIENT_TYPE == 'mobile' ? null : require('react-file-viewer'); const FileViewer = CLIENT_TYPE == 'mobile' ? null : require('react-file-viewer');
...@@ -13,6 +13,7 @@ export default class index extends Component { ...@@ -13,6 +13,7 @@ export default class index extends Component {
this.state = { this.state = {
visible: false, visible: false,
}; };
this.imageDom = null;
} }
showModal = () => { showModal = () => {
...@@ -33,13 +34,13 @@ export default class index extends Component { ...@@ -33,13 +34,13 @@ export default class index extends Component {
}); });
}; };
download = () => { download = () => {
let { path, pathName } = this.props; let {path, pathName} = this.props;
window.open(path, '_blank'); window.open(path, '_blank');
}; };
render() { render() {
let { path, pathName, width, height } = this.props; let {path, pathName, width, height} = this.props;
const { visible } = this.state; const {visible} = this.state;
let isShow = false; let isShow = false;
let type; let type;
let isImg = checkIsImage(pathName); let isImg = checkIsImage(pathName);
...@@ -53,7 +54,7 @@ export default class index extends Component { ...@@ -53,7 +54,7 @@ export default class index extends Component {
isShow = true; isShow = true;
} }
} }
if(isShow){ if (isShow) {
type = pathName.split('.'); type = pathName.split('.');
type = Array.isArray(type) && type.length && type[type.length - 1]; type = Array.isArray(type) && type.length && type[type.length - 1];
} }
...@@ -69,6 +70,7 @@ export default class index extends Component { ...@@ -69,6 +70,7 @@ export default class index extends Component {
cancelText='预览'> cancelText='预览'>
{isImg ? ( {isImg ? (
<img <img
ref={(node)=>{ this.imageDom = node;}}
style={{ style={{
width: width ? width : '100px', width: width ? width : '100px',
height: height ? height : 'auto', height: height ? height : 'auto',
...@@ -93,6 +95,8 @@ export default class index extends Component { ...@@ -93,6 +95,8 @@ export default class index extends Component {
visible={visible} visible={visible}
width={1200} width={1200}
destroyOnClose destroyOnClose
getContainer={false}
centered={true}
onOk={this.handleOk} onOk={this.handleOk}
onCancel={this.handleCancel}> onCancel={this.handleCancel}>
{type === 'pdf' ? ( {type === 'pdf' ? (
...@@ -106,8 +110,11 @@ export default class index extends Component { ...@@ -106,8 +110,11 @@ export default class index extends Component {
) : ( ) : (
<div <div
style={{ style={{
height: 600, height: 650,
}}> }}>
<a target={'_blank'} href={path}>
下载文件
</a>
{FileViewer && ( {FileViewer && (
<FileViewer <FileViewer
fileType={type} fileType={type}
......
...@@ -169,7 +169,9 @@ export default class TableSelect extends React.Component { ...@@ -169,7 +169,9 @@ export default class TableSelect extends React.Component {
dataSource, dataSource,
disabled, disabled,
} = this.props; } = this.props;
let { valueName, labelName } = this.props.json; // console.log(JSON.stringify(columns?.map((g) => g.width) ));
let { valueName, labelName } = this.props.json;
if (optionType == 'reference' && referenceObjId) { if (optionType == 'reference' && referenceObjId) {
valueName = this.props.dataColumn.referenceCodeName; valueName = this.props.dataColumn.referenceCodeName;
labelName = this.props.dataColumn.referenceNameName; labelName = this.props.dataColumn.referenceNameName;
...@@ -329,7 +331,7 @@ export default class TableSelect extends React.Component { ...@@ -329,7 +331,7 @@ export default class TableSelect extends React.Component {
size="small" size="small"
dataSource={dataSource.list} dataSource={dataSource.list}
columns={columns3} columns={columns3}
scroll={{ x: allWidth }} scroll={{ x: this.props.get === 'mobile' ? 'max-content' : allWidth }}
/> />
</> </>
)} )}
......
...@@ -24,6 +24,19 @@ export default function index(props) { ...@@ -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 { class UploadCom extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -65,11 +78,17 @@ class UploadCom extends React.Component { ...@@ -65,11 +78,17 @@ class UploadCom extends React.Component {
isSize = file => { isSize = file => {
const {limitWarnningMessage} = this.otherProps; const {limitWarnningMessage} = this.otherProps;
return new Promise((resolve, reject) => { 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 _URL = window.URL || window.webkitURL;
let img = new Image(); let img = new Image();
img.onload = function () { img.onload = function () {
let valid = img.width >= width && img.height >= height; 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(); valid ? resolve() : reject();
}; };
img.src = _URL.createObjectURL(file); img.src = _URL.createObjectURL(file);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论