提交 6d53a504 authored 作者: 徐立's avatar 徐立
......@@ -14,8 +14,13 @@ function dataURLtoFile (dataurl, filename) {
var arr = dataurl.split(','),
mime = arr[0].match(/:(.*?);/)[1],
bstr = atob(arr[1]),
n = bstr.length,
u8arr = new Uint8Array(n);
n = bstr.length
if(n<=2220){
message.error('请进行签名');
return null;
}
var u8arr = new Uint8Array(n);
while (n--) {
u8arr[n] = bstr.charCodeAt(n);
}
......@@ -61,7 +66,12 @@ export default class index extends Component {
}
trim=()=>{
const formData = new FormData()
formData.append('file',dataURLtoFile(this.sigCanvas.toDataURL('image/png'),"sign.png"))
const file = dataURLtoFile(this.sigCanvas.toDataURL('image/png'))
if(file==null){
return
}
formData.append('file',file,"sign.png")
reqwest({
url: config.uploadUrl,
method: 'post',
......
......@@ -7,7 +7,7 @@
* 在up 的时候 更新元素dom的新位置到props
* */
import React, { Fragment, Component } from 'react';
import React, { Component } from 'react';
import styles from './index.less';
import { imageStyleAll, A4Height, A4Width } from './ViewPrint/config';
......
......@@ -68,12 +68,13 @@ const normalTextRender = (text, config) => {
};
if (config.mark && text.indexOf(config.mark) > -1) { // 换行分隔符
text = text.split(config.mark);
let length = text.length;
return <span style={style}>
{text.map((x) => {
{text.map((x, index) => {
return <p
key={x}
style={{ marginBottom: '0' }}>
{x}
{x} {length > index + 1 ? config.mark : ''}
</p>;
})}
</span>;
......
......@@ -71,8 +71,29 @@ export default class ViewPrint extends Component {
});
};
beforePrint = () => {
console.log('beforePrint');
};
afterPrint = () => {
console.log('afterPrint');
};
componentDidMount() {
this.getViewData();
if (window.matchMedia) {
const mediaQueryList = window.matchMedia('print');
console.log(mediaQueryList);
mediaQueryList.addListener(function(mql) {
if (mql.matches) {
this.beforePrint();
} else {
this.afterPrint();
}
});
}
}
detailDom = (data) => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论