修改参考设定值添加单位

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,11 +14,11 @@
<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">
<!-- 通信脚本 -->
<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">
<Commun
:activeName="activeName"
@@ -95,7 +95,7 @@
? '/'
: '' +
row.channelList[item.num + 1].famp +
(valueCode == 'Absolute' ? 'V' : '%')
(valueCode == 'Absolute' ? 'A' : '%')
}}
</td>
<td>
@@ -126,46 +126,52 @@
</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>-->
<div class="loading-container" v-if="showLoading">
<div style="width: 80%; height: 80%;" class="loading-box">
<div class="loading-circle"></div>
<div class="loading-text">Loading...</div>
<!-- <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 class="loading-circle"></div>
<div class="loading-text">Loading...</div>
</div>
<!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>-->
</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 class="loading-circle static"></div>
<div class="loading-text">Loading</div>
<div class="loading-container" v-else>
<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>
<!-- <div style="color:#fff;width: 80%;text-align: center;">Loading...</div>-->
</div>
</div>
<div style="margin-top: 10px;">
<span>标准源加量输出:{{hour}}{{minute}}{{second}}</span>
</div>
<div style="margin-top: 10px;">
<el-button :icon="VideoPlay"
type="primary"
size="large"
@click="startLoading"
:disabled="pauseDisabled"
>启动</el-button>
<el-button :icon="VideoPause"
type="primary"
size="large"
@click="stopLoading"
:disabled="pauseDisabled"
>停止</el-button>
</div>
<div style="margin-top: 10px">
<span>标准源加量输出:{{ hour }}{{ minute }}{{ second }}</span>
</div>
<div style="margin-top: 10px">
<el-button
:icon="VideoPlay"
type="primary"
size="large"
@click="startLoading"
:disabled="pauseDisabled"
>
启动
</el-button>
<el-button
:icon="VideoPause"
type="primary"
size="large"
@click="stopLoading"
:disabled="pauseDisabled"
>
停止
</el-button>
</div>
</div>
</div>
</div>
@@ -187,12 +193,13 @@
v-if="showDialog"
/>
<!-- 查看 -->
<ViewRow ref="viewRowRef"
:activeName="activeName"
:formContent="props.formContent"
@close="viewDialog = false"
v-if="viewDialog"
/>
<ViewRow
ref="viewRowRef"
:activeName="activeName"
:formContent="props.formContent"
@close="viewDialog = false"
v-if="viewDialog"
/>
</div>
</template>
@@ -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
@@ -238,17 +255,16 @@ const props = defineProps({
type: Object,
required: true
},
startDisabeld: {
type:Boolean,
required:true
},
pauseDisabled: {
type: Boolean,
required: true
}
startDisabeld: {
type: Boolean,
required: true
},
pauseDisabled: {
type: Boolean,
required: true
}
})
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'])
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()
})
}
})
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: '',
userPageId: '',
scriptId: '',
scriptIndex: 0,
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,
@@ -357,17 +372,15 @@ const getTree = () => {
}
})
})
//console.log('2222',treeData.value)
tabChange()
}
})
//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,25 +454,23 @@ 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})
emit('update:startDisabeld', true)
emit('update:pauseDisabled', true)
ElMessage.success({ message: '启动中...', duration: 6000 })
// 启动加载逻辑
controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = props.formControl.scriptId
controlContent.value.scriptIndex = childActiveIndex.value
controlContent.value.sourceId = props.formControl.sourceId
setTimeout(async () => {
await startSimulateTest(controlContent.value)
},3000)
controlContent.value.sourceId = props.formControl.sourceId
setTimeout(async () => {
await startSimulateTest(controlContent.value)
}, 3000)
}
// 定义 startLoading 方法
@@ -472,44 +479,43 @@ const stopLoading = async () => {
controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = props.formControl.scriptId
controlContent.value.scriptIndex = childActiveIndex.value
controlContent.value.sourceId = props.formControl.sourceId
controlContent.value.sourceId = props.formControl.sourceId
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
// Loading效果展示
showLoading.value = true
if (!timer) {
hour.value = 0
minute.value = 0
second.value = 0
timeCount.value = 0
timer = setInterval(() => {
timeCount.value = timeCount.value + 1
secondToTime(timeCount.value)
}, 1000)
}
if (!timer) {
hour.value = 0
minute.value = 0
second.value = 0
timeCount.value = 0
timer = setInterval(() => {
timeCount.value = timeCount.value + 1
secondToTime(timeCount.value)
}, 1000)
}
}
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);
//将秒数转换成时分秒
hour.value = Math.floor(secd / 3600)
minute.value = Math.floor((secd - hour.value * 3600) / 60)
second.value = Math.floor(secd % 60)
}
const stopTimeCount = () => {
if (timer) {
clearInterval(timer)
timer = null
}
//Loading效果关闭
showLoading.value = false
if (timer) {
clearInterval(timer)
timer = null
}
//Loading效果关闭
showLoading.value = false
}
// 获取左边树数据
@@ -519,7 +525,6 @@ const addTab = (row: any) => {
}
onMounted(() => {
getTree()
props.options.forEach((item: any) => {
tabData.value.push({
@@ -537,8 +542,8 @@ onMounted(() => {
})
defineExpose({
startTimeCount,
stopTimeCount
startTimeCount,
stopTimeCount
})
</script>
<style lang="scss" scoped>
@@ -611,50 +616,50 @@ defineExpose({
}
.page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.black-container {
background-color: #000;
width: 300px;
height: 300px;
position: relative; /* 设置为相对定位 */
display: flex;
align-items: center;
justify-content: center;
margin-left: 20px;
background-color: #000;
width: 300px;
height: 300px;
position: relative; /* 设置为相对定位 */
display: flex;
align-items: center;
justify-content: center;
margin-left: 20px;
}
.loading-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.loading-box {
position: relative; /* 设置为相对定位 */
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
position: relative; /* 设置为相对定位 */
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.loading-circle {
border: 8px solid rgba(255, 255, 255, 0.932);
border-top: 8px solid var(--el-color-primary); /* 蓝色 */
border-bottom: 8px solid var(--el-color-primary); /* 蓝色 */
border-radius: 50%;
width: 200px;
height: 200px;
position: absolute; /* 设置为绝对定位 */
animation: spin 2s linear infinite;
border: 8px solid rgba(255, 255, 255, 0.932);
border-top: 8px solid var(--el-color-primary); /* 蓝色 */
border-bottom: 8px solid var(--el-color-primary); /* 蓝色 */
border-radius: 50%;
width: 200px;
height: 200px;
position: absolute; /* 设置为绝对定位 */
animation: spin 2s linear infinite;
}
.loading-circle.static {
@@ -662,35 +667,36 @@ defineExpose({
}
.loading-text {
position: absolute; /* 设置为绝对定位 */
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #fff;
font-size: 20px; /* 根据需要调整字体大小 */
text-align: center;
position: absolute; /* 设置为绝对定位 */
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #fff;
font-size: 20px; /* 根据需要调整字体大小 */
text-align: center;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.hidden-tab {
display: none;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
<style>
input::-webkit-inner-spin-button {