Merge branch 'release'

# Conflicts:
#	frontend/src/views/machine/controlSource/index.vue
This commit is contained in:
caozehui
2025-03-08 14:39:20 +08:00
6 changed files with 110 additions and 44 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

@@ -1,7 +1,9 @@
// ? 全局默认配置项 // ? 全局默认配置项
// 首页地址(默认) // 首页地址(默认)
export const HOME_URL: string = "/home/index"; // export const HOME_URL: string = "/home/index";
export const HOME_URL: string = "/machine/controlSource";
// 登录页地址(默认) // 登录页地址(默认)
export const LOGIN_URL: string = "/login"; export const LOGIN_URL: string = "/login";

View File

@@ -1,30 +1,38 @@
<template> <template>
<el-dropdown trigger="click"> <div class="userInfo">
<div class="userInfo"> <div class="icon">
<div class="icon"> <Avatar/>
<Avatar />
</div>
<div class="username">
{{ username }}
</div>
</div> </div>
<template #dropdown> <div class="username">
<el-dropdown-menu> {{ username }}
<el-dropdown-item @click="openDialog('infoRef')"> </div>
<el-icon><User /></el-icon>{{ $t("header.personalData") }} </div>
</el-dropdown-item> <!-- <el-dropdown trigger="click">-->
<el-dropdown-item @click="openDialog('passwordRef')"> <!-- <div class="userInfo"> -->
<el-icon><Edit /></el-icon>{{ $t("header.changePassword") }} <!-- <div class="icon">-->
</el-dropdown-item> <!-- <Avatar />-->
<el-dropdown-item @click="changeMode"> <!-- </div>-->
<el-icon><Edit /></el-icon>{{ $t("header.changeMode") }} <!-- <div class="username">-->
</el-dropdown-item> <!-- {{ username }}-->
<el-dropdown-item @click="openDialog('versionRegisterRef')"> <!-- </div>-->
<el-icon><SetUp /></el-icon>{{ $t("header.versionRegister") }} <!-- </div>-->
</el-dropdown-item> <!-- <template #dropdown>-->
</el-dropdown-menu> <!-- <el-dropdown-menu>-->
</template> <!-- <el-dropdown-item @click="openDialog('infoRef')">-->
</el-dropdown> <!-- <el-icon><User /></el-icon>{{ $t("header.personalData") }}-->
<!-- </el-dropdown-item>-->
<!-- <el-dropdown-item @click="openDialog('passwordRef')">-->
<!-- <el-icon><Edit /></el-icon>{{ $t("header.changePassword") }}-->
<!-- </el-dropdown-item>-->
<!-- <el-dropdown-item @click="changeMode">-->
<!-- <el-icon><Edit /></el-icon>{{ $t("header.changeMode") }}-->
<!-- </el-dropdown-item>-->
<!-- <el-dropdown-item @click="openDialog('versionRegisterRef')">-->
<!-- <el-icon><SetUp /></el-icon>{{ $t("header.versionRegister") }}-->
<!-- </el-dropdown-item>-->
<!-- </el-dropdown-menu>-->
<!-- </template>-->
<!-- </el-dropdown>-->
<div class="avatar"> <div class="avatar">
<img src="@/assets/icons/out_login.svg" alt="avatar" @click="logout" /> <img src="@/assets/icons/out_login.svg" alt="avatar" @click="logout" />
</div> </div>

View File

@@ -6,7 +6,7 @@
size='large' size='large'
> >
<el-form-item prop='username'> <el-form-item prop='username'>
<el-input v-model='loginForm.username' placeholder='用户名'> <el-input v-model='loginForm.username' placeholder='用户名' disabled>
<template #prefix> <template #prefix>
<el-icon class='el-input__icon'> <el-icon class='el-input__icon'>
<user /> <user />
@@ -21,6 +21,7 @@
placeholder='密码' placeholder='密码'
show-password show-password
autocomplete='new-password' autocomplete='new-password'
disabled
> >
<template #prefix> <template #prefix>
<el-icon class='el-input__icon'> <el-icon class='el-input__icon'>
@@ -87,8 +88,8 @@ const loginRules = reactive({
const loading = ref(false) const loading = ref(false)
const loginForm = reactive<Login.ReqLoginForm>({ const loginForm = reactive<Login.ReqLoginForm>({
username: '', username: 'user',
password: '', password: 'user12345.',
}) })
// login // login

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: '',
@@ -138,19 +146,30 @@ onMounted(async () => {
}) })
watch(webMsgSend, function (newValue, oldValue) { watch(webMsgSend, function (newValue, oldValue) {
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)
} }
} }
@@ -159,21 +178,37 @@ 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;
} }
break; break;
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;
} }
}) })
// 获取树字典 // 获取树字典
const treeInfo = async (currentMode: string) => { const treeInfo = async (currentMode: string) => {