2025-07-09 20:12:40 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<!-- 基础信息弹出框 -->
|
2025-10-29 14:24:01 +08:00
|
|
|
|
<el-dialog
|
|
|
|
|
|
:model-value="dialogVisible"
|
|
|
|
|
|
:title="dialogTitle"
|
|
|
|
|
|
v-bind="dialogMiddle"
|
|
|
|
|
|
width="50%"
|
|
|
|
|
|
@close="close"
|
|
|
|
|
|
align-center
|
|
|
|
|
|
>
|
2025-09-25 08:49:15 +08:00
|
|
|
|
<div>
|
2025-10-29 14:24:01 +08:00
|
|
|
|
<el-form :model="formContent" ref="dialogFormRef" :rules="rules" label-width="140" class="form-two">
|
2025-09-25 08:49:15 +08:00
|
|
|
|
<el-form-item label="名称" prop="name">
|
2025-10-30 11:09:50 +08:00
|
|
|
|
<el-input clearable v-model="formContent.name" placeholder="请输入监测点名称" />
|
2025-09-25 08:49:15 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="线路号" prop="num">
|
2025-10-30 11:09:50 +08:00
|
|
|
|
<el-select v-model="formContent.num" placeholder="请选择线路号" @change="handleMonNumChange">
|
2025-09-25 08:49:15 +08:00
|
|
|
|
<el-option v-for="item in lineNum" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="所属母线" prop="busbar">
|
2025-10-30 11:09:50 +08:00
|
|
|
|
<el-input v-model="formContent.busbar" clearable placeholder="请输入所属母线" />
|
2025-10-30 09:47:26 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- <el-form-item label="所属母线" prop="busbar">
|
2025-09-25 08:49:15 +08:00
|
|
|
|
<el-select
|
|
|
|
|
|
v-model="formContent.busbar"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
placeholder="请选择所属母线"
|
|
|
|
|
|
filterable
|
|
|
|
|
|
allow-create
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in selectOptions['busbar']"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
2025-10-30 09:47:26 +08:00
|
|
|
|
</el-form-item> -->
|
2025-10-29 14:24:01 +08:00
|
|
|
|
<el-form-item label="接线方式" prop="connection">
|
|
|
|
|
|
<el-select v-model="formContent.connection" clearable placeholder="请选择接线方式">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Dev_Connect')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.id"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item required>
|
|
|
|
|
|
<template #label>
|
|
|
|
|
|
<div style="display: flex; align-items: center">
|
|
|
|
|
|
<el-icon style="color: var(--el-color-error)"><WarningFilled /></el-icon>
|
|
|
|
|
|
<span>PT变比</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-10-20 10:16:18 +08:00
|
|
|
|
<div class="ratio-input-group">
|
|
|
|
|
|
<el-form-item prop="ptPrimary" class="ratio-form-item">
|
2025-10-20 14:04:20 +08:00
|
|
|
|
<el-input v-model="ptPrimary" placeholder="一次侧" @input="handlePtInput" />
|
2025-10-20 10:16:18 +08:00
|
|
|
|
</el-form-item>
|
2025-10-29 14:24:01 +08:00
|
|
|
|
<div class="colon">:</div>
|
|
|
|
|
|
<el-form-item prop="ptSecondary" style="margin-left: 10px" class="ratio-form-item">
|
2025-10-20 14:04:20 +08:00
|
|
|
|
<el-input v-model="ptSecondary" placeholder="二次侧" @input="handlePtInput" />
|
2025-10-20 10:16:18 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2025-09-25 08:49:15 +08:00
|
|
|
|
</el-form-item>
|
2025-10-20 14:04:20 +08:00
|
|
|
|
|
2025-10-20 10:16:18 +08:00
|
|
|
|
<!-- 修改CT变比部分 -->
|
2025-10-29 14:24:01 +08:00
|
|
|
|
<el-form-item required>
|
|
|
|
|
|
<template #label>
|
|
|
|
|
|
<div style="display: flex; align-items: center">
|
|
|
|
|
|
<el-icon style="color: var(--el-color-error)"><WarningFilled /></el-icon>
|
|
|
|
|
|
<span>CT变比</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-10-20 10:16:18 +08:00
|
|
|
|
<div class="ratio-input-group">
|
|
|
|
|
|
<el-form-item prop="ctPrimary" class="ratio-form-item">
|
2025-10-20 14:04:20 +08:00
|
|
|
|
<el-input v-model="ctPrimary" placeholder="一次侧" @input="handleCtInput" />
|
2025-10-20 10:16:18 +08:00
|
|
|
|
</el-form-item>
|
2025-10-29 14:24:01 +08:00
|
|
|
|
<div class="colon">:</div>
|
|
|
|
|
|
<el-form-item prop="ctSecondary" style="margin-left: 10px" class="ratio-form-item">
|
2025-10-20 14:04:20 +08:00
|
|
|
|
<el-input v-model="ctSecondary" placeholder="二次侧" @input="handleCtInput" />
|
2025-10-20 10:16:18 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2025-09-25 08:49:15 +08:00
|
|
|
|
</el-form-item>
|
2025-10-29 14:24:01 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
<el-form-item label="统计间隔" prop="statInterval">
|
|
|
|
|
|
<el-select v-model="formContent.statInterval" clearable placeholder="请选择统计间隔">
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in dictStore.getDictData('Dev_Chns')"
|
|
|
|
|
|
:key="item.id"
|
|
|
|
|
|
:label="item.name"
|
|
|
|
|
|
:value="item.code"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="谐波系统检测点id" prop="harmSysId" placeholder="请输入谐波系统检测点id">
|
|
|
|
|
|
<el-input v-model="formContent.harmSysId" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="是否参与检测" prop="checkFlag" placeholder="请输入CT编号">
|
|
|
|
|
|
<el-select v-model="formContent.checkFlag" clearable placeholder="请选择是否加密">
|
|
|
|
|
|
<el-option label="是" :value="1"></el-option>
|
|
|
|
|
|
<el-option label="否" :value="0"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</div>
|
2025-10-20 14:04:20 +08:00
|
|
|
|
<el-alert
|
|
|
|
|
|
title="注意:PT和CT变比请输入正常值,不可以缩小相同的倍数!"
|
2025-10-29 14:24:01 +08:00
|
|
|
|
type="error"
|
2025-10-20 14:04:20 +08:00
|
|
|
|
:closable="false"
|
|
|
|
|
|
></el-alert>
|
2025-09-25 08:49:15 +08:00
|
|
|
|
<template #footer>
|
|
|
|
|
|
<div class="dialog-footer">
|
|
|
|
|
|
<el-button @click="close()">取消</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="save()">保存</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
</template>
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
<script lang="ts" setup>
|
2025-10-23 09:26:57 +08:00
|
|
|
|
import { ElMessage, ElMessageBox, type FormItemRule } from 'element-plus'
|
2025-10-20 14:04:20 +08:00
|
|
|
|
import { computed, ref, type Ref } from 'vue'
|
2025-09-25 08:49:15 +08:00
|
|
|
|
import { type Monitor } from '@/api/device/interface/monitor'
|
|
|
|
|
|
import { dialogMiddle } from '@/utils/elementBind'
|
|
|
|
|
|
import { useDictStore } from '@/stores/modules/dict'
|
|
|
|
|
|
import { generateUUID } from '@/utils'
|
2025-10-20 14:04:20 +08:00
|
|
|
|
import { type Device } from '@/api/device/interface/device'
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
const dictStore = useDictStore()
|
|
|
|
|
|
const lineNum = ref<{ id: number; name: string }[]>([])
|
|
|
|
|
|
const originalNum = ref<number | null>(null) // 存储编辑前的 num 值
|
|
|
|
|
|
const monitorTable = ref<any[]>()
|
|
|
|
|
|
const selectOptions = ref<Record<string, Device.SelectOption[]>>({})
|
2025-10-20 10:16:18 +08:00
|
|
|
|
|
|
|
|
|
|
// 新增用于PT/CT变比的临时字段
|
|
|
|
|
|
const ptPrimary = ref<string>('')
|
|
|
|
|
|
const ptSecondary = ref<string>('')
|
|
|
|
|
|
const ctPrimary = ref<string>('')
|
|
|
|
|
|
const ctSecondary = ref<string>('')
|
|
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 定义弹出组件元信息
|
|
|
|
|
|
const dialogFormRef = ref()
|
|
|
|
|
|
function useMetaInfo() {
|
2025-07-09 20:12:40 +08:00
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
|
const titleType = ref('add')
|
|
|
|
|
|
const formContent = ref<Monitor.ResPqMon>({
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
devId: '',
|
|
|
|
|
|
busbar: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
num: 1,
|
|
|
|
|
|
pt: '',
|
|
|
|
|
|
ct: '',
|
|
|
|
|
|
connection: '',
|
|
|
|
|
|
statInterval: 1,
|
|
|
|
|
|
harmSysId: '',
|
2025-09-25 08:49:15 +08:00
|
|
|
|
checkFlag: 1
|
2025-07-09 20:12:40 +08:00
|
|
|
|
})
|
|
|
|
|
|
return { dialogVisible, titleType, formContent }
|
2025-09-25 08:49:15 +08:00
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
const emit = defineEmits(['get-parameter'])
|
2025-07-09 20:12:40 +08:00
|
|
|
|
// 清空formContent
|
|
|
|
|
|
const resetFormContent = () => {
|
|
|
|
|
|
formContent.value = {
|
2025-09-25 08:49:15 +08:00
|
|
|
|
id: '',
|
2025-07-09 20:12:40 +08:00
|
|
|
|
devId: '',
|
|
|
|
|
|
busbar: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
num: 1,
|
|
|
|
|
|
pt: '',
|
|
|
|
|
|
ct: '',
|
|
|
|
|
|
connection: '',
|
|
|
|
|
|
statInterval: 1,
|
|
|
|
|
|
harmSysId: '',
|
2025-09-25 08:49:15 +08:00
|
|
|
|
checkFlag: 1
|
2025-07-09 20:12:40 +08:00
|
|
|
|
}
|
2025-09-25 08:49:15 +08:00
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
let dialogTitle = computed(() => {
|
|
|
|
|
|
return titleType.value === 'add' ? '新增监测点台账' : '编辑监测点台账'
|
|
|
|
|
|
})
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 关闭弹窗
|
|
|
|
|
|
const close = () => {
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
//定义校验规则
|
|
|
|
|
|
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
|
|
|
|
|
name: [{ required: true, message: '监测点名称必填!', trigger: 'blur' }],
|
|
|
|
|
|
num: [{ required: true, message: '线路号必选', trigger: 'change' }],
|
|
|
|
|
|
connection: [{ required: true, message: '接线方式必选!', trigger: 'change' }],
|
2025-10-30 09:47:26 +08:00
|
|
|
|
//busbar: [{ required: true, message: '所属母线必选!', trigger: 'change' }],
|
|
|
|
|
|
busbar: [{ required: true, message: '所属母线必填!', trigger: 'blur' }],
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// harmSysId : [{ required: true, message: '谐波系统检测点id必填!', trigger: 'blur' }],
|
|
|
|
|
|
checkFlag: [{ required: true, message: '是否参与检测必选!', trigger: 'change' }]
|
|
|
|
|
|
})
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-10-20 10:16:18 +08:00
|
|
|
|
// 处理PT输入变化并更新formContent中的值
|
|
|
|
|
|
const handlePtInput = () => {
|
|
|
|
|
|
if (ptPrimary.value && ptSecondary.value) {
|
|
|
|
|
|
formContent.value.pt = `${ptPrimary.value}:${ptSecondary.value}`
|
|
|
|
|
|
} else {
|
|
|
|
|
|
formContent.value.pt = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理CT输入变化并更新formContent中的值
|
|
|
|
|
|
const handleCtInput = () => {
|
|
|
|
|
|
if (ctPrimary.value && ctSecondary.value) {
|
|
|
|
|
|
formContent.value.ct = `${ctPrimary.value}:${ctSecondary.value}`
|
|
|
|
|
|
} else {
|
|
|
|
|
|
formContent.value.ct = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 添加一个用于手动验证的引用
|
|
|
|
|
|
const extraFormRules = ref({
|
2025-10-20 14:04:20 +08:00
|
|
|
|
ptPrimary: [
|
|
|
|
|
|
{ required: true, message: 'PT变比一次侧必填!', trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /^[1-9]\d*$/, message: '请输入正整数', trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
ptSecondary: [
|
|
|
|
|
|
{ required: true, message: 'PT变比二次侧必填!', trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /^\d+(\.\d+)?$/, message: '请输入数字', trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
ctPrimary: [
|
|
|
|
|
|
{ required: true, message: 'CT变比一次侧必填!', trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /^[1-9]\d*$/, message: '请输入正整数', trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
ctSecondary: [
|
|
|
|
|
|
{ required: true, message: 'CT变比二次侧必填!', trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /^[1-9]\d*$/, message: '请输入正整数', trigger: 'blur' }
|
|
|
|
|
|
]
|
2025-10-20 10:16:18 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 保存数据
|
|
|
|
|
|
const save = () => {
|
2025-07-09 20:12:40 +08:00
|
|
|
|
try {
|
|
|
|
|
|
dialogFormRef.value?.validate(async (valid: boolean) => {
|
2025-09-25 08:49:15 +08:00
|
|
|
|
if (valid) {
|
2025-10-20 10:16:18 +08:00
|
|
|
|
// 手动验证额外的字段
|
2025-10-20 14:04:20 +08:00
|
|
|
|
let extraValid = true
|
|
|
|
|
|
const fieldsToValidate = ['ptPrimary', 'ptSecondary', 'ctPrimary', 'ctSecondary']
|
|
|
|
|
|
|
|
|
|
|
|
for (const field of fieldsToValidate) {
|
|
|
|
|
|
const value = eval(field) // 获取对应字段的值
|
|
|
|
|
|
const rules = extraFormRules.value[field]
|
|
|
|
|
|
|
|
|
|
|
|
for (const rule of rules) {
|
|
|
|
|
|
if (rule.required && !value.value) {
|
|
|
|
|
|
ElMessage.error({ message: rule.message as string })
|
|
|
|
|
|
extraValid = false
|
|
|
|
|
|
break
|
2025-10-20 10:16:18 +08:00
|
|
|
|
}
|
2025-10-20 14:04:20 +08:00
|
|
|
|
|
|
|
|
|
|
if (rule.pattern && value.value && !rule.pattern.test(value.value)) {
|
|
|
|
|
|
ElMessage.error({ message: rule.message as string })
|
|
|
|
|
|
extraValid = false
|
|
|
|
|
|
break
|
2025-10-20 10:16:18 +08:00
|
|
|
|
}
|
2025-10-20 14:04:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!extraValid) break
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!extraValid) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-10-20 10:16:18 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 校验名称是否重复
|
2025-10-20 14:04:20 +08:00
|
|
|
|
const isNameDuplicate = monitorTable.value?.some(
|
2025-09-25 08:49:15 +08:00
|
|
|
|
item => item.name === formContent.value.name && item.id !== formContent.value.id
|
|
|
|
|
|
)
|
|
|
|
|
|
if (isNameDuplicate) {
|
|
|
|
|
|
ElMessage.error({ message: '监测点名称已存在,请重新输入!' })
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-10-20 14:04:20 +08:00
|
|
|
|
// 添加PT CT逻辑
|
|
|
|
|
|
// PT 逻辑
|
|
|
|
|
|
let ptPrimaryValue = ptPrimary.value
|
|
|
|
|
|
let ptSecondaryValue = ptSecondary.value
|
|
|
|
|
|
let ptErrorTips = false
|
|
|
|
|
|
let ctErrorTips = false
|
|
|
|
|
|
const ptFinalValue = ['100', '380']
|
|
|
|
|
|
const ptFinalChangeValue = ['57.74', '220']
|
|
|
|
|
|
const ctFinalValue = ['1', '5']
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-10-20 14:04:20 +08:00
|
|
|
|
// 若值都为 1, 则改值为 380
|
|
|
|
|
|
if (ptPrimaryValue === '1' && ptSecondaryValue === '1') {
|
|
|
|
|
|
formContent.value.pt = `${ptFinalValue[1]}:${ptFinalValue[1]}`
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 若PT分母值不为 ['100', '380']
|
|
|
|
|
|
if (!ptFinalValue.includes(ptSecondaryValue)) {
|
|
|
|
|
|
// 若PT分母值不为 ['57.74', '220'],提示
|
|
|
|
|
|
if (ptFinalChangeValue.includes(ptSecondaryValue)) {
|
|
|
|
|
|
// 判断值为 57.74,则 57.74 => 100
|
|
|
|
|
|
if (ptSecondaryValue === ptFinalChangeValue[0]) {
|
|
|
|
|
|
ptSecondaryValue = ptFinalValue[0]
|
|
|
|
|
|
}
|
|
|
|
|
|
// 判断值为 220,则 220 => 380
|
|
|
|
|
|
if (ptSecondaryValue === ptFinalChangeValue[1]) {
|
|
|
|
|
|
ptSecondaryValue = ptFinalValue[1]
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ptErrorTips = true
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-22 11:40:57 +08:00
|
|
|
|
formContent.value.pt = `${ptPrimaryValue}:${ptSecondaryValue}`
|
2025-10-20 14:04:20 +08:00
|
|
|
|
// CT 逻辑, CT 分母是否为 ['1', '5']
|
|
|
|
|
|
if (!ctFinalValue.includes(ctSecondary.value)) {
|
|
|
|
|
|
ctErrorTips = true
|
|
|
|
|
|
}
|
|
|
|
|
|
if (ptErrorTips && ctErrorTips) {
|
2025-10-22 11:40:57 +08:00
|
|
|
|
await ElMessageBox.confirm('请确认PT和CT无误!', '提示', {
|
|
|
|
|
|
confirmButtonText: '继续保存',
|
|
|
|
|
|
cancelButtonText: '取消保存'
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
sendParameter()
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
return
|
|
|
|
|
|
})
|
2025-10-20 14:04:20 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
if (ptErrorTips) {
|
2025-10-22 11:40:57 +08:00
|
|
|
|
await ElMessageBox.confirm('请确认PT无误!', '提示', {
|
|
|
|
|
|
confirmButtonText: '继续保存',
|
|
|
|
|
|
cancelButtonText: '取消保存'
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
sendParameter()
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
return
|
|
|
|
|
|
})
|
2025-10-20 14:04:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (ctErrorTips) {
|
2025-10-22 11:40:57 +08:00
|
|
|
|
await ElMessageBox.confirm('请确认CT无误!', '提示', {
|
|
|
|
|
|
confirmButtonText: '确认保存',
|
|
|
|
|
|
cancelButtonText: '取消保存'
|
|
|
|
|
|
})
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
sendParameter()
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
return
|
|
|
|
|
|
})
|
2025-10-20 14:04:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-23 09:10:04 +08:00
|
|
|
|
if (!ptErrorTips && !ctErrorTips) {
|
|
|
|
|
|
sendParameter()
|
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
}
|
2025-09-25 08:49:15 +08:00
|
|
|
|
})
|
2025-07-09 20:12:40 +08:00
|
|
|
|
} catch (err) {
|
2025-09-25 08:49:15 +08:00
|
|
|
|
console.error('验证过程中出现错误', err)
|
2025-07-09 20:12:40 +08:00
|
|
|
|
}
|
2025-09-25 08:49:15 +08:00
|
|
|
|
}
|
2025-10-22 11:40:57 +08:00
|
|
|
|
const sendParameter = () => {
|
|
|
|
|
|
if (titleType.value != 'edit') {
|
|
|
|
|
|
formContent.value.id = generateUUID().replaceAll('-', '')
|
|
|
|
|
|
}
|
|
|
|
|
|
emit('get-parameter', formContent.value)
|
|
|
|
|
|
//ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
|
|
|
|
|
close()
|
|
|
|
|
|
}
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 打开弹窗,可能是新增,也可能是编辑
|
|
|
|
|
|
const open = async (sign: string, data: Monitor.ResPqMon, device: Device.ResPqDev, table: any[], options: any) => {
|
2025-07-21 13:47:56 +08:00
|
|
|
|
selectOptions.value = options
|
2025-07-09 20:12:40 +08:00
|
|
|
|
titleType.value = sign
|
|
|
|
|
|
dialogVisible.value = true
|
2025-09-25 08:49:15 +08:00
|
|
|
|
monitorTable.value = table || []
|
|
|
|
|
|
// 提取 table 中已使用的 num(安全处理)
|
|
|
|
|
|
const usedNums = new Set<number>()
|
|
|
|
|
|
if (table && table.length > 0) {
|
2025-07-09 20:12:40 +08:00
|
|
|
|
table.forEach(item => {
|
2025-09-25 08:49:15 +08:00
|
|
|
|
if (item.num != null) {
|
|
|
|
|
|
usedNums.add(Number(item.num))
|
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
})
|
2025-09-25 08:49:15 +08:00
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
lineNum.value = Array.from({ length: device.devChns }, (_, i) => {
|
|
|
|
|
|
const id = i + 1
|
|
|
|
|
|
return {
|
|
|
|
|
|
id,
|
|
|
|
|
|
name: id.toString()
|
|
|
|
|
|
}
|
|
|
|
|
|
}).filter(item => !usedNums.has(item.id)) // 过滤掉已被使用的线路号
|
2025-07-09 20:12:40 +08:00
|
|
|
|
if (sign == 'edit') {
|
2025-09-25 08:49:15 +08:00
|
|
|
|
formContent.value = { ...data }
|
|
|
|
|
|
originalNum.value = data.num // 记录原始线路号
|
2025-10-20 10:16:18 +08:00
|
|
|
|
|
|
|
|
|
|
// 解析PT变比
|
|
|
|
|
|
if (data.pt) {
|
|
|
|
|
|
const [primary, secondary] = data.pt.split(':')
|
|
|
|
|
|
ptPrimary.value = primary
|
|
|
|
|
|
ptSecondary.value = secondary
|
|
|
|
|
|
}
|
2025-10-20 14:04:20 +08:00
|
|
|
|
|
2025-10-20 10:16:18 +08:00
|
|
|
|
// 解析CT变比
|
|
|
|
|
|
if (data.ct) {
|
|
|
|
|
|
const [primary, secondary] = data.ct.split(':')
|
|
|
|
|
|
ctPrimary.value = primary
|
|
|
|
|
|
ctSecondary.value = secondary
|
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
} else {
|
2025-10-29 14:24:01 +08:00
|
|
|
|
// 清空PT和CT的临时变量
|
2025-10-23 14:41:08 +08:00
|
|
|
|
ptPrimary.value = ''
|
|
|
|
|
|
ptSecondary.value = ''
|
|
|
|
|
|
ctPrimary.value = ''
|
|
|
|
|
|
ctSecondary.value = ''
|
2025-10-29 14:24:01 +08:00
|
|
|
|
|
2025-10-23 14:41:08 +08:00
|
|
|
|
// 重置表单内容,但保留devId
|
|
|
|
|
|
const devId = formContent.value.devId
|
2025-10-23 09:54:52 +08:00
|
|
|
|
resetFormContent()
|
2025-10-23 14:41:08 +08:00
|
|
|
|
formContent.value.devId = devId
|
2025-10-23 09:26:57 +08:00
|
|
|
|
originalNum.value = null
|
2025-10-23 14:41:08 +08:00
|
|
|
|
|
|
|
|
|
|
// 使用nextTick确保DOM更新后再清除验证
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
dialogFormRef.value?.clearValidate()
|
|
|
|
|
|
}, 0)
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 设置默认选中第一个线路号
|
|
|
|
|
|
if (lineNum.value.length > 0) {
|
|
|
|
|
|
formContent.value.num = lineNum.value[0].id
|
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
}
|
2025-09-25 08:49:15 +08:00
|
|
|
|
formContent.value.devId = device.id
|
|
|
|
|
|
}
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
const handleMonNumChange = (value: string) => {
|
|
|
|
|
|
const newValue = parseInt(value)
|
2025-07-09 20:12:40 +08:00
|
|
|
|
if (originalNum.value && originalNum.value !== newValue) {
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 将原来的 num 添加回 lineNum(表示释放)
|
|
|
|
|
|
lineNum.value.push({
|
|
|
|
|
|
id: originalNum.value,
|
|
|
|
|
|
name: originalNum.value.toString()
|
|
|
|
|
|
})
|
|
|
|
|
|
//移除新选择的 num(因为已被占用)
|
|
|
|
|
|
lineNum.value = lineNum.value.filter(item => item.id !== newValue).sort((a, b) => a.id - b.id)
|
2025-07-09 20:12:40 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 更新 originalNum 为最新值,以便下次修改
|
|
|
|
|
|
originalNum.value = newValue
|
2025-07-09 20:12:40 +08:00
|
|
|
|
}
|
2025-09-25 08:49:15 +08:00
|
|
|
|
}
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-09-25 08:49:15 +08:00
|
|
|
|
// 对外映射
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
</script>
|
2025-07-21 13:47:56 +08:00
|
|
|
|
|
2025-10-20 10:16:18 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
.ratio-input-group {
|
2025-10-20 14:04:20 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2025-10-29 14:24:01 +08:00
|
|
|
|
justify-content: space-between;
|
2025-10-20 10:16:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.ratio-form-item {
|
2025-10-20 14:04:20 +08:00
|
|
|
|
margin-bottom: 0 !important;
|
2025-10-20 10:16:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.colon {
|
2025-10-29 14:24:01 +08:00
|
|
|
|
text-align: center;
|
2025-10-20 14:04:20 +08:00
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
}
|
|
|
|
|
|
.el-alert {
|
|
|
|
|
|
--el-alert-padding: 0px 12px !important;
|
|
|
|
|
|
--el-alert-title-font-size: 12px !important;
|
2025-10-20 10:16:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|