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

签名组件优化

web端 移动端 都搞成弹窗签名
上级 33d0a421
...@@ -54,7 +54,8 @@ export default class Index extends Component { ...@@ -54,7 +54,8 @@ export default class Index extends Component {
super(props); super(props);
const value = props.value; const value = props.value;
this.state = { this.state = {
url: value || getUserInfo().userSign, // url: value || getUserInfo().userSign,
url: value,
showModal: false, showModal: false,
}; };
} }
...@@ -208,6 +209,70 @@ export default class Index extends Component { ...@@ -208,6 +209,70 @@ export default class Index extends Component {
</Modal>); </Modal>);
}; };
WebModal = () => {
const { showModal } = this.state;
const height = 300;
const width = 600;
return (
showModal && <Modal className={styles.mobileModal}
width={700}
onCancel={this.changeShowModal}
visible={true}
onOk={this.trim}
title={'签名'}
bodyStyle={{
minHeight: '350px',
padding: '24px 12px',
}}
>
<div className={styles.borderDiv}>
<SignatureCanvas
penColor='black'
ref={(ref) => {
this.sigCanvas = ref;
}}
canvasProps={{
width: width + 'px',
height: height + 'px',
className: 'sigCanvas',
}}
/>
</div>
</Modal>);
};
WebSign = () => {
const {
width,
height,
} = this.props;
const { url } = this.state;
if (url) {
return <div className={styles.mobileSign}>
<Button type={'primary'}
onClick={this.changeShowModal}
className={styles.reSign}
>
重新签名
</Button>
<img src={config.httpServer + url} style={{
height,
width,
}}
/>
</div>;
} else {
return <div className={styles.mobileSign2}>
<Button type={'primary'} onClick={this.changeShowModal}>
点击开始签名
</Button>
</div>;
}
return null;
};
render() { render() {
// console.log('签名组件'); // console.log('签名组件');
const { const {
...@@ -225,62 +290,67 @@ export default class Index extends Component { ...@@ -225,62 +290,67 @@ export default class Index extends Component {
<this.MobileSign /> <this.MobileSign />
<this.MobileModal /> <this.MobileModal />
</>; </>;
}else{
return <>
<this.WebSign />
<this.WebModal />
</>;
} }
return ( // return (
<div id='canvas_signature' style={{ // <div id='canvas_signature' style={{
width: '100%', // width: '100%',
height: '100%', // height: '100%',
marginLeft: 5, // marginLeft: 5,
}}> // }}>
<div // <div
style={{ // style={{
width: width, // width: width,
textAlign: 'center', // textAlign: 'center',
height: height, // height: height,
border: '1px dashed gray', // border: '1px dashed gray',
position: 'relative', // position: 'relative',
}}> // }}>
{url ? ( // {url ? (
<img src={config.httpServer + url} style={{ // <img src={config.httpServer + url} style={{
width: width, // width: width,
height: height - 20, // height: height - 20,
}} /> // }} />
) : ( // ) : (
<SignatureCanvas // <SignatureCanvas
penColor='black' // penColor='black'
ref={(ref) => { // ref={(ref) => {
this.sigCanvas = ref; // this.sigCanvas = ref;
}} // }}
canvasProps={{ // canvasProps={{
width: width || 400, // width: width || 400,
height: height ? height - 20 : 200, // height: height ? height - 20 : 200,
className: 'sigCanvas', // className: 'sigCanvas',
}} // }}
/> // />
)} // )}
<div style={{ // <div style={{
position: 'absolute', // position: 'absolute',
left: 5, // left: 5,
bottom: 5, // bottom: 5,
}}> // }}>
{url ? ( // {url ? (
<Button type='danger' size='small' onClick={this.delete}> // <Button type='danger' size='small' onClick={this.delete}>
重写 // 重写
</Button> // </Button>
) : ( // ) : (
<> // <>
<Button style={{ marginLeft: 12 }} type='danger' size='small' onClick={this.clear}> // <Button style={{ marginLeft: 12 }} type='danger' size='small' onClick={this.clear}>
清除 // 清除
</Button> // </Button>
<Button style={{ marginLeft: 12 }} onClick={this.trim} size='small' type='primary'> // <Button style={{ marginLeft: 12 }} onClick={this.trim} size='small' type='primary'>
保存 // 保存
</Button> // </Button>
</> // </>
)} // )}
</div> // </div>
</div> // </div>
</div> // </div>
); // );
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论