diff --git a/frontend/src/api/device/controlSource/index.ts b/frontend/src/api/device/controlSource/index.ts
index 6dd154c..b47e9c5 100644
--- a/frontend/src/api/device/controlSource/index.ts
+++ b/frontend/src/api/device/controlSource/index.ts
@@ -13,12 +13,12 @@ export const checkSimulate = (params: controlSource.ResControl) => {
//启动
export const startSimulateTest = (params: controlSource.ResControl) => {
- return http.post(`prepare/startSimulateTest`,params)
+ return http.post(`prepare/startSimulateTest`,params,{loading:false})
}
//停止
export const closeSimulateTest = (params: controlSource.ResControl) => {
- return http.post(`/prepare/closeSimulateTest`,params)
+ return http.post(`/prepare/closeSimulateTest`,params,{loading:false})
}
diff --git a/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue b/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue
index 9ae539f..c77ac07 100644
--- a/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue
+++ b/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue
@@ -127,12 +127,14 @@
size="large"
@click="startLoading"
style="margin-left: 70px;margin-top: 10px;"
+ :disabled="startDisabeld"
>启动
停止
@@ -168,7 +170,7 @@
import { type PropType, ref, nextTick, onMounted, watch } from 'vue'
import Tree from './tree.vue'
import Commun from './communication.vue'
-import type { CascaderOption } from 'element-plus'
+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 type { TestScript } from '@/api/device/interface/testScript'
@@ -203,8 +205,18 @@ const props = defineProps({
formControl: {
type: Object,
required: true
- }
+ },
+ startDisabeld: {
+ type:Boolean,
+ required:true
+ },
+ pauseDisabled: {
+ type: Boolean,
+ required: true
+ }
})
+
+
const showDialog = ref(false)
const viewDialog = ref(false)
const dictStore = useDictStore()
@@ -234,7 +246,7 @@ const column = ref([
}
])
-const emit = defineEmits(['update:activeName','update:activeIndex'])
+const emit = defineEmits(['update:activeName','update:activeIndex','update:startDisabeld','update:pauseDisabled'])
const controlContent = ref({
userPageId: '',
scriptId: '',
@@ -373,12 +385,17 @@ const view = (row: Partial = {}) => {
// 定义 startLoading 方法
const startLoading = async () => {
+ emit('update:startDisabeld', true)
+ emit('update:pauseDisabled', true)
+ ElMessage.success({message:'启动中...',duration:4000})
// 启动加载逻辑
controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57'
controlContent.value.scriptIndex = childActiveIndex.value
controlContent.value.sourceId = props.formControl.sourceId
+ setTimeout(async () => {
await startSimulateTest(controlContent.value)
+ },3000)
}
// 定义 startLoading 方法
@@ -389,6 +406,9 @@ const stopLoading = async () => {
controlContent.value.scriptIndex = childActiveIndex.value
controlContent.value.sourceId = props.formControl.sourceId
await closeSimulateTest(controlContent.value)
+ emit('update:pauseDisabled', true)
+ emit('update:startDisabeld', true)
+ ElMessage.success({message:'停止中...',duration:4000})
}
// 获取左边树数据
diff --git a/frontend/src/views/machine/controlSource/index.vue b/frontend/src/views/machine/controlSource/index.vue
index b3786f9..79e4feb 100644
--- a/frontend/src/views/machine/controlSource/index.vue
+++ b/frontend/src/views/machine/controlSource/index.vue
@@ -19,7 +19,7 @@
- 通讯校验
+ 通讯校验
@@ -27,7 +27,12 @@
+ @update:active-index="handleActiveIndexChange"
+
+ v-model:startDisabeld="startDisabeld"
+ @update:startDisabeld="startDisabeld=$event"
+ v-model:pauseDisabled="pauseDisabled"
+ @update:pauseDisabled="pauseDisabled=$event"/>
@@ -69,6 +74,9 @@ const formContent = ref({
standardTime: '2025',
state: 1
})
+const connectDisabeld = ref(false)
+const startDisabeld = ref(false)
+const pauseDisabled = ref(true)
const controlContent = ref({
userPageId: '',
@@ -141,17 +149,27 @@ watch(webMsgSend, function (newValue, oldValue) {
console.log('webMsgSend:', newValue)
if (newValue.requestId.includes('formal_real&&') && newValue.operateCode === 'OPER_GATHER') {
if (newValue.code === 10200) {
- ElMessage.success('启动成功')
+ ElMessage.success('启动成功!')
+ startDisabeld.value = true
+ pauseDisabled.value = false
}else if(newValue.code !== 10201){
- ElMessage.error('启动失败')
+ ElMessage.error('启动失败!')
+ startDisabeld.value = false
+ pauseDisabled.value = true
console.log('错误信息:',webMsgSend)
}
}
if (newValue.requestId.includes('close_source') && newValue.operateCode === 'CLOSE_GATHER') {
if (newValue.code === 10200) {
- ElMessage.success('停止成功')
+ setTimeout(() => {
+ ElMessage.success('停止成功!')
+ startDisabeld.value = false
+ pauseDisabled.value = true
+ }, 5000)
} else {
- ElMessage.error('停止失败')
+ ElMessage.error('停止失败!')
+ startDisabeld.value = true
+ pauseDisabled.value = false
console.log('错误信息:',webMsgSend)
}
}
@@ -160,9 +178,9 @@ watch(webMsgSend, function (newValue, oldValue) {
switch (newValue.operateCode) {
case 'INIT_GATHER':
if (newValue.code == 10200) {
- ElMessage.success('源连接成功')
+ ElMessage.success('源连接成功!')
} else if(newValue.code !== 10201) {
- ElMessage.error('源连接失败')
+ ElMessage.error('源连接失败!')
console.log('错误信息:',webMsgSend)
}
break;
@@ -171,7 +189,20 @@ watch(webMsgSend, function (newValue, oldValue) {
case 'connect':
switch (newValue.operateCode) {
case "Source":
- ElMessage.error('源连接失败')
+ ElMessage.error('源连接失败!')
+ }
+ break;
+ case 'server_error':
+ if(newValue.operateCode === 'server_error'){
+ ElMessage.error('服务端主动关闭连接,请20秒后重试!')
+ connectDisabeld.value = true
+ startDisabeld.value = true
+ pauseDisabled.value = true
+ setTimeout(() => {
+ connectDisabeld.value = false
+ startDisabeld.value = true
+ pauseDisabled.value = true
+ }, 20000)
}
break;
}