This commit is contained in:
sjl
2025-09-15 10:43:53 +08:00
5 changed files with 278 additions and 29 deletions

View File

@@ -0,0 +1,184 @@
<template>
<el-dialog
v-model="dialogVisible"
title="报告生成"
destroy-on-close
width="900"
draggable
:close-on-click-modal="false"
>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane
v-for="(result, index) in resultData"
:key="result.monitorId"
:label="`测量回路${result.monitorNum}`"
:name="index"
>
<el-descriptions style="padding: 10px" :column="4" border>
<el-descriptions-item label="总测试次数:" label-align="right">
<el-text type="primary" tag="b">{{ result.totalNum }}</el-text>
</el-descriptions-item>
<el-descriptions-item label="合格次数:" label-align="right">
<el-text type="success" tag="b">{{ result.qualifiedNum }}</el-text>
</el-descriptions-item>
<el-descriptions-item label="不合格次数:" label-align="right">
<el-text type="danger" tag="b">{{ result.unQualifiedNum }}</el-text>
</el-descriptions-item>
<el-descriptions-item label="测试标准:" label-align="right">
<el-text type="info">{{ result.errorSysName }}</el-text>
</el-descriptions-item>
<el-descriptions-item label="检测结论:" label-align="right">
<el-tag disable-transitions v-if="result.checkResult === 1" type="success">及格</el-tag>
<el-tag disable-transitions v-else-if="result.checkResult === 2" type="danger">不及格</el-tag>
</el-descriptions-item>
<el-descriptions-item label="结论来源:" label-align="right">
<div style="display: flex; align-items: center; justify-content: space-between">
<el-text>{{ result.whichTime }}次检测的{{ result.resultOrigin }}</el-text>
<el-button type="primary" size="small" @click="handleChooseClick">重新选择</el-button>
</div>
</el-descriptions-item>
</el-descriptions>
</el-tab-pane>
</el-tabs>
<template #footer>
<el-button type="primary">确认生成</el-button>
</template>
<!-- 选择检测数据源弹框-->
<el-dialog
v-model="dialogSourceVisible"
append-to-body
title="选择检测数据源"
destroy-on-close
width="400"
:close-on-click-modal="false"
>
<el-form ref="formRef" :rules="rules" :model="submitSourceData" label-width="120px" label-position="top">
<el-form-item label="选择次数:" prop="whichTime">
<el-select v-model="submitSourceData.whichTime" placeholder="请选择次数" @change="handleTimeChange">
<el-option
v-for="time in whichTimeData"
:key="time"
:label="`第${time}次`"
:value="time"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="数据源和检测结论:" prop="resultType">
<el-select
v-model="submitSourceData.resultType"
placeholder="请选择数据源和检测结论"
clearable
@change="handleSourceChange"
>
<template #label="{ label }">
<div style="display: flex; align-items: center; justify-content: space-between">
<el-text>{{ label }}</el-text>
<el-tag disable-transitions v-if="submitSourceData.checkResult === 1" type="success">
及格
</el-tag>
<el-tag disable-transitions v-if="submitSourceData.checkResult === 2" type="danger">
不及格
</el-tag>
</div>
</template>
<el-option
v-for="item in sourceData"
:key="item.dataSourceCode"
:label="item.dataSourceName"
:value="item.dataSourceCode"
>
<div style="display: flex; align-items: center; justify-content: space-between">
<el-text>{{ item.dataSourceName }}</el-text>
<el-tag v-if="item.checkResult === 1" type="success">及格</el-tag>
<el-tag v-if="item.checkResult === 2" type="danger">不及格</el-tag>
</div>
</el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dialogSourceVisible = false">取消</el-button>
<el-button type="primary" @click="handleSureChoose">确认</el-button>
</template>
</el-dialog>
</el-dialog>
</template>
<script setup lang="ts" name="reportPopup">
import { getMonitorDataSourceResult, getMonitorResult, updateMonitorResult } from '@/api/result/result'
import { type MonitorResult } from '@/api/result/interface'
const dialogVisible = ref(false)
const dialogSourceVisible = ref(false)
const devData = ref<any>()
const activeName = ref<number>(0)
const resultData = ref<MonitorResult[]>([])
const resultSourceData = ref<any>({})
const whichTimeData = ref<any>([])
const sourceData = ref<any>([])
const formRef = ref()
const submitSourceData = reactive({
monitorId: '',
whichTime: '',
resultType: '',
checkResult: -1
})
const rules = {
whichTime: [{ required: true, message: '请选择次数', trigger: 'change' }],
resultType: [{ required: true, message: '请选择数据源和检测结论', trigger: 'change' }]
}
const open = (data: any) => {
devData.value = data
getResultData()
}
const getResultData = async () => {
const res = await getMonitorResult(devData.value.id)
if (res.data && Array.isArray(res.data)) {
resultData.value = res.data
}
dialogVisible.value = true
}
const handleTabClick = (tab: any) => {
activeName.value = tab.name
}
const handleChooseClick = async () => {
const currentResult = resultData.value[activeName.value]
if (currentResult) {
submitSourceData.monitorId = currentResult.monitorId
submitSourceData.whichTime = currentResult.whichTime
submitSourceData.resultType = currentResult.resultType
submitSourceData.checkResult = currentResult.checkResult
const res = await getMonitorDataSourceResult(currentResult.monitorId)
if (res.data) {
resultSourceData.value = res.data
// 选择第几次
whichTimeData.value = Object.keys(resultSourceData.value)
sourceData.value = resultSourceData.value[currentResult.whichTime]
}
}
dialogSourceVisible.value = true
}
const handleTimeChange = (value: any) => {
sourceData.value = resultSourceData.value[value]
submitSourceData.resultType = ''
submitSourceData.checkResult = -1
}
const handleSourceChange = (value: any) => {
submitSourceData.checkResult = resultSourceData.value[submitSourceData.whichTime].find(
(item: any) => item.dataSourceCode === value
).checkResult
}
const handleSureChoose = () => {
formRef.value.validate().then(async () => {
await updateMonitorResult(submitSourceData)
await getResultData()
dialogSourceVisible.value = false
})
}
defineExpose({
open
})
</script>
<style scoped lang="scss"></style>

