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

23524 签约审核--已处理--详情,,打印调整

上级 3dfd78b5
import React from 'react'; import React from 'react';
import { Button, Icon, message, Modal, Upload } from 'antd'; import {Button, Icon, message, Modal, Upload} from 'antd';
import { queryApiActionPath } from '../utils/queryConfig'; import {queryApiActionPath} from '../utils/queryConfig';
import config from '@/webPublic/one_stop_public/config'; import config from '@/webPublic/one_stop_public/config';
import styles from './style.less'; import styles from './style.less';
import UploadComDiyForQnZy from '@/webPublic/one_stop_public/libs/UploadComDiyForQnZy'; import UploadComDiyForQnZy from '@/webPublic/one_stop_public/libs/UploadComDiyForQnZy';
...@@ -40,7 +40,8 @@ class UploadCom extends React.Component { ...@@ -40,7 +40,8 @@ class UploadCom extends React.Component {
try { try {
this.otherProps = new Function(this.otherProps)(); this.otherProps = new Function(this.otherProps)();
console.log(this.otherProps); console.log(this.otherProps);
} catch (e) {} } catch (e) {
}
} }
} }
...@@ -62,12 +63,12 @@ class UploadCom extends React.Component { ...@@ -62,12 +63,12 @@ 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} = 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;
valid ? resolve() : reject(); valid ? resolve() : reject();
}; };
...@@ -97,11 +98,11 @@ class UploadCom extends React.Component { ...@@ -97,11 +98,11 @@ class UploadCom extends React.Component {
if (info.file.status === 'done') { if (info.file.status === 'done') {
message.success(`${info.file.name} 上传成功`); message.success(`${info.file.name} 上传成功`);
const files = this.state.files; const files = this.state.files;
files.push({ path: info.file.response, name: info.file.name }); files.push({path: info.file.response, name: info.file.name});
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.setState({ files }); this.setState({files});
} }
this.triggerChange({ files }); this.triggerChange({files});
} else if (info.file.status === 'error') { } else if (info.file.status === 'error') {
message.error(`${info.file.name} 上传失败`); message.error(`${info.file.name} 上传失败`);
} }
...@@ -115,14 +116,14 @@ class UploadCom extends React.Component { ...@@ -115,14 +116,14 @@ class UploadCom extends React.Component {
} }
} }
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.setState({ files }); this.setState({files});
} }
this.triggerChange({ files }); this.triggerChange({files});
}; };
render() { render() {
const { files, previewVisible, previewImage } = this.state; const {files, previewVisible, previewImage} = this.state;
const { isMultiple, accept, btnName, disabled } = this.props; const {isMultiple, accept, btnName, disabled} = this.props;
const props = { const props = {
name: 'file', name: 'file',
multiple: isMultiple, multiple: isMultiple,
...@@ -139,19 +140,19 @@ class UploadCom extends React.Component { ...@@ -139,19 +140,19 @@ class UploadCom extends React.Component {
<Upload {...props} disabled={disabled}> <Upload {...props} disabled={disabled}>
{!disabled && ( {!disabled && (
<Button> <Button>
<Icon type="upload" /> <Icon type="upload"/>
{btnName ? btnName : '上传附件'} {btnName ? btnName : '上传附件'}
</Button> </Button>
)} )}
</Upload> </Upload>
<ul style={{ paddingLeft: 8, display: 'flex' }}> <ul className={styles.ulImageList}>
{(files || []).map(f => { {(Array.isArray(files) && files || []).map(f => {
if (f.path && checkIsImage(f.path)) { if (f.path && checkIsImage(f.path)) {
return ( return (
<li key={f.path} className={styles.preview_img}> <li key={f.path} className={styles.preview_img}>
<div className={styles.preview_div}> <div className={styles.preview_div}>
<img <img
style={{ width: '100px', height: 'auto' }} style={{width: '100px', height: 'auto'}}
className={styles.img} className={styles.img}
src={queryApiActionPath() + f.path} src={queryApiActionPath() + f.path}
/> />
...@@ -165,12 +166,12 @@ class UploadCom extends React.Component { ...@@ -165,12 +166,12 @@ class UploadCom extends React.Component {
}); });
}} }}
> >
<Icon type="eye" className={styles.icon_eye} /> <Icon type="eye" className={styles.icon_eye}/>
</div> </div>
</div> </div>
{!disabled && ( {!disabled && (
<Icon <Icon
style={{ marginLeft: 10 }} style={{marginLeft: 10}}
type="delete" type="delete"
onClick={this.remove.bind(this, f.path)} onClick={this.remove.bind(this, f.path)}
/> />
...@@ -185,7 +186,7 @@ class UploadCom extends React.Component { ...@@ -185,7 +186,7 @@ class UploadCom extends React.Component {
</a>{' '} </a>{' '}
{!disabled && ( {!disabled && (
<Icon <Icon
style={{ marginLeft: 10 }} style={{marginLeft: 10}}
type="delete" type="delete"
onClick={this.remove.bind(this, f.path)} onClick={this.remove.bind(this, f.path)}
/> />
...@@ -197,10 +198,10 @@ class UploadCom extends React.Component { ...@@ -197,10 +198,10 @@ class UploadCom extends React.Component {
<Modal <Modal
visible={previewVisible} visible={previewVisible}
footer={null} footer={null}
onCancel={() => this.setState({ previewVisible: false })} onCancel={() => this.setState({previewVisible: false})}
width={'90vw'} width={'90vw'}
> >
<img alt="example" style={{ width: '100%', height: 'auto' }} src={previewImage} /> <img alt="example" style={{width: '100%', height: 'auto'}} src={previewImage}/>
</Modal> </Modal>
</div> </div>
); );
......
...@@ -267,3 +267,17 @@ ...@@ -267,3 +267,17 @@
} }
} }
} }
.ulImageList{
display: grid;
grid-row: auto;
grid-template-columns: repeat(auto-fill, 130px);
grid-auto-flow: column;
justify-items: start;
align-items: center;
column-gap: 10px;
.borderLi{
border: 1px solid gray;
display: grid;
padding: 5px;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论