车辆预览区域

This commit is contained in:
洛洛希雅 2024-05-08 16:14:10 +08:00
parent 0c34c90a74
commit 155b4f1f1e

View File

@ -19,6 +19,11 @@ const password = $toRef(mqttStore, 'password')
const clientId = $toRef(mqttStore, 'clientId') const clientId = $toRef(mqttStore, 'clientId')
let loading = $ref(false) let loading = $ref(false)
type CarPos = {
name: string
x: number
y: number
}
const publish = reactive({ const publish = reactive({
status: false, status: false,
index: 0, index: 0,
@ -38,7 +43,8 @@ const publish = reactive({
range: { range: {
start: 0, start: 0,
end: 0 end: 0
} },
cars: [] as CarPos[]
}) })
const active = $ref('CLC_track') const active = $ref('CLC_track')
@ -107,6 +113,7 @@ async function doPublish() {
const interval = setInterval(() => { const interval = setInterval(() => {
if (exit) { if (exit) {
clearInterval(interval) clearInterval(interval)
publish.cars = []
return return
} }
// if (publishing.pause) return // if (publishing.pause) return
@ -116,6 +123,7 @@ async function doPublish() {
let item = next() let item = next()
// //
if (item[0]?.content?.[0]) { if (item[0]?.content?.[0]) {
let list = item[0].content
// //
publish.lastRawTimestamp = item[0].content[0].timeStamp publish.lastRawTimestamp = item[0].content[0].timeStamp
// //
@ -126,7 +134,7 @@ async function doPublish() {
publish.lastTimestamp = publish.lastRawTimestamp + publish.timeOffset publish.lastTimestamp = publish.lastRawTimestamp + publish.timeOffset
// //
item = JSON.parse(JSON.stringify(item)) item = JSON.parse(JSON.stringify(item))
const list = item[0].content list = item[0].content
for (const it of list) it.timeStamp = it.timeStamp + offset for (const it of list) it.timeStamp = it.timeStamp + offset
} else { } else {
publish.lastTimestamp = publish.lastRawTimestamp publish.lastTimestamp = publish.lastRawTimestamp
@ -134,6 +142,11 @@ async function doPublish() {
if (publish.startTimestamp === 0) { if (publish.startTimestamp === 0) {
publish.startTimestamp = publish.lastTimestamp publish.startTimestamp = publish.lastTimestamp
} }
publish.cars = list.map((it) => ({
name: it.global_track_id,
x: it.x / 1.6,
y: it.y / 0.9
}))
} }
publish.onlineCars = item[0]?.content?.length ?? 0 publish.onlineCars = item[0]?.content?.length ?? 0
publish.percentage = Number(((publish.index / (publish.count | 1)) * 100).toFixed(2)) publish.percentage = Number(((publish.index / (publish.count | 1)) * 100).toFixed(2))
@ -202,7 +215,7 @@ function move(tick: number) {
<el-input v-model="password" /> <el-input v-model="password" />
</el-form-item> </el-form-item>
<el-form-item v-if="jobCancel" label="状态"> <el-form-item v-if="jobCancel" label="状态">
<el-descriptions border direction="vertical" column="4"> <el-descriptions border direction="vertical" :column="4">
<el-descriptions-item label="进度">{{ publish.index }} / {{ publish.count }}</el-descriptions-item> <el-descriptions-item label="进度">{{ publish.index }} / {{ publish.count }}</el-descriptions-item>
<el-descriptions-item label="运行时间"> <el-descriptions-item label="运行时间">
{{ (publish.lastTime - publish.startTime) / 1000 }} {{ (publish.lastTime - publish.startTime) / 1000 }}
@ -272,6 +285,17 @@ function move(tick: number) {
</template> </template>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div v-if="jobCancel" class="preview">
<div p2>车辆状态预览</div>
<div
class="preview-item"
v-for="car in publish.cars"
:key="car.name"
:style="{ left: car.x + '%', top: car.y + '%' }"
>
<span>{{ car.name }}</span>
</div>
</div>
</el-main> </el-main>
<el-aside /> <el-aside />
</el-container> </el-container>
@ -327,5 +351,30 @@ function move(tick: number) {
} }
} }
} }
.preview {
border: 1px solid black;
overflow: hidden;
height: 40vh;
position: relative;
.preview-item {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 0;
height: 0;
transition-property: left, top;
transition-duration: 0.3s;
span {
display: block;
border-radius: 4px;
//noinspection CssInvalidPropertyValue
text-wrap: nowarp;
color: white;
background-color: black;
padding: 5px;
}
}
}
} }
</style> </style>