View File

@@ -77,13 +77,20 @@
<el-button type="primary" icon="Search" @click="handleSearch">查询</el-button>
<el-button icon="Delete" @click="handleRefresh">重置</el-button>
<!-- 比对模式下的通道配对功能 -->
<el-button type="primary" icon="Clock" @click="handleTest2" v-if="modeStore.currentMode == '比对式'">手动检测</el-button>
<el-button
type="primary"
icon="Clock"
@click="handleTest2"
v-if="modeStore.currentMode == '比对式'"
>
手动检测
</el-button>
<!-- 设备检测模式下的操作按钮 -->
<el-button
type="primary"
icon="Clock"
@click="handleTest('手动检测')"
v-if="form.activeTabs === 0 &&modeStore.currentMode == '模拟式'"
v-if="form.activeTabs === 0 && modeStore.currentMode == '模拟式'"
>
手动检测
</el-button>
@@ -175,7 +182,7 @@
<!-- 检测过程显示弹窗 -->
<TestPopup ref="testPopup" @quitClicked="handleQuitClicked"></TestPopup>
<!-- 检测数据查询弹窗 -->
<dataCheckPopup ref="dataCheckPopupRef" :append-to-body="true"/>
<dataCheckPopup ref="dataCheckPopupRef" :append-to-body="true" />
<!-- 手动检测检测项选择弹窗 -->
<SelectTestItemPopup ref="selectTestItemPopupRef" @openTestDialog="openTestDialog"></SelectTestItemPopup>
<!-- 省平台模式下的温度湿度填写弹窗 -->
@@ -187,12 +194,14 @@
ref="dataCheckSingleChannelSingleTestPopupRef"
:append-to-body="true"
/>
<!-- 报告生成弹框 -->
<ReportResultPopup ref="reportPopup"></ReportResultPopup>
</div>
</template>
<script setup lang="tsx" name="useProTable">
import { onBeforeMount, onMounted, type PropType, reactive, ref, watch } from 'vue'
import { ElMessage, ElMessageBox, type Action } from 'element-plus'
import { type Action, ElMessage, ElMessageBox } from 'element-plus'
import TestPopup from './testPopup.vue'
import dataCheckPopup from './dataCheckSingleChannelSingleTestPopup.vue'
import CompareDataCheckSingleChannelSingleTestPopup from '@/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue'
@@ -201,13 +210,12 @@ import SelectTestItemPopup from '@/views/home/components/selectTestItemPopup.vue
import WriteTHPopup from '@/views/home/components/writeTHPopup.vue'
import DeviceConnectionPopup from '@/views/home/components/deviceConnectionPopup.vue'
import { type Device } from '@/api/device/interface/device'
import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/interface'
import { type ColumnProps, type ProTableInstance } from '@/components/ProTable/interface'
import { type Plan } from '@/api/plan/interface'
import { type StandardDevice } from '@/api/device/interface/standardDevice'
import { generateDevReport, getBoundPqDevList } from '@/api/plan/plan'
import { downloadDevData } from '@/api/plan/plan'
import { downloadDevData, generateDevReport, getBoundPqDevList } from '@/api/plan/plan'
import { getPqDev } from '@/api/device/device'
import { useModeStore, useAppSceneStore } from '@/stores/modules/mode' // 引入模式 store
import { useAppSceneStore, useModeStore } from '@/stores/modules/mode' // 引入模式 store
import { useCheckStore } from '@/stores/modules/check'
import { CheckData } from '@/api/check/interface'
import { useAuthStore } from '@/stores/modules/auth'
@@ -215,8 +223,7 @@ import { useDownload } from '@/hooks/useDownload'
import { documentedPqDev } from '@/api/device/report'
import { ResultEnum } from '@/enums/httpEnum'
import { getPqMonList } from '@/api/device/monitor/index.ts'
import ReportResultPopup from '@/views/home/components/reportResultPopup.vue'
const checkStore = useCheckStore()
let devNum = 0 //当前选取的被检设备数量
@@ -254,6 +261,7 @@ const checkStateShow = ref(true)
const factorCheckShow = ref(true)
const selectionShow = ref(true)
const testPopup = ref()
const reportPopup = ref()
const weiJianTab = ref(0) // 当前Tab索引用于控制选项显示逻辑
const channelsSelection = ref<Device.ResPqDev[]>([])
const props = defineProps({
@@ -464,7 +472,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
label: '检测次数',
minWidth: 100,
sortable: true,
isShow: modeStore.currentMode != '比对式',
isShow: modeStore.currentMode != '比对式'
},
{
prop: 'checkState',
@@ -651,9 +659,9 @@ function tableHeaderInit(val: number) {
selectionShow.value = true // 显示选择框
break
case 5: // 数据查询模式
if(modeStore.currentMode === '比对式'){
checkStateTable.value = [1,2, 3] // 显示检测中,检测完成和归档状态
}else{
if (modeStore.currentMode === '比对式') {
checkStateTable.value = [1, 2, 3] // 显示检测中,检测完成和归档状态
} else {
checkStateTable.value = [2, 3] // 显示检测完成和归档状态
}
columns[columns.length - 1].minWidth = 290
@@ -789,7 +797,7 @@ const handleTest2 = async () => {
const deviceNames = inconsistentPointDevices.map(d => d.name).join(', ')
ElMessage.warning(`以下设备存在通道未绑定监测点: ${deviceNames}`)
}
// 只传递有监测点的设备
deviceConnectionPopupRef.value?.open(filteredChannelsSelection, pqStandardDevList.value, props.id)
}
@@ -878,7 +886,7 @@ const handleTest = async (val: string) => {
if (action === 'cancel') {
ElMessage.success('全部复检')
checkStore.setReCheckType(1)
if (appSceneStore.currentScene === '0'&& modeStore.currentMode != '比对式') {
if (appSceneStore.currentScene === '0' && modeStore.currentMode != '比对式') {
writeTHPopupRef.value?.open()
} else {
selectTestItemPopupRef.value?.open()
@@ -906,7 +914,7 @@ const handleTest = async (val: string) => {
.then(() => {
ElMessage.success('不合格项复检')
checkStore.setReCheckType(0)
if (appSceneStore.currentScene === '0'&& modeStore.currentMode != '比对式') {
if (appSceneStore.currentScene === '0' && modeStore.currentMode != '比对式') {
writeTHPopupRef.value?.open()
} else {
openTestDialog(true)
@@ -916,7 +924,7 @@ const handleTest = async (val: string) => {
if (action === 'cancel') {
ElMessage.success('全部复检')
checkStore.setReCheckType(1)
if (appSceneStore.currentScene === '0'&& modeStore.currentMode != '比对式') {
if (appSceneStore.currentScene === '0' && modeStore.currentMode != '比对式') {
writeTHPopupRef.value?.open()
} else {
openTestDialog(true)
@@ -961,7 +969,7 @@ const handleTest = async (val: string) => {
}
const openTestDialog = (testData: any) => {
if (appSceneStore.currentScene === '0'&& modeStore.currentMode != '比对式') {
if (appSceneStore.currentScene === '0' && modeStore.currentMode != '比对式') {
if (testData) {
writeTHPopupRef.value?.open()
} else {
@@ -986,7 +994,8 @@ const openTestDialog2 = () => {
const openDrawer = async (title: string, row: any) => {
// 单个设备报告生成
if (title === '报告生成') {
await generateDevReport({
reportPopup.value?.open(row)
/*await generateDevReport({
planId: checkStore.plan.id,
devIdList: [row.id],
scriptId: checkStore.plan.scriptId,
@@ -995,7 +1004,7 @@ const openDrawer = async (title: string, row: any) => {
pageSize: 999
})
emit('batchGenerateClicked') // 触发事件
ElMessage.success({ message: `报告生成成功!` })
ElMessage.success({ message: `报告生成成功!` })*/
}
if (title === '报告下载') {
@@ -1022,12 +1031,11 @@ const openDrawer = async (title: string, row: any) => {
}
if (title === '误差体系更换') {
checkStore.setShowDetailType(1)
if (modeStore.currentMode == '模拟式') {
dataCheckPopupRef.value?.open(row.id, '-1', null)
if (modeStore.currentMode == '模拟式') {
dataCheckPopupRef.value?.open(row.id, '-1', null)
} else if (modeStore.currentMode == '比对式') {
dataCheckSingleChannelSingleTestPopupRef.value?.open(row, null, row.id, 2)
}
}
if (title === '归档') {