通道配对
This commit is contained in:
@@ -44,6 +44,9 @@ import {dialogBig} from "@/utils/elementBind";
|
||||
import {Platform,Promotion,Flag} from '@element-plus/icons-vue'
|
||||
import { c } from 'vite/dist/node/types.d-aGj9QkWt';
|
||||
import { de, el } from 'element-plus/es/locale';
|
||||
import { Device } from '@/api/device/interface/device';
|
||||
import { Plan } from '@/api/plan/interface';
|
||||
import { StandardDevice } from '@/api/device/interface/standardDevice';
|
||||
const dialogVisible = ref(false)
|
||||
// 初始化 VueFlow
|
||||
const { edges} = useVueFlow()
|
||||
@@ -331,30 +334,69 @@ function logConnections() {
|
||||
}
|
||||
|
||||
const nodes = ref([])
|
||||
const open = async () => {
|
||||
nodes.value = createNodes()
|
||||
const open = async (device:Device.ResPqDev[],standardDev:StandardDevice.ResPqStandardDevice[]) => {
|
||||
nodes.value = createNodes(device,standardDev)
|
||||
dialogVisible.value = true
|
||||
}
|
||||
|
||||
// 每台设备的通道数量
|
||||
const channelCounts = {
|
||||
'1': 1, // 被检设备1 → 4个通道
|
||||
'3': 3, // 被检设备2 → 2个通道
|
||||
'5': 2, // 被检设备3 → 2个通道
|
||||
'7': 4 // 被检设备4 → 4个通道
|
||||
}
|
||||
// // 每台设备的通道数量
|
||||
// const channelCounts = {
|
||||
// '1': 1, // 被检设备1 → 4个通道
|
||||
// '3': 3, // 被检设备2 → 2个通道
|
||||
// '5': 2, // 被检设备3 → 2个通道
|
||||
// '7': 4 // 被检设备4 → 4个通道
|
||||
// }
|
||||
|
||||
// 每台设备的通道数量
|
||||
const channelCounts2 = {
|
||||
'2': 2, // 标准设备1 → 2个通道
|
||||
'4': 1, // 标准设备2 → 1个通道
|
||||
}
|
||||
// const channelCounts2 = {
|
||||
// '2': 2, // 标准设备1 → 2个通道
|
||||
// '4': 1, // 标准设备2 → 1个通道
|
||||
// }
|
||||
|
||||
// const inspectionDevices = [
|
||||
// { id: '1', name: '被检设备1', type: 'normal', deviceType: 'PQS-882B4' },
|
||||
// { id: '3', name: '被检设备2', type: 'normal', deviceType: 'PQS-883A2' },
|
||||
// { id: '5', name: '被检设备3', type: 'normal', deviceType: 'PQS-882B2' },
|
||||
// { id: '7', name: '被检设备4', type: 'normal', deviceType: 'PQS_883B' }
|
||||
// ]
|
||||
|
||||
// const standardDevices = [
|
||||
// { id: '2', name: '标准设备1', type: 'normal', deviceType: 'PQS-882A' },
|
||||
// { id: '4', name: '标准设备2', type: 'normal', deviceType: 'PQS-882B2' },
|
||||
// ]
|
||||
|
||||
const createNodes = (device: Device.ResPqDev[], standardDev: StandardDevice.ResPqStandardDevice[]) => {
|
||||
|
||||
const channelCounts: Record<string, number> = {}
|
||||
// 每台被检设备的通道数量
|
||||
device.forEach(device => {
|
||||
channelCounts[device.id] = device.devChns || 0
|
||||
})
|
||||
// 每台被检设备的信息
|
||||
const inspectionDevices = device.map(d => ({
|
||||
id: d.id,
|
||||
name: d.name,
|
||||
type: 'normal',
|
||||
deviceType: d.devType
|
||||
}))
|
||||
|
||||
const channelCounts2: Record<string, number> = {}
|
||||
// 每台标准设备的通道数量
|
||||
standardDev.forEach(dev => {
|
||||
const channelList = dev.inspectChannel ? dev.inspectChannel.split(',') : []
|
||||
channelCounts2[dev.id] = channelList.length
|
||||
})
|
||||
console.log(standardDev)
|
||||
// 每台标准设备的信息
|
||||
const standardDevices = standardDev.map(d => ({
|
||||
id: d.id,
|
||||
name: d.name,
|
||||
type: 'normal',
|
||||
deviceType: d.devType
|
||||
}))
|
||||
|
||||
|
||||
|
||||
const createNodes = () => {
|
||||
const newNodes: any[] = []
|
||||
|
||||
|
||||
// 存储每组被检/标准通道的垂直范围
|
||||
const deviceChannelGroups: { deviceId: string; centerY: number; }[] = []
|
||||
const standardChannelGroups: any[] = []
|
||||
@@ -472,17 +514,6 @@ const createNodes = () => {
|
||||
return newNodes
|
||||
}
|
||||
|
||||
const inspectionDevices = [
|
||||
{ id: '1', name: '被检设备1', type: 'normal', deviceType: 'PQS-882B4' },
|
||||
{ id: '3', name: '被检设备2', type: 'normal', deviceType: 'PQS-883A2' },
|
||||
{ id: '5', name: '被检设备3', type: 'normal', deviceType: 'PQS-882B2' },
|
||||
{ id: '7', name: '被检设备4', type: 'normal', deviceType: 'PQS_883B' }
|
||||
]
|
||||
|
||||
const standardDevices = [
|
||||
{ id: '2', name: '标准设备1', type: 'normal', deviceType: 'PQS-882A' },
|
||||
{ id: '4', name: '标准设备2', type: 'normal', deviceType: 'PQS-882B2' },
|
||||
]
|
||||
|
||||
|
||||
defineExpose({open})
|
||||
|
||||
@@ -274,7 +274,7 @@ import reportPopup from './reportPopup.vue'
|
||||
import dataCheckPopup from './dataCheckSingleChannelSingleTestPopup.vue'
|
||||
import dataCheckChangeErrSysPopup from './dataCheckChangeErrSysPopup.vue'
|
||||
import {generateDevReport, getBoundPqDevList} from '@/api/plan/plan.ts'
|
||||
import {onBeforeMount, onMounted, reactive, ref, watch} from 'vue'
|
||||
import {onBeforeMount, onMounted, PropType, reactive, ref, watch} from 'vue'
|
||||
import {useDictStore} from '@/stores/modules/dict'
|
||||
import ChannelsTest from './channelsTest.vue'
|
||||
import {useModeStore,useAppSceneStore} from '@/stores/modules/mode' // 引入模式 store
|
||||
@@ -291,6 +291,9 @@ import {ResultEnum} from '@/enums/httpEnum'
|
||||
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 { Plan } from '@/api/plan/interface'
|
||||
import { StandardDevice } from '@/api/device/interface/standardDevice'
|
||||
import { s } from 'vite/dist/node/types.d-aGj9QkWt'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const checkStore = useCheckStore()
|
||||
@@ -363,6 +366,10 @@ const props = defineProps({
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
planArray: {
|
||||
type: Array as PropType<Plan.ReqPlan[]>,
|
||||
default: null,
|
||||
},
|
||||
})
|
||||
const appSceneStore = useAppSceneStore()
|
||||
|
||||
@@ -522,13 +529,47 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
minWidth: 100,
|
||||
minWidth: 150,
|
||||
// render: (scope) => {
|
||||
// // 查找设备类型名称
|
||||
// const name = devTypeOptions.value.find(option => option.id === scope.row.devType)
|
||||
// return <span>{name?.name}</span>
|
||||
// },
|
||||
},
|
||||
{
|
||||
prop: 'boundPlanName',
|
||||
label: '来源计划名称',
|
||||
minWidth: 200,
|
||||
isShow:modeStore.currentMode === '比对式',
|
||||
render(scope) {
|
||||
return scope.row.boundPlanName ? scope.row.boundPlanName : props.plan.name
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'standardDevs',
|
||||
label: '标准设备',
|
||||
minWidth: 200,
|
||||
isShow:modeStore.currentMode === '比对式',
|
||||
render(scope) {
|
||||
const boundPlanName = ref('')
|
||||
if(scope.row.boundPlanName){
|
||||
boundPlanName.value = scope.row.boundPlanName
|
||||
}else{
|
||||
boundPlanName.value = props.plan.name
|
||||
}
|
||||
const standardDevNames = props.planArray.flatMap(item => {
|
||||
if (item.children) {
|
||||
return item.children
|
||||
.filter(child => child.name === boundPlanName.value)
|
||||
.flatMap(child =>
|
||||
child.standardDevs.map(dev => dev.name)
|
||||
)
|
||||
}
|
||||
return []
|
||||
})
|
||||
return standardDevNames.length > 0 ? standardDevNames.join(',') : '/'
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'devChns',
|
||||
label: '通道数',
|
||||
@@ -631,6 +672,7 @@ const resetSearchForm = () => {
|
||||
let testType = 'test'//检测还是复检
|
||||
|
||||
const handleSelectionChange = (selection: any[]) => {
|
||||
|
||||
channelsSelection.value = selection
|
||||
devNum = selection.length
|
||||
devChannelsNum = 0
|
||||
@@ -852,7 +894,64 @@ const addDevice = (val: string) => {
|
||||
|
||||
|
||||
const handleTest2 = () => {
|
||||
deviceConnectionPopupRef.value?.open()
|
||||
if (devNum == 0) {
|
||||
ElMessageBox.confirm(
|
||||
'请先选择被检设备',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
const planName = channelsSelection.value.map(item => item.boundPlanName)
|
||||
const isPlanConsistent = new Set(planName).size === 1
|
||||
if (!isPlanConsistent) {
|
||||
ElMessageBox.confirm(
|
||||
'所勾选被检设备所属计划名称不一致,请重新选择',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
const boundPlanName = ref('')
|
||||
if(channelsSelection.value[0].boundPlanName){
|
||||
boundPlanName.value = channelsSelection.value[0].boundPlanName
|
||||
}else{
|
||||
boundPlanName.value = props.plan.name
|
||||
}
|
||||
const pqStandardDevList=ref<StandardDevice.ResPqStandardDevice[]>([])
|
||||
pqStandardDevList.value = props.planArray.flatMap(item => {
|
||||
if (item.children) {
|
||||
return item.children
|
||||
.filter(child => child.name === boundPlanName.value)
|
||||
.flatMap(child =>
|
||||
child.standardDevs
|
||||
)
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
if(pqStandardDevList.value.length==0){
|
||||
ElMessageBox.confirm(
|
||||
'所勾选被检设备所属计划无标准设备,请重新选择',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
deviceConnectionPopupRef.value?.open(channelsSelection.value,pqStandardDevList.value)
|
||||
}
|
||||
|
||||
const handleTest = async (val: string) => {
|
||||
|
||||
Reference in New Issue
Block a user