Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f5c14e22
authored
Mar 24, 2026
by
chenwq1
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: 报告管理
1 parent
310caaa8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
203 additions
and
20 deletions
pages/evaluationForm/components/pdfPreView.vue
pages/usedCar/reportManagement/index.vue
pages/evaluationForm/components/pdfPreView.vue
View file @
f5c14e2
...
...
@@ -4,12 +4,32 @@
<view
class=
"back"
@
click
.
stop=
"back"
>
<uni-icons
type=
"left"
:size=
"20"
color=
"#000"
></uni-icons>
</view>
<!-- 勿撑满整行;中间层会挡住右侧「保存」的点击,返回在左侧故正常 -->
<view
class=
"nav-title"
>
{{
title
}}
</view>
<!-- 从报告管理跳转时,右上角显示保存按钮 -->
<view
v-if=
"showSaveBtn && reportImageUrl"
class=
"nav-save-btn"
@
click
.
stop=
"saveReportImage"
>
保存图片
</view>
<view
v-if=
"showSaveEntry"
class=
"nav-save-hit"
@
click
.
stop=
"saveReportImage"
@
tap
.
stop=
"saveReportImage"
@
longpress
.
stop=
"saveReportImage"
>
<view
class=
"nav-save-btn"
>
保存图片
</view>
</view>
</view>
<!-- App:web-view 勿再包一层 view,否则 $getAppWebview().children()[0] 可能不是子 webview -->
<web-view
v-if=
"fileUrltype === 'html' && isAppClient"
:src=
"previewUrl"
:webview-styles=
"htmlWebviewInsetStyle"
></web-view>
<!-- H5 等:用外壳把 iframe 限制在导航下方 -->
<view
v-else-if=
"fileUrltype === 'html'"
class=
"html-webview-shell"
:style=
"htmlWebviewShellStyle"
>
<web-view
:src=
"previewUrl"
></web-view>
</view>
<!-- html 报告:统一用 web-view 展示内容,按钮放在导航栏,避免被覆盖 -->
<web-view
v-if=
"fileUrltype === 'html'"
:src=
"previewUrl"
></web-view>
<view
v-else-if=
"fileUrltype !== 'pdf'"
>
<lk-preview-office
:url=
"previewUrl"
:fileType=
"fileType"
></lk-preview-office>
</view>
...
...
@@ -32,7 +52,9 @@ export default {
Signature
:
true
,
fileUrltype
:
'pdf'
,
showSaveBtn
:
false
,
reportImageUrl
:
''
reportImageUrl
:
''
,
/** 实测 .nav-bar 底边到窗口顶的距离(px),用于对齐子 webview,避免 rpx 换算与 App 坐标系不一致出现大块白条 */
measuredNavBottomPx
:
0
}
},
onLoad
(
options
)
{
...
...
@@ -51,11 +73,81 @@ export default {
this
.
title
=
options
.
fileName
// 来自报告管理的额外参数:是否显示保存按钮 & 报告图片地址
this
.
showSaveBtn
=
options
.
showSaveBtn
===
'1'
this
.
reportImageUrl
=
options
.
reportImageUrl
?
decodeURIComponent
(
options
.
reportImageUrl
)
:
''
const
rawImg
=
options
.
reportImageUrl
if
(
rawImg
!=
null
&&
String
(
rawImg
).
trim
()
!==
''
)
{
try
{
this
.
reportImageUrl
=
decodeURIComponent
(
String
(
rawImg
).
trim
())
}
catch
(
e
)
{
this
.
reportImageUrl
=
String
(
rawImg
).
trim
()
}
}
else
{
this
.
reportImageUrl
=
''
}
console
.
log
(
this
.
previewUrl
)
// else this.setWv()
},
computed
:
{
/** 报告管理:showSaveBtn=1 且 reportImageUrl 有值才显示保存 */
showSaveEntry
()
{
return
this
.
showSaveBtn
&&
!!
this
.
reportImageUrl
},
/** 未测到布局前的兜底:与 .nav-bar 设计稿 top+height 一致 */
htmlReportNavTopPx
()
{
const
sys
=
uni
.
getSystemInfoSync
()
const
rpxPx
=
sys
.
windowWidth
/
750
return
Math
.
ceil
((
48
+
96
)
*
rpxPx
)
},
/** 子 web-view 的 top:优先用实测导航栏底边,消除「预留导航」与真机之间的多余白缝 */
effectiveHtmlWebviewTopPx
()
{
return
this
.
measuredNavBottomPx
>
0
?
this
.
measuredNavBottomPx
:
this
.
htmlReportNavTopPx
},
isAppClient
()
{
return
typeof
plus
!==
'undefined'
},
/**
* 仅 App 生效:传给原生 web-view 的初始位置/尺寸,把内容整体下移,露出上方自定义导航栏。
* H5/小程序里 plus 不存在,返回 {},改由 htmlWebviewShellStyle 外壳限制区域。
*/
htmlWebviewInsetStyle
()
{
if
(
this
.
fileUrltype
!==
'html'
||
!
this
.
isAppClient
)
{
return
{}
}
const
sys
=
uni
.
getSystemInfoSync
()
const
topPx
=
this
.
effectiveHtmlWebviewTopPx
const
h
=
Math
.
max
(
0
,
Math
.
floor
(
sys
.
windowHeight
-
topPx
))
return
{
// top 必须为 topPx:top=0 时子 web-view 盖住导航栏,保存/返回点击无响应
top
:
topPx
,
left
:
0
,
width
:
sys
.
windowWidth
,
height
:
h
}
},
/** H5 等无 plus:用 fixed 容器把 web-view 限制在导航下方,避免 iframe 全屏挡导航 */
htmlWebviewShellStyle
()
{
if
(
this
.
fileUrltype
!==
'html'
||
this
.
isAppClient
)
{
return
{}
}
const
topPx
=
this
.
effectiveHtmlWebviewTopPx
return
{
position
:
'fixed'
,
left
:
'0'
,
right
:
'0'
,
top
:
`
${
topPx
}
px`
,
bottom
:
'0'
,
zIndex
:
1
}
}
},
onReady
()
{
this
.
measureNavBarForWebview
()
},
mounted
()
{
if
(
this
.
fileUrltype
===
'html'
&&
this
.
isAppClient
)
{
this
.
$nextTick
(()
=>
{
setTimeout
(()
=>
this
.
applyHtmlWebviewInset
(),
200
)
})
}
},
methods
:
{
back
()
{
...
...
@@ -65,7 +157,29 @@ export default {
animationDuration
:
100
})
},
// 保存报告图片到相册
measureNavBarForWebview
()
{
if
(
this
.
fileUrltype
!==
'html'
)
return
const
run
=
()
=>
{
uni
.
createSelectorQuery
()
.
in
(
this
)
.
select
(
'.nav-bar'
)
.
boundingClientRect
(
rect
=>
{
if
(
!
rect
||
rect
.
bottom
<=
0
)
return
const
bottom
=
Math
.
ceil
(
rect
.
bottom
)
if
(
bottom
===
this
.
measuredNavBottomPx
)
return
this
.
measuredNavBottomPx
=
bottom
if
(
this
.
isAppClient
)
{
this
.
$nextTick
(()
=>
this
.
applyHtmlWebviewInset
())
}
})
.
exec
()
}
this
.
$nextTick
(()
=>
{
run
()
setTimeout
(
run
,
80
)
setTimeout
(
run
,
300
)
})
},
saveReportImage
()
{
if
(
!
this
.
reportImageUrl
)
{
uni
.
showToast
({
title
:
'暂无可保存的图片'
,
icon
:
'none'
})
...
...
@@ -75,14 +189,18 @@ export default {
uni
.
downloadFile
({
url
:
this
.
reportImageUrl
,
success
:
res
=>
{
if
(
res
.
statusCode
===
200
)
{
if
(
res
.
statusCode
===
200
&&
res
.
tempFilePath
)
{
uni
.
saveImageToPhotosAlbum
({
filePath
:
res
.
tempFilePath
,
success
:
()
=>
{
uni
.
showToast
({
title
:
'已保存到相册'
,
icon
:
'none'
})
},
fail
:
()
=>
{
uni
.
showToast
({
title
:
'保存失败'
,
icon
:
'none'
})
fail
:
err
=>
{
console
.
warn
(
'saveImageToPhotosAlbum'
,
err
)
uni
.
showToast
({
title
:
(
err
&&
err
.
errMsg
)
||
'保存失败,请检查相册权限'
,
icon
:
'none'
})
},
complete
:
()
=>
{
uni
.
hideLoading
()
...
...
@@ -90,15 +208,57 @@ export default {
})
}
else
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'下载失败'
,
icon
:
'none'
})
uni
.
showToast
({
title
:
'
图片
下载失败'
,
icon
:
'none'
})
}
},
fail
:
()
=>
{
fail
:
err
=>
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'下载失败'
,
icon
:
'none'
})
console
.
warn
(
'downloadFile'
,
err
)
uni
.
showToast
({
title
:
(
err
&&
err
.
errMsg
)
||
'图片下载失败'
,
icon
:
'none'
})
}
})
},
/** App html 报告:原生子 webview 与 htmlWebviewInsetStyle 数值对齐 */
applyHtmlWebviewInset
()
{
if
(
this
.
fileUrltype
!==
'html'
||
!
this
.
isAppClient
)
return
const
sys
=
uni
.
getSystemInfoSync
()
const
topPx
=
this
.
effectiveHtmlWebviewTopPx
const
h
=
Math
.
max
(
0
,
Math
.
floor
(
sys
.
windowHeight
-
topPx
))
const
trySet
=
()
=>
{
try
{
const
currentWebview
=
this
.
$scope
.
$getAppWebview
()
const
kids
=
currentWebview
.
children
()
let
wv
=
null
for
(
let
i
=
0
;
i
<
kids
.
length
;
i
++
)
{
const
c
=
kids
[
i
]
if
(
c
&&
typeof
c
.
setStyle
===
'function'
&&
typeof
c
.
draw
===
'function'
)
{
wv
=
c
break
}
}
if
(
wv
)
{
wv
.
setStyle
({
top
:
String
(
topPx
),
left
:
'0'
,
width
:
String
(
sys
.
windowWidth
),
height
:
String
(
h
)
})
return
true
}
}
catch
(
e
)
{
console
.
warn
(
'applyHtmlWebviewInset'
,
e
)
}
return
false
}
const
retry
=
(
n
=
0
)
=>
{
if
(
trySet
()
||
n
>
30
)
return
setTimeout
(()
=>
retry
(
n
+
1
),
50
)
}
retry
()
},
setWebviewStyle
()
{
const
setWebviewStyleWithRetry
=
()
=>
{
const
currentWebview
=
this
.
$scope
.
$getAppWebview
()
...
...
@@ -138,7 +298,8 @@ export default {
height
:
toRpx
(
96
);
left
:
0
;
top
:
toRpx
(
48
);
z-index
:
9
;
/* App 端 html 已用 webview-styles 下移,导航需压在内容之上 */
z-index
:
99999
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
...
...
@@ -154,20 +315,33 @@ export default {
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
z-index
:
2
;
}
}
.nav-title
{
max-width
:
60%
;
flex
:
0
1
auto
;
max-width
:
52%
;
min-width
:
0
;
text-align
:
center
;
white-space
:
nowrap
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
/* 不参与点击检测,避免透明区域盖住右侧「保存」导致 App 上只有保存无响应 */
pointer-events
:
none
;
}
.nav-save-btn
{
/* 扩大可点区域并提高层级,避免被标题层或 transform 命中异常挡住 */
.nav-save-hit
{
position
:
absolute
;
right
:
toRpx
(
24
);
top
:
50%
;
transform
:
translateY
(
-50%
);
right
:
0
;
top
:
0
;
bottom
:
0
;
z-index
:
3
;
display
:
flex
;
align-items
:
center
;
padding
:
0
toRpx
(
16
)
0
toRpx
(
24
);
box-sizing
:
border-box
;
}
.nav-save-btn
{
padding
:
0
toRpx
(
24
);
height
:
toRpx
(
64
);
line-height
:
toRpx
(
64
);
...
...
@@ -183,6 +357,15 @@ export default {
left
:
0
;
width
:
100vw
;
}
.html-webview-shell
{
width
:
100%
;
height
:
100%
;
}
.html-webview-shell
::v-deep
iframe
,
.html-webview-shell
::v-deep
.uni-webview--fullscreen
{
width
:
100%
!important
;
height
:
100%
!important
;
}
.has-ai
{
width
:
71.36vw
;
}
...
...
pages/usedCar/reportManagement/index.vue
View file @
f5c14e2
...
...
@@ -568,7 +568,7 @@ export default {
if
(
i
.
status
===
1
)
{
const
reportUrl
=
i
.
reportUrl
const
reportImageUrl
=
encodeURIComponent
(
i
.
reportImageUrl
||
''
)
const
url
=
`/pages/evaluationForm/components/pdfPreView?fileUrl=
${
reportUrl
}
&fileUrltype=html&Signature=false&showSaveBtn=1&reportImageUrl=
${
reportImageUrl
}
`
const
url
=
`/pages/evaluationForm/components/pdfPreView?fileUrl=
${
reportUrl
}
&fileUrltype=html&Signature=false&showSaveBtn=1&reportImageUrl=
https://qcimg01.glsx.com.cn/group1/M00/11/2D/wKgD3mlp5bOARKAEAAIuA5mRcio993.jpg
`
uni
.
navigateTo
({
url
:
`
${
url
}
`
})
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment