This commit is contained in:
caozehui
2024-12-31 19:03:52 +08:00
parent 081aeacff7
commit 5e8dda0b75
6 changed files with 306 additions and 360 deletions

View File

@@ -1,5 +1,4 @@
import http from "@/api"; import http from "@/api";
import {CheckData} from "@/api/check/interface";
export const getBigTestItem = (planId: string) => { export const getBigTestItem = (planId: string) => {
return http.get(`/adPlan/getBigTestItem?planId=${planId}`, {loading: false}); return http.get(`/adPlan/getBigTestItem?planId=${planId}`, {loading: false});
@@ -9,7 +8,12 @@ export const getBigTestItem = (planId: string) => {
* 获取弹出框表单数据 * 获取弹出框表单数据
* @param params 当为scriptType为null时表示查询所有脚本类型否则只查询指定脚本类型。当为chnNum为-1时表示查询所有通道否则只查询指定通道。 * @param params 当为scriptType为null时表示查询所有脚本类型否则只查询指定脚本类型。当为chnNum为-1时表示查询所有通道否则只查询指定通道。
*/ */
export const getFormData = (params: { planId: string, deviceId: string, chnNum: string, scriptType: string|null }) => { export const getFormData = (params: {
scriptId: string,
deviceId: string,
chnNum: string,
scriptType: string | null
}) => {
return http.post("/result/formContent/", params, {loading: false}); return http.post("/result/formContent/", params, {loading: false});
} }
@@ -17,7 +21,13 @@ export const getFormData = (params: { planId: string, deviceId: string, chnNum:
* 获取树形结构数据 * 获取树形结构数据
* @param params * @param params
*/ */
export const getTreeData = (params: { deviceId: string, chnNum: string, checkItemId: string }) => { export const getTreeData = (params: {
scriptId: string,
deviceId: string,
chnNum: string,
scriptType: string | null,
flag: number
}) => {
return http.post("/result/treeData/", params, {loading: false}); return http.post("/result/treeData/", params, {loading: false});
} }
@@ -25,6 +35,11 @@ export const getTreeData = (params: { deviceId: string, chnNum: string, checkIte
* 获取检查数据 * 获取检查数据
* @param params * @param params
*/ */
export const getTableData = (params: { deviceId: string, chnNum: string, checkItemId: string }) => { export const getTableData = (params: {
scriptId: string,
deviceId: string,
chnNum: string,
scriptType: string | null
}) => {
return http.post("/result/tableData/", params, {loading: false}); return http.post("/result/tableData/", params, {loading: false});
} }

View File

@@ -9,6 +9,7 @@ export const useCheckStore = defineStore("check", {
state: () => ({ state: () => ({
devices: Array<CheckData.Device>(), devices: Array<CheckData.Device>(),
planId: String(""), planId: String(""),
scriptId: String(""),
}), }),
getters: {}, getters: {},
@@ -24,6 +25,10 @@ export const useCheckStore = defineStore("check", {
setPlanId(planId: string) { setPlanId(planId: string) {
this.planId = planId this.planId = planId
},
setScriptId(scriptId: string) {
this.scriptId = scriptId
} }
} }
}); });

View File

@@ -37,7 +37,6 @@ const phaseFlag = computed(() => {
if (tableData.length > 0) { if (tableData.length > 0) {
result = !tableData[0].T ? 0 : 1; result = !tableData[0].T ? 0 : 1;
} }
console.log(result);
return result; return result;
}) })

View File

@@ -90,7 +90,6 @@ const phaseFlag = computed(() => {
if (tableData.length > 0) { if (tableData.length > 0) {
result = !tableData[0].T ? 0:1; result = !tableData[0].T ? 0:1;
} }
console.log(result);
return result; return result;
}) })

View File

@@ -17,7 +17,7 @@
<el-input v-model='formContent.deviceName' :disabled="true"/> <el-input v-model='formContent.deviceName' :disabled="true"/>
</el-form-item> </el-form-item>
<el-form-item label='通道号'> <el-form-item label='通道号'>
<el-select v-model="formContent.monitorIdx" @change="handleChnChange"> <el-select v-model="formContent.chnNum">
<el-option v-for="item in chnList" :key="item.value" :label="item.label" <el-option v-for="item in chnList" :key="item.value" :label="item.label"
:value="item.value"/> :value="item.value"/>
</el-select> </el-select>
@@ -28,14 +28,14 @@
<div class="data-check-body"> <div class="data-check-body">
<div class="content-left-tree"> <div class="content-left-tree">
<div> <div>
<el-radio-group v-model="switchItem"> <el-radio-group v-model="switchItem" @change="handleSwitchChange">
<el-radio-button label="不符合测试项" :value="0"/> <el-radio-button label="不符合测试项" :value="0"/>
<el-radio-button label="全部测试项" :value="1"/> <el-radio-button label="全部测试项" :value="1"/>
</el-radio-group> </el-radio-group>
</div> </div>
<div class="content-tree"> <div class="content-tree">
<el-tree v-if="switchItem === 0" :default-expanded-keys="defaultExpandedKeys" node-key="id" <el-tree v-if="switchItem === 0" :default-expanded-keys="defaultExpandedKeys" node-key="id"
:data="treeDataUnQualified" :props="defaultProps" @node-click="handleNodeClick"/> :data="treeDataUnqualified" :props="defaultProps" @node-click="handleNodeClick"/>
<el-tree v-if="switchItem === 1" :default-expanded-keys="defaultExpandedKeys" node-key="id" <el-tree v-if="switchItem === 1" :default-expanded-keys="defaultExpandedKeys" node-key="id"
:data="treeDataAll" :props="defaultProps" @node-click="handleNodeClick"/> :data="treeDataAll" :props="defaultProps" @node-click="handleNodeClick"/>
</div> </div>
@@ -68,7 +68,6 @@ import {reactive, ref} from 'vue'
import DataCheckResultTable from './dataCheckResultTable.vue' import DataCheckResultTable from './dataCheckResultTable.vue'
import DataCheckRawDataTable from './dataCheckRawDataTable.vue' import DataCheckRawDataTable from './dataCheckRawDataTable.vue'
import {CheckData} from "@/api/check/interface"; import {CheckData} from "@/api/check/interface";
import {getFormData, getTreeData, getTableData} from "@/api/check/test";
import {useDictStore} from "@/stores/modules/dict"; import {useDictStore} from "@/stores/modules/dict";
import {useCheckStore} from "@/stores/modules/check"; import {useCheckStore} from "@/stores/modules/check";
@@ -92,7 +91,7 @@ const formContent = reactive<CheckData.DataCheck>({
errorSysName: '', errorSysName: '',
dataRule: '', dataRule: '',
deviceName: '', deviceName: '',
monitorIdx: '', chnNum: '',
}) })
let deviceId: string = '' let deviceId: string = ''
let scriptType: string | null = null let scriptType: string | null = null
@@ -101,22 +100,21 @@ let scriptType: string | null = null
let chnList: any[] = [] let chnList: any[] = []
// 不符合测试项、全部测试项切换 // 不符合测试项、全部测试项切换
const switchItem = ref<number>(-1) const switchItem = ref<number>(0)
// 左侧树数据-不符合测试项 // 左侧树数据
let treeDataUnQualified: CheckData.ScriptItem[] = [] let treeDataUnqualified: CheckData.ScriptItem[] = []
// 左侧树数据-全部测试项
let treeDataAll: CheckData.ScriptItem[] = [] let treeDataAll: CheckData.ScriptItem[] = []
// 左侧树被选中的叶子节点id // 左侧树被选中的叶子节点id
const checkedScriptId = ref<string>('') const checkedScriptId = ref<string>('')
const currentScriptDsc = ref(''); const currentScriptDsc = ref('');
// 右侧Tab选中项 // 右侧Tab选中项
const activeTab = ref<string>('resultTab') const activeTab = ref<string>('resultTab')
// 检测结果表格数据 // 检测结果表格数据
const checkResultTableData = reactive<CheckData.CheckResult[]>([]) let checkResultTableData: CheckData.CheckResult = []
// 原始数据表格数据 // 原始数据表格数据
const rawTableData = reactive<CheckData.RawDataItem[]>([]) let rawTableData: CheckData.RawDataItem[] = []
const resultTableRef = ref() const resultTableRef = ref()
const rawDataTableRef = ref() const rawDataTableRef = ref()
@@ -124,35 +122,146 @@ const rawDataTableRef = ref()
// 左侧树默认展开节点id // 左侧树默认展开节点id
let defaultExpandedKeys: string[] = [] let defaultExpandedKeys: string[] = []
// 监控通道号下拉框
const handleChnChange = (data: any) => {
console.log("通道号下拉框", data);
// 后端请求,查询该通道号下的测试项(可以只查询不合格测试项,也可以全部测试项、不合格测试项都查询)
// const result = await getTreeData({deviceId, formContent.monitorIdx, scriptType})
// treeDataUnQualified=[]
// treeDataAll=[]
switchItem.value = 0
}
// 点击左侧树节点触发事件 // 点击左侧树节点触发事件
const handleNodeClick = (data: any) => { const handleNodeClick = async (data: any) => {
if (!data.children) { if (!data.children) {
checkedScriptId.value = data.id checkedScriptId.value = data.id
currentScriptDsc.value = data.scriptName currentScriptDsc.value = data.scriptName
if (checkedScriptId.value) {
await updateTableData()
}
} }
}; };
watch(checkedScriptId, (newVal, oldVal) => { watch(() => formContent.chnNum, async (newVal, oldVal) => {
if (newVal) { console.log("通道号", newVal);
console.log("左侧树被选中的叶子节点id", newVal);
// 发起请求,查询该测试项的检测结果
// const result = await getTableData({deviceId, formContent.monitorIdx, scriptType})
Object.assign(checkResultTableData, [{ switchItem.value = 0
await handleSwitchChange(0)
})
const handleSwitchChange = async (data: any) => {
console.log("切换不合格测试项、全部测试项", data);
if (data === 0) {
// 发起请求,查询该测试项的检测结果
// const result = await getTreeData({checkStore.scriptId,deviceId, formContent.chnNum+'', scriptType,0})
treeDataUnqualified = [{
"id": "1",
"scriptName": "频率准确度检测",
"children": [
{
"id": "1-2",
"scriptName": "电压对频率测量的影响",
"children": [
{
"id": "1-2-1",
"scriptName": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"id": "1-2-2",
"scriptName": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"id": "1-2-3",
"scriptName": "输入:频率 52.05Hz Ua =10%Un..."
}
]
},
{
"id": "1-3",
"scriptName": "谐波对频率测量的影响",
"children": [
{
"id": "1-3-1",
"scriptName": "输入:频率 50.05Hz Ua =100%Un..."
}
]
}
]
}]
} else {
// 发起请求,查询该测试项的检测结果
// const result = await getTreeData({checkStore.scriptId,deviceId, formContent.chnNum+'', scriptType,1})
treeDataAll = [{
"id": "1",
"scriptName": "频率准确度检测",
"children": [
{
"id": "1-1",
"scriptName": "额定工作条件下的检测",
"children": [
{
"id": "1-1-1",
"scriptName": "输入:频率 42.5Hz..."
},
{
"id": "1-1-2",
"scriptName": "输入:频率 50.0Hz..."
},
{
"id": "1-1-3",
"scriptName": "输入:频率 50.05Hz...."
}
]
},
{
"id": "1-2",
"scriptName": "电压对频率测量的影响",
"children": [
{
"id": "1-2-1",
"scriptName": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"id": "1-2-2",
"scriptName": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"id": "1-2-3",
"scriptName": "输入:频率 52.05Hz Ua =10%Un..."
}
]
},
{
"id": "1-3",
"scriptName": "谐波对频率测量的影响",
"children": [
{
"id": "1-3-1",
"scriptName": "输入:频率 50.05Hz Ua =100%Un..."
}
]
}
]
}]
}
defaultOperate()
await updateTableData()
}
// 默认操作
const defaultOperate = () => {
let node = null
if (switchItem.value === 0) {
node = getDefaultNode(treeDataUnqualified)
} else {
node = getDefaultNode(treeDataAll)
}
currentScriptDsc.value = node?.scriptName
checkedScriptId.value = node?.id
defaultExpandedKeys = [node?.id]
}
const updateTableData = async () => {
console.log("左侧树被选中的叶子节点id", checkedScriptId.value);
// 发起请求,查询该测试项的检测结果
// const result = await getTableData({checkStore.scriptId,deviceId, formContent.chnNum, scriptType})
checkResultTableData = [{
chnNum: '1', chnNum: '1',
standardValue: 57.74, standardValue: 57.74,
A: 57.73, A: 57.73,
@@ -163,17 +272,9 @@ watch(checkedScriptId, (newVal, oldVal) => {
C_errValue: 0.01, C_errValue: 0.01,
maxErrVaule: 0.05774, maxErrVaule: 0.05774,
result: '合格', result: '合格',
}]) }]
// Object.assign(checkResultTableData, [{
// chnNum: '1',
// standardValue: 57.74,
// T: 57.73,
// T_errValue: 0.01,
// maxErrVaule: 0.05774,
// result: '合格',
// }])
Object.assign(rawTableData, [ rawTableData = [
{ {
updateTime: "2024-10-10 09:30:00", updateTime: "2024-10-10 09:30:00",
A: 57.73, A: 57.73,
@@ -294,115 +395,16 @@ watch(checkedScriptId, (newVal, oldVal) => {
B: 57.73, B: 57.73,
C: 57.73, C: 57.73,
} }
]) ]
}
// Object.assign(rawTableData, [ const open = (_deviceId: string, chnNum: string, _scriptType: string | null) => {
// { console.log(checkStore.scriptId, _deviceId, chnNum, _scriptType);
// updateTime: "2024-10-10 09:30:00",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:03",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:06",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:09",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:12",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:15",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:18",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:21",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:24",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:27",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:30",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:33",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:36",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:39",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:42",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:45",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:48",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:51",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:54",
// T: 57.73,
// },
// {
// updateTime: "2024-10-10 09:30:57",
// T: 57.73,
// }
// ])
}
})
// 切换不合格测试项、全部测试项 触发事件
watch(switchItem, (newVal, oldVal) => {
let node = null
if (newVal === 0) {
node = getDefaultNode(treeDataUnQualified)
}
if (newVal === 1) {
node = getDefaultNode(treeDataAll)
}
currentScriptDsc.value = node?.scriptName
checkedScriptId.value = node?.id
defaultExpandedKeys = [node?.id]
})
const open = async (_deviceId: string, chnNum: string, _scriptType: string | null) => {
console.log(_deviceId, chnNum, _scriptType);
deviceId = _deviceId deviceId = _deviceId
scriptType = _scriptType scriptType = _scriptType
switchItem.value = 0
// 发起后端请求,查询详细信息 当chnNum为-1时查询所有通道号 // 发起后端请求,查询详细信息 当chnNum为-1时查询所有通道号
//const resFormContent = await getFormData({checkStore.planId,deviceId, chnNum,scriptType}) //const resFormContent = await getFormData({checkStore.scriptId,deviceId, chnNum,scriptType})
// 数据处理 // 数据处理
let resFormContent = { let resFormContent = {
@@ -423,87 +425,9 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul
let dataRuleName = dictStore.getDictData('Data_Rule').find(item => item.id == resFormContent.dataRule)?.name let dataRuleName = dictStore.getDictData('Data_Rule').find(item => item.id == resFormContent.dataRule)?.name
Object.assign(formContent, {...resFormContent, dataRule: dataRuleName, monitorIdx: chnList[0].value}) Object.assign(formContent, {...resFormContent, dataRule: dataRuleName, chnNum: chnList[0].value})
// const result2 = await getTreeData({deviceId, formContent.monitorIdx, checkItemId})
treeDataAll = [{
"id": "1",
"scriptName": "频率准确度检测",
"children": [
{
"id": "1-1",
"scriptName": "额定工作条件下的检测",
"children": [
{
"id": "1-1-1",
"scriptName": "输入:频率 42.5Hz..."
},
{
"id": "1-1-2",
"scriptName": "输入:频率 50.0Hz..."
},
{
"id": "1-1-3",
"scriptName": "输入:频率 50.05Hz...."
}
]
},
{
"id": "1-2",
"scriptName": "电压对频率测量的影响",
"children": [
{
"id": "1-2-1",
"scriptName": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"id": "1-2-1",
"scriptName": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"id": "1-2-2",
"scriptName": "输入:频率 52.05Hz Ua =10%Un..."
}
]
},
{
"id": "1-3",
"scriptName": "谐波对频率测量的影响",
"children": [
{
"id": "1-3-1",
"scriptName": "输入:频率 50.05Hz Ua =100%Un..."
}
]
}
]
}]
treeDataUnQualified = [{
"id": "1",
"scriptName": "频率准确度检测",
"children": [
{
"id": "1-2",
"scriptName": "电压对频率测量的影响",
"children": [
{
"id": "1-2-1",
"scriptName": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"id": "1-2-1",
"scriptName": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"id": "1-2-2",
"scriptName": "输入:频率 52.05Hz Ua =10%Un..."
}
]
}
]
}]
visible.value = true; visible.value = true;
} }
@@ -514,14 +438,14 @@ const close = () => {
errorSysName: '', errorSysName: '',
dataRule: '', dataRule: '',
deviceName: '', deviceName: '',
monitorIdx: '', chnNum: '',
}) })
treeDataUnqualified = []
treeDataAll = [] treeDataAll = []
treeDataUnQualified = []
checkedScriptId.value = '' checkedScriptId.value = ''
activeTab.value = 'rawDataTab' activeTab.value = 'rawDataTab'
currentScriptDsc.value = '' currentScriptDsc.value = ''
switchItem.value = -1 switchItem.value = 0
visible.value = false; visible.value = false;
}; };

View File

@@ -37,8 +37,11 @@ import { type Plan } from '@/api/plan/interface';
import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue' import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue'
import { onMounted, ref, watch } from 'vue'; import { onMounted, ref, watch } from 'vue';
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import {useCheckStore} from "@/stores/modules/check";
const router = useRouter() const router = useRouter()
const checkStore = useCheckStore()
const data: any = ref([]) const data: any = ref([])
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
@@ -71,6 +74,7 @@ watch(
}, },
) )
const handleNodeClick = (data: Plan.ResPlan) => { const handleNodeClick = (data: Plan.ResPlan) => {
checkStore.setScriptId(data.scriptId)
updateSelectedTreeNode(data.id) updateSelectedTreeNode(data.id)
} }
const filterNode = (value: string, data: any) => { const filterNode = (value: string, data: any) => {