源程控-时间展示

This commit is contained in:
caozehui
2025-03-10 10:10:32 +08:00
parent 258d3d692f
commit 3cf5019880
3 changed files with 71 additions and 16 deletions

View File

@@ -122,23 +122,26 @@
</template>
</el-progress>
</div>
<el-button :icon="CirclePlus"
<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"
style="margin-left: 70px;margin-top: 10px;"
:disabled="startDisabeld"
>启动</el-button>
<el-button :icon="CirclePlus"
<el-button :icon="VideoPause"
type="primary"
size="large"
@click="stopLoading"
style="margin-top: 10px;"
:disabled="pauseDisabled"
>停止</el-button>
</div>
</div>
</div>
</div>
</el-tab-pane>
</el-tabs>
</div>
@@ -172,7 +175,7 @@ import Tree from './tree.vue'
import Commun from './communication.vue'
import {type CascaderOption, ElMessage} from 'element-plus'
import { getTreeData } from '@/api/check/test'
import { CirclePlus, Delete, Check, CopyDocument, View, EditPen } from '@element-plus/icons-vue'
import {CirclePlus, Delete, Check, CopyDocument, View, EditPen, VideoPlay,VideoPause} 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'
@@ -246,6 +249,13 @@ const column = ref([
}
])
// 时间计数器
let timer: any = null
const timeCount = ref(0)
const hour = ref(0)
const minute = ref(0)
const second = ref(0)
const emit = defineEmits(['update:activeName','update:activeIndex','update:startDisabeld','update:pauseDisabled'])
const controlContent = ref<controlSource.ResControl>({
userPageId: '',
@@ -414,6 +424,32 @@ const stopLoading = async () => {
ElMessage.success({message:'停止中...',duration:5000})
}
const startTimeCount = () => {
if (!timer) {
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);
}
const stopTimeCount = () => {
if (timer) {
clearInterval(timer)
}
hour.value = 0
minute.value = 0
second.value = 0
}
// 获取左边树数据
// 新增保存
const addTab = (row: any) => {
@@ -436,6 +472,11 @@ onMounted(() => {
.getDictData('Script_Value_Type')
.filter(item => item.id == props.formContent.valueType)[0].code
})
defineExpose({
startTimeCount,
stopTimeCount
})
</script>
<style lang="scss" scoped>
.data-check-content {
@@ -506,6 +547,12 @@ onMounted(() => {
}
}
.page{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.loading-container {
background-color: #000;
width: 300px;
@@ -515,6 +562,8 @@ onMounted(() => {
justify-content: center;
margin-left: 20px;
}
}
</style>
<style>
input::-webkit-inner-spin-button {

View File

@@ -42,6 +42,7 @@ const childActiveName = ref('')
const activeIndex = ref()
const handleNodeClick = (data, node) => {
console.log('handleNodeClick', props.treeData)
if(data.index!= null){
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
const parents = getParentNodes(node, [])
parents.pop()
@@ -50,7 +51,7 @@ const handleNodeClick = (data, node) => {
let active = parents[0].scriptTypeCode
let childActive = findTargetCodes(parents, code)[0] || ''
// 获取当前节点的直接父节点
if (activeName.value != active || childActiveName.value != childActive) {
if (activeName.value != active || childActiveName.value != childActive || activeIndex.value != data.index) {
activeName.value = active
childActiveName.value = childActive
emit('setTab', {
@@ -60,6 +61,7 @@ const handleNodeClick = (data, node) => {
})
}
}
}
// 返回父级
const getParentNodes = (node, parents) => {

View File

@@ -32,7 +32,8 @@
v-model:startDisabeld="startDisabeld"
@update:startDisabeld="startDisabeld=$event"
v-model:pauseDisabled="pauseDisabled"
@update:pauseDisabled="pauseDisabled=$event"/>
@update:pauseDisabled="pauseDisabled=$event"
ref="controlSourceDetailRef"/>
</el-card>
</div>
</template>
@@ -77,6 +78,7 @@ const formContent = ref<TestScript.ResTestScript>({
const connectDisabeld = ref(false)
const startDisabeld = ref(true)
const pauseDisabled = ref(true)
const controlSourceDetailRef=ref<InstanceType<typeof ControlSourceDetail>>()
const controlContent = ref<controlSource.ResControl>({
userPageId: '',
@@ -154,6 +156,7 @@ watch(webMsgSend, function (newValue, oldValue) {
ElMessage.success('启动成功!')
startDisabeld.value = false
pauseDisabled.value = false
controlSourceDetailRef.value?.startTimeCount()
}else if(newValue.code !== 10201){
ElMessage.error('启动失败!')
startDisabeld.value = false
@@ -168,6 +171,7 @@ watch(webMsgSend, function (newValue, oldValue) {
connectDisabeld.value = false
startDisabeld.value = true
pauseDisabled.value = true
controlSourceDetailRef.value?.stopTimeCount()
}, 5000)
} else {
ElMessage.error('停止失败!')