This commit is contained in:
caozehui
2025-03-08 14:36:48 +08:00
parent 3021f7e4d3
commit 70531a0729
3 changed files with 65 additions and 14 deletions

View File

@@ -13,12 +13,12 @@ export const checkSimulate = (params: controlSource.ResControl) => {
//启动 //启动
export const startSimulateTest = (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) => { export const closeSimulateTest = (params: controlSource.ResControl) => {
return http.post(`/prepare/closeSimulateTest`,params) return http.post(`/prepare/closeSimulateTest`,params,{loading:false})
} }

View File

@@ -127,12 +127,14 @@
size="large" size="large"
@click="startLoading" @click="startLoading"
style="margin-left: 70px;margin-top: 10px;" style="margin-left: 70px;margin-top: 10px;"
:disabled="startDisabeld"
>启动</el-button> >启动</el-button>
<el-button :icon="CirclePlus" <el-button :icon="CirclePlus"
type="primary" type="primary"
size="large" size="large"
@click="stopLoading" @click="stopLoading"
style="margin-top: 10px;" style="margin-top: 10px;"
:disabled="pauseDisabled"
>停止</el-button> >停止</el-button>
</div> </div>
</div> </div>
@@ -168,7 +170,7 @@
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 './communication.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 { getTreeData } from '@/api/check/test'
import { CirclePlus, Delete, Check, CopyDocument, View, EditPen } from '@element-plus/icons-vue' import { CirclePlus, Delete, Check, CopyDocument, View, EditPen } from '@element-plus/icons-vue'
import type { TestScript } from '@/api/device/interface/testScript' import type { TestScript } from '@/api/device/interface/testScript'
@@ -203,8 +205,18 @@ const props = defineProps({
formControl: { formControl: {
type: Object, type: Object,
required: true required: true
} },
startDisabeld: {
type:Boolean,
required:true
},
pauseDisabled: {
type: Boolean,
required: true
}
}) })
const showDialog = ref(false) const showDialog = ref(false)
const viewDialog = ref(false) const viewDialog = ref(false)
const dictStore = useDictStore() 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<controlSource.ResControl>({ const controlContent = ref<controlSource.ResControl>({
userPageId: '', userPageId: '',
scriptId: '', scriptId: '',
@@ -373,12 +385,17 @@ const view = (row: Partial<TestScript.ResTestScript> = {}) => {
// 定义 startLoading 方法 // 定义 startLoading 方法
const startLoading = async () => { const startLoading = async () => {
emit('update:startDisabeld', true)
emit('update:pauseDisabled', true)
ElMessage.success({message:'启动中...',duration:4000})
// 启动加载逻辑 // 启动加载逻辑
controlContent.value.userPageId = 'cdf' controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57' controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57'
controlContent.value.scriptIndex = childActiveIndex.value controlContent.value.scriptIndex = childActiveIndex.value
controlContent.value.sourceId = props.formControl.sourceId controlContent.value.sourceId = props.formControl.sourceId
setTimeout(async () => {
await startSimulateTest(controlContent.value) await startSimulateTest(controlContent.value)
},3000)
} }
// 定义 startLoading 方法 // 定义 startLoading 方法
@@ -389,6 +406,9 @@ const stopLoading = async () => {
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:startDisabeld', true)
ElMessage.success({message:'停止中...',duration:4000})
} }
// 获取左边树数据 // 获取左边树数据

View File

@@ -19,7 +19,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<div class="formBut"> <div class="formBut">
<el-button type="primary" :icon="Select" @click="start()">通讯校验</el-button> <el-button type="primary" :icon="Select" @click="start()" :disabled="connectDisabeld">通讯校验</el-button>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
@@ -27,7 +27,12 @@
<el-card v-if="show"> <el-card v-if="show">
<ControlSourceDetail v-if="secondLevelOptions.length > 0" :options="secondLevelOptions" :formContent="formContent" :formControl="controlContent" <ControlSourceDetail v-if="secondLevelOptions.length > 0" :options="secondLevelOptions" :formContent="formContent" :formControl="controlContent"
@update:activeName="handleActiveNameChange" @update:activeName="handleActiveNameChange"
@update:active-index="handleActiveIndexChange"/> @update:active-index="handleActiveIndexChange"
v-model:startDisabeld="startDisabeld"
@update:startDisabeld="startDisabeld=$event"
v-model:pauseDisabled="pauseDisabled"
@update:pauseDisabled="pauseDisabled=$event"/>
</el-card> </el-card>
</div> </div>
</template> </template>
@@ -69,6 +74,9 @@ const formContent = ref<TestScript.ResTestScript>({
standardTime: '2025', standardTime: '2025',
state: 1 state: 1
}) })
const connectDisabeld = ref(false)
const startDisabeld = ref(false)
const pauseDisabled = ref(true)
const controlContent = ref<controlSource.ResControl>({ const controlContent = ref<controlSource.ResControl>({
userPageId: '', userPageId: '',
@@ -141,17 +149,27 @@ watch(webMsgSend, function (newValue, oldValue) {
console.log('webMsgSend:', newValue) console.log('webMsgSend:', newValue)
if (newValue.requestId.includes('formal_real&&') && newValue.operateCode === 'OPER_GATHER') { if (newValue.requestId.includes('formal_real&&') && newValue.operateCode === 'OPER_GATHER') {
if (newValue.code === 10200) { if (newValue.code === 10200) {
ElMessage.success('启动成功') ElMessage.success('启动成功!')
startDisabeld.value = true
pauseDisabled.value = false
}else if(newValue.code !== 10201){ }else if(newValue.code !== 10201){
ElMessage.error('启动失败') ElMessage.error('启动失败!')
startDisabeld.value = false
pauseDisabled.value = true
console.log('错误信息:',webMsgSend) console.log('错误信息:',webMsgSend)
} }
} }
if (newValue.requestId.includes('close_source') && newValue.operateCode === 'CLOSE_GATHER') { if (newValue.requestId.includes('close_source') && newValue.operateCode === 'CLOSE_GATHER') {
if (newValue.code === 10200) { if (newValue.code === 10200) {
ElMessage.success('停止成功') setTimeout(() => {
ElMessage.success('停止成功!')
startDisabeld.value = false
pauseDisabled.value = true
}, 5000)
} else { } else {
ElMessage.error('停止失败') ElMessage.error('停止失败!')
startDisabeld.value = true
pauseDisabled.value = false
console.log('错误信息:',webMsgSend) console.log('错误信息:',webMsgSend)
} }
} }
@@ -160,9 +178,9 @@ watch(webMsgSend, function (newValue, oldValue) {
switch (newValue.operateCode) { switch (newValue.operateCode) {
case 'INIT_GATHER': case 'INIT_GATHER':
if (newValue.code == 10200) { if (newValue.code == 10200) {
ElMessage.success('源连接成功') ElMessage.success('源连接成功!')
} else if(newValue.code !== 10201) { } else if(newValue.code !== 10201) {
ElMessage.error('源连接失败') ElMessage.error('源连接失败!')
console.log('错误信息:',webMsgSend) console.log('错误信息:',webMsgSend)
} }
break; break;
@@ -171,7 +189,20 @@ watch(webMsgSend, function (newValue, oldValue) {
case 'connect': case 'connect':
switch (newValue.operateCode) { switch (newValue.operateCode) {
case "Source": 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; break;
} }