|
|
@@ -20,56 +20,53 @@
|
|
|
defineOptions({ name: 'Device' })
|
|
|
import Meta2dView from '@/components/business/meta2d/Meta2dView.vue'
|
|
|
import { useCourseRun } from '@/views/train/course/course.helper'
|
|
|
- // import dataJson from './device.json'
|
|
|
import FaultList from './fault-list.vue'
|
|
|
import DeviceList from './device-list.vue'
|
|
|
- const { runConrseLine, runConrseStation } = useCourseRun()
|
|
|
+ const { runConrseLine } = useCourseRun()
|
|
|
|
|
|
- watch(runConrseLine, loadJson)
|
|
|
- watch(runConrseStation, loadJson)
|
|
|
-
|
|
|
- // ---------- 下拉选择主线路图
|
|
|
- const isManual = ref<boolean>(false)
|
|
|
- const deviceActive = ref<string>('0')
|
|
|
- const deviceOptions = [
|
|
|
- { value: '0', label: '小合隆' },
|
|
|
- { value: '1', label: '长春西' },
|
|
|
- { value: '2', label: '实训基地' }
|
|
|
- ]
|
|
|
- watch(deviceActive, () => {
|
|
|
- isManual.value = true
|
|
|
- loadJson()
|
|
|
- })
|
|
|
-
|
|
|
- // -------- 主线路图的数据配置
|
|
|
+ // ---------- 线路图 ----------
|
|
|
+ const dataJson = ref<any>(null)
|
|
|
const deviceList = [
|
|
|
- { index: '0', value: 'device.json', line: '555', station: '1' },
|
|
|
- { index: '1', value: 'device.001.json', line: '556', station: '35' },
|
|
|
- { index: '2', value: 'device.002.json', line: '557', station: '36' }
|
|
|
+ { value: '0', label: '小合隆', draw: 'device.json', line: '555', station: '555001' },
|
|
|
+ { value: '1', label: '长春西', draw: 'device.001.json', line: '556', station: '556001' },
|
|
|
+ { value: '2', label: '实训基地', draw: 'device.002.json', line: '556', station: '556001' }
|
|
|
]
|
|
|
- const getCurrentDevice = () => {
|
|
|
- if (isManual.value) {
|
|
|
- return deviceList.find((item) => item.index == deviceActive.value) || deviceList[0]
|
|
|
- }
|
|
|
- const device = deviceList.find((item) => item.station == runConrseStation.value && item.line == runConrseLine.value) || deviceList[0]
|
|
|
- deviceActive.value = device.index
|
|
|
- return device
|
|
|
- }
|
|
|
+ // ---------- 线路图:下拉 ----------
|
|
|
+ const deviceActive = ref<string>('0')
|
|
|
+ const deviceOptions = ref<{ value: string; label: string }[]>(deviceList.map((item) => ({ value: item.value, label: item.label })))
|
|
|
|
|
|
+ // ---------- 线路图:设备监控 ----------
|
|
|
const faultListRef = ref()
|
|
|
- const dataJson = ref<any>(null)
|
|
|
- async function loadJson() {
|
|
|
- const device = getCurrentDevice()
|
|
|
- const url = `${import.meta.env.BASE_URL}${device.value}`
|
|
|
+ // ---------- 线路图:工况监控 ----------
|
|
|
+ const deviceListRef = ref()
|
|
|
+ const showDeviceList = () => {
|
|
|
+ deviceListRef.value?.show(runConrseLine.value)
|
|
|
+ }
|
|
|
+ // -------- ----------
|
|
|
+ const updateDraw = async (val: string = runConrseLine.value) => {
|
|
|
+ // 线路下拉
|
|
|
+ let l = deviceList.filter((item) => item.line == val)
|
|
|
+ if (l.length == 0) l = deviceList
|
|
|
+ deviceOptions.value = l.map((item) => ({ value: item.value, label: item.label }))
|
|
|
+ // 线路下拉选中
|
|
|
+ const device = l.find((item) => item.line == val) || l[0]
|
|
|
+ deviceActive.value = device.value
|
|
|
+ // 线路绘制
|
|
|
+ const url = `${import.meta.env.BASE_URL}${device.draw}`
|
|
|
const res = await fetch(url)
|
|
|
dataJson.value = await res.json()
|
|
|
}
|
|
|
|
|
|
- const deviceListRef = ref()
|
|
|
- const showDeviceList = () => {
|
|
|
- deviceListRef.value?.show()
|
|
|
- }
|
|
|
- onMounted(loadJson)
|
|
|
+ // 开课线路
|
|
|
+ watch(runConrseLine, async (val) => updateDraw(val))
|
|
|
+ // 下拉选中
|
|
|
+ watch(deviceActive, async (val) => {
|
|
|
+ const device = deviceList.find((item) => item.value == val) || deviceList[0]
|
|
|
+ const url = `${import.meta.env.BASE_URL}${device.draw}`
|
|
|
+ const res = await fetch(url)
|
|
|
+ dataJson.value = await res.json()
|
|
|
+ })
|
|
|
+ onMounted(() => updateDraw())
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped></style>
|