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

签名组件优化,

utils 优化
上级 a1637d47
...@@ -49,19 +49,17 @@ function blobToFile(Blob, fileName) { ...@@ -49,19 +49,17 @@ function blobToFile(Blob, fileName) {
return Blob; return Blob;
} }
export default class Index extends Component { export default class Signature extends Component {
constructor(props) { constructor(props) {
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,
}; };
} }
triggerChange = (changedValue) => { triggerChange = (changedValue) => {
// Should provide an event to pass value to Form.
const onChange = this.props.onChange; const onChange = this.props.onChange;
if (onChange) { if (onChange) {
onChange(changedValue); onChange(changedValue);
...@@ -72,9 +70,9 @@ export default class Index extends Component { ...@@ -72,9 +70,9 @@ export default class Index extends Component {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps && nextProps.value) { if ('value' in nextProps && nextProps.value) {
const value = nextProps.value; const value = nextProps.value;
this.setState({ url: value }); if (value !== this.state.url) {
this.setState({ url: value });
// }
} }
} }
...@@ -141,8 +139,10 @@ export default class Index extends Component { ...@@ -141,8 +139,10 @@ export default class Index extends Component {
}; };
componentDidMount() { componentDidMount() {
if (!this.props.value && this.state.value) { if (!this.props.value && this.state.url) {
this.triggerChange(this.state.value); setTimeout(() => {
this.triggerChange(this.state.url);
}, 2000);
} }
} }
...@@ -191,19 +191,19 @@ export default class Index extends Component { ...@@ -191,19 +191,19 @@ export default class Index extends Component {
padding: '24px 12px', padding: '24px 12px',
}} }}
> >
<div className={styles.borderDiv}> <div className={styles.borderDiv}>
<SignatureCanvas <SignatureCanvas
penColor='black' penColor="black"
ref={(ref) => { ref={(ref) => {
this.sigCanvas = ref; this.sigCanvas = ref;
}} }}
canvasProps={{ canvasProps={{
width: width + 'px', width: width + 'px',
height: height + 'px', height: height + 'px',
className: 'sigCanvas', className: 'sigCanvas',
}} }}
/> />
</div> </div>
</Modal>); </Modal>);
}; };
...@@ -225,7 +225,7 @@ export default class Index extends Component { ...@@ -225,7 +225,7 @@ export default class Index extends Component {
> >
<div className={styles.borderDiv}> <div className={styles.borderDiv}>
<SignatureCanvas <SignatureCanvas
penColor='black' penColor="black"
ref={(ref) => { ref={(ref) => {
this.sigCanvas = ref; this.sigCanvas = ref;
}} }}
...@@ -284,70 +284,14 @@ export default class Index extends Component { ...@@ -284,70 +284,14 @@ export default class Index extends Component {
// const MobileSign = this.MobileSign; // const MobileSign = this.MobileSign;
// const MobileModal = this.MobileModal; // const MobileModal = this.MobileModal;
return <> return <>
<this.MobileSign /> <this.MobileSign/>
<this.MobileModal /> <this.MobileModal/>
</>; </>;
}else{ } else {
return <> return <>
<this.WebSign /> <this.WebSign/>
<this.WebModal /> <this.WebModal/>
</>; </>;
} }
// return (
// <div id='canvas_signature' style={{
// width: '100%',
// height: '100%',
// marginLeft: 5,
// }}>
// <div
// style={{
// width: width,
// textAlign: 'center',
// height: height,
// border: '1px dashed gray',
// position: 'relative',
// }}>
// {url ? (
// <img src={config.httpServer + url} style={{
// width: width,
// height: height - 20,
// }} />
// ) : (
// <SignatureCanvas
// penColor='black'
// ref={(ref) => {
// this.sigCanvas = ref;
// }}
// canvasProps={{
// width: width || 400,
// height: height ? height - 20 : 200,
// className: 'sigCanvas',
// }}
// />
// )}
// <div style={{
// position: 'absolute',
// left: 5,
// bottom: 5,
// }}>
// {url ? (
// <Button type='danger' size='small' onClick={this.delete}>
// 重写
// </Button>
// ) : (
// <>
// <Button style={{ marginLeft: 12 }} type='danger' size='small' onClick={this.clear}>
// 清除
// </Button>
// <Button style={{ marginLeft: 12 }} onClick={this.trim} size='small' type='primary'>
// 保存
// </Button>
// </>
// )}
// </div>
// </div>
// </div>
// );
} }
} }
...@@ -1138,6 +1138,7 @@ export default class TableCom extends Component { ...@@ -1138,6 +1138,7 @@ export default class TableCom extends Component {
render: getRender, render: getRender,
base64: getBase64, base64: getBase64,
form: this.props.form, form: this.props.form,
preHandle,
}, },
functionObj, functionObj,
this.props.routerState, this.props.routerState,
......
...@@ -122,10 +122,6 @@ export function preHandle(values) { ...@@ -122,10 +122,6 @@ export function preHandle(values) {
// childObj[j][index] = childObj[j][index].valueOf(); // childObj[j][index] = childObj[j][index].valueOf();
} }
}); });
if(j === 'LckrMFujFgw$LckrXpIoQdc'){
// console.log(values[key][k]['LckrMFujFgw'], key, k, j);
// console.log(values[key][k]['LckrXpIoQdc'], key, k, j);
}
delete childObj[j]; delete childObj[j];
// 我写的代码 // 我写的代码
......
...@@ -175,7 +175,7 @@ export const requestOrigin = (url, data, options = {}) => { ...@@ -175,7 +175,7 @@ export const requestOrigin = (url, data, options = {}) => {
// method: "POST", // method: "POST",
requestType: 'form', requestType: 'form',
...getHeaders(), ...getHeaders(url),
...options, ...options,
}) })
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论