优化检测脚本页面

录入检测脚本
This commit is contained in:
GGJ
2025-02-27 08:41:33 +08:00
parent 8b2cda80b1
commit 0bae200241
11 changed files with 924 additions and 334 deletions

View File

@@ -1,6 +1,6 @@
<template>
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogBig" width="1400px">
<el-carousel height="620px" :autoplay="false" ref="carouselRef" indicator-position="none">
<el-dialog :title="dialogTitle" v-model="dialogVisible" @close="close" v-bind="dialogBig" width="1450px">
<el-carousel height="600px" :autoplay="false" ref="carouselRef" indicator-position="none">
<el-carousel-item :name="0" style="height: 100%; overflow-y: auto">
<div class="dialog-content">
<el-tabs type="border-card" class="right-tabs">
@@ -110,16 +110,11 @@
<el-tabs type="border-card" class="right-tabs" style="height: 100%">
<el-tab-pane label="全局设置菜单">
<!-- 全局设置菜单内容 -->
<div style="height: 295px">
<div style="height: 295px; width: 170px">
<div class="form-item-container">
<el-form-item label="频率:" prop="name">
<div class="input-label-container">
<el-input
type="number"
@mousewheel.native.prevent
style="width: 100px"
v-model="form.ffreq"
/>
<el-input type="number" style="width: 100px" v-model="form.ffreq" />
<label>Hz</label>
</div>
</el-form-item>
@@ -132,7 +127,7 @@
</el-tab-pane>
</el-tabs>
</div>
<div style="margin-top: 10px; height: 245px">
<div style="margin-top: 10px; height: 234px">
<el-tabs type="border-card" class="custom-tabs">
<el-tab-pane label="电压/电流编辑" v-if="childForm[0].channelFlag || childForm[1].channelFlag">
<TestScriptVolCurTab :childForm="childForm" :valueCode="valueCode" />
@@ -213,6 +208,7 @@ const props = defineProps({
required: true
}
})
const copyRowList = ref({})
const key = ref(0)
// let valueType
const showSetValueTable = ref(false)
@@ -262,7 +258,7 @@ const tableStyle = {
}
}
const handleRowClick = async (row: any, column: any) => {
if (column.label == '相别') {
if (column.label == '相别' || column.label == '操作') {
childForm.value = []
selectedRow.value = row.name
childForm.value.push(form.value.channelList[row.sort * 2])
@@ -283,6 +279,12 @@ const close = () => {
const save = () => {
let copyForm = handleHarmData()
copyForm.checkDataList = setValueTableRef.value?.getTableData()
if (copyForm.checkDataList.some(item => item.value === null || item.value === '')) {
return ElMessage.warning({
message: '请填写所有参考设定值',
type: 'warning'
})
}
addScriptDtls({ ...copyForm, scriptId: props.formContent.id, scriptType: props.activeName }).then(res => {
if (res.code === 'A0000') {
ElMessage.success({
@@ -305,48 +307,207 @@ const next = () => {
emit('getCommunication')
setTimeout(() => {
// 判断通讯脚本
if (!checkFlags(props.communicationList)) {
if (form.value.ffreq == '') {
ElMessage.warning({
message: '请先完善通讯脚本',
message: '请填写频率!',
type: 'warning'
})
return
}
// 判断够选通道
if (!checkChannel(form.value)) {
let { flag, message } = checkFlags()
// // 判断够选通道
if (!flag) {
ElMessage.warning({
message: '请先选择使能通道',
message: message,
type: 'warning'
})
return
}
}, 100)
showSetValueTable.value = true
setTimeout(() => {
setValueTableRef.value?.open(props.communicationList)
carouselRef.value.setActiveItem(1)
showSetValueTable.value = true
setTimeout(() => {
setValueTableRef.value?.open(props.communicationList, copyRowList.value)
carouselRef.value.setActiveItem(1)
}, 100)
}, 100)
// 切换轮播图
}
// 判断通讯脚本是否有值
const checkFlags = (data: any) => {
for (let i = 0; i < data.length; i++) {
const item = data[i]
if (item.children) {
for (let j = 0; j < item.children.length; j++) {
const child = item.children[j]
if (child.errorFlag != 0 || child.enable != 0) {
return true
}
}
// 判断够选通道
const checkFlags = () => {
let list: any = []
let flag = true
let message = ''
props.communicationList.forEach((item: any) => {
list.push(...item.children.filter((item: any) => item.enable != 0 || item.errorFlag != 0))
})
for (const item of list) {
switch (item.pname) {
case '频率':
flag = form.value.channelList.some(item => item.channelFlag == true)
message = '请选择通道使能'
break
case '电压':
if (
form.value.channelList[0].channelFlag == false &&
form.value.channelList[2].channelFlag == false &&
form.value.channelList[4].channelFlag == false
)
return { flag: false, message: '通讯脚本中够选了电压,请选择电压通道使能' }
break
case '谐波电压':
if (
form.value.channelList[0].harmFlag == false &&
form.value.channelList[2].harmFlag == false &&
form.value.channelList[4].harmFlag == false
)
return { flag: false, message: '通讯脚本中够选了谐波电压,请选择谐波电压通道使能' }
break
case '谐波电流':
if (
form.value.channelList[1].harmFlag == false &&
form.value.channelList[3].harmFlag == false &&
form.value.channelList[5].harmFlag == false
)
return { flag: false, message: '通讯脚本中够选了谐波电流,请选择谐波电流通道使能' }
break
case '谐波有功功率':
if (
form.value.channelList[0].harmFlag == false &&
form.value.channelList[1].harmFlag == false &&
form.value.channelList[2].harmFlag == false &&
form.value.channelList[3].harmFlag == false &&
form.value.channelList[4].harmFlag == false &&
form.value.channelList[5].harmFlag == false
)
return { flag: false, message: '通讯脚本中够选了谐波有功功率,请选择间电压、电流谐波通道使能' }
break
case '间谐波电压':
if (
form.value.channelList[0].inHarmFlag == false &&
form.value.channelList[2].inHarmFlag == false &&
form.value.channelList[4].inHarmFlag == false
)
return { flag: false, message: '通讯脚本中够选了间谐波电压,请选择间谐波电压通道使能' }
break
case '间谐波电流':
if (
form.value.channelList[1].inHarmFlag == false &&
form.value.channelList[3].inHarmFlag == false &&
form.value.channelList[5].inHarmFlag == false
)
return { flag: false, message: '通讯脚本中够选了间谐波电流,请选择间谐波电流通道使能' }
break
case '暂态':
if (
form.value.channelList[0].dipFlag == false &&
form.value.channelList[2].dipFlag == false &&
form.value.channelList[4].dipFlag == false
)
return { flag: false, message: '通讯脚本中够选了暂态,请选择电压暂态通道使能' }
break
case '电流':
if (
form.value.channelList[1].channelFlag == false &&
form.value.channelList[3].channelFlag == false &&
form.value.channelList[5].channelFlag == false
)
return { flag: false, message: '通讯脚本中够选了电压,请选择电压通道使能' }
break
case '三相电压不平衡度':
if (
form.value.channelList[0].channelFlag == false ||
form.value.channelList[2].channelFlag == false ||
form.value.channelList[4].channelFlag == false
)
return { flag: false, message: '通讯脚本中够选了三相电压不平衡度,请选择电压A、B、C通道使能' }
break
case '三相电流不平衡度':
if (
form.value.channelList[1].channelFlag == false ||
form.value.channelList[3].channelFlag == false ||
form.value.channelList[5].channelFlag == false
)
return { flag: false, message: '通讯脚本中够选了三相电流不平衡度,请选择电流A、B、C通道使能' }
break
case '闪变':
if (
form.value.channelList[0].flickerFlag == false &&
form.value.channelList[2].flickerFlag == false &&
form.value.channelList[4].flickerFlag == false
)
return { flag: false, message: '通讯脚本中够选了闪变,请选择电压闪变通道使能' }
break
}
}
return false
for (let index = 0; index < form.value.channelList.length; index++) {
const item = form.value.channelList[index]
const result = checkChannelValues(item, index)
if (!result.flag) {
flag = result.flag
message = result.message
break // 如果发现错误,直接退出循环
}
}
return { flag, message }
}
// 判断够选通道
const checkChannel = (data: row) => {
return data.channelList.every(item => item.channelFlag === true)
// 判断通道
const checkChannelValues = (item: any, index: number) => {
const channelNames = ['L1/Ua', 'L1/Ia', 'L2/Ub', 'L2/Ib', 'L3/Uc', 'L3/Ic']
const channelName = channelNames[index] || ''
// 检查通道使能
if (item.channelFlag === false && (item.harmFlag || item.inHarmFlag || item.flickerFlag || item.dipFlag)) {
return { flag: false, message: `请选择${channelName}通道使能` }
}
// 检查通道使能值
if (item.channelFlag === true && (item.famp === '' || item.fphase === '')) {
return { flag: false, message: '请填写通道使能值' }
}
// 检查谐波使能值
if (item.harmFlag === true && item.harmList.filter(harm => harm.famp != 0 || harm.fphase != 0).length == 0) {
return { flag: false, message: '请填写谐波使能值' }
}
// 检查间谐波使能值
if (
item.inHarmFlag === true &&
item.inharmList.filter(harm => harm.inharm !== '' || harm.famp !== 0 || harm.fphase !== 0).length === 0
) {
return { flag: false, message: '请填写间谐波使能值' }
}
// 检查闪变使能值
if (
item.flickerFlag === true &&
(item.flickerData.fchagFre === '' || item.flickerData.fchagValue === '') &&
index != 1 &&
index != 3 &&
index != 5
) {
return { flag: false, message: '请填写闪变使能值' }
}
// 检查暂态使能值
if (
item.dipFlag === true &&
(item.dipData.ftransValue === '' || item.dipData.retainTime === '') &&
index != 1 &&
index != 3 &&
index != 5
) {
return { flag: false, message: '请填写暂态使能值' }
}
return { flag: true, message: '' }
}
//处理谐波数据
const handleHarmData = () => {
@@ -354,7 +515,7 @@ const handleHarmData = () => {
copyForm.channelList.forEach((channel: any) => {
// 筛选出 famp 和 fphase 不同时为 0 的对象
channel.harmList = channel.harmList.filter((item: any) => item.famp !== 0 || item.fphase !== 0)
channel.harmList = channel.harmList.filter((item: any) => item.famp != 0 || item.fphase != 0)
channel.inharmList = channel.inharmList.filter(
(item: any) => item.inharm !== '' || item.famp !== 0 || item.fphase !== 0
)
@@ -365,40 +526,61 @@ const handleHarmData = () => {
// 打开弹窗,可能是新增,也可能是编辑
const open = (sign: string, row: any) => {
dialogVisible.value = true
dialogTitle.value = sign === 'add' ? '新增检测项目信息' : '编辑检测项目信息'
// 添加选择检测项目
tabChildren.value = props.options.filter(item => item.value == props.activeName)[0].children || []
// subType.value = tabChildren.value[0].code || ''
if (sign == 'add') {
form.value.subType = props.childActiveName == '' ? tabChildren.value[0].code || '' : props.childActiveName
} else {
form.value = setharmList(JSON.parse(JSON.stringify(row)))
}
handleRowClick({ name: 'L1', sort: 0 }, { label: '相别' })
dictStore.getDictData('Script_Value_Type')
valueCode.value = dictStore
.getDictData('Script_Value_Type')
.filter(item => item.id == props.formContent.valueType)[0].code
dialogTitle.value = sign === 'add' ? '新增检测项目信息' : '编辑检测项目信息'
// 添加选择检测项目
tabChildren.value = JSON.parse(
JSON.stringify(props.options.filter(item => item.value == props.activeName)[0].children || [])
)
// 判断是否存在 code 在 targetCodes 中
const hasTargetCode = tabChildren.value.some(item =>
['Base_0_10', 'Base_20_85', 'Base_110_200'].includes(item.code)
)
if (hasTargetCode) {
tabChildren.value.unshift({
code: 'Base',
label: '额定工作条件下的检测',
value: '999999999999999999'
})
tabChildren.value = tabChildren.value.filter(
item => item.code !== 'Base_0_10' && item.code !== 'Base_20_85' && item.code !== 'Base_110_200'
)
}
// subType.value = tabChildren.value[0].code || ''
if (sign == 'add') {
form.value.subType =
props.childActiveName == ''
? JSON.parse(JSON.stringify(tabChildren.value[0].code)) || ''
: JSON.parse(JSON.stringify(props.childActiveName))
if (valueCode.value == 'Absolute') {
form.value.channelList.forEach((item: any) => {
item.famp = 0
item.fphase = 0
})
}
} else {
form.value = setharmList(JSON.parse(JSON.stringify(row)))
copyRowList.value = JSON.parse(JSON.stringify(row))
}
if (['Base_0_10', 'Base_20_85', 'Base_110_200'].includes(form.value.subType)) {
form.value.subType = 'Base'
}
handleRowClick({ name: 'L1', sort: 0 }, { label: '相别' })
dictStore.getDictData('Script_Value_Type')
}
// 判断后台没有谐波,简谐波值 用于回显
const setharmList = (row: any) => {
row.channelList.forEach((item: any) => {
let harmList = []
for (let i = 2; i < 51; i++) {
let data = item.harmList.filter((harm: any) => harm.harm == i)
if (data.length > 0) {
harmList.push({ harm: i, famp: data[0].famp, fphase: data[0].fphase })
} else {
harmList.push({ harm: i, famp: 0, fphase: 0 })
}
}
item.harmList = harmList
if (item.inharmList.length == 0) {
item.inharmList.push({ inharm: 0, famp: 0, fphase: 0 })
item.inharmList.push({ inharm: '', famp: 0, fphase: 0 })
}
})
@@ -408,12 +590,12 @@ const setharmList = (row: any) => {
const copyRow = (num: number, index: number) => {
form.value.channelList[index] = JSON.parse(JSON.stringify(form.value.channelList[num]))
form.value.channelList[index + 1] = JSON.parse(JSON.stringify(form.value.channelList[num + 1]))
form.value.channelList[num].channelType == 'Ua'
? (form.value.channelList[index].channelType = 'Ub')
: (form.value.channelList[index].channelType = 'Uc')
form.value.channelList[num + 1].channelType == 'Ia'
? (form.value.channelList[index + 1].channelType = 'Ib')
: (form.value.channelList[index + 1].channelType = 'Ic')
form.value.channelList[0].channelType = 'Ua'
form.value.channelList[1].channelType = 'Ia'
form.value.channelList[2].channelType = 'Ub'
form.value.channelList[3].channelType = 'Ia'
form.value.channelList[4].channelType = 'Uc'
form.value.channelList[5].channelType = 'Ic'
key.value += 1
ElMessage.success({
message: '复制成功!',
@@ -480,4 +662,10 @@ defineExpose({ open })
:deep(.el-carousel__arrow) {
display: none !important;
}
:deep(.el-tabs--border-card > .el-tabs__content) {
padding: 10px;
}
:deep(.el-table__body) {
border-top: var(--el-table-border);
}
</style>