修改参考设定值添加单位

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

@@ -6,7 +6,7 @@
</div>
<div class="data-check-content">
<div class="content-tree">
<Tree ref="treeRef" :treeData="treeData" @setTab="setTab"/>
<Tree ref="treeRef" :treeData="treeData" @setTab="setTab" />
</div>
<div class="content-right-Tabs" style="height: calc(100vh - 315px); width: 100px">
@@ -14,7 +14,7 @@
<el-tab-pane v-for="tab in tabData" :key="tab.value" :label="tab.label" :name="tab.value">
<div v-if="activeName == tab.value">
<div class="dialog-footer">
<!-- <el-button :icon="CirclePlus" type="primary" @click="openDialog('add')">新增</el-button>-->
<!-- <el-button :icon="CirclePlus" type="primary" @click="openDialog('add')">新增</el-button>-->
</div>
<div style="display: flex">
<!-- 通信脚本 -->
@@ -95,7 +95,7 @@
? '/'
: '' +
row.channelList[item.num + 1].famp +
(valueCode == 'Absolute' ? 'V' : '%')
(valueCode == 'Absolute' ? 'A' : '%')
}}
</td>
<td>
@@ -126,45 +126,51 @@
</el-tabs>
<div class="page">
<div class="black-container">
<!-- <el-progress-->
<!-- v-if="loading"-->
<!-- type="circle"-->
<!-- >-->
<!-- <template #default="{}">-->
<!-- <span class="Loading">Loading</span>-->
<!-- </template>-->
<!-- </el-progress>-->
<!-- <el-progress-->
<!-- v-if="loading"-->
<!-- type="circle"-->
<!-- >-->
<!-- <template #default="{}">-->
<!-- <span class="Loading">Loading</span>-->
<!-- </template>-->
<!-- </el-progress>-->
<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-text">Loading...</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 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-text">Loading</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 style="margin-top: 10px;">
<span>标准源加量输出:{{hour}}{{minute}}{{second}}</span>
<div style="margin-top: 10px">
<span>标准源加量输出:{{ hour }}{{ minute }}{{ second }}</span>
</div>
<div style="margin-top: 10px;">
<el-button :icon="VideoPlay"
<div style="margin-top: 10px">
<el-button
:icon="VideoPlay"
type="primary"
size="large"
@click="startLoading"
:disabled="pauseDisabled"
>启动</el-button>
<el-button :icon="VideoPause"
>
启动
</el-button>
<el-button
:icon="VideoPause"
type="primary"
size="large"
@click="stopLoading"
:disabled="pauseDisabled"
>停止</el-button>
>
停止
</el-button>
</div>
</div>
</div>
@@ -187,7 +193,8 @@
v-if="showDialog"
/>
<!-- 查看 -->
<ViewRow ref="viewRowRef"
<ViewRow
ref="viewRowRef"
:activeName="activeName"
:formContent="props.formContent"
@close="viewDialog = false"
@@ -200,9 +207,19 @@
import { type PropType, ref, nextTick, onMounted, watch } from 'vue'
import Tree from './tree.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 {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 TestProjectPopup from '@/views/machine/testScript/components/testProjectPopup.vue'
import { CheckData } from '@/api/check/interface'
@@ -211,7 +228,7 @@ import { useDictStore } from '@/stores/modules/dict'
import { useHandleData } from '@/hooks/useHandleData'
import { scriptDtlsCheckDataList } from '@/api/device/testScript/index'
import ViewRow from '@/views/machine/testScript/components/viewRow.vue'
import { startSimulateTest,closeSimulateTest } from '@/api/device/controlSource/index.ts'
import { startSimulateTest, closeSimulateTest } from '@/api/device/controlSource/index.ts'
import { controlSource } from '@/api/device/interface/controlSource'
interface TabOption {
label?: string
@@ -239,8 +256,8 @@ const props = defineProps({
required: true
},
startDisabeld: {
type:Boolean,
required:true
type: Boolean,
required: true
},
pauseDisabled: {
type: Boolean,
@@ -248,7 +265,6 @@ const props = defineProps({
}
})
const showDialog = ref(false)
const viewDialog = ref(false)
const dictStore = useDictStore()
@@ -285,47 +301,47 @@ const hour = ref(0)
const minute = ref(0)
const second = ref(0)
const emit = defineEmits(['update:activeName','update:activeIndex','update:startDisabeld','update:pauseDisabled'])
watch(()=>props.formControl.scriptId,async ()=>{
if(props.formControl.scriptId!=''){
const emit = defineEmits(['update:activeName', 'update:activeIndex', 'update:startDisabeld', 'update:pauseDisabled'])
watch(
() => props.formControl.scriptId,
async () => {
if (props.formControl.scriptId != '') {
nextTick(async () => {
await getTree()
console.log('props.formControl.scriptId')
treeRef.value.checkTree()
})
}
})
}
)
const controlContent = ref<controlSource.ResControl>({
userPageId: '',
scriptId: '',
scriptIndex: 0,
sourceId: '',
sourceId: ''
})
// 获取树
const getTree = () => {
getTreeData({
scriptId: props.formControl.scriptId,
scriptId: props.formControl.scriptId
}).then(res => {
if (res.code === 'A0000') {
treeData.value = res.data
//console.log('tree',res.data)
// 为 treeData 及其子节点添加 id
let idCounter = 0;
let idCounter = 0
const addIdToTree = (nodes: any[]) => {
nodes.forEach(node => {
node.id = idCounter++; // 为每个节点添加唯一的 id
node.id = idCounter++ // 为每个节点添加唯一的 id
if (node.children && node.children.length > 0) {
node.disabled = true
addIdToTree(node.children); // 递归为子节点添加 id
addIdToTree(node.children) // 递归为子节点添加 id
}
})
}
});
};
addIdToTree(treeData.value);
addIdToTree(treeData.value)
// 添加tab子项
props.options.forEach((k: any, i: number) => {
@@ -335,7 +351,6 @@ const getTree = () => {
item.children.forEach((s: any) => {
k.children.forEach((P: any) => {
if (P.code == s.scriptTypeCode) {
tabData.value[i].children.push({
label: P.label,
value: P.code,
@@ -364,10 +379,8 @@ const getTree = () => {
}
})
//console.log('获取树')
}
// 设置树点击tab
const setTab = row => {
activeName.value = row.activeName
@@ -396,8 +409,6 @@ const tabChange = () => {
childActiveName.value =
tabData.value.filter((item: any) => item.value == activeName.value)[0]?.children[0]?.value || ''
}
}
inquireTable()
}
@@ -425,13 +436,11 @@ const inquireTable = () => {
//console.log('treeData',treeData.value)
}
// 查看
const view = (row: Partial<TestScript.ResTestScript> = {}) => {
getCommunication()
//当前点击的一级tab
const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称';
const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称'
//当前点击的二级tab
const childrenTabName = ref('')
tabData.value.forEach((item: any) => {
@@ -445,17 +454,15 @@ const view = (row: Partial<TestScript.ResTestScript> = {}) => {
})
viewDialog.value = true
setTimeout(() => {
viewRowRef.value?.open(row, communicationList.value, parentTabName, childrenTabName.value)
}, 0)
}
// 定义 startLoading 方法
const startLoading = async () => {
emit('update:startDisabeld', true)
emit('update:pauseDisabled', true)
ElMessage.success({message:'启动中...',duration:6000})
ElMessage.success({ message: '启动中...', duration: 6000 })
// 启动加载逻辑
controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = props.formControl.scriptId
@@ -463,7 +470,7 @@ const startLoading = async () => {
controlContent.value.sourceId = props.formControl.sourceId
setTimeout(async () => {
await startSimulateTest(controlContent.value)
},3000)
}, 3000)
}
// 定义 startLoading 方法
@@ -476,10 +483,9 @@ const stopLoading = async () => {
await closeSimulateTest(controlContent.value)
emit('update:pauseDisabled', true)
emit('update:startDisabeld', true)
ElMessage.success({message:'停止中...',duration:5000})
ElMessage.success({ message: '停止中...', duration: 5000 })
}
const startTimeCount = () => {
// Loading效果展示
showLoading.value = true
@@ -500,7 +506,7 @@ const secondToTime = (secd: number) => {
//将秒数转换成时分秒
hour.value = Math.floor(secd / 3600)
minute.value = Math.floor((secd - hour.value * 3600) / 60)
second.value = Math.floor(secd % 60);
second.value = Math.floor(secd % 60)
}
const stopTimeCount = () => {
@@ -519,7 +525,6 @@ const addTab = (row: any) => {
}
onMounted(() => {
getTree()
props.options.forEach((item: any) => {
tabData.value.push({
@@ -672,12 +677,14 @@ defineExpose({
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.hidden-tab {
display: none;
}
@@ -690,7 +697,6 @@ defineExpose({
transform: rotate(360deg);
}
}
</style>
<style>
input::-webkit-inner-spin-button {

View File

@@ -33,7 +33,7 @@
<el-table-column prop="phase" label="相别" />
<el-table-column prop="value" label="参考设定值">
<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="请输入值" />
</template>
</el-table-column>
@@ -96,6 +96,10 @@ const props = defineProps({
form: {
type: [Object, Array],
required: true
},
valueCode: {
type: String,
required: true
}
})
const emit = defineEmits(['recalculation'])
@@ -213,6 +217,112 @@ const isEqual = (obj1: any, obj2: any) => {
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 = () => {
dialogVisible.value = false
}
@@ -224,6 +334,7 @@ const getTableData = () => {
const close = () => {
dialogVisible.value = false
}
onMounted(() => {})
// 对外映射

View File

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

View File

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