Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
6d53a504
提交
6d53a504
authored
6月 03, 2020
作者:
徐立
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
http://scjoyedu.eicp.net:9121/front-team/webPublic
上级
5b801ba2
f508eba4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
254 行增加
和
222 行删除
+254
-222
index.jsx
one_stop_public/Signature/index.jsx
+13
-3
DragSetting.js
zyd_private/DragAndPrint/DragSetting.js
+1
-1
DetailDom.js
zyd_private/DragAndPrint/ViewPrint/DetailDom.js
+3
-2
index.js
zyd_private/DragAndPrint/ViewPrint/index.js
+237
-216
没有找到文件。
one_stop_public/Signature/index.jsx
浏览文件 @
6d53a504
...
...
@@ -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'
,
...
...
zyd_private/DragAndPrint/DragSetting.js
浏览文件 @
6d53a504
...
...
@@ -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'
;
...
...
zyd_private/DragAndPrint/ViewPrint/DetailDom.js
浏览文件 @
6d53a504
...
...
@@ -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>
;
...
...
zyd_private/DragAndPrint/ViewPrint/index.js
浏览文件 @
6d53a504
...
...
@@ -11,226 +11,247 @@ import DetailDom from './DetailDom';
import
{
imageStyleAll
,
A4Width
,
A4Height
}
from
'./config'
;
export
default
class
ViewPrint
extends
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
configAll
:
null
,
viewData
:
null
,
loading
:
false
,
minHeight
:
0
,
showWindowPrint
:
false
,
};
this
.
getConfigInfo
=
queryConfig
.
bind
(
this
);
}
countImageHeight
=
()
=>
{
if
(
!
this
.
state
.
configAll
)
{
return
false
;
}
const
{
configAll
:
{
backgroundUrl
},
}
=
this
.
state
;
const
img
=
new
Image
();
img
.
src
=
backgroundUrl
;
img
.
onload
=
()
=>
{
this
.
setState
({
minHeight
:
img
.
height
,
});
};
};
getViewData
=
()
=>
{
const
{
selectedRows
}
=
this
.
props
;
const
ids
=
selectedRows
.
map
((
x
)
=>
x
.
id
);
this
.
getConfigInfo
().
then
((
x
)
=>
{
this
.
countImageHeight
();
if
(
x
&&
x
.
queryUrl
)
{
getInfo
(
{
ids
:
ids
.
join
(
','
),
},
x
.
queryUrl
,
).
then
((
viewData
)
=>
{
if
(
!
viewData
||
!
viewData
.
length
)
{
message
.
warning
(
'未查询到可打印的奖状数据'
);
console
.
error
(
`
${
x
.
queryUrl
}
接口报错或者没有返回数据`
);
return
false
;
}
for
(
let
item
of
viewData
)
{
for
(
let
x
in
item
)
{
if
(
item
[
x
]
===
null
||
item
[
x
]
===
'null'
)
{
item
[
x
]
=
''
;
}
}
}
this
.
setState
({
viewData
,
});
});
}
});
};
componentDidMount
()
{
this
.
getViewData
();
}
detailDom
=
(
data
)
=>
{
const
{
configAll
:
{
config
},
}
=
this
.
state
;
const
res
=
[];
for
(
const
item
of
config
)
{
res
.
push
(
DetailDom
({
config
:
item
,
data
:
data
[
item
.
fieldCode
],
}),
);
}
return
res
;
};
onBeforeGetContent
=
()
=>
{
this
.
setState
({
loading
:
true
,
});
return
new
Promise
((
resolve
,
reject
)
=>
{
const
{
selectedRows
}
=
this
.
props
;
const
{
configAll
}
=
this
.
state
;
const
ids
=
selectedRows
.
map
((
x
)
=>
{
return
x
.
id
;
});
if
(
configAll
.
callUrl
&&
false
)
{
// 暂时关闭调用这个接口 不通知后台是否打印了
getInfo
({
ids
:
ids
.
join
(
','
)
},
configAll
.
callUrl
).
then
((
x
)
=>
{
if
(
x
)
{
this
.
setState
({
showWindowPrint
:
true
},
()
=>
{
resolve
(
true
);
});
}
else
{
resolve
(
true
);
}
});
}
else
{
this
.
setState
({
showWindowPrint
:
true
},
()
=>
{
resolve
(
true
);
});
}
});
};
render
()
{
const
{
loading
,
configAll
,
viewData
,
showWindowPrint
,
minHeight
,
}
=
this
.
state
;
if
(
!
viewData
||
!
minHeight
)
{
return
null
;
}
if
(
!
configAll
.
backgroundUrl
)
{
console
.
error
(
'没有设置模版图片无法使用'
);
return
null
;
}
const
{
hasPrintBackground
,
backgroundUrl
,
wide
,
high
}
=
configAll
;
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
configAll
:
null
,
viewData
:
null
,
loading
:
false
,
minHeight
:
0
,
showWindowPrint
:
false
,
};
this
.
getConfigInfo
=
queryConfig
.
bind
(
this
);
}
countImageHeight
=
()
=>
{
if
(
!
this
.
state
.
configAll
)
{
return
false
;
}
const
{
configAll
:
{
backgroundUrl
},
}
=
this
.
state
;
const
img
=
new
Image
();
img
.
src
=
backgroundUrl
;
img
.
onload
=
()
=>
{
this
.
setState
({
minHeight
:
img
.
height
,
});
};
};
getViewData
=
()
=>
{
const
{
selectedRows
}
=
this
.
props
;
const
ids
=
selectedRows
.
map
((
x
)
=>
x
.
id
);
this
.
getConfigInfo
().
then
((
x
)
=>
{
this
.
countImageHeight
();
if
(
x
&&
x
.
queryUrl
)
{
getInfo
(
{
ids
:
ids
.
join
(
','
),
},
x
.
queryUrl
,
).
then
((
viewData
)
=>
{
if
(
!
viewData
||
!
viewData
.
length
)
{
message
.
warning
(
'未查询到可打印的奖状数据'
);
console
.
error
(
`
${
x
.
queryUrl
}
接口报错或者没有返回数据`
);
return
false
;
}
for
(
let
item
of
viewData
)
{
for
(
let
x
in
item
)
{
if
(
item
[
x
]
===
null
||
item
[
x
]
===
'null'
)
{
item
[
x
]
=
''
;
}
}
}
this
.
setState
({
viewData
,
});
});
}
});
};
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
)
=>
{
const
{
configAll
:
{
config
},
}
=
this
.
state
;
const
res
=
[];
for
(
const
item
of
config
)
{
res
.
push
(
DetailDom
({
config
:
item
,
data
:
data
[
item
.
fieldCode
],
}),
);
}
return
res
;
};
onBeforeGetContent
=
()
=>
{
this
.
setState
({
loading
:
true
,
});
return
new
Promise
((
resolve
,
reject
)
=>
{
const
{
selectedRows
}
=
this
.
props
;
const
{
configAll
}
=
this
.
state
;
const
ids
=
selectedRows
.
map
((
x
)
=>
{
return
x
.
id
;
});
if
(
configAll
.
callUrl
&&
false
)
{
// 暂时关闭调用这个接口 不通知后台是否打印了
getInfo
({
ids
:
ids
.
join
(
','
)
},
configAll
.
callUrl
).
then
((
x
)
=>
{
if
(
x
)
{
this
.
setState
({
showWindowPrint
:
true
},
()
=>
{
resolve
(
true
);
});
}
else
{
resolve
(
true
);
}
});
}
else
{
this
.
setState
({
showWindowPrint
:
true
},
()
=>
{
resolve
(
true
);
});
}
});
};
render
()
{
const
{
loading
,
configAll
,
viewData
,
showWindowPrint
,
minHeight
,
}
=
this
.
state
;
if
(
!
viewData
||
!
minHeight
)
{
return
null
;
}
if
(
!
configAll
.
backgroundUrl
)
{
console
.
error
(
'没有设置模版图片无法使用'
);
return
null
;
}
const
{
hasPrintBackground
,
backgroundUrl
,
wide
,
high
}
=
configAll
;
const
imageStyle
=
{
height
:
`
${
high
}
cm`
||
A4Height
,
width
:
`
${
wide
}
cm`
||
A4Width
,
};
return
(
<
Fragment
>
<
Shell
styleShell
=
{{
marginTop
:
'0'
,
marginBottom
:
'20px'
}}
>
<
div
style
=
{{
height
:
'54px'
,
padding
:
'12px 0 12px 12px'
}}
>
<
ReactToPrint
trigger
=
{()
=>
(
<
Button
shape
=
"round"
type
=
"primary"
loading
=
{
loading
}
style
=
{{
marginRight
:
'20px'
}}
>
打印
<
/Button
>
)}
content
=
{()
=>
this
.
content
}
onBeforeGetContent
=
{
this
.
onBeforeGetContent
}
onAfterPrint
=
{()
=>
{
this
.
setState
({
showWindowPrint
:
false
,
loading
:
false
,
});
}}
/
>
<
ButtonDiy
name
=
{
'返回'
}
handleClick
=
{()
=>
{
router
.
goBack
();
}}
/
>
<
/div
>
<
/Shell
>
{
/** 预览的dom **/
}
{
viewData
&&
viewData
.
length
?
(
<
div
>
{
viewData
.
map
((
info
,
index
)
=>
{
return
(
<
div
className
=
{
styles
.
outSideDivPrint
}
key
=
{
index
+
'divKey'
}
style
=
{{
...
imageStyle
,
}}
>
<
img
src
=
{
backgroundUrl
}
draggable
=
{
false
}
className
=
{
styles
.
bgimagePrint
}
alt
=
{
'背景图'
}
return
(
<
Fragment
>
<
Shell
styleShell
=
{{
marginTop
:
'0'
,
marginBottom
:
'20px'
}}
>
<
div
style
=
{{
height
:
'54px'
,
padding
:
'12px 0 12px 12px'
}}
>
<
ReactToPrint
trigger
=
{()
=>
(
<
Button
shape
=
"round"
type
=
"primary"
loading
=
{
loading
}
style
=
{{
marginRight
:
'20px'
}}
>
打印
<
/Button
>
)}
content
=
{()
=>
this
.
content
}
onBeforeGetContent
=
{
this
.
onBeforeGetContent
}
onAfterPrint
=
{()
=>
{
this
.
setState
({
showWindowPrint
:
false
,
loading
:
false
,
});
}}
/
>
<
ButtonDiy
name
=
{
'返回'
}
handleClick
=
{()
=>
{
router
.
goBack
();
}}
/
>
<
/div
>
<
/Shell
>
{
/** 预览的dom **/
}
{
viewData
&&
viewData
.
length
?
(
<
div
>
{
viewData
.
map
((
info
,
index
)
=>
{
return
(
<
div
className
=
{
styles
.
outSideDivPrint
}
key
=
{
index
+
'divKey'
}
style
=
{{
...
imageStyle
,
}}
>
<
img
src
=
{
backgroundUrl
}
draggable
=
{
false
}
className
=
{
styles
.
bgimagePrint
}
alt
=
{
'背景图'
}
style
=
{
imageStyleAll
}
/
>
{
this
.
detailDom
(
info
)}
<
/div
>
);
})}
<
/div
>
)
:
null
}
{
/** 打印的dom */
}
{
viewData
&&
viewData
.
length
?
(
<
div
ref
=
{(
node
)
=>
(
this
.
content
=
node
)}
style
=
{{
display
:
showWindowPrint
/*|| true*/
?
'block'
:
'none'
,
}}
>
{
viewData
.
map
((
info
,
index
)
=>
{
return
(
<
div
className
=
{
styles
.
outSideDivPrint
}
key
=
{
`
${
index
}
divKey`
}
style
=
{{
...
imageStyle
,
}}
>
{
hasPrintBackground
?
(
<
img
src
=
{
backgroundUrl
}
draggable
=
{
false
}
className
=
{
styles
.
bgimagePrint
}
alt
=
{
'背景图'
}
style
=
{
imageStyleAll
}
/
>
)
:
null
}
{
this
.
detailDom
(
info
)}
<
/div
>
);
})}
<
/div
>
)
:
null
}
<
/Fragment
>
);
}
/
>
{
this
.
detailDom
(
info
)}
<
/div
>
);
})}
<
/div
>
)
:
null
}
{
/** 打印的dom */
}
{
viewData
&&
viewData
.
length
?
(
<
div
ref
=
{(
node
)
=>
(
this
.
content
=
node
)}
style
=
{{
display
:
showWindowPrint
/*|| true*/
?
'block'
:
'none'
,
}}
>
{
viewData
.
map
((
info
,
index
)
=>
{
return
(
<
div
className
=
{
styles
.
outSideDivPrint
}
key
=
{
`
${
index
}
divKey`
}
style
=
{{
...
imageStyle
,
}}
>
{
hasPrintBackground
?
(
<
img
src
=
{
backgroundUrl
}
draggable
=
{
false
}
className
=
{
styles
.
bgimagePrint
}
alt
=
{
'背景图'
}
style
=
{
imageStyleAll
}
/
>
)
:
null
}
{
this
.
detailDom
(
info
)}
<
/div
>
);
})}
<
/div
>
)
:
null
}
<
/Fragment
>
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论