修改参考设定值添加单位

This commit is contained in:
GGJ
2025-03-27 18:34:40 +08:00
parent e0941d628b
commit 60145ec4f7
4 changed files with 299 additions and 181 deletions

View File

@@ -95,7 +95,7 @@
? '/' ? '/'
: '' + : '' +
row.channelList[item.num + 1].famp + row.channelList[item.num + 1].famp +
(valueCode == 'Absolute' ? 'V' : '%') (valueCode == 'Absolute' ? 'A' : '%')
}} }}
</td> </td>
<td> <td>
@@ -135,36 +135,42 @@
<!-- </template>--> <!-- </template>-->
<!-- </el-progress>--> <!-- </el-progress>-->
<div class="loading-container" v-if="showLoading"> <div class="loading-container" v-if="showLoading">
<div style="width: 80%; height: 80%;" class="loading-box"> <div style="width: 80%; height: 80%" class="loading-box">
<div class="loading-circle"></div> <div class="loading-circle"></div>
<div class="loading-text">Loading...</div> <div class="loading-text">Loading...</div>
</div> </div>
<!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>--> <!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>-->
</div> </div>
<div class="loading-container" v-else> <div class="loading-container" v-else>
<div style="width: 80%; height: 80%; " class="loading-box"> <div style="width: 80%; height: 80%" class="loading-box">
<div class="loading-circle static"></div> <div class="loading-circle static"></div>
<div class="loading-text">Loading</div> <div class="loading-text">Loading</div>
</div> </div>
<!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>--> <!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>-->
</div> </div>
</div> </div>
<div style="margin-top: 10px;"> <div style="margin-top: 10px">
<span>标准源加量输出:{{ hour }}{{ minute }}{{ second }}</span> <span>标准源加量输出:{{ hour }}{{ minute }}{{ second }}</span>
</div> </div>
<div style="margin-top: 10px;"> <div style="margin-top: 10px">
<el-button :icon="VideoPlay" <el-button
:icon="VideoPlay"
type="primary" type="primary"
size="large" size="large"
@click="startLoading" @click="startLoading"
:disabled="pauseDisabled" :disabled="pauseDisabled"
>启动</el-button> >
<el-button :icon="VideoPause" 启动
</el-button>
<el-button
:icon="VideoPause"
type="primary" type="primary"
size="large" size="large"
@click="stopLoading" @click="stopLoading"
:disabled="pauseDisabled" :disabled="pauseDisabled"
>停止</el-button> >
停止
</el-button>
</div> </div>
</div> </div>
</div> </div>
@@ -187,7 +193,8 @@
v-if="showDialog" v-if="showDialog"
/> />
<!-- 查看 --> <!-- 查看 -->
<ViewRow ref="viewRowRef" <ViewRow
ref="viewRowRef"
:activeName="activeName" :activeName="activeName"
:formContent="props.formContent" :formContent="props.formContent"
@close="viewDialog = false" @close="viewDialog = false"
@@ -202,7 +209,17 @@ import Tree from './tree.vue'
import Commun from '@/views/machine/testScript/components//communication.vue' import Commun from '@/views/machine/testScript/components//communication.vue'
import { type CascaderOption, ElMessage } from 'element-plus' import { type CascaderOption, ElMessage } from 'element-plus'
import { getTreeData } from '@/api/check/test' import { getTreeData } from '@/api/check/test'
import {CirclePlus, Delete, Check, CopyDocument, View, EditPen, VideoPlay, VideoPause, Loading} from '@element-plus/icons-vue' import {
CirclePlus,
Delete,
Check,
CopyDocument,
View,
EditPen,
VideoPlay,
VideoPause,
Loading
} from '@element-plus/icons-vue'
import type { TestScript } from '@/api/device/interface/testScript' import type { TestScript } from '@/api/device/interface/testScript'
import TestProjectPopup from '@/views/machine/testScript/components/testProjectPopup.vue' import TestProjectPopup from '@/views/machine/testScript/components/testProjectPopup.vue'
import { CheckData } from '@/api/check/interface' import { CheckData } from '@/api/check/interface'
@@ -248,7 +265,6 @@ const props = defineProps({
} }
}) })
const showDialog = ref(false) const showDialog = ref(false)
const viewDialog = ref(false) const viewDialog = ref(false)
const dictStore = useDictStore() const dictStore = useDictStore()
@@ -287,45 +303,45 @@ const second = ref(0)
const emit = defineEmits(['update:activeName', 'update:activeIndex', 'update:startDisabeld', 'update:pauseDisabled']) const emit = defineEmits(['update:activeName', 'update:activeIndex', 'update:startDisabeld', 'update:pauseDisabled'])
watch(()=>props.formControl.scriptId,async ()=>{ watch(
() => props.formControl.scriptId,
async () => {
if (props.formControl.scriptId != '') { if (props.formControl.scriptId != '') {
nextTick(async () => { nextTick(async () => {
await getTree() await getTree()
console.log('props.formControl.scriptId') console.log('props.formControl.scriptId')
treeRef.value.checkTree() treeRef.value.checkTree()
}) })
} }
}) }
)
const controlContent = ref<controlSource.ResControl>({ const controlContent = ref<controlSource.ResControl>({
userPageId: '', userPageId: '',
scriptId: '', scriptId: '',
scriptIndex: 0, scriptIndex: 0,
sourceId: '', sourceId: ''
}) })
// 获取树 // 获取树
const getTree = () => { const getTree = () => {
getTreeData({ getTreeData({
scriptId: props.formControl.scriptId, scriptId: props.formControl.scriptId
}).then(res => { }).then(res => {
if (res.code === 'A0000') { if (res.code === 'A0000') {
treeData.value = res.data treeData.value = res.data
//console.log('tree',res.data) //console.log('tree',res.data)
// 为 treeData 及其子节点添加 id // 为 treeData 及其子节点添加 id
let idCounter = 0; let idCounter = 0
const addIdToTree = (nodes: any[]) => { const addIdToTree = (nodes: any[]) => {
nodes.forEach(node => { nodes.forEach(node => {
node.id = idCounter++; // 为每个节点添加唯一的 id node.id = idCounter++ // 为每个节点添加唯一的 id
if (node.children && node.children.length > 0) { if (node.children && node.children.length > 0) {
node.disabled = true node.disabled = true
addIdToTree(node.children); // 递归为子节点添加 id addIdToTree(node.children) // 递归为子节点添加 id
}
})
} }
});
};
addIdToTree(treeData.value); addIdToTree(treeData.value)
// 添加tab子项 // 添加tab子项
props.options.forEach((k: any, i: number) => { props.options.forEach((k: any, i: number) => {
@@ -335,7 +351,6 @@ const getTree = () => {
item.children.forEach((s: any) => { item.children.forEach((s: any) => {
k.children.forEach((P: any) => { k.children.forEach((P: any) => {
if (P.code == s.scriptTypeCode) { if (P.code == s.scriptTypeCode) {
tabData.value[i].children.push({ tabData.value[i].children.push({
label: P.label, label: P.label,
value: P.code, value: P.code,
@@ -364,10 +379,8 @@ const getTree = () => {
} }
}) })
//console.log('获取树') //console.log('获取树')
} }
// 设置树点击tab // 设置树点击tab
const setTab = row => { const setTab = row => {
activeName.value = row.activeName activeName.value = row.activeName
@@ -396,8 +409,6 @@ const tabChange = () => {
childActiveName.value = childActiveName.value =
tabData.value.filter((item: any) => item.value == activeName.value)[0]?.children[0]?.value || '' tabData.value.filter((item: any) => item.value == activeName.value)[0]?.children[0]?.value || ''
} }
} }
inquireTable() inquireTable()
} }
@@ -425,13 +436,11 @@ const inquireTable = () => {
//console.log('treeData',treeData.value) //console.log('treeData',treeData.value)
} }
// 查看 // 查看
const view = (row: Partial<TestScript.ResTestScript> = {}) => { const view = (row: Partial<TestScript.ResTestScript> = {}) => {
getCommunication() getCommunication()
//当前点击的一级tab //当前点击的一级tab
const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称'; const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称'
//当前点击的二级tab //当前点击的二级tab
const childrenTabName = ref('') const childrenTabName = ref('')
tabData.value.forEach((item: any) => { tabData.value.forEach((item: any) => {
@@ -445,10 +454,8 @@ const view = (row: Partial<TestScript.ResTestScript> = {}) => {
}) })
viewDialog.value = true viewDialog.value = true
setTimeout(() => { setTimeout(() => {
viewRowRef.value?.open(row, communicationList.value, parentTabName, childrenTabName.value) viewRowRef.value?.open(row, communicationList.value, parentTabName, childrenTabName.value)
}, 0) }, 0)
} }
// 定义 startLoading 方法 // 定义 startLoading 方法
@@ -479,7 +486,6 @@ const stopLoading = async () => {
ElMessage.success({ message: '停止中...', duration: 5000 }) ElMessage.success({ message: '停止中...', duration: 5000 })
} }
const startTimeCount = () => { const startTimeCount = () => {
// Loading效果展示 // Loading效果展示
showLoading.value = true showLoading.value = true
@@ -500,7 +506,7 @@ const secondToTime = (secd: number) => {
//将秒数转换成时分秒 //将秒数转换成时分秒
hour.value = Math.floor(secd / 3600) hour.value = Math.floor(secd / 3600)
minute.value = Math.floor((secd - hour.value * 3600) / 60) minute.value = Math.floor((secd - hour.value * 3600) / 60)
second.value = Math.floor(secd % 60); second.value = Math.floor(secd % 60)
} }
const stopTimeCount = () => { const stopTimeCount = () => {
@@ -519,7 +525,6 @@ const addTab = (row: any) => {
} }
onMounted(() => { onMounted(() => {
getTree() getTree()
props.options.forEach((item: any) => { props.options.forEach((item: any) => {
tabData.value.push({ tabData.value.push({
@@ -672,11 +677,13 @@ defineExpose({
} }
@keyframes spin { @keyframes spin {
0% { transform: rotate(0deg); } 0% {
100% { transform: rotate(360deg); } transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
} }
.hidden-tab { .hidden-tab {
display: none; display: none;
@@ -690,7 +697,6 @@ defineExpose({
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
</style> </style>
<style> <style>
input::-webkit-inner-spin-button { input::-webkit-inner-spin-button {

View File

@@ -33,7 +33,7 @@
<el-table-column prop="phase" label="相别" /> <el-table-column prop="phase" label="相别" />
<el-table-column prop="value" label="参考设定值"> <el-table-column prop="value" label="参考设定值">
<template #default="{ row }"> <template #default="{ row }">
<span v-if="row.show">{{ parseFloat((row.value - 0).toFixed(4)) }}</span> <span v-if="row.show">{{ parseFloat((row.value - 0).toFixed(4)) }}{{ setUnit(row) || '' }}</span>
<el-input type="number" v-else v-model="row.value" placeholder="请输入值" /> <el-input type="number" v-else v-model="row.value" placeholder="请输入值" />
</template> </template>
</el-table-column> </el-table-column>
@@ -96,6 +96,10 @@ const props = defineProps({
form: { form: {
type: [Object, Array], type: [Object, Array],
required: true required: true
},
valueCode: {
type: String,
required: true
} }
}) })
const emit = defineEmits(['recalculation']) const emit = defineEmits(['recalculation'])
@@ -213,6 +217,112 @@ const isEqual = (obj1: any, obj2: any) => {
return true return true
} }
const unit = [
{
label: '频率',
unit: 'Hz'
},
{
label: '相电压有效值',
unit: 'V'
},
{
label: '电压偏差',
unit: '%'
},
{
label: '电压相角',
unit: '°'
},
{
label: '基波电压有效值',
unit: ''
},
{
label: '电流有效值',
unit: 'A'
},
{
label: '电流相角',
unit: '°'
},
{
label: '基波电流有效值',
unit: ''
},
{
label: '谐波电压',
unit: '%'
},
{
label: '谐波电流',
unit: '%'
},
{
label: '谐波电流幅值',
unit: 'A'
},
{
label: '谐波有功功率',
unit: 'W'
},
{
label: '间谐波电压',
unit: '%'
},
{
label: '间谐波电流',
unit: '%'
},
{
label: '电压幅值',
unit: '%'
},
{
label: '持续时间',
unit: '周波'
},
{
label: '三相电压不平衡度',
unit: '%'
},
{
label: '三相电流不平衡度',
unit: '%'
},
{
label: '闪变',
unit: ''
},
{
label: '电流',
unit: props.valueCode == 'Absolute' ? 'A' : '%'
},
]
// 参考设定值添加单位
const setUnit = (row: any) => {
console.log('🚀 ~ setUnit ~ row:', row)
let text = ''
if (row.pname == '暂态') {
row.name == '电压幅值' ? (text = '%') : ''
row.name == '持续时间' ? (text = '周波') : ''
} else if (row.pname == '电压') {
let o = props.valueCode == 'Absolute' ? 'V' : '%'
row.name == '相电压有效值' ? (text = o) : ''
row.name == '电压偏差' ? (text = '%') : ''
row.name == '电压相角' ? (text = '°') : ''
}else if (row.pname == '电流') {
let o = props.valueCode == 'Absolute' ? 'A' : '%'
row.name == '电流有效值' ? (text = o) : ''
row.name == '电流相角' ? (text = '°') : ''
} else {
text = unit.filter(item => item.label == row.pname)[0]?.unit
}
return text || ''
}
const save = () => { const save = () => {
dialogVisible.value = false dialogVisible.value = false
} }
@@ -224,6 +334,7 @@ const getTableData = () => {
const close = () => { const close = () => {
dialogVisible.value = false dialogVisible.value = false
} }
onMounted(() => {}) onMounted(() => {})
// 对外映射 // 对外映射

View File

@@ -154,6 +154,7 @@
:formContent="props.formContent" :formContent="props.formContent"
:form="form" :form="form"
:key="initial" :key="initial"
:valueCode=valueCode
@recalculation="recalculation" @recalculation="recalculation"
/> />
</el-carousel-item> </el-carousel-item>

View File

@@ -102,7 +102,7 @@
? '/' ? '/'
: '' + : '' +
row.channelList[item.num + 1].famp + row.channelList[item.num + 1].famp +
(valueCode == 'Absolute' ? 'V' : '%') (valueCode == 'Absolute' ? 'A' : '%')
}} }}
</td> </td>
<td> <td>