This commit is contained in:
sjl
2025-03-07 14:00:20 +08:00
parent f68da773ab
commit d3a74e830f
4 changed files with 62 additions and 10 deletions

View File

@@ -25,12 +25,14 @@
</el-form>
</el-card>
<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>
</div>
</template>
<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 ControlSourceDetail from '@/views/machine/controlSource/components/controlSourceDetail.vue'
import { type TestScript } from '@/api/device/interface/testScript'
@@ -71,7 +73,7 @@ const formContent = ref<TestScript.ResTestScript>({
const controlContent = ref<controlSource.ResControl>({
userPageId: '',
scriptId: '',
scriptIndex: '',
scriptIndex: 0,
sourceId: '',
})
//开始创建webSocket客户端
@@ -79,6 +81,7 @@ const dataSocket = reactive({
socketServe: socketClient.Instance,
});
const webMsgSend = ref()//webSocket推送的数据
onMounted(async () => {
// 检查 socketClient.Instance 是否存在
if (!socketClient.Instance) {
@@ -162,7 +165,6 @@ const treeInfo = async (currentMode: string) => {
const setAllTree = await setTree(allOptions[0]?.children, result1)
secondLevelOptions.push(...(setAllTree || []))
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
console.log('🚀 ~ treeInfo ~ result1:', currentMode)
}
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 () => {
controlContent.value.userPageId = 'cdf'
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b5'
controlContent.value.scriptIndex = '1'
controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57'
controlContent.value.scriptIndex = scriptIndex.value
await checkSimulate(controlContent.value)
}