微调
This commit is contained in:
@@ -9,7 +9,7 @@ export namespace controlSource {
|
|||||||
export interface ResControl {
|
export interface ResControl {
|
||||||
userPageId: string;
|
userPageId: string;
|
||||||
scriptId: string;
|
scriptId: string;
|
||||||
scriptIndex: string;
|
scriptIndex: number;
|
||||||
sourceId: string;
|
sourceId: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,6 +179,8 @@ import { useDictStore } from '@/stores/modules/dict'
|
|||||||
import { useHandleData } from '@/hooks/useHandleData'
|
import { useHandleData } from '@/hooks/useHandleData'
|
||||||
import { scriptDtlsCheckDataList } from '@/api/device/testScript/index'
|
import { scriptDtlsCheckDataList } from '@/api/device/testScript/index'
|
||||||
import ViewRow from '@/views/machine/testScript/components/viewRow.vue'
|
import ViewRow from '@/views/machine/testScript/components/viewRow.vue'
|
||||||
|
import { startSimulateTest,closeSimulateTest } from '@/api/device/controlSource/index.ts'
|
||||||
|
import { controlSource } from '@/api/device/interface/controlSource'
|
||||||
interface TabOption {
|
interface TabOption {
|
||||||
label?: string
|
label?: string
|
||||||
name?: string
|
name?: string
|
||||||
@@ -197,6 +199,10 @@ const props = defineProps({
|
|||||||
formContent: {
|
formContent: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
formControl: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const showDialog = ref(false)
|
const showDialog = ref(false)
|
||||||
@@ -204,6 +210,7 @@ const viewDialog = ref(false)
|
|||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
const activeName = ref('')
|
const activeName = ref('')
|
||||||
const childActiveName = ref('')
|
const childActiveName = ref('')
|
||||||
|
const childActiveIndex = ref(0)
|
||||||
const firstName = 'first'
|
const firstName = 'first'
|
||||||
const viewRowRef = ref()
|
const viewRowRef = ref()
|
||||||
const communicationList = ref([])
|
const communicationList = ref([])
|
||||||
@@ -226,6 +233,14 @@ const column = ref([
|
|||||||
num: 4
|
num: 4
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:activeName','update:activeIndex'])
|
||||||
|
const controlContent = ref<controlSource.ResControl>({
|
||||||
|
userPageId: '',
|
||||||
|
scriptId: '',
|
||||||
|
scriptIndex: 0,
|
||||||
|
sourceId: '',
|
||||||
|
})
|
||||||
// 获取树
|
// 获取树
|
||||||
const getTree = () => {
|
const getTree = () => {
|
||||||
getTreeData({
|
getTreeData({
|
||||||
@@ -273,7 +288,10 @@ const getTree = () => {
|
|||||||
const setTab = row => {
|
const setTab = row => {
|
||||||
activeName.value = row.activeName
|
activeName.value = row.activeName
|
||||||
childActiveName.value = row.childActiveName
|
childActiveName.value = row.childActiveName
|
||||||
|
childActiveIndex.value = row.activeIndex
|
||||||
getTree()
|
getTree()
|
||||||
|
emit('update:activeName', activeName.value) // 触发事件并传递 activeName.value
|
||||||
|
emit('update:activeIndex', row.activeIndex) // 触发事件并传递 activeName.value
|
||||||
}
|
}
|
||||||
const copyActiveName = ref('')
|
const copyActiveName = ref('')
|
||||||
// 获取通讯脚本点击
|
// 获取通讯脚本点击
|
||||||
@@ -353,6 +371,25 @@ const view = (row: Partial<TestScript.ResTestScript> = {}) => {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 定义 startLoading 方法
|
||||||
|
const startLoading = async () => {
|
||||||
|
// 启动加载逻辑
|
||||||
|
controlContent.value.userPageId = 'cdf'
|
||||||
|
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57'
|
||||||
|
controlContent.value.scriptIndex = props.formControl.scriptIndex
|
||||||
|
controlContent.value.sourceId = props.formControl.sourceId
|
||||||
|
await startSimulateTest(controlContent.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 定义 startLoading 方法
|
||||||
|
const stopLoading = async () => {
|
||||||
|
// 启动加载逻辑
|
||||||
|
controlContent.value.userPageId = 'cdf'
|
||||||
|
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57'
|
||||||
|
controlContent.value.scriptIndex = childActiveIndex.value
|
||||||
|
controlContent.value.sourceId = props.formControl.sourceId
|
||||||
|
await closeSimulateTest(controlContent.value)
|
||||||
|
}
|
||||||
|
|
||||||
// 获取左边树数据
|
// 获取左边树数据
|
||||||
// 新增保存
|
// 新增保存
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
:highlight-current="true"
|
:highlight-current="true"
|
||||||
@node-click="handleNodeClick"
|
@node-click="handleNodeClick"
|
||||||
show-checkbox
|
show-checkbox
|
||||||
@check-change="handleCheckChange"
|
@check-change="handleCheckChange"
|
||||||
>
|
>
|
||||||
<template #default="{ node, data }">
|
<template #default="{ node, data }">
|
||||||
<el-tooltip effect="dark" :content="data.sourceDesc || data.scriptTypeName" placement="top" :hide-after="0">
|
<el-tooltip effect="dark" :content="data.sourceDesc || data.scriptTypeName" placement="top" :hide-after="0">
|
||||||
@@ -39,8 +39,9 @@ const defaultProps = {
|
|||||||
}
|
}
|
||||||
const activeName = ref('')
|
const activeName = ref('')
|
||||||
const childActiveName = ref('')
|
const childActiveName = ref('')
|
||||||
|
const activeIndex = ref()
|
||||||
const handleNodeClick = (data, node) => {
|
const handleNodeClick = (data, node) => {
|
||||||
console.log('handleNodeClick', data, node)
|
console.log('handleNodeClick', props.treeData)
|
||||||
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
|
let code = ['Base', 'VOL', 'Freq', 'Harm', 'Base_0_10', 'Base_20_85', 'Base_110_200']
|
||||||
const parents = getParentNodes(node, [])
|
const parents = getParentNodes(node, [])
|
||||||
parents.pop()
|
parents.pop()
|
||||||
@@ -54,7 +55,8 @@ const handleNodeClick = (data, node) => {
|
|||||||
childActiveName.value = childActive
|
childActiveName.value = childActive
|
||||||
emit('setTab', {
|
emit('setTab', {
|
||||||
activeName: active,
|
activeName: active,
|
||||||
childActiveName: childActive
|
childActiveName: childActive,
|
||||||
|
activeIndex:data.index
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,6 +100,7 @@ function findTargetCodes(data: any[], targetCodes: string[]) {
|
|||||||
function handleCheckChange(data, checked) {
|
function handleCheckChange(data, checked) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
// Uncheck all other nodes
|
// Uncheck all other nodes
|
||||||
|
console.log('handleCheckChange', data.id)
|
||||||
props.treeData.forEach((node) => {
|
props.treeData.forEach((node) => {
|
||||||
if (node.id !== data.id) {
|
if (node.id !== data.id) {
|
||||||
node.checked = false;
|
node.checked = false;
|
||||||
|
|||||||
@@ -25,12 +25,14 @@
|
|||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card v-if="show">
|
<el-card v-if="show">
|
||||||
<ControlSourceDetail v-if="secondLevelOptions.length > 0" :options="secondLevelOptions" :formContent="formContent" />
|
<ControlSourceDetail v-if="secondLevelOptions.length > 0" :options="secondLevelOptions" :formContent="formContent" :formControl="controlContent"
|
||||||
|
@update:activeName="handleActiveNameChange"
|
||||||
|
@update:active-index="handleActiveIndexChange"/>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, nextTick, onMounted, onBeforeMount, reactive } from 'vue'
|
import { ref, nextTick, onMounted, onBeforeMount, reactive, watch } from 'vue'
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import ControlSourceDetail from '@/views/machine/controlSource/components/controlSourceDetail.vue'
|
import ControlSourceDetail from '@/views/machine/controlSource/components/controlSourceDetail.vue'
|
||||||
import { type TestScript } from '@/api/device/interface/testScript'
|
import { type TestScript } from '@/api/device/interface/testScript'
|
||||||
@@ -71,7 +73,7 @@ const formContent = ref<TestScript.ResTestScript>({
|
|||||||
const controlContent = ref<controlSource.ResControl>({
|
const controlContent = ref<controlSource.ResControl>({
|
||||||
userPageId: '',
|
userPageId: '',
|
||||||
scriptId: '',
|
scriptId: '',
|
||||||
scriptIndex: '',
|
scriptIndex: 0,
|
||||||
sourceId: '',
|
sourceId: '',
|
||||||
})
|
})
|
||||||
//开始创建webSocket客户端
|
//开始创建webSocket客户端
|
||||||
@@ -79,6 +81,7 @@ const dataSocket = reactive({
|
|||||||
socketServe: socketClient.Instance,
|
socketServe: socketClient.Instance,
|
||||||
});
|
});
|
||||||
const webMsgSend = ref()//webSocket推送的数据
|
const webMsgSend = ref()//webSocket推送的数据
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
// 检查 socketClient.Instance 是否存在
|
// 检查 socketClient.Instance 是否存在
|
||||||
if (!socketClient.Instance) {
|
if (!socketClient.Instance) {
|
||||||
@@ -162,7 +165,6 @@ const treeInfo = async (currentMode: string) => {
|
|||||||
const setAllTree = await setTree(allOptions[0]?.children, result1)
|
const setAllTree = await setTree(allOptions[0]?.children, result1)
|
||||||
secondLevelOptions.push(...(setAllTree || []))
|
secondLevelOptions.push(...(setAllTree || []))
|
||||||
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
||||||
console.log('🚀 ~ treeInfo ~ result1:', currentMode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const setTree = async (data, data1) => {
|
const setTree = async (data, data1) => {
|
||||||
@@ -186,11 +188,21 @@ const convertToOptions = (dictTree: Dict.ResDictTree[]): CascaderOption[] => {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const scriptId = ref('')
|
||||||
|
const scriptIndex = ref(0)
|
||||||
|
const handleActiveNameChange = (newActiveName: string) => {
|
||||||
|
scriptId.value = newActiveName
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleActiveIndexChange = (newActiveIndex: number) => {
|
||||||
|
|
||||||
|
scriptIndex.value = newActiveIndex
|
||||||
|
}
|
||||||
|
|
||||||
const start = async () => {
|
const start = async () => {
|
||||||
controlContent.value.userPageId = 'cdf'
|
controlContent.value.userPageId = 'cdf'
|
||||||
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b5'
|
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57'
|
||||||
controlContent.value.scriptIndex = '1'
|
controlContent.value.scriptIndex = scriptIndex.value
|
||||||
await checkSimulate(controlContent.value)
|
await checkSimulate(controlContent.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user