数据查询树替换接口联调
This commit is contained in:
@@ -11,6 +11,13 @@ export const getBigTestItem = (params: {
|
|||||||
return http.post(`/adPlan/getBigTestItem`, params, {loading: false})
|
return http.post(`/adPlan/getBigTestItem`, params, {loading: false})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getScriptList = (params: {
|
||||||
|
devId:string,
|
||||||
|
chnNum:number,
|
||||||
|
}) => {
|
||||||
|
return http.post('/result/getCheckItem', params, {loading: false})
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取弹出框表单数据
|
* 获取弹出框表单数据
|
||||||
* @param params 当为scriptType为null时,表示查询所有脚本类型,否则只查询指定脚本类型。当为chnNum为-1时,表示查询所有通道,否则只查询指定通道。
|
* @param params 当为scriptType为null时,表示查询所有脚本类型,否则只查询指定脚本类型。当为chnNum为-1时,表示查询所有通道,否则只查询指定通道。
|
||||||
|
|||||||
@@ -134,12 +134,16 @@ const prop = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 添加单位
|
// 添加单位
|
||||||
const outerUnit = computed(() => {
|
const outerUnit = computed(() => {
|
||||||
return prop.tableData.length > 0 ? prop.tableData[0].unit : '';
|
return prop.tableData.length > 0 ? prop.tableData[0].unit : '';
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const addPercentSigns = (text: string, unit: string) => {
|
const addPercentSigns = (text: string, unit: string) => {
|
||||||
return text
|
return text
|
||||||
.split('~')
|
.split('~')
|
||||||
|
|||||||
@@ -38,8 +38,8 @@
|
|||||||
<el-option v-for="item in chnList" :key="item" :label="item" :value="item" />
|
<el-option v-for="item in chnList" :key="item" :label="item" :value="item" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="检测次数" :disabled="sourceKey == 1">
|
<el-form-item label="检测次数" >
|
||||||
<el-select v-model="formContent.num" clearable @change="getResults">
|
<el-select v-model="formContent.num" clearable @change="handleNumChange" :disabled="sourceKey == 1">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in chnMapList[formContent.chnNum]"
|
v-for="item in chnMapList[formContent.chnNum]"
|
||||||
:key="item"
|
:key="item"
|
||||||
@@ -66,7 +66,9 @@
|
|||||||
node-key="id"
|
node-key="id"
|
||||||
ref="treeRef"
|
ref="treeRef"
|
||||||
@node-click="handleNodeClick"
|
@node-click="handleNodeClick"
|
||||||
/>
|
>
|
||||||
|
|
||||||
|
</el-tree>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-right">
|
<div class="content-right">
|
||||||
<div class="content-right-title">
|
<div class="content-right-title">
|
||||||
@@ -125,6 +127,7 @@
|
|||||||
:currentCheckItem="currentCheckItem"
|
:currentCheckItem="currentCheckItem"
|
||||||
:currentScriptTypeName="currentScriptTypeName"
|
:currentScriptTypeName="currentScriptTypeName"
|
||||||
v-if="activeTab === 'resultTab'"
|
v-if="activeTab === 'resultTab'"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane label="原始数据" name="rawDataTab">
|
<el-tab-pane label="原始数据" name="rawDataTab">
|
||||||
@@ -144,7 +147,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { dialogBig } from '@/utils/elementBind'
|
import { dialogBig } from '@/utils/elementBind'
|
||||||
import { reactive, ref, watch, computed } from 'vue'
|
import { reactive, ref, watch, computed, nextTick } from 'vue'
|
||||||
import CompareDataCheckResultTable from './compareDataCheckResultTable.vue'
|
import CompareDataCheckResultTable from './compareDataCheckResultTable.vue'
|
||||||
import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue'
|
import CompareDataCheckRawDataTable from './compareDataCheckRawDataTable.vue'
|
||||||
import { CheckData } from '@/api/check/interface'
|
import { CheckData } from '@/api/check/interface'
|
||||||
@@ -153,7 +156,7 @@ import { Histogram, Postcard } from '@element-plus/icons-vue'
|
|||||||
import { getPqErrSysList } from '@/api/plan/plan'
|
import { getPqErrSysList } from '@/api/plan/plan'
|
||||||
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
import { useModeStore } from '@/stores/modules/mode' // 引入模式 store
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import { getContrastFormContent, getContrastResult, getBigTestItem } from '@/api/check/test'
|
import { getContrastFormContent, getContrastResult, getScriptList } from '@/api/check/test'
|
||||||
|
|
||||||
const { appendToBody } = withDefaults(
|
const { appendToBody } = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -209,6 +212,8 @@ const currentScriptTypeName = ref('')
|
|||||||
const checkResultData = ref<CheckData.CheckResult[]>([])
|
const checkResultData = ref<CheckData.CheckResult[]>([])
|
||||||
// 检测脚本配置数据
|
// 检测脚本配置数据
|
||||||
const scriptData = ref<CheckData.ScriptItem[]>([])
|
const scriptData = ref<CheckData.ScriptItem[]>([])
|
||||||
|
//录波对应当前检测项下拉框
|
||||||
|
const selectScript = ref<CheckData.ScriptItem[]>([])
|
||||||
// 原始数据表格数据
|
// 原始数据表格数据
|
||||||
const rawTableData = ref<CheckData.RawDataItem[]>([])
|
const rawTableData = ref<CheckData.RawDataItem[]>([])
|
||||||
const tesList: any = ref([])
|
const tesList: any = ref([])
|
||||||
@@ -222,6 +227,7 @@ const currentRawTableData = computed(() => {
|
|||||||
return Array.isArray(data) ? data : []
|
return Array.isArray(data) ? data : []
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
const open = async (row: any, chnNum: string, deviceId: string | null, source: number) => {
|
const open = async (row: any, chnNum: string, deviceId: string | null, source: number) => {
|
||||||
isWaveData.value = false
|
isWaveData.value = false
|
||||||
pattern.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
|
pattern.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
|
||||||
@@ -229,6 +235,8 @@ const open = async (row: any, chnNum: string, deviceId: string | null, source: n
|
|||||||
formContent.deviceId = deviceId || ''
|
formContent.deviceId = deviceId || ''
|
||||||
formContent.chnNum = chnNum
|
formContent.chnNum = chnNum
|
||||||
sourceKey.value = source
|
sourceKey.value = source
|
||||||
|
// 获取基本信息
|
||||||
|
await getBasicInformation(row.scriptType)
|
||||||
if (source == 1) {
|
if (source == 1) {
|
||||||
// 正式检测进入页面 - 创建新的对象避免引用共享
|
// 正式检测进入页面 - 创建新的对象避免引用共享
|
||||||
rowList.value = {
|
rowList.value = {
|
||||||
@@ -237,10 +245,9 @@ const open = async (row: any, chnNum: string, deviceId: string | null, source: n
|
|||||||
// 复制其他需要的属性
|
// 复制其他需要的属性
|
||||||
devices: row.devices ? [...row.devices] : []
|
devices: row.devices ? [...row.devices] : []
|
||||||
}
|
}
|
||||||
} else if (source == 2) {
|
}
|
||||||
// 检测数据查询进入
|
// 检测数据查询进入---不区分检测数据查询和正式检测
|
||||||
await initScriptData(row)
|
await initScriptData()
|
||||||
}
|
|
||||||
visible.value = true
|
visible.value = true
|
||||||
scriptType = null
|
scriptType = null
|
||||||
formContent.errorSysId = checkStore.plan.errorSysId
|
formContent.errorSysId = checkStore.plan.errorSysId
|
||||||
@@ -249,16 +256,50 @@ const open = async (row: any, chnNum: string, deviceId: string | null, source: n
|
|||||||
// 获取误差体系
|
// 获取误差体系
|
||||||
let { data: resPqErrorList } = await getPqErrSysList()
|
let { data: resPqErrorList } = await getPqErrSysList()
|
||||||
Object.assign(pqErrorList, resPqErrorList)
|
Object.assign(pqErrorList, resPqErrorList)
|
||||||
// 获取基本信息
|
|
||||||
await getBasicInformation()
|
initGetResult()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const initGetResult = async () => {
|
||||||
|
// 查询表格数据
|
||||||
|
if(sourceKey.value == 1 && rowList.value.scriptName == "录波"){
|
||||||
|
isWaveData.value = true
|
||||||
|
// 设置录波数据相关的选项,与选中左侧录波树时保持一致
|
||||||
|
scriptNameOptions.value = selectScript.value
|
||||||
|
//.filter(item => item.code !== 'wave_data' && item.code !== 'FREQ')
|
||||||
|
.map(item => ({
|
||||||
|
label: item.scriptName,
|
||||||
|
value: item.scriptName
|
||||||
|
}))
|
||||||
|
|
||||||
|
// 默认选中第一个选项
|
||||||
|
if (scriptNameOptions.value.length > 0) {
|
||||||
|
|
||||||
|
selectedScriptName.value = scriptNameOptions.value[0].value
|
||||||
|
// 更新rowList以匹配选中的script
|
||||||
|
const selectedItem = scriptData.value.find(item => item.scriptName === selectedScriptName.value)
|
||||||
|
if (selectedItem) {
|
||||||
|
rowList.value.scriptName = selectedScriptName.value
|
||||||
|
rowList.value.scriptType = selectedItem.id
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await getResults('wave_data')
|
||||||
|
} else {
|
||||||
|
await getResults('')
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 查询大项树
|
// 查询大项树
|
||||||
const initScriptData = async (row?: any) => {
|
const initScriptData = async () => {
|
||||||
let response: any = await getBigTestItem({
|
let response: any = await getScriptList({
|
||||||
reCheckType: checkStore.reCheckType,
|
devId: formContent.deviceId,
|
||||||
planId: checkStore.plan.id,
|
chnNum: formContent.chnNum,
|
||||||
devIds: checkStore.devices.map(item => item.deviceId),
|
|
||||||
patternId: pattern.value
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// 格式化脚本数据
|
// 格式化脚本数据
|
||||||
@@ -268,10 +309,27 @@ const initScriptData = async (row?: any) => {
|
|||||||
scriptName: item.scriptName
|
scriptName: item.scriptName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 保存脚本数据
|
// 保存脚本数据
|
||||||
scriptData.value = temp
|
scriptData.value = temp
|
||||||
|
|
||||||
|
// 查找code为"录波"的项
|
||||||
|
let luoboItem = response.data.find((item: any) => item.code === 'wave_data');
|
||||||
|
// 如果找到了"录波"项,则使用其subitems,否则使用空数组
|
||||||
|
let temp2 = [];
|
||||||
|
if (luoboItem && luoboItem.subItems) {
|
||||||
|
|
||||||
|
// 格式化脚本数据
|
||||||
|
temp2 = luoboItem.subItems.map((item: any) => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
scriptName: item.scriptName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
selectScript.value = temp2
|
||||||
|
|
||||||
|
|
||||||
// 只有在sourceKey == 2时才设置rowList和tree相关属性
|
// 只有在sourceKey == 2时才设置rowList和tree相关属性
|
||||||
if (sourceKey.value === 2 && temp.length > 0) {
|
if (sourceKey.value === 2 && temp.length > 0) {
|
||||||
rowList.value.scriptName = temp[0].scriptName
|
rowList.value.scriptName = temp[0].scriptName
|
||||||
@@ -281,31 +339,43 @@ const initScriptData = async (row?: any) => {
|
|||||||
treeRef.value?.setCurrentKey(temp[0].id)
|
treeRef.value?.setCurrentKey(temp[0].id)
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取基本信息
|
|
||||||
const getBasicInformation = async () => {
|
|
||||||
|
// 获取基本信息
|
||||||
|
const getBasicInformation = async (scriptType: any) => {
|
||||||
checkResultData.value = []
|
checkResultData.value = []
|
||||||
rawTableData.value = []
|
rawTableData.value = []
|
||||||
|
const scriptType2 = ref('')
|
||||||
|
|
||||||
// 确保scriptData已初始化
|
if(sourceKey.value == 1){
|
||||||
if (scriptData.value.length === 0) {
|
scriptType2.value = scriptType
|
||||||
await initScriptData()
|
}else{
|
||||||
}
|
scriptType2.value = ''
|
||||||
|
}
|
||||||
getContrastFormContent({
|
|
||||||
planId: checkStore.plan.id,
|
//确保scriptData已初始化
|
||||||
scriptType: rowList.value.scriptType,
|
// if (scriptData.value.length === 0) {
|
||||||
deviceId: formContent.deviceId,
|
// await initScriptData()
|
||||||
chnNum: formContent.chnNum,
|
// }
|
||||||
num: formContent.num == '' ? null : parseInt(formContent.num),
|
|
||||||
patternId: pattern.value
|
try {
|
||||||
}).then((res: any) => {
|
const res: any = await getContrastFormContent({
|
||||||
|
planId: checkStore.plan.id,
|
||||||
|
scriptType: scriptType2.value,
|
||||||
|
deviceId: formContent.deviceId,
|
||||||
|
chnNum: formContent.chnNum,
|
||||||
|
num: formContent.num == '' ? null : parseInt(formContent.num),
|
||||||
|
patternId: pattern.value
|
||||||
|
})
|
||||||
|
|
||||||
formContent.dataRule = res.data.dataRule
|
formContent.dataRule = res.data.dataRule
|
||||||
formContent.deviceName = res.data.deviceName
|
formContent.deviceName = res.data.deviceName
|
||||||
formContent.errorSysId = res.data.errorSysId
|
formContent.errorSysId = res.data.errorSysId
|
||||||
chnMapList.value = res.data.chnMap
|
chnMapList.value = res.data.chnMap
|
||||||
//formContent.num = res.data.checkNum
|
|
||||||
|
|
||||||
let chnMap: string[] = []
|
let chnMap: string[] = []
|
||||||
for (let key in res.data.chnMap) {
|
for (let key in res.data.chnMap) {
|
||||||
@@ -313,7 +383,8 @@ const getBasicInformation = async () => {
|
|||||||
}
|
}
|
||||||
chnList.value = chnMap
|
chnList.value = chnMap
|
||||||
formContent.chnNum = formContent.chnNum == null ? chnList.value[0] : formContent.chnNum
|
formContent.chnNum = formContent.chnNum == null ? chnList.value[0] : formContent.chnNum
|
||||||
// 新增:设置检测次数默认值为chnMap数组的最后一位
|
|
||||||
|
// 设置检测次数默认值为chnMap数组的最后一位
|
||||||
if (chnMapList.value[formContent.chnNum] && chnMapList.value[formContent.chnNum].length > 0) {
|
if (chnMapList.value[formContent.chnNum] && chnMapList.value[formContent.chnNum].length > 0) {
|
||||||
// 获取当前通道号对应的检测次数数组,并设置为最后一个值(最大值)
|
// 获取当前通道号对应的检测次数数组,并设置为最后一个值(最大值)
|
||||||
const numList = chnMapList.value[formContent.chnNum]
|
const numList = chnMapList.value[formContent.chnNum]
|
||||||
@@ -321,41 +392,52 @@ const getBasicInformation = async () => {
|
|||||||
}
|
}
|
||||||
waveNumCount.value = res.data.waveNumTotal
|
waveNumCount.value = res.data.waveNumTotal
|
||||||
|
|
||||||
// 查询表格数据
|
|
||||||
if(sourceKey.value == 1 && rowList.value.scriptName == "录波"){
|
} catch (error) {
|
||||||
isWaveData.value = true
|
console.error('获取基本信息失败:', error)
|
||||||
// 设置录波数据相关的选项,与选中左侧录波树时保持一致
|
}
|
||||||
scriptNameOptions.value = scriptData.value
|
|
||||||
.filter(item => item.code !== 'wave_data' && item.code !== 'FREQ')
|
|
||||||
.map(item => ({
|
|
||||||
label: item.scriptName,
|
|
||||||
value: item.scriptName
|
|
||||||
}))
|
|
||||||
|
|
||||||
// 默认选中第一个选项
|
|
||||||
if (scriptNameOptions.value.length > 0) {
|
|
||||||
selectedScriptName.value = scriptNameOptions.value[0].value
|
|
||||||
// 更新rowList以匹配选中的script
|
|
||||||
const selectedItem = scriptData.value.find(item => item.scriptName === selectedScriptName.value)
|
|
||||||
if (selectedItem) {
|
|
||||||
rowList.value.scriptName = selectedScriptName.value
|
|
||||||
rowList.value.scriptType = selectedItem.id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getResults('wave_data')
|
|
||||||
}else{
|
|
||||||
getResults('')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleChnNumChange = async (value: string) => {
|
||||||
const handleChnNumChange = (value: string) => {
|
|
||||||
formContent.chnNum = value
|
formContent.chnNum = value
|
||||||
// 更新检测次数为当前通道的最后一条记录
|
// 更新检测次数为当前通道的最后一条记录
|
||||||
updateCheckNumForChn(value)
|
updateCheckNumForChn(value)
|
||||||
// 获取结果数据
|
// 执行通用变更处理逻辑
|
||||||
getResults('')
|
await handleCommonChange()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理检测次数变更
|
||||||
|
const handleNumChange = async (value: string) => {
|
||||||
|
formContent.num = value
|
||||||
|
// 执行通用变更处理逻辑
|
||||||
|
await handleCommonChange()
|
||||||
|
}
|
||||||
|
// 通用的变更处理函数
|
||||||
|
const handleCommonChange = async () => {
|
||||||
|
// 重新初始化脚本数据(更新左侧树)
|
||||||
|
await initScriptData()
|
||||||
|
|
||||||
|
// 触发当前选中节点的点击事件,保持界面状态一致
|
||||||
|
if (sourceKey.value === 2 && scriptData.value.length > 0) {
|
||||||
|
// 查找当前选中的节点
|
||||||
|
const currentNode = scriptData.value.find((item: any) => item.id === rowList.value.scriptType)
|
||||||
|
|
||||||
|
if (currentNode) {
|
||||||
|
// 如果找到了当前节点,则触发点击事件
|
||||||
|
handleNodeClick(currentNode)
|
||||||
|
} else {
|
||||||
|
// 如果没有找到当前节点,则默认触发第一个节点的点击事件
|
||||||
|
handleNodeClick(scriptData.value[0])
|
||||||
|
}
|
||||||
|
} else if (sourceKey.value === 1 && rowList.value.scriptType) {
|
||||||
|
// 对于正式检测进入的情况,创建一个临时节点对象来触发handleNodeClick
|
||||||
|
const tempNode = {
|
||||||
|
scriptName: rowList.value.scriptName,
|
||||||
|
id: rowList.value.scriptType,
|
||||||
|
code: rowList.value.scriptName === "录波" ? 'wave_data' : ''
|
||||||
|
}
|
||||||
|
handleNodeClick(tempNode)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新检测次数为指定通道的最后一条记录
|
// 更新检测次数为指定通道的最后一条记录
|
||||||
@@ -376,8 +458,8 @@ const handleNodeClick = (data: any) => {
|
|||||||
if (data.code === 'wave_data') {
|
if (data.code === 'wave_data') {
|
||||||
isWaveData.value = true
|
isWaveData.value = true
|
||||||
// 过滤掉"录波"选项,设置下拉框数据
|
// 过滤掉"录波"选项,设置下拉框数据
|
||||||
scriptNameOptions.value = scriptData.value
|
scriptNameOptions.value = selectScript.value
|
||||||
.filter(item => item.code !== 'wave_data' && item.code !== 'FREQ')
|
//.filter(item => item.code !== 'wave_data' && item.code !== 'FREQ')
|
||||||
.map(item => ({
|
.map(item => ({
|
||||||
label: item.scriptName,
|
label: item.scriptName,
|
||||||
value: item.scriptName
|
value: item.scriptName
|
||||||
@@ -405,7 +487,6 @@ const getResults = async (code: any) => {
|
|||||||
checkResultData.value = []
|
checkResultData.value = []
|
||||||
rawTableData.value = []
|
rawTableData.value = []
|
||||||
|
|
||||||
|
|
||||||
// 判断是否为录波数据请求
|
// 判断是否为录波数据请求
|
||||||
const isWaveDataRequest = code === 'wave_data' || isWaveData.value
|
const isWaveDataRequest = code === 'wave_data' || isWaveData.value
|
||||||
|
|
||||||
@@ -427,6 +508,8 @@ const getResults = async (code: any) => {
|
|||||||
tesList.value = list
|
tesList.value = list
|
||||||
checkResultData.value = res.data.resultMap
|
checkResultData.value = res.data.resultMap
|
||||||
rawTableData.value = res.data.rawDataMap
|
rawTableData.value = res.data.rawDataMap
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user