修改参考设定值添加单位

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>
<div class="data-check-content"> <div class="data-check-content">
<div class="content-tree"> <div class="content-tree">
<Tree ref="treeRef" :treeData="treeData" @setTab="setTab"/> <Tree ref="treeRef" :treeData="treeData" @setTab="setTab" />
</div> </div>
<div class="content-right-Tabs" style="height: calc(100vh - 315px); width: 100px"> <div class="content-right-Tabs" style="height: calc(100vh - 315px); width: 100px">
@@ -14,11 +14,11 @@
<el-tab-pane v-for="tab in tabData" :key="tab.value" :label="tab.label" :name="tab.value"> <el-tab-pane v-for="tab in tabData" :key="tab.value" :label="tab.label" :name="tab.value">
<div v-if="activeName == tab.value"> <div v-if="activeName == tab.value">
<div class="dialog-footer"> <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>
<div style="display: flex"> <div style="display: flex">
<!-- 通信脚本 --> <!-- 通信脚本 -->
<el-tabs type="border-card" v-model="firstName" style="height: 100%" class="hidden-tab"> <el-tabs type="border-card" v-model="firstName" style="height: 100%" class="hidden-tab">
<el-tab-pane label="通讯脚本" name="first"> <el-tab-pane label="通讯脚本" name="first">
<Commun <Commun
:activeName="activeName" :activeName="activeName"
@@ -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>
@@ -126,46 +126,52 @@
</el-tabs> </el-tabs>
<div class="page"> <div class="page">
<div class="black-container"> <div class="black-container">
<!-- <el-progress--> <!-- <el-progress-->
<!-- v-if="loading"--> <!-- v-if="loading"-->
<!-- type="circle"--> <!-- type="circle"-->
<!-- >--> <!-- >-->
<!-- <template #default="{}">--> <!-- <template #default="{}">-->
<!-- <span class="Loading">Loading</span>--> <!-- <span class="Loading">Loading</span>-->
<!-- </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 style="color:#fff;width: 80%;text-align: center;">Loading...</div>-->
</div> </div>
<!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>--> <div class="loading-container" v-else>
</div> <div style="width: 80%; height: 80%" class="loading-box">
<div class="loading-container" v-else> <div class="loading-circle static"></div>
<div style="width: 80%; height: 80%; " class="loading-box"> <div class="loading-text">Loading</div>
<div class="loading-circle static"></div> </div>
<div class="loading-text">Loading</div> <!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>-->
</div> </div>
<!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</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
type="primary" :icon="VideoPlay"
size="large" type="primary"
@click="startLoading" size="large"
:disabled="pauseDisabled" @click="startLoading"
>启动</el-button> :disabled="pauseDisabled"
<el-button :icon="VideoPause" >
type="primary" 启动
size="large" </el-button>
@click="stopLoading" <el-button
:disabled="pauseDisabled" :icon="VideoPause"
>停止</el-button> type="primary"
</div> size="large"
@click="stopLoading"
:disabled="pauseDisabled"
>
停止
</el-button>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -187,12 +193,13 @@
v-if="showDialog" v-if="showDialog"
/> />
<!-- 查看 --> <!-- 查看 -->
<ViewRow ref="viewRowRef" <ViewRow
:activeName="activeName" ref="viewRowRef"
:formContent="props.formContent" :activeName="activeName"
@close="viewDialog = false" :formContent="props.formContent"
v-if="viewDialog" @close="viewDialog = false"
/> v-if="viewDialog"
/>
</div> </div>
</template> </template>
@@ -200,9 +207,19 @@
import { type PropType, ref, nextTick, onMounted, watch } from 'vue' import { type PropType, ref, nextTick, onMounted, watch } from 'vue'
import Tree from './tree.vue' 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'
@@ -211,7 +228,7 @@ import { useDictStore } from '@/stores/modules/dict'
import { useHandleData } from '@/hooks/useHandleData' import { useHandleData } from '@/hooks/useHandleData'
import { scriptDtlsCheckDataList } from '@/api/device/testScript/index' import { scriptDtlsCheckDataList } from '@/api/device/testScript/index'
import ViewRow from '@/views/machine/testScript/components/viewRow.vue' 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' import { controlSource } from '@/api/device/interface/controlSource'
interface TabOption { interface TabOption {
label?: string label?: string
@@ -238,17 +255,16 @@ const props = defineProps({
type: Object, type: Object,
required: true required: true
}, },
startDisabeld: { startDisabeld: {
type:Boolean, type: Boolean,
required:true required: true
}, },
pauseDisabled: { pauseDisabled: {
type: Boolean, type: Boolean,
required: true required: true
} }
}) })
const showDialog = ref(false) const showDialog = ref(false)
const viewDialog = ref(false) const viewDialog = ref(false)
const dictStore = useDictStore() const dictStore = useDictStore()
@@ -285,47 +301,47 @@ const hour = ref(0)
const minute = ref(0) const minute = ref(0)
const second = ref(0) 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(
if(props.formControl.scriptId!=''){ () => props.formControl.scriptId,
async () => {
nextTick(async () => { if (props.formControl.scriptId != '') {
await getTree() nextTick(async () => {
console.log('props.formControl.scriptId') await getTree()
treeRef.value.checkTree() console.log('props.formControl.scriptId')
}) 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,
@@ -357,17 +372,15 @@ const getTree = () => {
} }
}) })
}) })
//console.log('2222',treeData.value) //console.log('2222',treeData.value)
tabChange() tabChange()
} }
}) })
//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,25 +454,23 @@ 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 方法
const startLoading = async () => { const startLoading = async () => {
emit('update:startDisabeld', true) emit('update:startDisabeld', true)
emit('update:pauseDisabled', true) emit('update:pauseDisabled', true)
ElMessage.success({message:'启动中...',duration:6000}) ElMessage.success({ message: '启动中...', duration: 6000 })
// 启动加载逻辑 // 启动加载逻辑
controlContent.value.userPageId = 'cdf' controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = props.formControl.scriptId controlContent.value.scriptId = props.formControl.scriptId
controlContent.value.scriptIndex = childActiveIndex.value controlContent.value.scriptIndex = childActiveIndex.value
controlContent.value.sourceId = props.formControl.sourceId controlContent.value.sourceId = props.formControl.sourceId
setTimeout(async () => { setTimeout(async () => {
await startSimulateTest(controlContent.value) await startSimulateTest(controlContent.value)
},3000) }, 3000)
} }
// 定义 startLoading 方法 // 定义 startLoading 方法
@@ -472,44 +479,43 @@ const stopLoading = async () => {
controlContent.value.userPageId = 'cdf' controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = props.formControl.scriptId controlContent.value.scriptId = props.formControl.scriptId
controlContent.value.scriptIndex = childActiveIndex.value controlContent.value.scriptIndex = childActiveIndex.value
controlContent.value.sourceId = props.formControl.sourceId controlContent.value.sourceId = props.formControl.sourceId
await closeSimulateTest(controlContent.value) await closeSimulateTest(controlContent.value)
emit('update:pauseDisabled', true) emit('update:pauseDisabled', true)
emit('update:startDisabeld', true) emit('update:startDisabeld', true)
ElMessage.success({message:'停止中...',duration:5000}) ElMessage.success({ message: '停止中...', duration: 5000 })
} }
const startTimeCount = () => { const startTimeCount = () => {
// Loading效果展示 // Loading效果展示
showLoading.value = true showLoading.value = true
if (!timer) { if (!timer) {
hour.value = 0 hour.value = 0
minute.value = 0 minute.value = 0
second.value = 0 second.value = 0
timeCount.value = 0 timeCount.value = 0
timer = setInterval(() => { timer = setInterval(() => {
timeCount.value = timeCount.value + 1 timeCount.value = timeCount.value + 1
secondToTime(timeCount.value) secondToTime(timeCount.value)
}, 1000) }, 1000)
} }
} }
const secondToTime = (secd: number) => { 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 = () => {
if (timer) { if (timer) {
clearInterval(timer) clearInterval(timer)
timer = null timer = null
} }
//Loading效果关闭 //Loading效果关闭
showLoading.value = false showLoading.value = false
} }
// 获取左边树数据 // 获取左边树数据
@@ -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({
@@ -537,8 +542,8 @@ onMounted(() => {
}) })
defineExpose({ defineExpose({
startTimeCount, startTimeCount,
stopTimeCount stopTimeCount
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -611,50 +616,50 @@ defineExpose({
} }
.page { .page {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.black-container { .black-container {
background-color: #000; background-color: #000;
width: 300px; width: 300px;
height: 300px; height: 300px;
position: relative; /* 设置为相对定位 */ position: relative; /* 设置为相对定位 */
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-left: 20px; margin-left: 20px;
} }
.loading-container { .loading-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.loading-box { .loading-box {
position: relative; /* 设置为相对定位 */ position: relative; /* 设置为相对定位 */
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }
.loading-circle { .loading-circle {
border: 8px solid rgba(255, 255, 255, 0.932); border: 8px solid rgba(255, 255, 255, 0.932);
border-top: 8px solid var(--el-color-primary); /* 蓝色 */ border-top: 8px solid var(--el-color-primary); /* 蓝色 */
border-bottom: 8px solid var(--el-color-primary); /* 蓝色 */ border-bottom: 8px solid var(--el-color-primary); /* 蓝色 */
border-radius: 50%; border-radius: 50%;
width: 200px; width: 200px;
height: 200px; height: 200px;
position: absolute; /* 设置为绝对定位 */ position: absolute; /* 设置为绝对定位 */
animation: spin 2s linear infinite; animation: spin 2s linear infinite;
} }
.loading-circle.static { .loading-circle.static {
@@ -662,35 +667,36 @@ defineExpose({
} }
.loading-text { .loading-text {
position: absolute; /* 设置为绝对定位 */ position: absolute; /* 设置为绝对定位 */
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
color: #fff; color: #fff;
font-size: 20px; /* 根据需要调整字体大小 */ font-size: 20px; /* 根据需要调整字体大小 */
text-align: center; text-align: center;
} }
@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;
} }
@keyframes rotate { @keyframes rotate {
from { from {
transform: rotate(0deg); transform: rotate(0deg);
} }
to { to {
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>