feat:查询条件调整

This commit is contained in:
houjunxiang
2025-11-14 17:46:43 +08:00
parent 45ba9b4899
commit d3f6ad4bf6
8 changed files with 412 additions and 136 deletions

View File

@@ -1,9 +1,9 @@
<template>
<view>
<navbar-back title="任务单预览"></navbar-back>
<view></view>
<!-- #ifdef H5 -->
<web-view :src="pdfUrlH5"></web-view>
<u-button v-if="showConfirmBtn" class="confirm-btn" type="success" @click="handleConfirm()">数据确认</u-button>
<!-- #endif -->
</view>
</template>
@@ -21,9 +21,21 @@ const reportKey = ref('')
const hideResultFlag = ref('')
const viewerUrl = '/hybrid/html/web/viewer.html?file='
const pdfUrlH5 = ref('')
const showConfirmBtn = ref(false)
let confirmButtonRef = null // 用于保存按钮实
let wv = null // 计划创建的 webview
function handleConfirm() {
const params = {
businessAssayTaskId: businessAssayTaskId.value
}
nx.$api.assayTask.submitTask(params).then(res => {
uni.redirectTo({
url: '/pages/analysis/sample/sample-work-list'
})
})
}
// 方法:下载 PDF
const downloadPdf = (pdfUrl, retryCount = 0) => {
const MAX_RETRY = 3 // 最多重试 3 次
@@ -79,10 +91,59 @@ const loadPdfOnAndroid = async pdfUrl => {
bottom: 0
})
wv.loadURL(allUrl)
confirmButtonRef = createConfirmButton()
const currentWebview = getCurrentPages().pop().$getAppWebview()
currentWebview.append(wv)
currentWebview.append(confirmButtonRef)
if (!showConfirmBtn.value) {
hideNativeButton()
}
}
const createConfirmButton = () => {
const sysInfo = uni.getSystemInfoSync()
const btnWidth = 100
const btnHeight = 40
const margin = 10
const left = sysInfo.windowWidth - btnWidth - margin
const top = sysInfo.windowHeight - btnHeight - margin
const buttonView = new plus.nativeObj.View('confirm-btn-native', {
left: left,
top: top,
width: btnWidth,
height: btnHeight
})
buttonView.drawRect({ color: '#5ac725', radius: '4px' }, { top: 0, left: 0, width: btnWidth, height: btnHeight })
buttonView.drawText(
'确认上报',
{ top: 11, left: 0, width: btnWidth, height: 18 },
{ size: '14px', color: '#ffffff', align: 'center' }
)
buttonView.interceptTouchEvent(true)
buttonView.addEventListener('click', () => {
handleConfirm()
})
return buttonView
}
// 隐藏按钮
function hideNativeButton() {
if (confirmButtonRef) {
confirmButtonRef.hide()
}
}
function destroyNativeButton() {
if (confirmButtonRef) {
confirmButtonRef.close() // 或 remove()
confirmButtonRef = null
}
}
// 获取 PDF 预览 URL
const getPdf = async () => {
const printBaseUrl = getBaseUrl()
@@ -128,6 +189,9 @@ onLoad(param => {
reportKey.value = param.reportKey
hideResultFlag.value = param.hideResultFlag
}
if (param.showConfirmBtn && param.showConfirmBtn === 'true') {
showConfirmBtn.value = true
}
getPdf()
})
@@ -137,7 +201,16 @@ onHide(() => {
onUnload(() => {
deleteTmpFile()
destroyNativeButton()
})
</script>
<style scoped></style>
<style scoped>
.confirm-btn {
position: fixed;
bottom: 10px;
right: 10px;
width: 10%;
z-index: 9999;
}
</style>